UaaIdentityProviderConfigValidator extends BaseIdentityProviderValidator { @Override public void validate(AbstractIdentityProviderDefinition definition) { if (definition == null) { return; } UaaIdentityProviderDefinition def = (UaaIdentityProviderDefinition) definition; PasswordPolicy passwordPolicy = def.getPasswordPolicy(); LockoutPolicy lockoutPolicy = def.getLockoutPolicy(); if (passwordPolicy == null && lockoutPolicy == null) { return; } else { boolean isValid = true; if (passwordPolicy != null) { isValid = passwordPolicy.allPresentAndPositive(); } if (lockoutPolicy != null) { isValid = isValid && lockoutPolicy.allPresentAndPositive(); } if (!isValid) { throw new IllegalArgumentException("Invalid Password/Lockout policy"); } } }  @Override void validate(AbstractIdentityProviderDefinition definition);  }
@Test public void nullConfigIsAllowed() { configValidator.validate((AbstractIdentityProviderDefinition) null); }
@Test public void nullLockoutPolicy_isAllowed() { uaaIdentityProviderDef.setLockoutPolicy(null); configValidator.validate(uaaIdentityProviderDef); }
@Test public void nullPasswordPolicy_isAllowed() { uaaIdentityProviderDef.setPasswordPolicy(null); configValidator.validate(uaaIdentityProviderDef); }
@Test(expected = IllegalArgumentException.class) public void passwordPolicyIsNotNullAndIncomplete() { uaaIdentityProviderDef.setPasswordPolicy(new PasswordPolicy(8, 8, -1, 1, 8, 1, 3)); configValidator.validate(uaaIdentityProviderDef); }
@Test(expected = IllegalArgumentException.class) public void lockoutPolicyIsNotNullAndIncomplete() { uaaIdentityProviderDef.setLockoutPolicy(new LockoutPolicy(-1, 1, 1)); configValidator.validate(uaaIdentityProviderDef); }