Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

test(auth): cover the 2FA duplicate submit guard

peaklabs-devaff973cce99a
diff --git a/tests/v4/Browser/LoginTest.php b/tests/v4/Browser/LoginTest.php
index 987120e955..df960a71b1 100644
--- a/tests/v4/Browser/LoginTest.php
+++ b/tests/v4/Browser/LoginTest.php
@@ -70,7 +70,7 @@ it('fails login with invalid credentials', function () {
->screenshot(filename: 'login-invalid-credentials');
});
-it('prevents Enter from duplicating the automatic two factor challenge submission', function () {
+it('submits the automatic two factor challenge only once', function () {
config(['app.maintenance.driver' => 'file']);
$user = createRootUser();
@@ -97,11 +97,11 @@ it('prevents Enter from duplicating the automatic two factor challenge submissio
});
JS);
- foreach (str_split('123456') as $index => $digit) {
- $page->keys(sprintf('[aria-label="Digit %d"]', $index + 1), $digit);
- }
-
- $page->keys('[aria-label="Digit 6"]', 'Enter')
+ $page->fill('code', '123456')
+ ->keys('code', 'Enter')
+ ->assertScript('window.acceptedTwoFactorSubmissions', 1)
+ ->assertDisabled('Verify and continue')
+ ->fill('code', '654321')
->assertScript('window.acceptedTwoFactorSubmissions', 1)
->assertNoJavaScriptErrors()
->screenshot(filename: 'login-two-factor-enter-single-submission');