File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313 **/
1414
1515use Auth \User ;
16- use Illuminate \Support \Facades \Http ;
1716use Illuminate \Support \Facades \Session ;
1817use LaravelDoctrine \ORM \Facades \EntityManager ;
18+ use RyanChandler \LaravelCloudflareTurnstile \Facades \Turnstile ;
1919
2020/**
2121 * Class UserLoginTurnstileTest
2929 */
3030final class UserLoginTurnstileTest extends BrowserKitTestCase
3131{
32- private const TURNSTILE_SITEVERIFY_URL = 'https://challenges.cloudflare.com/turnstile/v0/siteverify ' ;
33- private const LOGIN_URL = '/auth/login ' ;
32+ private const LOGIN_URL = '/auth/login ' ;
3433 // Matches ServerConfigurationService::DefaultMaxFailedLoginAttempts2ShowCaptcha
3534 private const CAPTCHA_THRESHOLD = 3 ;
3635
@@ -78,19 +77,12 @@ private function postLogin(array $overrides = [])
7877
7978 private function fakeTurnstilePass (): void
8079 {
81- Http::fake ([
82- self ::TURNSTILE_SITEVERIFY_URL => Http::response (['success ' => true ], 200 ),
83- ]);
80+ Turnstile::fake (); // FakeClient defaults to shouldPass=true → returns SiteverifyResponse::success()
8481 }
8582
8683 private function fakeTurnstileFail (): void
8784 {
88- Http::fake ([
89- self ::TURNSTILE_SITEVERIFY_URL => Http::response (
90- ['success ' => false , 'error-codes ' => ['timeout-or-duplicate ' ]],
91- 200
92- ),
93- ]);
85+ Turnstile::fake ()->expired (); // FakeClient returns failure(['timeout-or-duplicate'])
9486 }
9587
9688 /**
You can’t perform that action at this time.
0 commit comments