Search in sources :

Example 11 with DefaultPasswordRuleConf

use of org.apache.syncope.common.lib.policy.DefaultPasswordRuleConf in project syncope by apache.

the class PolicyTest method update.

@Test
public void update() {
    PasswordPolicy policy = policyDAO.find("ce93fcda-dc3a-4369-a7b0-a6108c261c85");
    assertNotNull(policy);
    assertEquals(1, policy.getRules().size());
    DefaultPasswordRuleConf ruleConf = new DefaultPasswordRuleConf();
    ruleConf.setMaxLength(8);
    ruleConf.setMinLength(6);
    Implementation rule = entityFactory.newEntity(Implementation.class);
    rule.setKey("PasswordRule" + UUID.randomUUID().toString());
    rule.setEngine(ImplementationEngine.JAVA);
    rule.setType(ImplementationType.PASSWORD_RULE);
    rule.setBody(POJOHelper.serialize(ruleConf));
    rule = implementationDAO.save(rule);
    policy.add(rule);
    policy = policyDAO.save(policy);
    assertNotNull(policy);
    rule = policy.getRules().get(1);
    DefaultPasswordRuleConf actual = POJOHelper.deserialize(rule.getBody(), DefaultPasswordRuleConf.class);
    assertEquals(actual.getMaxLength(), 8);
    assertEquals(actual.getMinLength(), 6);
}
Also used : DefaultPasswordRuleConf(org.apache.syncope.common.lib.policy.DefaultPasswordRuleConf) PasswordPolicy(org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy) Implementation(org.apache.syncope.core.persistence.api.entity.Implementation) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Aggregations

DefaultPasswordRuleConf (org.apache.syncope.common.lib.policy.DefaultPasswordRuleConf)11 Test (org.junit.jupiter.api.Test)8 PasswordPolicy (org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy)7 ArrayList (java.util.ArrayList)5 PasswordPolicyTO (org.apache.syncope.common.lib.policy.PasswordPolicyTO)2 ImplementationTO (org.apache.syncope.common.lib.to.ImplementationTO)2 InvalidPasswordRuleConf (org.apache.syncope.core.provisioning.api.utils.policy.InvalidPasswordRuleConf)2 List (java.util.List)1 Optional (java.util.Optional)1 Response (javax.ws.rs.core.Response)1 StringUtils (org.apache.commons.lang3.StringUtils)1 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)1 RealmTO (org.apache.syncope.common.lib.to.RealmTO)1 UserTO (org.apache.syncope.common.lib.to.UserTO)1 PasswordRule (org.apache.syncope.core.persistence.api.dao.PasswordRule)1 Implementation (org.apache.syncope.core.persistence.api.entity.Implementation)1 ExternalResource (org.apache.syncope.core.persistence.api.entity.resource.ExternalResource)1 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)1 PolicyPattern (org.apache.syncope.core.provisioning.api.utils.policy.PolicyPattern)1 ImplementationManager (org.apache.syncope.core.spring.ImplementationManager)1