Search in sources :

Example 1 with DefaultAccountRuleConf

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

the class RealmITCase method deletingAccountPolicy.

@Test
public void deletingAccountPolicy() {
    // 1. create account policy
    DefaultAccountRuleConf ruleConf = new DefaultAccountRuleConf();
    ruleConf.setMinLength(3);
    ruleConf.setMaxLength(8);
    ImplementationTO rule = new ImplementationTO();
    rule.setKey("DefaultAccountRuleConf" + UUID.randomUUID().toString());
    rule.setEngine(ImplementationEngine.JAVA);
    rule.setType(ImplementationType.ACCOUNT_RULE);
    rule.setBody(POJOHelper.serialize(ruleConf));
    Response response = implementationService.create(rule);
    rule.setKey(response.getHeaderString(RESTHeaders.RESOURCE_KEY));
    AccountPolicyTO policy = new AccountPolicyTO();
    policy.setDescription("deletingAccountPolicy");
    policy.getRules().add(rule.getKey());
    policy = createPolicy(PolicyType.ACCOUNT, policy);
    assertNotNull(policy);
    // 2. create realm with policy assigned
    RealmTO realm = new RealmTO();
    realm.setName("withppolicy");
    response = realmService.create(SyncopeConstants.ROOT_REALM, realm);
    RealmTO[] actuals = getObject(response.getLocation(), RealmService.class, RealmTO[].class);
    assertNotNull(actuals);
    assertTrue(actuals.length > 0);
    realm = actuals[0];
    String existingAccountPolicy = realm.getAccountPolicy();
    realm.setAccountPolicy(policy.getKey());
    realmService.update(realm);
    actuals = getObject(response.getLocation(), RealmService.class, RealmTO[].class);
    assertNotNull(actuals);
    assertTrue(actuals.length > 0);
    RealmTO actual = actuals[0];
    assertEquals(policy.getKey(), actual.getAccountPolicy());
    // 3. remove policy
    policyService.delete(PolicyType.ACCOUNT, policy.getKey());
    // 4. verify
    actual = getRealm(actual.getFullPath()).get();
    assertEquals(existingAccountPolicy, actual.getAccountPolicy());
}
Also used : ImplementationTO(org.apache.syncope.common.lib.to.ImplementationTO) Response(javax.ws.rs.core.Response) DefaultAccountRuleConf(org.apache.syncope.common.lib.policy.DefaultAccountRuleConf) RealmService(org.apache.syncope.common.rest.api.service.RealmService) RealmTO(org.apache.syncope.common.lib.to.RealmTO) AccountPolicyTO(org.apache.syncope.common.lib.policy.AccountPolicyTO) Test(org.junit.jupiter.api.Test)

Example 2 with DefaultAccountRuleConf

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

the class PolicyITCase method issueSYNCOPE682.

@Test
public void issueSYNCOPE682() {
    AccountPolicyTO policy = new AccountPolicyTO();
    policy.setDescription("SYNCOPE682");
    policy.getPassthroughResources().add(RESOURCE_NAME_LDAP);
    DefaultAccountRuleConf ruleConf = new DefaultAccountRuleConf();
    ruleConf.setMinLength(3);
    ruleConf.setMaxLength(8);
    ImplementationTO rule = new ImplementationTO();
    rule.setKey("DefaultAccountRuleConf" + getUUIDString());
    rule.setEngine(ImplementationEngine.JAVA);
    rule.setType(ImplementationType.ACCOUNT_RULE);
    rule.setBody(POJOHelper.serialize(ruleConf));
    Response response = implementationService.create(rule);
    rule.setKey(response.getHeaderString(RESTHeaders.RESOURCE_KEY));
    policy.getRules().add(rule.getKey());
    policy = createPolicy(PolicyType.ACCOUNT, policy);
    assertNotNull(policy);
}
Also used : ImplementationTO(org.apache.syncope.common.lib.to.ImplementationTO) Response(javax.ws.rs.core.Response) DefaultAccountRuleConf(org.apache.syncope.common.lib.policy.DefaultAccountRuleConf) AccountPolicyTO(org.apache.syncope.common.lib.policy.AccountPolicyTO) Test(org.junit.jupiter.api.Test)

Example 3 with DefaultAccountRuleConf

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

the class PolicyITCase method issueSYNCOPE553.

@Test
public void issueSYNCOPE553() {
    AccountPolicyTO policy = new AccountPolicyTO();
    policy.setDescription("SYNCOPE553");
    DefaultAccountRuleConf ruleConf = new DefaultAccountRuleConf();
    ruleConf.setMinLength(3);
    ruleConf.setMaxLength(8);
    ImplementationTO rule = new ImplementationTO();
    rule.setKey("DefaultAccountRuleConf" + getUUIDString());
    rule.setEngine(ImplementationEngine.JAVA);
    rule.setType(ImplementationType.ACCOUNT_RULE);
    rule.setBody(POJOHelper.serialize(ruleConf));
    Response response = implementationService.create(rule);
    rule.setKey(response.getHeaderString(RESTHeaders.RESOURCE_KEY));
    policy.getRules().add(rule.getKey());
    policy = createPolicy(PolicyType.ACCOUNT, policy);
    assertNotNull(policy);
}
Also used : ImplementationTO(org.apache.syncope.common.lib.to.ImplementationTO) Response(javax.ws.rs.core.Response) DefaultAccountRuleConf(org.apache.syncope.common.lib.policy.DefaultAccountRuleConf) AccountPolicyTO(org.apache.syncope.common.lib.policy.AccountPolicyTO) Test(org.junit.jupiter.api.Test)

Aggregations

Response (javax.ws.rs.core.Response)3 AccountPolicyTO (org.apache.syncope.common.lib.policy.AccountPolicyTO)3 DefaultAccountRuleConf (org.apache.syncope.common.lib.policy.DefaultAccountRuleConf)3 ImplementationTO (org.apache.syncope.common.lib.to.ImplementationTO)3 Test (org.junit.jupiter.api.Test)3 RealmTO (org.apache.syncope.common.lib.to.RealmTO)1 RealmService (org.apache.syncope.common.rest.api.service.RealmService)1