Skip to content

Commit

Permalink
Fix Flaky test: RequiredActionTotpSetupTest.setupTotpExistingReusable…
Browse files Browse the repository at this point in the history
…CodeDisabled (keycloak#15779)

Closes keycloak#15564
  • Loading branch information
stianst authored and cracky5457 committed Dec 13, 2022
1 parent 453a0cd commit 5933120
Showing 1 changed file with 6 additions and 7 deletions.
Expand Up @@ -352,7 +352,9 @@ public void setupTotpExisting(boolean reusableCodesEnabled) {

String totpSecret = totpPage.getTotpSecret();

totpPage.configure(totp.generateTOTP(totpSecret));
String firstCode = totp.generateTOTP(totpSecret);

totpPage.configure(firstCode);

String authSessionId = events.expectRequiredAction(EventType.UPDATE_TOTP).assertEvent()
.getDetails().get(Details.CODE_ID);
Expand All @@ -366,17 +368,14 @@ public void setupTotpExisting(boolean reusableCodesEnabled) {

events.expectLogout(authSessionId).assertEvent();

if (!reusableCodesEnabled) {
setTimeOffset(TimeBasedOTP.DEFAULT_INTERVAL_SECONDS);
}

loginPage.open();
loginPage.login("test-user@localhost", "password");
String src = driver.getPageSource();
loginTotpPage.login(totp.generateTOTP(totpSecret));

loginTotpPage.login(firstCode);

if (!reusableCodesEnabled) {
loginTotpPage.assertCurrent();
assertEquals("Invalid authenticator code.", loginTotpPage.getInputError());
} else {
assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType());
events.expectLogin().assertEvent();
Expand Down

0 comments on commit 5933120

Please sign in to comment.