From b168656eaba28f44958f8cc0339df4fa1e4df497 Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Tue, 24 Nov 2015 20:44:39 +0100 Subject: [PATCH] KEYCLOAK-2118 OTP Policy form doesn't remember Number of Digits --- .../admin/resources/js/controllers/realm.js | 2 ++ .../admin/resources/partials/otp-policy.html | 4 +--- .../otppolicy/OTPPolicyForm.java | 16 +++++++++------- .../console/authentication/OTPPolicyTest.java | 18 +++++++++--------- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js index a837f4f45f..451e3d5504 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js @@ -327,6 +327,8 @@ module.controller('RealmLoginSettingsCtrl', function($scope, Current, Realm, rea }); module.controller('RealmOtpPolicyCtrl', function($scope, Current, Realm, realm, serverInfo, $http, $location, Dialog, Notifications) { + $scope.optionsDigits = [ 6, 8 ]; + genericRealmUpdate($scope, Current, Realm, realm, serverInfo, $http, $location, Dialog, Notifications, "/realms/" + realm.realm + "/authentication/otp-policy"); }); diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/otp-policy.html b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/otp-policy.html index eaaf8116b0..4abe5a2add 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/otp-policy.html +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/otp-policy.html @@ -34,9 +34,7 @@
-
diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/authentication/otppolicy/OTPPolicyForm.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/authentication/otppolicy/OTPPolicyForm.java index 1e88cb3193..8414de9ce6 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/authentication/otppolicy/OTPPolicyForm.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/authentication/otppolicy/OTPPolicyForm.java @@ -26,6 +26,8 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.ui.Select; +import java.util.List; + /** * * @author Vlastislav Ramik @@ -53,7 +55,8 @@ public class OTPPolicyForm extends Form { public void setValues(OTPType otpType, OTPHashAlg otpHashAlg, Digits digits, String lookAhead, String periodOrCounter) { this.otpType.selectByValue(otpType.getName()); this.otpHashAlg.selectByValue(otpHashAlg.getName()); - this.digits.selectByValue(digits.getName()); + this.digits.selectByVisibleText("" + digits.getName()); + setInputValue(this.lookAhead, lookAhead); switch (otpType) { @@ -102,17 +105,16 @@ public class OTPPolicyForm extends Form { public enum Digits { - EMPTY("? number:6 ?"), - SIX("6"), - EIGHT("8"); + SIX(6), + EIGHT(8); - private final String name; + private final int name; - private Digits(String name) { + private Digits(int name) { this.name = name; } - public String getName() { + public int getName() { return name; } } diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/console/authentication/OTPPolicyTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/console/authentication/OTPPolicyTest.java index d9f8f89bd0..5e431bb5e8 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/console/authentication/OTPPolicyTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/console/authentication/OTPPolicyTest.java @@ -69,17 +69,17 @@ public class OTPPolicyTest extends AbstractConsoleTest { @Test @Ignore //KEYCLOAK-2051 when you close notification, it is not displayed again public void invalidValuesTest() { - otpPolicyPage.form().setValues(OTPType.TIME_BASED, OTPHashAlg.SHA1, Digits.EMPTY, "", "30"); + otpPolicyPage.form().setValues(OTPType.TIME_BASED, OTPHashAlg.SHA1, Digits.SIX, "", "30"); assertEquals("Error! Missing or invalid field(s). Please verify the fields in red.", otpPolicyPage.getErrorMessage()); otpPolicyPage.closeNotification(); otpPolicyPage.navigateTo();// workaround: input.clear() doesn't work when