KEYCLOAK-2118 OTP Policy form doesn't remember Number of Digits
This commit is contained in:
parent
ccd456dba6
commit
b168656eab
4 changed files with 21 additions and 19 deletions
|
@ -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");
|
||||
});
|
||||
|
||||
|
|
|
@ -34,9 +34,7 @@
|
|||
<label class="col-md-2 control-label" for="digits">Number of Digits</label>
|
||||
<div class="col-md-2">
|
||||
<div>
|
||||
<select id="digits" ng-model="realm.otpPolicyDigits" class="form-control">
|
||||
<option value="6">6</option>
|
||||
<option value="8">8</option>
|
||||
<select id="digits" ng-model="realm.otpPolicyDigits" class="form-control" ng-options="item as item for item in optionsDigits">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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 <a href="mailto:vramik@redhat.com">Vlastislav Ramik</a>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 <input type="number" ...
|
||||
|
||||
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();
|
||||
|
||||
otpPolicyPage.form().setValues(OTPType.TIME_BASED, OTPHashAlg.SHA1, Digits.EMPTY, "no number", "30");
|
||||
otpPolicyPage.form().setValues(OTPType.TIME_BASED, OTPHashAlg.SHA1, Digits.SIX, "no number", "30");
|
||||
assertEquals("Error! Missing or invalid field(s). Please verify the fields in red.", otpPolicyPage.getErrorMessage());
|
||||
otpPolicyPage.closeNotification();
|
||||
otpPolicyPage.navigateTo();
|
||||
|
@ -87,17 +87,17 @@ public class OTPPolicyTest extends AbstractConsoleTest {
|
|||
RealmRepresentation realm = testRealmResource().toRepresentation();
|
||||
assertEquals(Integer.valueOf(1), realm.getOtpPolicyLookAheadWindow());
|
||||
|
||||
otpPolicyPage.form().setValues(OTPType.TIME_BASED, OTPHashAlg.SHA1, Digits.EMPTY, "1", "");
|
||||
otpPolicyPage.form().setValues(OTPType.TIME_BASED, OTPHashAlg.SHA1, Digits.SIX, "1", "");
|
||||
assertEquals("Error! Missing or invalid field(s). Please verify the fields in red.", otpPolicyPage.getErrorMessage());
|
||||
otpPolicyPage.closeNotification();
|
||||
otpPolicyPage.navigateTo();
|
||||
|
||||
otpPolicyPage.form().setValues(OTPType.TIME_BASED, OTPHashAlg.SHA1, Digits.EMPTY, "1", " ");
|
||||
otpPolicyPage.form().setValues(OTPType.TIME_BASED, OTPHashAlg.SHA1, Digits.SIX, "1", " ");
|
||||
assertEquals("Error! Missing or invalid field(s). Please verify the fields in red.", otpPolicyPage.getErrorMessage());
|
||||
otpPolicyPage.closeNotification();
|
||||
otpPolicyPage.navigateTo();
|
||||
|
||||
otpPolicyPage.form().setValues(OTPType.TIME_BASED, OTPHashAlg.SHA1, Digits.EMPTY, "1", "no number");
|
||||
otpPolicyPage.form().setValues(OTPType.TIME_BASED, OTPHashAlg.SHA1, Digits.SIX, "1", "no number");
|
||||
assertEquals("Error! Missing or invalid field(s). Please verify the fields in red.", otpPolicyPage.getErrorMessage());
|
||||
otpPolicyPage.closeNotification();
|
||||
otpPolicyPage.navigateTo();
|
||||
|
@ -105,17 +105,17 @@ public class OTPPolicyTest extends AbstractConsoleTest {
|
|||
realm = testRealmResource().toRepresentation();
|
||||
assertEquals(Integer.valueOf(30), realm.getOtpPolicyPeriod());
|
||||
|
||||
otpPolicyPage.form().setValues(OTPType.COUNTER_BASED, OTPHashAlg.SHA1, Digits.EMPTY, "1", "");
|
||||
otpPolicyPage.form().setValues(OTPType.COUNTER_BASED, OTPHashAlg.SHA1, Digits.SIX, "1", "");
|
||||
assertEquals("Error! Missing or invalid field(s). Please verify the fields in red.", otpPolicyPage.getErrorMessage());
|
||||
otpPolicyPage.closeNotification();
|
||||
otpPolicyPage.navigateTo();
|
||||
|
||||
otpPolicyPage.form().setValues(OTPType.COUNTER_BASED, OTPHashAlg.SHA1, Digits.EMPTY, "1", " ");
|
||||
otpPolicyPage.form().setValues(OTPType.COUNTER_BASED, OTPHashAlg.SHA1, Digits.SIX, "1", " ");
|
||||
assertEquals("Error! Missing or invalid field(s). Please verify the fields in red.", otpPolicyPage.getErrorMessage());
|
||||
otpPolicyPage.closeNotification();
|
||||
otpPolicyPage.navigateTo();
|
||||
|
||||
otpPolicyPage.form().setValues(OTPType.COUNTER_BASED, OTPHashAlg.SHA1, Digits.EMPTY, "1", "no number");
|
||||
otpPolicyPage.form().setValues(OTPType.COUNTER_BASED, OTPHashAlg.SHA1, Digits.SIX, "1", "no number");
|
||||
assertEquals("Error! Missing or invalid field(s). Please verify the fields in red.", otpPolicyPage.getErrorMessage());
|
||||
otpPolicyPage.closeNotification();
|
||||
otpPolicyPage.navigateTo();
|
||||
|
|
Loading…
Reference in a new issue