use of org.keycloak.policy.PasswordPolicyManagerProvider in project keycloak by keycloak.
the class PasswordPolicyTest method testBlacklistPasswordPolicyWithTestBlacklist.
/**
* KEYCLOAK-5244
*/
@Test
public void testBlacklistPasswordPolicyWithTestBlacklist() throws Exception {
ContainerAssume.assumeNotAuthServerRemote();
testingClient.server("passwordPolicy").run(session -> {
RealmModel realmModel = session.getContext().getRealm();
PasswordPolicyManagerProvider policyManager = session.getProvider(PasswordPolicyManagerProvider.class);
realmModel.setPasswordPolicy(PasswordPolicy.parse(session, "passwordBlacklist(test-password-blacklist.txt)"));
Assert.assertEquals(BlacklistPasswordPolicyProvider.ERROR_MESSAGE, policyManager.validate("jdoe", "blacklisted1").getMessage());
Assert.assertEquals(BlacklistPasswordPolicyProvider.ERROR_MESSAGE, policyManager.validate("jdoe", "blacklisted2").getMessage());
Assert.assertEquals(BlacklistPasswordPolicyProvider.ERROR_MESSAGE, policyManager.validate("jdoe", "bLaCkLiSteD2").getMessage());
assertNull(policyManager.validate("jdoe", "notblacklisted"));
});
}
Aggregations