KEYCLOAK-13445 Modify SigningInTest for changes in credential type
This commit is contained in:
parent
bf92bd16b0
commit
4b6e46d1a9
2 changed files with 54 additions and 4 deletions
|
@ -219,6 +219,8 @@ public class SigningInTest extends BaseAccountPageTest {
|
|||
|
||||
@Test
|
||||
public void otpTest() {
|
||||
testContext.setTestRealmReps(emptyList());
|
||||
|
||||
assertFalse(otpCredentialType.isSetUp());
|
||||
otpCredentialType.clickSetUpLink();
|
||||
otpSetupPage.cancel();
|
||||
|
@ -240,6 +242,18 @@ public class SigningInTest extends BaseAccountPageTest {
|
|||
assertEquals(2, otpCredentialType.getUserCredentialsCount());
|
||||
assertUserCredential(label2, true, otp2);
|
||||
|
||||
assertTrue("Set up link is not visible", otpCredentialType.isSetUpLinkVisible());
|
||||
RequiredActionProviderRepresentation requiredAction = new RequiredActionProviderRepresentation();
|
||||
requiredAction.setEnabled(false);
|
||||
testRealmResource().flows().updateRequiredAction(CONFIGURE_TOTP.name(), requiredAction);
|
||||
|
||||
refreshPageAndWaitForLoad();
|
||||
|
||||
assertFalse("Set up link for \"otp\" is visible", otpCredentialType.isSetUpLinkVisible());
|
||||
assertFalse("Not set up link for \"otp\" is visible", otpCredentialType.isNotSetUpLabelVisible());
|
||||
assertTrue("Title for \"otp\" is not visible", otpCredentialType.isTitleVisible());
|
||||
assertEquals(2, otpCredentialType.getUserCredentialsCount());
|
||||
|
||||
testRemoveCredential(otp1);
|
||||
}
|
||||
|
||||
|
@ -254,23 +268,29 @@ public class SigningInTest extends BaseAccountPageTest {
|
|||
}
|
||||
|
||||
private void testWebAuthn(boolean passwordless) {
|
||||
testContext.setTestRealmReps(emptyList());
|
||||
|
||||
WebAuthnAssume.assumeChrome(driver); // we need some special flags to be able to register security key
|
||||
|
||||
SigningInPage.CredentialType credentialType;
|
||||
final String expectedHelpText;
|
||||
final String providerId;
|
||||
|
||||
if (passwordless) {
|
||||
credentialType = webAuthnPwdlessCredentialType;
|
||||
expectedHelpText = "Use your security key for passwordless log in.";
|
||||
providerId = WebAuthnPasswordlessRegisterFactory.PROVIDER_ID;
|
||||
}
|
||||
else {
|
||||
credentialType = webAuthnCredentialType;
|
||||
expectedHelpText = "Use your security key to log in.";
|
||||
providerId = WebAuthnRegisterFactory.PROVIDER_ID;
|
||||
}
|
||||
|
||||
assertFalse(credentialType.isSetUp());
|
||||
// no way to simulate registration cancellation
|
||||
|
||||
assertTrue("Set up link for \"" + credentialType.getType() + "\" is not visible", credentialType.isSetUpLinkVisible());
|
||||
assertEquals("Security Key", credentialType.getTitle());
|
||||
assertEquals(expectedHelpText, credentialType.getHelpText());
|
||||
|
||||
|
@ -286,6 +306,17 @@ public class SigningInTest extends BaseAccountPageTest {
|
|||
assertEquals(2, credentialType.getUserCredentialsCount());
|
||||
assertUserCredential(label2, true, webAuthn2);
|
||||
|
||||
RequiredActionProviderRepresentation requiredAction = new RequiredActionProviderRepresentation();
|
||||
requiredAction.setEnabled(false);
|
||||
testRealmResource().flows().updateRequiredAction(providerId, requiredAction);
|
||||
|
||||
refreshPageAndWaitForLoad();
|
||||
|
||||
assertFalse("Set up link for \"" + credentialType.getType() + "\" is visible", credentialType.isSetUpLinkVisible());
|
||||
assertFalse("Not set up link for \"" + credentialType.getType() + "\" is visible", credentialType.isNotSetUpLabelVisible());
|
||||
assertTrue("Title for \"" + credentialType.getType() + "\" is not visible", credentialType.isTitleVisible());
|
||||
assertEquals(2, credentialType.getUserCredentialsCount());
|
||||
|
||||
testRemoveCredential(webAuthn1);
|
||||
}
|
||||
|
||||
|
@ -297,17 +328,17 @@ public class SigningInTest extends BaseAccountPageTest {
|
|||
}
|
||||
|
||||
private void testSetUpLink(SigningInPage.CredentialType credentialType, String requiredActionProviderId) {
|
||||
assertTrue("Set up link is visible", credentialType.isSetUpLinkVisible());
|
||||
assertTrue("Set up link for \"" + credentialType.getType() + "\" is not visible", credentialType.isSetUpLinkVisible());
|
||||
|
||||
RequiredActionProviderRepresentation requiredAction = new RequiredActionProviderRepresentation();
|
||||
requiredAction.setEnabled(false);
|
||||
testRealmResource().flows().updateRequiredAction(requiredActionProviderId, requiredAction);
|
||||
|
||||
refreshPageAndWaitForLoad();
|
||||
assertFalse("Set up link is not visible", credentialType.isSetUpLinkVisible());
|
||||
|
||||
assertFalse("Credential type is not set up", credentialType.isSetUp()); // this also check the cred type is present
|
||||
assertNotNull("Title is present", credentialType.getTitle());
|
||||
assertFalse("Set up link for \"" + credentialType.getType() + "\" is visible", credentialType.isSetUpLinkVisible());
|
||||
assertFalse("Title for \"" + credentialType.getType() + "\" is visible", credentialType.isTitleVisible());
|
||||
assertFalse("Set up link for \"" + credentialType.getType() + "\" is visible", credentialType.isNotSetUpLabelVisible());
|
||||
}
|
||||
|
||||
private SigningInPage.UserCredential addOtpCredential(String label) {
|
||||
|
|
|
@ -91,6 +91,7 @@ public class SigningInPage extends AbstractLoggedInPage {
|
|||
|
||||
public boolean isSetUp() {
|
||||
boolean notSetUpLabelPresent;
|
||||
|
||||
try {
|
||||
notSetUpLabelPresent = getItemElement(NOT_SET_UP).isDisplayed();
|
||||
}
|
||||
|
@ -124,6 +125,24 @@ public class SigningInPage extends AbstractLoggedInPage {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isNotSetUpLabelVisible() {
|
||||
try {
|
||||
return getItemElement(NOT_SET_UP).isDisplayed();
|
||||
}
|
||||
catch (NoSuchElementException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isTitleVisible() {
|
||||
try {
|
||||
return getItemElement(TITLE).isDisplayed();
|
||||
}
|
||||
catch (NoSuchElementException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return getTextFromElement(getItemElement(TITLE));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue