2_test_login_totp.t reads the page before the TOTP enrollment and verification API calls return
Categories
(bugzilla.mozilla.org :: Continous Integration, defect)
Tracking
()
People
(Reporter: xavier.lhour, Assigned: xavier.lhour)
Details
Attachments
(1 external file)
qa/t/2_test_login_totp.t (test_selenium_2) fails intermittently, at a different step each time:
- line 91,
Correctly received secret32 from the form: the secret is empty, so enrollment then fails (titleErrorinstead ofUser Preferences) and the rest of the file cascades - line 164 (test 42): after a valid code, the title is still
Account Verificationinstead ofBugzilla Main Page
Both steps wait on an asynchronous API call that the test doesn't wait for:
- Enrollment:
js/account.js(line 106) writes the secret into themfa-enable-totp-frameiframe only afterawait Bugzilla.API.get('user/mfa/totp/enroll')returns. The test reads#secretright after typing the password. - Verification:
js/mfa_totp.jscancels the form submit, posts the code touser/mfa/verify_totp_code, and only submits the form (the navigation to the main page) once that returns. WebDriver's click returns before that navigation starts, andtitle_ischecks once without waiting.
The same applies to every Submit on the verification page: lines 159 and 203 read #verify-totp-error, which is filled in when the API call fails, and lines 184 and 210 check the title after a recovery code.
The server side is not involved: Bugzilla::MFA::TOTP::check accepts the previous 30-second window too (verify($code, 1)), and the test and the web server run in the same container.
Seen recently on test_selenium_2: mozilla/bmo runs 41681665590, 41552084371 and 40949670595 (first attempts), and in bmo-private (run 40899070301 on 29/10, run 42253741795 twice on 06/11).
Possible fix: wait for each of these conditions before checking it, like 2_test_login_duo.t (line 81) already does for its title, e.g. a small helper in the test:
sub wait_until {
my ($check) = @_;
foreach (1 .. WAIT_TIME / 1000) {
return 1 if $check->();
sleep 1;
}
return 0;
}
used for the secret (non-empty #secret in the iframe), the title after each Submit, and the error text.
Comment 1•10 days ago
|
||
(via GitHub webhook, authenticated as shared-secret)
Updated•7 days ago
|
Description
•