Webauthn tests logout fix (#11040)

Closes #11030
This commit is contained in:
Marek Posolda 2022-04-01 08:06:39 +02:00 committed by GitHub
parent 3a443118c5
commit c50f09da25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 12 deletions

View file

@ -41,7 +41,9 @@ import org.keycloak.testsuite.admin.ApiUtil;
import org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude;
import org.keycloak.testsuite.arquillian.annotation.EnableFeature;
import org.keycloak.testsuite.pages.AppPage;
import org.keycloak.testsuite.pages.InfoPage;
import org.keycloak.testsuite.pages.LoginPage;
import org.keycloak.testsuite.pages.LogoutConfirmPage;
import org.keycloak.testsuite.pages.RegisterPage;
import org.keycloak.testsuite.util.WaitUtils;
import org.keycloak.testsuite.webauthn.authenticators.DefaultVirtualAuthOptions;
@ -106,6 +108,12 @@ public abstract class AbstractWebAuthnVirtualTest extends AbstractTestRealmKeycl
@Page
protected AppPage appPage;
@Page
protected LogoutConfirmPage logoutConfirmPage;
@Page
protected InfoPage infoPage;
protected static final String ALL_ZERO_AAGUID = "00000000-0000-0000-0000-000000000000";
protected static final String ALL_ONE_AAGUID = "11111111-1111-1111-1111-111111111111";
protected static final String USERNAME = "UserWebAuthn";
@ -383,9 +391,11 @@ public abstract class AbstractWebAuthnVirtualTest extends AbstractTestRealmKeycl
protected void logout() {
try {
waitForPageToLoad();
appPage.open();
appPage.assertCurrent();
appPage.logout();
String logoutUrl = oauth.getLogoutUrl().build();
driver.navigate().to(logoutUrl);
logoutConfirmPage.assertCurrent();
logoutConfirmPage.confirmLogout();
infoPage.assertCurrent();
waitForPageToLoad();
} catch (Exception e) {
throw new RuntimeException("Cannot logout user", e);

View file

@ -247,8 +247,9 @@ public class WebAuthnIdlessTest extends AbstractWebAuthnVirtualTest {
.user(userId)
.assertEvent().getSessionId();
events.clear();
appPage.logout();
logout();
events.expectLogout(sessionId)
.removeDetail(Details.REDIRECT_URI)
.user(userId)
.assertEvent();
return credentialId;
@ -302,8 +303,9 @@ public class WebAuthnIdlessTest extends AbstractWebAuthnVirtualTest {
.assertEvent().getSessionId();
events.clear();
appPage.logout();
logout();
events.expectLogout(sessionId)
.removeDetail(Details.REDIRECT_URI)
.user(userId)
.assertEvent();
}
@ -331,8 +333,9 @@ public class WebAuthnIdlessTest extends AbstractWebAuthnVirtualTest {
.assertEvent().getSessionId();
events.clear();
appPage.logout();
logout();
events.expectLogout(sessionId)
.removeDetail(Details.REDIRECT_URI)
.user(userId)
.assertEvent();
}
@ -363,8 +366,9 @@ public class WebAuthnIdlessTest extends AbstractWebAuthnVirtualTest {
.assertEvent().getSessionId();
events.clear();
appPage.logout();
logout();
events.expectLogout(sessionId)
.removeDetail(Details.REDIRECT_URI)
.user(userId)
.assertEvent();
}

View file

@ -145,9 +145,11 @@ public class WebAuthnRegisterAndLoginTest extends AbstractWebAuthnVirtualTest {
events.clear();
// logout by user
appPage.logout();
logout();
// confirm logout event
events.expectLogout(sessionId)
.removeDetail(Details.REDIRECT_URI)
.user(userId)
.assertEvent();
@ -176,9 +178,11 @@ public class WebAuthnRegisterAndLoginTest extends AbstractWebAuthnVirtualTest {
events.clear();
// logout by user
appPage.logout();
logout();
// confirm logout event
events.expectLogout(sessionId)
.removeDetail(Details.REDIRECT_URI)
.user(userId)
.assertEvent();
} finally {
@ -248,9 +252,10 @@ public class WebAuthnRegisterAndLoginTest extends AbstractWebAuthnVirtualTest {
events.clear();
appPage.logout();
logout();
events.expectLogout(sessionID)
.removeDetail(Details.REDIRECT_URI)
.user(userId)
.assertEvent();
@ -271,7 +276,7 @@ public class WebAuthnRegisterAndLoginTest extends AbstractWebAuthnVirtualTest {
webAuthnLoginPage.clickAuthenticate();
appPage.assertCurrent();
appPage.logout();
logout();
// Only passwordless login
loginUsernamePage.open();
@ -292,7 +297,7 @@ public class WebAuthnRegisterAndLoginTest extends AbstractWebAuthnVirtualTest {
webAuthnLoginPage.clickAuthenticate();
appPage.assertCurrent();
appPage.logout();
logout();
} finally {
removeFirstCredentialForUser(userId, WebAuthnCredentialModel.TYPE_TWOFACTOR, WEBAUTHN_LABEL);
removeFirstCredentialForUser(userId, WebAuthnCredentialModel.TYPE_PASSWORDLESS, PASSWORDLESS_LABEL);