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
|
@Test
|
||||||
public void otpTest() {
|
public void otpTest() {
|
||||||
|
testContext.setTestRealmReps(emptyList());
|
||||||
|
|
||||||
assertFalse(otpCredentialType.isSetUp());
|
assertFalse(otpCredentialType.isSetUp());
|
||||||
otpCredentialType.clickSetUpLink();
|
otpCredentialType.clickSetUpLink();
|
||||||
otpSetupPage.cancel();
|
otpSetupPage.cancel();
|
||||||
|
@ -240,6 +242,18 @@ public class SigningInTest extends BaseAccountPageTest {
|
||||||
assertEquals(2, otpCredentialType.getUserCredentialsCount());
|
assertEquals(2, otpCredentialType.getUserCredentialsCount());
|
||||||
assertUserCredential(label2, true, otp2);
|
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);
|
testRemoveCredential(otp1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,23 +268,29 @@ public class SigningInTest extends BaseAccountPageTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testWebAuthn(boolean passwordless) {
|
private void testWebAuthn(boolean passwordless) {
|
||||||
|
testContext.setTestRealmReps(emptyList());
|
||||||
|
|
||||||
WebAuthnAssume.assumeChrome(driver); // we need some special flags to be able to register security key
|
WebAuthnAssume.assumeChrome(driver); // we need some special flags to be able to register security key
|
||||||
|
|
||||||
SigningInPage.CredentialType credentialType;
|
SigningInPage.CredentialType credentialType;
|
||||||
final String expectedHelpText;
|
final String expectedHelpText;
|
||||||
|
final String providerId;
|
||||||
|
|
||||||
if (passwordless) {
|
if (passwordless) {
|
||||||
credentialType = webAuthnPwdlessCredentialType;
|
credentialType = webAuthnPwdlessCredentialType;
|
||||||
expectedHelpText = "Use your security key for passwordless log in.";
|
expectedHelpText = "Use your security key for passwordless log in.";
|
||||||
|
providerId = WebAuthnPasswordlessRegisterFactory.PROVIDER_ID;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
credentialType = webAuthnCredentialType;
|
credentialType = webAuthnCredentialType;
|
||||||
expectedHelpText = "Use your security key to log in.";
|
expectedHelpText = "Use your security key to log in.";
|
||||||
|
providerId = WebAuthnRegisterFactory.PROVIDER_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
assertFalse(credentialType.isSetUp());
|
assertFalse(credentialType.isSetUp());
|
||||||
// no way to simulate registration cancellation
|
// no way to simulate registration cancellation
|
||||||
|
|
||||||
|
assertTrue("Set up link for \"" + credentialType.getType() + "\" is not visible", credentialType.isSetUpLinkVisible());
|
||||||
assertEquals("Security Key", credentialType.getTitle());
|
assertEquals("Security Key", credentialType.getTitle());
|
||||||
assertEquals(expectedHelpText, credentialType.getHelpText());
|
assertEquals(expectedHelpText, credentialType.getHelpText());
|
||||||
|
|
||||||
|
@ -286,6 +306,17 @@ public class SigningInTest extends BaseAccountPageTest {
|
||||||
assertEquals(2, credentialType.getUserCredentialsCount());
|
assertEquals(2, credentialType.getUserCredentialsCount());
|
||||||
assertUserCredential(label2, true, webAuthn2);
|
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);
|
testRemoveCredential(webAuthn1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,17 +328,17 @@ public class SigningInTest extends BaseAccountPageTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testSetUpLink(SigningInPage.CredentialType credentialType, String requiredActionProviderId) {
|
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();
|
RequiredActionProviderRepresentation requiredAction = new RequiredActionProviderRepresentation();
|
||||||
requiredAction.setEnabled(false);
|
requiredAction.setEnabled(false);
|
||||||
testRealmResource().flows().updateRequiredAction(requiredActionProviderId, requiredAction);
|
testRealmResource().flows().updateRequiredAction(requiredActionProviderId, requiredAction);
|
||||||
|
|
||||||
refreshPageAndWaitForLoad();
|
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
|
assertFalse("Set up link for \"" + credentialType.getType() + "\" is visible", credentialType.isSetUpLinkVisible());
|
||||||
assertNotNull("Title is present", credentialType.getTitle());
|
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) {
|
private SigningInPage.UserCredential addOtpCredential(String label) {
|
||||||
|
|
|
@ -91,6 +91,7 @@ public class SigningInPage extends AbstractLoggedInPage {
|
||||||
|
|
||||||
public boolean isSetUp() {
|
public boolean isSetUp() {
|
||||||
boolean notSetUpLabelPresent;
|
boolean notSetUpLabelPresent;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
notSetUpLabelPresent = getItemElement(NOT_SET_UP).isDisplayed();
|
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() {
|
public String getTitle() {
|
||||||
return getTextFromElement(getItemElement(TITLE));
|
return getTextFromElement(getItemElement(TITLE));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue