KEYCLOAK-4752 Change required actions UI to uncheck and disable the default checkbox when the enable checkbox is not checked. The API will continue to silently drop actions that are not enabled for the realm.
This commit is contained in:
parent
b71bb96540
commit
bed6f96fc6
3 changed files with 107 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<tr ng-repeat="requiredAction in requiredActions | orderBy : 'name'" data-ng-show="requiredActions.length > 0">
|
||||
<td>{{requiredAction.name}}</td>
|
||||
<td><input type="checkbox" ng-model="requiredAction.enabled" ng-change="updateRequiredAction(requiredAction)" id="{{requiredAction.alias}}.enabled"></td>
|
||||
<td><input type="checkbox" ng-model="requiredAction.defaultAction" ng-change="updateRequiredAction(requiredAction)" id="{{requiredAction.alias}}.defaultAction"></td>
|
||||
<td><input type="checkbox" ng-model="requiredAction.defaultAction" ng-change="updateRequiredAction(requiredAction)" ng-disabled="!requiredAction.enabled" ng-checked="requiredAction.enabled && requiredAction.defaultAction" id="{{requiredAction.alias}}.defaultAction"></td>
|
||||
</tr>
|
||||
<tr data-ng-show="requiredActions.length == 0">
|
||||
<td>{{:: 'no-required-actions-configured' | translate}}</td>
|
||||
|
@ -31,4 +31,4 @@
|
|||
|
||||
</div>
|
||||
|
||||
<kc-menu></kc-menu>
|
||||
<kc-menu></kc-menu>
|
||||
|
|
Loading…
Reference in a new issue