diff --git a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/authentication/RequiredActions.java b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/authentication/RequiredActions.java index 7e4c29c9ff..09f5f1cb48 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/authentication/RequiredActions.java +++ b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/authentication/RequiredActions.java @@ -85,4 +85,60 @@ public class RequiredActions extends Authentication { public void setUpdateProfileDefaultAction(boolean value) { setRequiredActionDefaultValue(UPDATE_PROFILE, value); } + + private boolean getRequiredActionValue(String id) { + WaitUtils.waitUntilElement(requiredActionTable).is().present(); + + WebElement checkbox = requiredActionTable.findElement(By.id(id)); + + return checkbox.isSelected(); + } + + private boolean getRequiredActionEnabledValue(String id) { + return getRequiredActionValue(id + ENABLED); + } + + private boolean getRequiredActionDefaultValue(String id) { + return getRequiredActionValue(id + DEFAULT); + } + + public boolean getTermsAndConditionEnabled() { + return getRequiredActionEnabledValue(TERMS_AND_CONDITIONS); + } + + public boolean getTermsAndConditionDefaultAction() { + return getRequiredActionDefaultValue(TERMS_AND_CONDITIONS); + } + + public boolean getVerifyEmailEnabled() { + return getRequiredActionEnabledValue(VERIFY_EMAIL); + } + + public boolean getVerifyEmailDefaultAction() { + return getRequiredActionDefaultValue(VERIFY_EMAIL); + } + + public boolean getUpdatePasswordEnabled() { + return getRequiredActionEnabledValue(UPDATE_PASSWORD); + } + + public boolean getUpdatePasswordDefaultAction() { + return getRequiredActionDefaultValue(UPDATE_PASSWORD); + } + + public boolean getConfigureTotpEnabled() { + return getRequiredActionEnabledValue(CONFIGURE_TOTP); + } + + public boolean getConfigureTotpDefaultAction() { + return getRequiredActionDefaultValue(CONFIGURE_TOTP); + } + + public boolean getUpdateProfileEnabled() { + return getRequiredActionEnabledValue(UPDATE_PROFILE); + } + + public boolean getUpdateProfileDefaultAction() { + return getRequiredActionDefaultValue(UPDATE_PROFILE); + } } diff --git a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/authentication/RequiredActionsTest.java b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/authentication/RequiredActionsTest.java index b8217f8499..b879e18322 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/authentication/RequiredActionsTest.java +++ b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/authentication/RequiredActionsTest.java @@ -21,8 +21,11 @@ import org.jboss.arquillian.graphene.page.Page; import org.junit.Before; import org.junit.Test; import org.keycloak.representations.idm.UserRepresentation; +import org.keycloak.testsuite.Assert; +import org.keycloak.testsuite.auth.page.AuthRealm; import org.keycloak.testsuite.auth.page.login.Registration; import org.keycloak.testsuite.console.AbstractConsoleTest; +import org.keycloak.testsuite.console.page.AdminConsoleRealm; import org.keycloak.testsuite.console.page.authentication.RequiredActions; import org.keycloak.testsuite.console.page.realm.LoginSettings; import org.openqa.selenium.By; @@ -71,6 +74,52 @@ public class RequiredActionsTest extends AbstractConsoleTest { driver.findElement(By.xpath("//div[@id='kc-header-wrapper' and text()[contains(.,'Terms and Conditions')]]")); } + @Test + public void defaultCheckboxUncheckableWhenEnabledIsFalse() { + requiredActionsPage.setTermsAndConditionEnabled(false); + Assert.assertFalse(requiredActionsPage.getTermsAndConditionEnabled()); + requiredActionsPage.setTermsAndConditionDefaultAction(true); + Assert.assertFalse(requiredActionsPage.getTermsAndConditionDefaultAction()); + } + + @Test + public void defaultCheckboxUncheckedWhenEnabledBecomesFalse() { + requiredActionsPage.setTermsAndConditionEnabled(true); + Assert.assertTrue(requiredActionsPage.getTermsAndConditionEnabled()); + requiredActionsPage.setTermsAndConditionDefaultAction(true); + Assert.assertTrue(requiredActionsPage.getTermsAndConditionDefaultAction()); + requiredActionsPage.setTermsAndConditionEnabled(false); + Assert.assertFalse(requiredActionsPage.getTermsAndConditionEnabled()); + Assert.assertFalse(requiredActionsPage.getTermsAndConditionDefaultAction()); + assertAlertSuccess(); + } + + @Test + public void defaultCheckboxKeepsValueWhenEnabledIsToggled() { + requiredActionsPage.setTermsAndConditionEnabled(true); + requiredActionsPage.setTermsAndConditionDefaultAction(false); + Assert.assertTrue(requiredActionsPage.getTermsAndConditionEnabled()); + Assert.assertFalse(requiredActionsPage.getTermsAndConditionDefaultAction()); + requiredActionsPage.setTermsAndConditionEnabled(false); + Assert.assertFalse(requiredActionsPage.getTermsAndConditionEnabled()); + Assert.assertFalse(requiredActionsPage.getTermsAndConditionDefaultAction()); + requiredActionsPage.setTermsAndConditionEnabled(true); + Assert.assertTrue(requiredActionsPage.getTermsAndConditionEnabled()); + Assert.assertFalse(requiredActionsPage.getTermsAndConditionDefaultAction()); + + requiredActionsPage.setTermsAndConditionDefaultAction(true); + Assert.assertTrue(requiredActionsPage.getTermsAndConditionEnabled()); + Assert.assertTrue(requiredActionsPage.getTermsAndConditionDefaultAction()); + requiredActionsPage.setTermsAndConditionEnabled(false); + Assert.assertFalse(requiredActionsPage.getTermsAndConditionEnabled()); + Assert.assertFalse(requiredActionsPage.getTermsAndConditionDefaultAction()); + requiredActionsPage.setTermsAndConditionEnabled(true); + Assert.assertTrue(requiredActionsPage.getTermsAndConditionEnabled()); + Assert.assertTrue(requiredActionsPage.getTermsAndConditionDefaultAction()); + + assertAlertSuccess(); + } + @Test public void configureTotpDefaultActionTest() { requiredActionsPage.setConfigureTotpDefaultAction(true); diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/required-actions.html b/themes/src/main/resources/theme/base/admin/resources/partials/required-actions.html index 45a5be6de7..17dcc05685 100755 --- a/themes/src/main/resources/theme/base/admin/resources/partials/required-actions.html +++ b/themes/src/main/resources/theme/base/admin/resources/partials/required-actions.html @@ -21,7 +21,7 @@ {{requiredAction.name}} - + {{:: 'no-required-actions-configured' | translate}} @@ -31,4 +31,4 @@ - \ No newline at end of file +