http://git-wip-us.apache.org/repos/asf/syncope/blob/4095f1e8/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractITCase.java index 0f0560a..fc4af36 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractITCase.java @@ -22,7 +22,6 @@ import static org.junit.Assert.assertNotNull; import java.io.InputStream; import java.net.URI; -import java.util.Hashtable; import java.util.Map; import java.util.Properties; import java.util.UUID; @@ -37,13 +36,13 @@ import org.apache.cxf.jaxrs.client.WebClient; import org.apache.syncope.client.lib.SyncopeClient; import org.apache.syncope.client.lib.SyncopeClientFactoryBean; import org.apache.syncope.common.lib.mod.AttrMod; -import org.apache.syncope.common.lib.mod.RoleMod; +import org.apache.syncope.common.lib.mod.GroupMod; import org.apache.syncope.common.lib.mod.UserMod; import org.apache.syncope.common.lib.to.AbstractPolicyTO; import org.apache.syncope.common.lib.to.AbstractSchemaTO; import org.apache.syncope.common.lib.to.AttrTO; import org.apache.syncope.common.lib.to.ResourceTO; -import org.apache.syncope.common.lib.to.RoleTO; +import org.apache.syncope.common.lib.to.GroupTO; import org.apache.syncope.common.lib.to.UserTO; import org.apache.syncope.common.lib.types.AttributableType; import org.apache.syncope.common.lib.types.ConnConfProperty; @@ -58,7 +57,7 @@ import org.apache.syncope.common.rest.api.service.NotificationService; import org.apache.syncope.common.rest.api.service.PolicyService; import org.apache.syncope.common.rest.api.service.ReportService; import org.apache.syncope.common.rest.api.service.ResourceService; -import org.apache.syncope.common.rest.api.service.RoleService; +import org.apache.syncope.common.rest.api.service.GroupService; import org.apache.syncope.common.rest.api.service.SchemaService; import org.apache.syncope.common.rest.api.service.SecurityQuestionService; import org.apache.syncope.common.rest.api.service.SyncopeService; @@ -153,7 +152,7 @@ public abstract class AbstractITCase { protected static UserWorkflowService userWorkflowService; - protected static RoleService roleService; + protected static GroupService groupService; protected static ResourceService resourceService; @@ -178,7 +177,7 @@ public abstract class AbstractITCase { protected static PolicyService policyService; protected static SecurityQuestionService securityQuestionService; - + protected static CamelRouteService camelRouteService; @Autowired @@ -218,7 +217,7 @@ public abstract class AbstractITCase { userService = adminClient.getService(UserService.class); userSelfService = adminClient.getService(UserSelfService.class); userWorkflowService = adminClient.getService(UserWorkflowService.class); - roleService = adminClient.getService(RoleService.class); + groupService = adminClient.getService(GroupService.class); resourceService = adminClient.getService(ResourceService.class); entitlementService = adminClient.getService(EntitlementService.class); configurationService = adminClient.getService(ConfigurationService.class); @@ -302,23 +301,23 @@ public abstract class AbstractITCase { return (T) getObject(response.getLocation(), SchemaService.class, schemaTO.getClass()); } - protected RoleTO createRole(final RoleTO newRoleTO) { - Response response = roleService.create(newRoleTO); + protected GroupTO createGroup(final GroupTO newGroupTO) { + Response response = groupService.create(newGroupTO); if (response.getStatusInfo().getStatusCode() != Response.Status.CREATED.getStatusCode()) { Exception ex = clientFactory.getExceptionMapper().fromResponse(response); if (ex != null) { throw (RuntimeException) ex; } } - return getObject(response.getLocation(), RoleService.class, RoleTO.class); + return getObject(response.getLocation(), GroupService.class, GroupTO.class); } - protected RoleTO updateRole(final RoleMod roleMod) { - return roleService.update(roleMod.getKey(), roleMod).readEntity(RoleTO.class); + protected GroupTO updateGroup(final GroupMod groupMod) { + return groupService.update(groupMod.getKey(), groupMod).readEntity(GroupTO.class); } - protected RoleTO deleteRole(final Long id) { - return roleService.delete(id).readEntity(RoleTO.class); + protected GroupTO deleteGroup(final Long id) { + return groupService.delete(id).readEntity(GroupTO.class); } @SuppressWarnings("unchecked") @@ -351,7 +350,7 @@ public abstract class AbstractITCase { final Map<String, ConnConfProperty> ldapConnConf = connectorService.read(ldapRes.getConnectorId()).getConfigurationMap(); - Hashtable env = new Hashtable(); + Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://" + ldapConnConf.get("host").getValues().get(0) + ":" + ldapConnConf.get("port").getValues().get(0) + "/");
http://git-wip-us.apache.org/repos/asf/syncope/blob/4095f1e8/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ActivitiDetector.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ActivitiDetector.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ActivitiDetector.java index f697c19..798a313 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ActivitiDetector.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ActivitiDetector.java @@ -26,7 +26,7 @@ public class ActivitiDetector { return syncopeService.info().getUserWorkflowAdapter().indexOf("Activiti") != -1; } - public static boolean isActivitiEnabledForRoles(final SyncopeService syncopeService) { - return syncopeService.info().getRoleWorkflowAdapter().indexOf("Activiti") != -1; + public static boolean isActivitiEnabledForGroups(final SyncopeService syncopeService) { + return syncopeService.info().getGroupWorkflowAdapter().indexOf("Activiti") != -1; } } http://git-wip-us.apache.org/repos/asf/syncope/blob/4095f1e8/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AuthenticationITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AuthenticationITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AuthenticationITCase.java index 4623f25..ef99feb 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AuthenticationITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AuthenticationITCase.java @@ -40,7 +40,7 @@ import org.apache.syncope.common.lib.to.BulkActionResult; import org.apache.syncope.common.lib.to.MembershipTO; import org.apache.syncope.common.lib.to.PagedResult; import org.apache.syncope.common.lib.to.PlainSchemaTO; -import org.apache.syncope.common.lib.to.RoleTO; +import org.apache.syncope.common.lib.to.GroupTO; import org.apache.syncope.common.lib.to.UserTO; import org.apache.syncope.common.lib.to.WorkflowFormPropertyTO; import org.apache.syncope.common.lib.to.WorkflowFormTO; @@ -99,14 +99,14 @@ public class AuthenticationITCase extends AbstractITCase { @Test public void testUserSchemaAuthorization() { - // 0. create a role that can only read schemas - RoleTO authRoleTO = new RoleTO(); - authRoleTO.setName("authRole" + getUUIDString()); - authRoleTO.setParent(8L); - authRoleTO.getEntitlements().add("SCHEMA_READ"); + // 0. create a group that can only read schemas + GroupTO authGroupTO = new GroupTO(); + authGroupTO.setName("authGroup" + getUUIDString()); + authGroupTO.setParent(8L); + authGroupTO.getEntitlements().add("SCHEMA_READ"); - authRoleTO = createRole(authRoleTO); - assertNotNull(authRoleTO); + authGroupTO = createGroup(authGroupTO); + assertNotNull(authGroupTO); String schemaName = "authTestSchema" + getUUIDString(); @@ -119,11 +119,11 @@ public class AuthenticationITCase extends AbstractITCase { PlainSchemaTO newPlainSchemaTO = createSchema(AttributableType.USER, SchemaType.PLAIN, schemaTO); assertEquals(schemaTO, newPlainSchemaTO); - // 2. create an user with the role created above (as admin) + // 2. create an user with the group created above (as admin) UserTO userTO = UserITCase.getUniqueSampleTO("[email protected]"); MembershipTO membershipTO = new MembershipTO(); - membershipTO.setRoleId(authRoleTO.getKey()); + membershipTO.setGroupId(authGroupTO.getKey()); AttrTO testAttrTO = new AttrTO(); testAttrTO.setSchema("testAttribute"); testAttrTO.getValues().add("a value"); @@ -146,7 +146,7 @@ public class AuthenticationITCase extends AbstractITCase { // 5. update the schema create above (as user) - failure try { - schemaService2.update(AttributableType.ROLE, SchemaType.PLAIN, schemaName, schemaTO); + schemaService2.update(AttributableType.GROUP, SchemaType.PLAIN, schemaName, schemaTO); fail("Schemaupdate as user schould not work"); } catch (SyncopeClientException e) { assertNotNull(e); @@ -164,7 +164,7 @@ public class AuthenticationITCase extends AbstractITCase { UserTO userTO = UserITCase.getUniqueSampleTO("[email protected]"); MembershipTO membershipTO = new MembershipTO(); - membershipTO.setRoleId(7L); + membershipTO.setGroupId(7L); AttrTO testAttrTO = new AttrTO(); testAttrTO.setSchema("testAttribute"); testAttrTO.getValues().add("a value"); @@ -190,7 +190,7 @@ public class AuthenticationITCase extends AbstractITCase { exception = e; } assertNotNull(exception); - assertEquals(ClientExceptionType.UnauthorizedRole, exception.getType()); + assertEquals(ClientExceptionType.UnauthorizedGroup, exception.getType()); } @Test @@ -198,7 +198,7 @@ public class AuthenticationITCase extends AbstractITCase { UserTO userTO = UserITCase.getUniqueSampleTO("[email protected]"); MembershipTO membershipTO = new MembershipTO(); - membershipTO.setRoleId(7L); + membershipTO.setGroupId(7L); AttrTO testAttrTO = new AttrTO(); testAttrTO.setSchema("testAttribute"); testAttrTO.getValues().add("a value"); @@ -240,7 +240,7 @@ public class AuthenticationITCase extends AbstractITCase { UserTO userTO = UserITCase.getUniqueSampleTO("[email protected]"); MembershipTO membershipTO = new MembershipTO(); - membershipTO.setRoleId(7L); + membershipTO.setGroupId(7L); AttrTO testAttrTO = new AttrTO(); testAttrTO.setSchema("testAttribute"); testAttrTO.getValues().add("a value"); @@ -273,7 +273,7 @@ public class AuthenticationITCase extends AbstractITCase { UserTO userTO = UserITCase.getUniqueSampleTO("[email protected]"); MembershipTO membershipTO = new MembershipTO(); - membershipTO.setRoleId(7L); + membershipTO.setGroupId(7L); AttrTO testAttrTO = new AttrTO(); testAttrTO.setSchema("testAttribute"); testAttrTO.getValues().add("a value"); @@ -322,56 +322,56 @@ public class AuthenticationITCase extends AbstractITCase { @Test public void issueSYNCOPE48() { - // Parent role, able to create users with role 1 - RoleTO parentRole = new RoleTO(); - parentRole.setName("parentAdminRole" + getUUIDString()); - parentRole.getEntitlements().add("USER_CREATE"); - parentRole.getEntitlements().add("ROLE_1"); - parentRole.setParent(1L); - parentRole = createRole(parentRole); - assertNotNull(parentRole); - - // Child role, with no entitlements - RoleTO childRole = new RoleTO(); - childRole.setName("childAdminRole"); - childRole.setParent(parentRole.getKey()); - - childRole = createRole(childRole); - assertNotNull(childRole); - - // User with child role, created by admin - UserTO role1Admin = UserITCase.getUniqueSampleTO("[email protected]"); - role1Admin.setPassword("password"); + // Parent group, able to create users with group 1 + GroupTO parentGroup = new GroupTO(); + parentGroup.setName("parentAdminGroup" + getUUIDString()); + parentGroup.getEntitlements().add("USER_CREATE"); + parentGroup.getEntitlements().add("GROUP_1"); + parentGroup.setParent(1L); + parentGroup = createGroup(parentGroup); + assertNotNull(parentGroup); + + // Child group, with no entitlements + GroupTO childGroup = new GroupTO(); + childGroup.setName("childAdminGroup"); + childGroup.setParent(parentGroup.getKey()); + + childGroup = createGroup(childGroup); + assertNotNull(childGroup); + + // User with child group, created by admin + UserTO group1Admin = UserITCase.getUniqueSampleTO("[email protected]"); + group1Admin.setPassword("password"); MembershipTO membershipTO = new MembershipTO(); - membershipTO.setRoleId(childRole.getKey()); - role1Admin.getMemberships().add(membershipTO); + membershipTO.setGroupId(childGroup.getKey()); + group1Admin.getMemberships().add(membershipTO); - role1Admin = createUser(role1Admin); - assertNotNull(role1Admin); + group1Admin = createUser(group1Admin); + assertNotNull(group1Admin); - UserService userService2 = clientFactory.create(role1Admin.getUsername(), "password").getService( + UserService userService2 = clientFactory.create(group1Admin.getUsername(), "password").getService( UserService.class); - // User with role 1, created by user with child role created above - UserTO role1User = UserITCase.getUniqueSampleTO("[email protected]"); + // User with group 1, created by user with child group created above + UserTO group1User = UserITCase.getUniqueSampleTO("[email protected]"); membershipTO = new MembershipTO(); - membershipTO.setRoleId(1L); - role1User.getMemberships().add(membershipTO); + membershipTO.setGroupId(1L); + group1User.getMemberships().add(membershipTO); - Response response = userService2.create(role1User, true); + Response response = userService2.create(group1User, true); assertNotNull(response); - role1User = response.readEntity(UserTO.class); - assertNotNull(role1User); + group1User = response.readEntity(UserTO.class); + assertNotNull(group1User); } @Test public void issueSYNCOPE434() { Assume.assumeTrue(ActivitiDetector.isActivitiEnabledForUsers(syncopeService)); - // 1. create user with role 9 (users with role 9 are defined in workflow as subject to approval) + // 1. create user with group 9 (users with group 9 are defined in workflow as subject to approval) UserTO userTO = UserITCase.getUniqueSampleTO("[email protected]"); MembershipTO membershipTO = new MembershipTO(); - membershipTO.setRoleId(9L); + membershipTO.setGroupId(9L); userTO.getMemberships().add(membershipTO); userTO = createUser(userTO); http://git-wip-us.apache.org/repos/asf/syncope/blob/4095f1e8/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelDetector.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelDetector.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelDetector.java index 47cad19..a061005 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelDetector.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelDetector.java @@ -26,7 +26,7 @@ public class CamelDetector { return syncopeService.info().getUserProvisioningManager().indexOf("Camel") != -1; } - public static boolean isCamelEnabledForRoles(final SyncopeService syncopeService) { - return syncopeService.info().getRoleProvisioningManager().indexOf("Camel") != -1; + public static boolean isCamelEnabledForGroups(final SyncopeService syncopeService) { + return syncopeService.info().getGroupProvisioningManager().indexOf("Camel") != -1; } } http://git-wip-us.apache.org/repos/asf/syncope/blob/4095f1e8/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelRouteITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelRouteITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelRouteITCase.java index 1b3e91d..35f270c 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelRouteITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelRouteITCase.java @@ -50,13 +50,13 @@ public class CamelRouteITCase extends AbstractITCase { } @Test - public void roleRoutes() { - Assume.assumeTrue(CamelDetector.isCamelEnabledForRoles(syncopeService)); + public void groupRoutes() { + Assume.assumeTrue(CamelDetector.isCamelEnabledForGroups(syncopeService)); - List<CamelRouteTO> roleRoutes = camelRouteService.list(SubjectType.ROLE); - assertNotNull(roleRoutes); - assertEquals(7, roleRoutes.size()); - for (CamelRouteTO route : roleRoutes) { + List<CamelRouteTO> groupRoutes = camelRouteService.list(SubjectType.GROUP); + assertNotNull(groupRoutes); + assertEquals(7, groupRoutes.size()); + for (CamelRouteTO route : groupRoutes) { assertNotNull(route.getContent()); } } http://git-wip-us.apache.org/repos/asf/syncope/blob/4095f1e8/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConfigurationITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConfigurationITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConfigurationITCase.java index 27fb19b..3277305 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConfigurationITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConfigurationITCase.java @@ -41,7 +41,7 @@ import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.to.AttrTO; import org.apache.syncope.common.lib.to.ConfTO; import org.apache.syncope.common.lib.to.PlainSchemaTO; -import org.apache.syncope.common.lib.to.RoleTO; +import org.apache.syncope.common.lib.to.GroupTO; import org.apache.syncope.common.lib.types.AttrSchemaType; import org.apache.syncope.common.lib.types.AttributableType; import org.apache.syncope.common.lib.types.ClientExceptionType; @@ -194,16 +194,17 @@ public class ConfigurationITCase extends AbstractITCase { membershipKey.setType(AttrSchemaType.String); createSchema(AttributableType.MEMBERSHIP, SchemaType.PLAIN, membershipKey); - PlainSchemaTO roleKey = new PlainSchemaTO(); - roleKey.setKey("roleKey" + getUUIDString()); - roleKey.setType(AttrSchemaType.String); - createSchema(AttributableType.ROLE, SchemaType.PLAIN, roleKey); + PlainSchemaTO groupKey = new PlainSchemaTO(); + groupKey.setKey("group" + + "Key" + getUUIDString()); + groupKey.setType(AttrSchemaType.String); + createSchema(AttributableType.GROUP, SchemaType.PLAIN, groupKey); - RoleTO roleTO = new RoleTO(); - roleTO.setName("aRole" + getUUIDString()); - roleTO.getMPlainAttrTemplates().add(membershipKey.getKey()); - roleTO.getRPlainAttrTemplates().add(roleKey.getKey()); - roleTO = createRole(roleTO); + GroupTO groupTO = new GroupTO(); + groupTO.setName("aGroup" + getUUIDString()); + groupTO.getMPlainAttrTemplates().add(membershipKey.getKey()); + groupTO.getGPlainAttrTemplates().add(groupKey.getKey()); + groupTO = createGroup(groupTO); try { Response response = configurationService.export(); @@ -219,11 +220,11 @@ public class ConfigurationITCase extends AbstractITCase { assertFalse(configExport.isEmpty()); assertTrue(configExport.length() > 1000); - String[] result = substringsBetween(configExport, "<RPLAINATTRTEMPLATE", "/>"); + String[] result = substringsBetween(configExport, "<GPLAINATTRTEMPLATE", "/>"); assertNotNull(result); boolean rattrExists = false; for (String entry : result) { - if (entry.contains(roleKey.getKey())) { + if (entry.contains(groupKey.getKey())) { rattrExists = true; } } @@ -239,7 +240,7 @@ public class ConfigurationITCase extends AbstractITCase { } assertTrue(mattrExists); } finally { - deleteRole(roleTO.getKey()); + deleteGroup(groupTO.getKey()); } } } http://git-wip-us.apache.org/repos/asf/syncope/blob/4095f1e8/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DerSchemaITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DerSchemaITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DerSchemaITCase.java index a5c14ad..adbcdf7 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DerSchemaITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DerSchemaITCase.java @@ -71,19 +71,19 @@ public class DerSchemaITCase extends AbstractITCase { @Test public void delete() { - DerSchemaTO schema = schemaService.read(AttributableType.ROLE, SchemaType.DERIVED, "rderiveddata"); + DerSchemaTO schema = schemaService.read(AttributableType.GROUP, SchemaType.DERIVED, "rderiveddata"); assertNotNull(schema); - schemaService.delete(AttributableType.ROLE, SchemaType.DERIVED, schema.getKey()); + schemaService.delete(AttributableType.GROUP, SchemaType.DERIVED, schema.getKey()); try { - schemaService.read(AttributableType.ROLE, SchemaType.DERIVED, "rderiveddata"); + schemaService.read(AttributableType.GROUP, SchemaType.DERIVED, "rderiveddata"); fail(); } catch (SyncopeClientException e) { assertEquals(ClientExceptionType.NotFound, e.getType()); } finally { // Recreate schema to make test re-runnable - schema = createSchema(AttributableType.ROLE, SchemaType.DERIVED, schema); + schema = createSchema(AttributableType.GROUP, SchemaType.DERIVED, schema); assertNotNull(schema); } } @@ -113,11 +113,11 @@ public class DerSchemaITCase extends AbstractITCase { @Test public void issueSYNCOPE323() { - DerSchemaTO actual = schemaService.read(AttributableType.ROLE, SchemaType.DERIVED, "rderiveddata"); + DerSchemaTO actual = schemaService.read(AttributableType.GROUP, SchemaType.DERIVED, "rderiveddata"); assertNotNull(actual); try { - createSchema(AttributableType.ROLE, SchemaType.DERIVED, actual); + createSchema(AttributableType.GROUP, SchemaType.DERIVED, actual); fail(); } catch (SyncopeClientException e) { assertEquals(Response.Status.CONFLICT, e.getType().getResponseStatus()); @@ -126,7 +126,7 @@ public class DerSchemaITCase extends AbstractITCase { actual.setKey(null); try { - createSchema(AttributableType.ROLE, SchemaType.DERIVED, actual); + createSchema(AttributableType.GROUP, SchemaType.DERIVED, actual); fail(); } catch (SyncopeClientException e) { assertEquals(Response.Status.BAD_REQUEST, e.getType().getResponseStatus()); @@ -141,7 +141,7 @@ public class DerSchemaITCase extends AbstractITCase { schema.setExpression("derived_sx + '_' + derived_dx"); try { - createSchema(AttributableType.ROLE, SchemaType.DERIVED, schema); + createSchema(AttributableType.GROUP, SchemaType.DERIVED, schema); fail(); } catch (SyncopeClientException e) { assertEquals(ClientExceptionType.InvalidDerSchema, e.getType()); http://git-wip-us.apache.org/repos/asf/syncope/blob/4095f1e8/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java new file mode 100644 index 0000000..edbb5e1 --- /dev/null +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java @@ -0,0 +1,887 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.syncope.fit.core.reference; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.io.InputStream; +import java.security.AccessControlException; +import java.util.List; +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.directory.DirContext; +import javax.naming.directory.SearchControls; +import javax.naming.directory.SearchResult; +import javax.ws.rs.core.Response; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.syncope.client.lib.SyncopeClient; +import org.apache.syncope.common.lib.SyncopeClientException; +import org.apache.syncope.common.lib.mod.ReferenceMod; +import org.apache.syncope.common.lib.mod.GroupMod; +import org.apache.syncope.common.lib.to.BulkActionResult; +import org.apache.syncope.common.lib.to.ConnObjectTO; +import org.apache.syncope.common.lib.to.MappingItemTO; +import org.apache.syncope.common.lib.to.PagedResult; +import org.apache.syncope.common.lib.to.PlainSchemaTO; +import org.apache.syncope.common.lib.to.ResourceTO; +import org.apache.syncope.common.lib.to.GroupTO; +import org.apache.syncope.common.lib.to.UserTO; +import org.apache.syncope.common.lib.types.AttributableType; +import org.apache.syncope.common.lib.types.ClientExceptionType; +import org.apache.syncope.common.lib.types.IntMappingType; +import org.apache.syncope.common.lib.types.MappingPurpose; +import org.apache.syncope.common.lib.types.ResourceAssociationActionType; +import org.apache.syncope.common.lib.types.ResourceDeassociationActionType; +import org.apache.syncope.common.lib.types.SchemaType; +import org.apache.syncope.common.lib.types.SubjectType; +import org.apache.syncope.common.lib.wrap.ResourceName; +import org.apache.syncope.common.rest.api.CollectionWrapper; +import org.apache.syncope.common.rest.api.Preference; +import org.apache.syncope.common.rest.api.RESTHeaders; +import org.apache.syncope.common.rest.api.service.GroupService; +import org.identityconnectors.framework.common.objects.Name; +import org.junit.FixMethodOrder; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +@FixMethodOrder(MethodSorters.JVM) +public class GroupITCase extends AbstractITCase { + + private GroupTO buildBasicGroupTO(final String name) { + GroupTO groupTO = new GroupTO(); + groupTO.setName(name + getUUIDString()); + groupTO.setParent(8L); + return groupTO; + } + + private GroupTO buildGroupTO(final String name) { + GroupTO groupTO = buildBasicGroupTO(name); + + // verify inheritance password and account policies + groupTO.setInheritAccountPolicy(false); + // not inherited so setter execution shouldn't be ignored + groupTO.setAccountPolicy(6L); + + groupTO.setInheritPasswordPolicy(true); + // inherited so setter execution should be ignored + groupTO.setPasswordPolicy(2L); + + groupTO.getGPlainAttrTemplates().add("icon"); + groupTO.getPlainAttrs().add(attrTO("icon", "anIcon")); + + groupTO.getResources().add(RESOURCE_NAME_LDAP); + return groupTO; + } + + @Test + public void createWithException() { + GroupTO newGroupTO = new GroupTO(); + newGroupTO.getPlainAttrs().add(attrTO("attr1", "value1")); + + try { + createGroup(newGroupTO); + fail(); + } catch (SyncopeClientException e) { + assertEquals(ClientExceptionType.InvalidGroup, e.getType()); + } + } + + @Test + @Ignore + public void create() { + GroupTO groupTO = buildGroupTO("lastGroup"); + groupTO.getGVirAttrTemplates().add("rvirtualdata"); + groupTO.getVirAttrs().add(attrTO("rvirtualdata", "rvirtualvalue")); + groupTO.setGroupOwner(8L); + + groupTO = createGroup(groupTO); + assertNotNull(groupTO); + + assertNotNull(groupTO.getVirAttrMap()); + assertNotNull(groupTO.getVirAttrMap().get("rvirtualdata").getValues()); + assertFalse(groupTO.getVirAttrMap().get("rvirtualdata").getValues().isEmpty()); + assertEquals("rvirtualvalue", groupTO.getVirAttrMap().get("rvirtualdata").getValues().get(0)); + + assertNotNull(groupTO.getAccountPolicy()); + assertEquals(6L, (long) groupTO.getAccountPolicy()); + + assertNotNull(groupTO.getPasswordPolicy()); + assertEquals(4L, (long) groupTO.getPasswordPolicy()); + + assertTrue(groupTO.getResources().contains(RESOURCE_NAME_LDAP)); + + ConnObjectTO connObjectTO = + resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.GROUP, groupTO.getKey()); + assertNotNull(connObjectTO); + assertNotNull(connObjectTO.getPlainAttrMap().get("owner")); + + // SYNCOPE-515: remove ownership + final GroupMod groupMod = new GroupMod(); + groupMod.setKey(groupTO.getKey()); + groupMod.setGroupOwner(new ReferenceMod()); + + assertNull(updateGroup(groupMod).getGroupOwner()); + } + + @Test + public void createWithPasswordPolicy() { + GroupTO groupTO = new GroupTO(); + groupTO.setName("groupWithPassword" + getUUIDString()); + groupTO.setParent(8L); + groupTO.setPasswordPolicy(4L); + + GroupTO actual = createGroup(groupTO); + assertNotNull(actual); + + actual = groupService.read(actual.getKey()); + assertNotNull(actual); + assertNotNull(actual.getPasswordPolicy()); + assertEquals(4L, (long) actual.getPasswordPolicy()); + } + + @Test + public void delete() { + try { + groupService.delete(0L); + } catch (SyncopeClientException e) { + assertEquals(Response.Status.NOT_FOUND, e.getType().getResponseStatus()); + } + + GroupTO groupTO = new GroupTO(); + groupTO.setName("toBeDeleted" + getUUIDString()); + groupTO.setParent(8L); + + groupTO.getResources().add(RESOURCE_NAME_LDAP); + + groupTO = createGroup(groupTO); + assertNotNull(groupTO); + + GroupTO deletedGroup = deleteGroup(groupTO.getKey()); + assertNotNull(deletedGroup); + + try { + groupService.read(deletedGroup.getKey()); + } catch (SyncopeClientException e) { + assertEquals(Response.Status.NOT_FOUND, e.getType().getResponseStatus()); + } + } + + @Test + public void list() { + PagedResult<GroupTO> groupTOs = groupService.list(); + assertNotNull(groupTOs); + assertTrue(groupTOs.getResult().size() >= 8); + for (GroupTO groupTO : groupTOs.getResult()) { + assertNotNull(groupTO); + } + } + + @Test + public void parent() { + GroupTO groupTO = groupService.parent(7L); + + assertNotNull(groupTO); + assertEquals(groupTO.getKey(), 6L); + } + + @Test + public void read() { + GroupTO groupTO = groupService.read(1L); + + assertNotNull(groupTO); + assertNotNull(groupTO.getPlainAttrs()); + assertFalse(groupTO.getPlainAttrs().isEmpty()); + } + + @Test + public void selfRead() { + UserTO userTO = userService.read(1L); + assertNotNull(userTO); + + assertTrue(userTO.getMembershipMap().containsKey(1L)); + assertFalse(userTO.getMembershipMap().containsKey(3L)); + + GroupService groupService2 = clientFactory.create("rossini", ADMIN_PWD).getService(GroupService.class); + + try { + groupService2.readSelf(3L); + fail(); + } catch (SyncopeClientException e) { + assertEquals(ClientExceptionType.UnauthorizedGroup, e.getType()); + } + + GroupTO groupTO = groupService2.readSelf(1L); + assertNotNull(groupTO); + assertNotNull(groupTO.getPlainAttrs()); + assertFalse(groupTO.getPlainAttrs().isEmpty()); + } + + @Test + public void update() { + GroupTO groupTO = buildGroupTO("latestGroup" + getUUIDString()); + groupTO.getGPlainAttrTemplates().add("show"); + groupTO = createGroup(groupTO); + + assertEquals(1, groupTO.getPlainAttrs().size()); + + assertNotNull(groupTO.getAccountPolicy()); + assertEquals(6L, (long) groupTO.getAccountPolicy()); + + assertNotNull(groupTO.getPasswordPolicy()); + assertEquals(4L, (long) groupTO.getPasswordPolicy()); + + GroupMod groupMod = new GroupMod(); + groupMod.setKey(groupTO.getKey()); + String modName = "finalGroup" + getUUIDString(); + groupMod.setName(modName); + groupMod.getPlainAttrsToUpdate().add(attrMod("show", "FALSE")); + + // change password policy inheritance + groupMod.setInheritPasswordPolicy(Boolean.FALSE); + + groupTO = updateGroup(groupMod); + + assertEquals(modName, groupTO.getName()); + assertEquals(2, groupTO.getPlainAttrs().size()); + + // changes ignored because not requested (null ReferenceMod) + assertNotNull(groupTO.getAccountPolicy()); + assertEquals(6L, (long) groupTO.getAccountPolicy()); + + // password policy null because not inherited + assertNull(groupTO.getPasswordPolicy()); + } + + @Test + public void updateRemovingVirAttribute() { + GroupTO groupTO = buildBasicGroupTO("withvirtual" + getUUIDString()); + groupTO.getGVirAttrTemplates().add("rvirtualdata"); + groupTO.getVirAttrs().add(attrTO("rvirtualdata", null)); + + groupTO = createGroup(groupTO); + + assertNotNull(groupTO); + assertEquals(1, groupTO.getVirAttrs().size()); + + final GroupMod groupMod = new GroupMod(); + groupMod.setKey(groupTO.getKey()); + groupMod.getVirAttrsToRemove().add("rvirtualdata"); + + groupTO = updateGroup(groupMod); + assertNotNull(groupTO); + assertTrue(groupTO.getVirAttrs().isEmpty()); + } + + @Test + public void updateRemovingDerAttribute() { + GroupTO groupTO = buildBasicGroupTO("withderived" + getUUIDString()); + groupTO.getGDerAttrTemplates().add("rderivedschema"); + groupTO.getDerAttrs().add(attrTO("rderivedschema", null)); + + groupTO = createGroup(groupTO); + + assertNotNull(groupTO); + assertEquals(1, groupTO.getDerAttrs().size()); + + final GroupMod groupMod = new GroupMod(); + groupMod.setKey(groupTO.getKey()); + groupMod.getDerAttrsToRemove().add("rderivedschema"); + + groupTO = updateGroup(groupMod); + assertNotNull(groupTO); + assertTrue(groupTO.getDerAttrs().isEmpty()); + } + + @Test + public void updateAsGroupOwner() { + // 1. read group as admin + GroupTO groupTO = groupService.read(7L); + + // issue SYNCOPE-15 + assertNotNull(groupTO.getCreationDate()); + assertNotNull(groupTO.getLastChangeDate()); + assertEquals("admin", groupTO.getCreator()); + assertEquals("admin", groupTO.getLastModifier()); + + // 2. prepare update + GroupMod groupMod = new GroupMod(); + groupMod.setKey(groupTO.getKey()); + groupMod.setName("Managing Director"); + + // 3. try to update as verdi, not owner of group 7 - fail + GroupService groupService2 = clientFactory.create("verdi", ADMIN_PWD).getService(GroupService.class); + + try { + groupService2.update(groupMod.getKey(), groupMod); + fail(); + } catch (SyncopeClientException e) { + assertEquals(Response.Status.UNAUTHORIZED, e.getType().getResponseStatus()); + } catch (AccessControlException e) { + assertNotNull(e); + } + + // 4. update as puccini, owner of group 7 because owner of group 6 with inheritance - success + GroupService groupService3 = clientFactory.create("puccini", ADMIN_PWD).getService(GroupService.class); + + groupTO = groupService3.update(groupMod.getKey(), groupMod).readEntity(GroupTO.class); + assertEquals("Managing Director", groupTO.getName()); + + // issue SYNCOPE-15 + assertNotNull(groupTO.getCreationDate()); + assertNotNull(groupTO.getLastChangeDate()); + assertEquals("admin", groupTO.getCreator()); + assertEquals("puccini", groupTO.getLastModifier()); + assertTrue(groupTO.getCreationDate().before(groupTO.getLastChangeDate())); + } + + /** + * Group rename used to fail in case of parent null. + */ + @Test + public void issue178() { + GroupTO groupTO = new GroupTO(); + String groupName = "torename" + getUUIDString(); + groupTO.setName(groupName); + + GroupTO actual = createGroup(groupTO); + + assertNotNull(actual); + assertEquals(groupName, actual.getName()); + assertEquals(0L, actual.getParent()); + + GroupMod groupMod = new GroupMod(); + groupMod.setKey(actual.getKey()); + String renamedGroup = "renamed" + getUUIDString(); + groupMod.setName(renamedGroup); + + actual = updateGroup(groupMod); + assertNotNull(actual); + assertEquals(renamedGroup, actual.getName()); + assertEquals(0L, actual.getParent()); + } + + @Test + public void issueSYNCOPE228() { + GroupTO groupTO = buildGroupTO("issueSYNCOPE228"); + groupTO.getEntitlements().add("USER_READ"); + groupTO.getEntitlements().add("SCHEMA_READ"); + + groupTO = createGroup(groupTO); + assertNotNull(groupTO); + assertNotNull(groupTO.getEntitlements()); + assertFalse(groupTO.getEntitlements().isEmpty()); + + List<String> entitlements = groupTO.getEntitlements(); + + GroupMod groupMod = new GroupMod(); + groupMod.setKey(groupTO.getKey()); + groupMod.setInheritDerAttrs(Boolean.TRUE); + + groupTO = updateGroup(groupMod); + assertNotNull(groupTO); + assertEquals(entitlements, groupTO.getEntitlements()); + + groupMod = new GroupMod(); + groupMod.setKey(groupTO.getKey()); + groupMod.setModEntitlements(true); + groupMod.getEntitlements().clear(); + + groupTO = updateGroup(groupMod); + assertNotNull(groupTO); + assertTrue(groupTO.getEntitlements().isEmpty()); + } + + @Test + public void unlink() { + GroupTO actual = createGroup(buildGroupTO("unlink")); + assertNotNull(actual); + + assertNotNull(resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.GROUP, actual.getKey())); + + assertNotNull(groupService.bulkDeassociation(actual.getKey(), + ResourceDeassociationActionType.UNLINK, + CollectionWrapper.wrap(RESOURCE_NAME_LDAP, ResourceName.class)). + readEntity(BulkActionResult.class)); + + actual = groupService.read(actual.getKey()); + assertNotNull(actual); + assertTrue(actual.getResources().isEmpty()); + + assertNotNull(resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.GROUP, actual.getKey())); + } + + @Test + public void link() { + GroupTO groupTO = buildGroupTO("link"); + groupTO.getResources().clear(); + + GroupTO actual = createGroup(groupTO); + assertNotNull(actual); + + try { + resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.GROUP, actual.getKey()); + fail(); + } catch (Exception e) { + assertNotNull(e); + } + + assertNotNull(groupService.bulkAssociation(actual.getKey(), + ResourceAssociationActionType.LINK, + CollectionWrapper.wrap(RESOURCE_NAME_LDAP, ResourceName.class)). + readEntity(BulkActionResult.class)); + + actual = groupService.read(actual.getKey()); + assertFalse(actual.getResources().isEmpty()); + + try { + resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.GROUP, actual.getKey()); + fail(); + } catch (Exception e) { + assertNotNull(e); + } + } + + @Test + public void unassign() { + GroupTO actual = createGroup(buildGroupTO("unassign")); + assertNotNull(actual); + + assertNotNull(resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.GROUP, actual.getKey())); + + assertNotNull(groupService.bulkDeassociation(actual.getKey(), + ResourceDeassociationActionType.UNASSIGN, + CollectionWrapper.wrap(RESOURCE_NAME_LDAP, ResourceName.class)). + readEntity(BulkActionResult.class)); + + actual = groupService.read(actual.getKey()); + assertNotNull(actual); + assertTrue(actual.getResources().isEmpty()); + + try { + resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.GROUP, actual.getKey()); + fail(); + } catch (Exception e) { + assertNotNull(e); + } + } + + @Test + public void assign() { + GroupTO groupTO = buildGroupTO("assign"); + groupTO.getResources().clear(); + + GroupTO actual = createGroup(groupTO); + assertNotNull(actual); + + try { + resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.GROUP, actual.getKey()); + fail(); + } catch (Exception e) { + assertNotNull(e); + } + + assertNotNull(groupService.bulkAssociation(actual.getKey(), + ResourceAssociationActionType.ASSIGN, + CollectionWrapper.wrap(RESOURCE_NAME_LDAP, ResourceName.class)). + readEntity(BulkActionResult.class)); + + actual = groupService.read(actual.getKey()); + assertFalse(actual.getResources().isEmpty()); + assertNotNull(resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.GROUP, actual.getKey())); + } + + @Test + public void deprovision() { + GroupTO actual = createGroup(buildGroupTO("deprovision")); + assertNotNull(actual); + + assertNotNull(resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.GROUP, actual.getKey())); + + assertNotNull(groupService.bulkDeassociation(actual.getKey(), + ResourceDeassociationActionType.DEPROVISION, + CollectionWrapper.wrap(RESOURCE_NAME_LDAP, ResourceName.class)). + readEntity(BulkActionResult.class)); + + actual = groupService.read(actual.getKey()); + assertNotNull(actual); + assertFalse(actual.getResources().isEmpty()); + + try { + resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.GROUP, actual.getKey()); + fail(); + } catch (Exception e) { + assertNotNull(e); + } + } + + @Test + public void provision() { + GroupTO groupTO = buildGroupTO("assign"); + groupTO.getResources().clear(); + + GroupTO actual = createGroup(groupTO); + assertNotNull(actual); + + try { + resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.GROUP, actual.getKey()); + fail(); + } catch (Exception e) { + assertNotNull(e); + } + + assertNotNull(groupService.bulkAssociation(actual.getKey(), + ResourceAssociationActionType.PROVISION, + CollectionWrapper.wrap(RESOURCE_NAME_LDAP, ResourceName.class)). + readEntity(BulkActionResult.class)); + + actual = groupService.read(actual.getKey()); + assertTrue(actual.getResources().isEmpty()); + + assertNotNull(resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.GROUP, actual.getKey())); + } + + @Test + public void deprovisionUnlinked() { + GroupTO groupTO = buildGroupTO("assign"); + groupTO.getResources().clear(); + + GroupTO actual = createGroup(groupTO); + assertNotNull(actual); + + try { + resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.GROUP, actual.getKey()); + fail(); + } catch (Exception e) { + assertNotNull(e); + } + + assertNotNull(groupService.bulkAssociation(actual.getKey(), + ResourceAssociationActionType.PROVISION, + CollectionWrapper.wrap("resource-ldap", ResourceName.class)). + readEntity(BulkActionResult.class)); + + actual = groupService.read(actual.getKey()); + assertTrue(actual.getResources().isEmpty()); + + assertNotNull(resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.GROUP, actual.getKey())); + + assertNotNull(groupService.bulkDeassociation(actual.getKey(), + ResourceDeassociationActionType.DEPROVISION, + CollectionWrapper.wrap(RESOURCE_NAME_LDAP, ResourceName.class)). + readEntity(BulkActionResult.class)); + + actual = groupService.read(actual.getKey()); + assertNotNull(actual); + assertTrue(actual.getResources().isEmpty()); + + try { + resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.GROUP, actual.getKey()); + fail(); + } catch (Exception e) { + assertNotNull(e); + } + } + + @Test + public void createWithMandatorySchemaNotTemplate() { + // 1. create a group mandatory schema + PlainSchemaTO badge = new PlainSchemaTO(); + badge.setKey("badge"); + badge.setMandatoryCondition("true"); + schemaService.create(AttributableType.GROUP, SchemaType.PLAIN, badge); + + // 2. create a group *without* an attribute for that schema: it works + GroupTO groupTO = buildGroupTO("lastGroup"); + assertFalse(groupTO.getPlainAttrMap().containsKey(badge.getKey())); + groupTO = createGroup(groupTO); + assertNotNull(groupTO); + assertFalse(groupTO.getPlainAttrMap().containsKey(badge.getKey())); + + // 3. add a template for badge to the group just created - + // failure since no values are provided and it is mandatory + GroupMod groupMod = new GroupMod(); + groupMod.setKey(groupTO.getKey()); + groupMod.setModRAttrTemplates(true); + groupMod.getRPlainAttrTemplates().add("badge"); + + try { + updateGroup(groupMod); + fail(); + } catch (SyncopeClientException e) { + assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType()); + } + + // 4. also add an actual attribute for badge - it will work + groupMod.getPlainAttrsToUpdate().add(attrMod(badge.getKey(), "xxxxxxxxxx")); + + groupTO = updateGroup(groupMod); + assertNotNull(groupTO); + assertTrue(groupTO.getPlainAttrMap().containsKey(badge.getKey())); + } + + @Test + public void anonymous() { + GroupService unauthenticated = clientFactory.createAnonymous().getService(GroupService.class); + try { + unauthenticated.list(); + fail(); + } catch (AccessControlException e) { + assertNotNull(e); + } + + GroupService anonymous = clientFactory.create(ANONYMOUS_UNAME, ANONYMOUS_KEY).getService(GroupService.class); + assertFalse(anonymous.list().getResult().isEmpty()); + } + + @Test + public void noContent() throws IOException { + SyncopeClient noContentclient = clientFactory.create(ADMIN_UNAME, ADMIN_PWD); + GroupService noContentService = noContentclient.prefer(GroupService.class, Preference.RETURN_NO_CONTENT); + + GroupTO group = buildGroupTO("noContent"); + + Response response = noContentService.create(group); + assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus()); + assertEquals(Preference.RETURN_NO_CONTENT.toString(), response.getHeaderString(RESTHeaders.PREFERENCE_APPLIED)); + assertEquals(StringUtils.EMPTY, IOUtils.toString((InputStream) response.getEntity())); + + group = getObject(response.getLocation(), GroupService.class, GroupTO.class); + assertNotNull(group); + + GroupMod groupMod = new GroupMod(); + groupMod.getPlainAttrsToUpdate().add(attrMod("badge", "xxxxxxxxxx")); + + response = noContentService.update(group.getKey(), groupMod); + assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus()); + assertEquals(Preference.RETURN_NO_CONTENT.toString(), response.getHeaderString(RESTHeaders.PREFERENCE_APPLIED)); + assertEquals(StringUtils.EMPTY, IOUtils.toString((InputStream) response.getEntity())); + + response = noContentService.delete(group.getKey()); + assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus()); + assertEquals(Preference.RETURN_NO_CONTENT.toString(), response.getHeaderString(RESTHeaders.PREFERENCE_APPLIED)); + assertEquals(StringUtils.EMPTY, IOUtils.toString((InputStream) response.getEntity())); + } + + @Test + public void issueSYNCOPE455() { + final String parentName = "issueSYNCOPE455-PGroup"; + final String childName = "issueSYNCOPE455-CGroup"; + + // 1. create parent group + GroupTO parent = buildBasicGroupTO(parentName); + parent.getResources().add(RESOURCE_NAME_LDAP); + + parent = createGroup(parent); + assertTrue(parent.getResources().contains(RESOURCE_NAME_LDAP)); + + final ConnObjectTO parentRemoteObject = + resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.GROUP, parent.getKey()); + assertNotNull(parentRemoteObject); + assertNotNull(getLdapRemoteObject(parentRemoteObject.getPlainAttrMap().get(Name.NAME).getValues().get(0))); + + // 2. create child group + GroupTO child = buildBasicGroupTO(childName); + child.getResources().add(RESOURCE_NAME_LDAP); + child.setParent(parent.getKey()); + + child = createGroup(child); + assertTrue(child.getResources().contains(RESOURCE_NAME_LDAP)); + + final ConnObjectTO childRemoteObject = + resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.GROUP, child.getKey()); + assertNotNull(childRemoteObject); + assertNotNull(getLdapRemoteObject(childRemoteObject.getPlainAttrMap().get(Name.NAME).getValues().get(0))); + + // 3. remove parent group + groupService.delete(parent.getKey()); + + // 4. asserts for issue 455 + try { + groupService.read(parent.getKey()); + fail(); + } catch (SyncopeClientException scce) { + assertNotNull(scce); + } + + try { + groupService.read(child.getKey()); + fail(); + } catch (SyncopeClientException scce) { + assertNotNull(scce); + } + + assertNull(getLdapRemoteObject(parentRemoteObject.getPlainAttrMap().get(Name.NAME).getValues().get(0))); + assertNull(getLdapRemoteObject(childRemoteObject.getPlainAttrMap().get(Name.NAME).getValues().get(0))); + } + + @Test + public void issueSYNCOPE543() { + final String ancestorName = "issueSYNCOPE543-AGroup"; + final String parentName = "issueSYNCOPE543-PGroup"; + final String childName = "issueSYNCOPE543-CGroup"; + + // 1. create ancestor group + GroupTO ancestor = buildBasicGroupTO(ancestorName); + ancestor.setParent(0L); + ancestor.getGPlainAttrTemplates().add("icon"); + ancestor.getPlainAttrs().add(attrTO("icon", "ancestorIcon")); + ancestor = createGroup(ancestor); + assertEquals("ancestorIcon", ancestor.getPlainAttrMap().get("icon").getValues().get(0)); + + // 2. create parent group + GroupTO parent = buildBasicGroupTO(parentName); + parent.setParent(ancestor.getKey()); + parent.getGPlainAttrTemplates().add("icon"); + parent.getPlainAttrs().add(attrTO("icon", "parentIcon")); + parent = createGroup(parent); + assertEquals("parentIcon", parent.getPlainAttrMap().get("icon").getValues().get(0)); + + // 3. create child group + GroupTO child = buildBasicGroupTO(childName); + child.setParent(parent.getKey()); + child.getGPlainAttrTemplates().add("icon"); + child.getPlainAttrs().add(attrTO("icon", "childIcon")); + child = createGroup(child); + assertEquals("childIcon", child.getPlainAttrMap().get("icon").getValues().get(0)); + + final GroupMod groupChildMod = new GroupMod(); + groupChildMod.setKey(child.getKey()); + groupChildMod.setInheritPlainAttrs(Boolean.TRUE); + updateGroup(groupChildMod); + + child = groupService.read(child.getKey()); + assertNotNull(child); + assertNotNull(child.getPlainAttrMap().get("icon").getValues()); + assertEquals("parentIcon", child.getPlainAttrMap().get("icon").getValues().get(0)); + + final GroupMod groupParentMod = new GroupMod(); + groupParentMod.setKey(parent.getKey()); + groupParentMod.setInheritPlainAttrs(Boolean.TRUE); + updateGroup(groupParentMod); + + child = groupService.read(child.getKey()); + assertNotNull(child); + assertNotNull(child.getPlainAttrMap().get("icon").getValues()); + assertEquals("ancestorIcon", child.getPlainAttrMap().get("icon").getValues().get(0)); + + parent = groupService.read(parent.getKey()); + assertNotNull(parent); + assertNotNull(parent.getPlainAttrMap().get("icon").getValues()); + assertEquals("ancestorIcon", parent.getPlainAttrMap().get("icon").getValues().get(0)); + + groupParentMod.setInheritPlainAttrs(Boolean.FALSE); + updateGroup(groupParentMod); + + child = groupService.read(child.getKey()); + assertNotNull(child); + assertNotNull(child.getPlainAttrMap().get("icon").getValues()); + assertEquals("parentIcon", child.getPlainAttrMap().get("icon").getValues().get(0)); + } + + @Test + public void issueSYNCOPE632() { + GroupTO groupTO = null; + try { + // 1. create new LDAP resource having account id mapped to a derived attribute + ResourceTO newLDAP = resourceService.read(RESOURCE_NAME_LDAP); + newLDAP.setKey("new-ldap"); + newLDAP.setPropagationPrimary(true); + MappingItemTO accountId = newLDAP.getGmapping().getAccountIdItem(); + accountId.setIntMappingType(IntMappingType.GroupDerivedSchema); + accountId.setIntAttrName("displayProperty"); + newLDAP.getGmapping().setAccountIdItem(accountId); + newLDAP.getGmapping().setAccountLink("'cn=' + displayProperty + ',ou=groups,o=isp'"); + + MappingItemTO description = new MappingItemTO(); + description.setIntMappingType(IntMappingType.GroupId); + description.setExtAttrName("description"); + description.setPurpose(MappingPurpose.BOTH); + newLDAP.getGmapping().addItem(description); + + newLDAP = createResource(newLDAP); + assertNotNull(newLDAP); + + // 2. create a group and give the resource created above + groupTO = buildGroupTO("lastGroup"); + groupTO.getGPlainAttrTemplates().add("icon"); + groupTO.getPlainAttrs().add(attrTO("icon", "anIcon")); + groupTO.getGPlainAttrTemplates().add("show"); + groupTO.getPlainAttrs().add(attrTO("show", "true")); + groupTO.getGDerAttrTemplates().add("displayProperty"); + groupTO.getDerAttrs().add(attrTO("displayProperty", null)); + groupTO.getResources().clear(); + groupTO.getResources().add("new-ldap"); + + groupTO = createGroup(groupTO); + assertNotNull(groupTO); + + // 3. update the group + GroupMod groupMod = new GroupMod(); + groupMod.setKey(groupTO.getKey()); + groupMod.getPlainAttrsToRemove().add("icon"); + groupMod.getPlainAttrsToUpdate().add(attrMod("icon", "anotherIcon")); + + groupTO = updateGroup(groupMod); + assertNotNull(groupTO); + + // 4. check that a single group exists in LDAP for the group created and updated above + int entries = 0; + DirContext ctx = null; + try { + ctx = getLdapResourceDirContext(null, null); + + SearchControls ctls = new SearchControls(); + ctls.setReturningAttributes(new String[] { "*", "+" }); + ctls.setSearchScope(SearchControls.SUBTREE_SCOPE); + + NamingEnumeration<SearchResult> result = + ctx.search("ou=groups,o=isp", "(description=" + groupTO.getKey() + ")", ctls); + while (result.hasMore()) { + result.next(); + entries++; + } + } catch (Exception e) { + // ignore + } finally { + if (ctx != null) { + try { + ctx.close(); + } catch (NamingException e) { + // ignore + } + } + } + + assertEquals(1, entries); + } finally { + if (groupTO != null) { + groupService.delete(groupTO.getKey()); + } + resourceService.delete("new-ldap"); + } + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/4095f1e8/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/LoggerITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/LoggerITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/LoggerITCase.java index 7b5e845..012c6ab 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/LoggerITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/LoggerITCase.java @@ -37,7 +37,7 @@ import org.apache.syncope.common.lib.types.ResourceOperation; import org.apache.syncope.common.rest.api.CollectionWrapper; import org.apache.syncope.core.logic.ReportLogic; import org.apache.syncope.core.logic.ResourceLogic; -import org.apache.syncope.core.logic.RoleLogic; +import org.apache.syncope.core.logic.GroupLogic; import org.apache.syncope.core.logic.UserLogic; import org.junit.FixMethodOrder; import org.junit.Test; @@ -143,7 +143,7 @@ public class LoggerITCase extends AbstractITCase { found = false; for (EventCategoryTO eventCategoryTO : events) { - if (RoleLogic.class.getSimpleName().equals(eventCategoryTO.getCategory())) { + if (GroupLogic.class.getSimpleName().equals(eventCategoryTO.getCategory())) { assertEquals(EventCategoryType.REST, eventCategoryTO.getType()); assertTrue(eventCategoryTO.getEvents().contains("create")); assertTrue(eventCategoryTO.getEvents().contains("list")); http://git-wip-us.apache.org/repos/asf/syncope/blob/4095f1e8/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/NotificationITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/NotificationITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/NotificationITCase.java index 03a557f..d5c9570 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/NotificationITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/NotificationITCase.java @@ -75,7 +75,7 @@ public class NotificationITCase extends AbstractITCase { @Test public void create() { NotificationTO notificationTO = buildNotificationTO(); - notificationTO.setRecipients(SyncopeClient.getUserSearchConditionBuilder().hasRoles(7L).query()); + notificationTO.setRecipients(SyncopeClient.getUserSearchConditionBuilder().inGroups(7L).query()); Response response = notificationService.create(notificationTO); NotificationTO actual = getObject(response.getLocation(), NotificationService.class, @@ -90,7 +90,7 @@ public class NotificationITCase extends AbstractITCase { @Test public void update() { NotificationTO notificationTO = notificationService.read(10L); - notificationTO.setRecipients(SyncopeClient.getUserSearchConditionBuilder().hasRoles(7L).query()); + notificationTO.setRecipients(SyncopeClient.getUserSearchConditionBuilder().inGroups(7L).query()); notificationService.update(notificationTO.getKey(), notificationTO); NotificationTO actual = notificationService.read(notificationTO.getKey()); @@ -155,7 +155,8 @@ public class NotificationITCase extends AbstractITCase { public void issueSYNCOPE446() { NotificationTO notificationTO = buildNotificationTO(); notificationTO.getStaticRecipients().add("[email protected]"); - notificationTO.setRoleAbout(SyncopeClient.getRoleSearchConditionBuilder().hasEntitlements("ROLE_READ").query()); + notificationTO.setGroupAbout( + SyncopeClient.getGroupSearchConditionBuilder().hasEntitlements("GROUP_READ").query()); NotificationTO actual = null; try { http://git-wip-us.apache.org/repos/asf/syncope/blob/4095f1e8/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/NotificationTaskITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/NotificationTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/NotificationTaskITCase.java index ee75de9..1fb1a93 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/NotificationTaskITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/NotificationTaskITCase.java @@ -109,9 +109,9 @@ public class NotificationTaskITCase extends AbstractTaskITCase { notification.setTraceLevel(TraceLevel.FAILURES); notification.getEvents().add("[REST]:[UserLogic]:[]:[create]:[SUCCESS]"); - notification.setUserAbout(SyncopeClient.getUserSearchConditionBuilder().hasRoles(7L).query()); + notification.setUserAbout(SyncopeClient.getUserSearchConditionBuilder().inGroups(7L).query()); - notification.setRecipients(SyncopeClient.getUserSearchConditionBuilder().hasRoles(8L).query()); + notification.setRecipients(SyncopeClient.getUserSearchConditionBuilder().inGroups(8L).query()); notification.setSelfAsRecipient(true); notification.setRecipientAttrName("email"); @@ -130,7 +130,7 @@ public class NotificationTaskITCase extends AbstractTaskITCase { // 2. create user UserTO userTO = UserITCase.getUniqueSampleTO("[email protected]"); MembershipTO membershipTO = new MembershipTO(); - membershipTO.setRoleId(7); + membershipTO.setGroupId(7); userTO.getMemberships().add(membershipTO); userTO = createUser(userTO); http://git-wip-us.apache.org/repos/asf/syncope/blob/4095f1e8/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PlainSchemaITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PlainSchemaITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PlainSchemaITCase.java index b9d8239..1968206 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PlainSchemaITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PlainSchemaITCase.java @@ -92,7 +92,7 @@ public class PlainSchemaITCase extends AbstractITCase { schemaTO.setType(AttrSchemaType.Enum); try { - createSchema(AttributableType.ROLE, SchemaType.PLAIN, schemaTO); + createSchema(AttributableType.GROUP, SchemaType.PLAIN, schemaTO); fail("This should not be reacheable"); } catch (SyncopeClientException e) { assertEquals(ClientExceptionType.InvalidPlainSchema, e.getType()); @@ -136,7 +136,7 @@ public class PlainSchemaITCase extends AbstractITCase { schemaTO.setType(AttrSchemaType.Binary); schemaTO.setMimeType("application/x-x509-ca-cert"); - createSchema(AttributableType.ROLE, SchemaType.PLAIN, schemaTO); + createSchema(AttributableType.GROUP, SchemaType.PLAIN, schemaTO); } @Test @@ -163,9 +163,9 @@ public class PlainSchemaITCase extends AbstractITCase { assertNotNull(schemaTO); } - List<PlainSchemaTO> roleSchemas = schemaService.list(AttributableType.ROLE, SchemaType.PLAIN); - assertFalse(roleSchemas.isEmpty()); - for (PlainSchemaTO schemaTO : roleSchemas) { + List<PlainSchemaTO> groupSchemas = schemaService.list(AttributableType.GROUP, SchemaType.PLAIN); + assertFalse(groupSchemas.isEmpty()); + for (PlainSchemaTO schemaTO : groupSchemas) { assertNotNull(schemaTO); } @@ -178,16 +178,16 @@ public class PlainSchemaITCase extends AbstractITCase { @Test public void update() { - PlainSchemaTO schemaTO = schemaService.read(AttributableType.ROLE, SchemaType.PLAIN, "icon"); + PlainSchemaTO schemaTO = schemaService.read(AttributableType.GROUP, SchemaType.PLAIN, "icon"); assertNotNull(schemaTO); - schemaService.update(AttributableType.ROLE, SchemaType.PLAIN, schemaTO.getKey(), schemaTO); - PlainSchemaTO updatedTO = schemaService.read(AttributableType.ROLE, SchemaType.PLAIN, "icon"); + schemaService.update(AttributableType.GROUP, SchemaType.PLAIN, schemaTO.getKey(), schemaTO); + PlainSchemaTO updatedTO = schemaService.read(AttributableType.GROUP, SchemaType.PLAIN, "icon"); assertEquals(schemaTO, updatedTO); updatedTO.setType(AttrSchemaType.Date); try { - schemaService.update(AttributableType.ROLE, SchemaType.PLAIN, schemaTO.getKey(), updatedTO); + schemaService.update(AttributableType.GROUP, SchemaType.PLAIN, schemaTO.getKey(), updatedTO); fail("This should not be reacheable"); } catch (SyncopeClientException e) { assertEquals(ClientExceptionType.InvalidPlainSchema, e.getType()); @@ -233,7 +233,7 @@ public class PlainSchemaITCase extends AbstractITCase { UserTO newUserTO = SerializationUtils.clone(userTO); MembershipTO membership = new MembershipTO(); - membership.setRoleId(2L); + membership.setGroupId(2L); newUserTO.getMemberships().add(membership); UserMod userMod = AttributableOperations.diff(newUserTO, userTO); @@ -266,11 +266,11 @@ public class PlainSchemaITCase extends AbstractITCase { @Test public void issueSYNCOPE323() { - PlainSchemaTO actual = schemaService.read(AttributableType.ROLE, SchemaType.PLAIN, "icon"); + PlainSchemaTO actual = schemaService.read(AttributableType.GROUP, SchemaType.PLAIN, "icon"); assertNotNull(actual); try { - createSchema(AttributableType.ROLE, SchemaType.PLAIN, actual); + createSchema(AttributableType.GROUP, SchemaType.PLAIN, actual); fail(); } catch (SyncopeClientException e) { assertEquals(Response.Status.CONFLICT, e.getType().getResponseStatus()); @@ -279,7 +279,7 @@ public class PlainSchemaITCase extends AbstractITCase { actual.setKey(null); try { - createSchema(AttributableType.ROLE, SchemaType.PLAIN, actual); + createSchema(AttributableType.GROUP, SchemaType.PLAIN, actual); fail(); } catch (SyncopeClientException e) { assertEquals(Response.Status.BAD_REQUEST, e.getType().getResponseStatus()); @@ -293,7 +293,7 @@ public class PlainSchemaITCase extends AbstractITCase { AttrSchemaType.Double); try { - createSchema(AttributableType.ROLE, SchemaType.PLAIN, schema); + createSchema(AttributableType.GROUP, SchemaType.PLAIN, schema); fail(); } catch (SyncopeClientException e) { assertEquals(ClientExceptionType.InvalidPlainSchema, e.getType()); http://git-wip-us.apache.org/repos/asf/syncope/blob/4095f1e8/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PolicyITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PolicyITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PolicyITCase.java index 409f29d..bdf3f90 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PolicyITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PolicyITCase.java @@ -68,7 +68,7 @@ public class PolicyITCase extends AbstractITCase { assertNotNull(policyTO); assertTrue(policyTO.getUsedByResources().isEmpty()); - assertEquals(Arrays.asList(6L, 7L, 10L, 14L), policyTO.getUsedByRoles()); + assertTrue(policyTO.getUsedByGroups().containsAll(Arrays.asList(6L, 7L, 10L, 14L))); } @Test @@ -77,7 +77,7 @@ public class PolicyITCase extends AbstractITCase { assertNotNull(policyTO); assertTrue(policyTO.getUsedByResources().contains(RESOURCE_NAME_NOPROPAGATION)); - assertEquals(Arrays.asList(6L, 7L, 10L, 8L), policyTO.getUsedByRoles()); + assertTrue(policyTO.getUsedByGroups().containsAll(Arrays.asList(6L, 7L, 10L, 8L))); } @Test @@ -85,7 +85,7 @@ public class PolicyITCase extends AbstractITCase { SyncPolicyTO policyTO = policyService.read(1L); assertNotNull(policyTO); - assertTrue(policyTO.getUsedByRoles().isEmpty()); + assertTrue(policyTO.getUsedByGroups().isEmpty()); } @Test @@ -114,7 +114,7 @@ public class PolicyITCase extends AbstractITCase { assertEquals(PolicyType.GLOBAL_SYNC, policyTO.getType()); assertFalse(policyTO.getUsedByResources().contains(RESOURCE_NAME_CSV)); assertFalse(policyTO.getUsedByResources().contains(RESOURCE_NAME_WS2)); - assertTrue(policyTO.getUsedByRoles().isEmpty()); + assertTrue(policyTO.getUsedByGroups().isEmpty()); } @Test http://git-wip-us.apache.org/repos/asf/syncope/blob/4095f1e8/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PushTaskITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PushTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PushTaskITCase.java index 3427a1d..76da48c 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PushTaskITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PushTaskITCase.java @@ -39,7 +39,7 @@ import org.apache.syncope.common.lib.to.PagedResult; import org.apache.syncope.common.lib.to.PlainSchemaTO; import org.apache.syncope.common.lib.to.PushTaskTO; import org.apache.syncope.common.lib.to.ResourceTO; -import org.apache.syncope.common.lib.to.RoleTO; +import org.apache.syncope.common.lib.to.GroupTO; import org.apache.syncope.common.lib.to.TaskExecTO; import org.apache.syncope.common.lib.types.AttrSchemaType; import org.apache.syncope.common.lib.types.AttributableType; @@ -94,8 +94,8 @@ public class PushTaskITCase extends AbstractTaskITCase { task.setResource(RESOURCE_NAME_WS2); task.setUserFilter( SyncopeClient.getUserSearchConditionBuilder().hasNotResources(RESOURCE_NAME_TESTDB2).query()); - task.setRoleFilter( - SyncopeClient.getRoleSearchConditionBuilder().isNotNull("cool").query()); + task.setGroupFilter( + SyncopeClient.getGroupSearchConditionBuilder().isNotNull("cool").query()); task.setMatchingRule(MatchingRule.LINK); final Response response = taskService.create(task); @@ -107,24 +107,24 @@ public class PushTaskITCase extends AbstractTaskITCase { assertEquals(task.getKey(), actual.getKey()); assertEquals(task.getJobClassName(), actual.getJobClassName()); assertEquals(task.getUserFilter(), actual.getUserFilter()); - assertEquals(task.getRoleFilter(), actual.getRoleFilter()); + assertEquals(task.getGroupFilter(), actual.getGroupFilter()); assertEquals(UnmatchingRule.ASSIGN, actual.getUnmatchingRule()); assertEquals(MatchingRule.LINK, actual.getMatchingRule()); } @Test - public void pushMatchingUnmatchingRoles() { - assertFalse(roleService.read(3L).getResources().contains(RESOURCE_NAME_LDAP)); + public void pushMatchingUnmatchingGroups() { + assertFalse(groupService.read(3L).getResources().contains(RESOURCE_NAME_LDAP)); execSyncTask(23L, 50, false); - assertNotNull(resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.ROLE, 3L)); - assertTrue(roleService.read(3L).getResources().contains(RESOURCE_NAME_LDAP)); + assertNotNull(resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.GROUP, 3L)); + assertTrue(groupService.read(3L).getResources().contains(RESOURCE_NAME_LDAP)); execSyncTask(23L, 50, false); - assertNotNull(resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.ROLE, 3L)); - assertFalse(roleService.read(3L).getResources().contains(RESOURCE_NAME_LDAP)); + assertNotNull(resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.GROUP, 3L)); + assertFalse(groupService.read(3L).getResources().contains(RESOURCE_NAME_LDAP)); } @Test @@ -247,27 +247,27 @@ public class PushTaskITCase extends AbstractTaskITCase { @Test public void issueSYNCOPE598() { - // create a new role schema + // create a new group schema final PlainSchemaTO schemaTO = new PlainSchemaTO(); schemaTO.setKey("LDAPGroupName" + getUUIDString()); schemaTO.setType(AttrSchemaType.String); schemaTO.setMandatoryCondition("true"); - final PlainSchemaTO newPlainSchemaTO = createSchema(AttributableType.ROLE, SchemaType.PLAIN, schemaTO); + final PlainSchemaTO newPlainSchemaTO = createSchema(AttributableType.GROUP, SchemaType.PLAIN, schemaTO); assertEquals(schemaTO, newPlainSchemaTO); - // create a new sample role - RoleTO roleTO = new RoleTO(); - roleTO.setName("all" + getUUIDString()); - roleTO.setParent(8L); + // create a new sample group + GroupTO groupTO = new GroupTO(); + groupTO.setName("all" + getUUIDString()); + groupTO.setParent(8L); - roleTO.getRPlainAttrTemplates().add(newPlainSchemaTO.getKey()); - roleTO.getPlainAttrs().add(attrTO(newPlainSchemaTO.getKey(), "all")); + groupTO.getGPlainAttrTemplates().add(newPlainSchemaTO.getKey()); + groupTO.getPlainAttrs().add(attrTO(newPlainSchemaTO.getKey(), "all")); - roleTO = createRole(roleTO); - assertNotNull(roleTO); + groupTO = createGroup(groupTO); + assertNotNull(groupTO); - String resourceName = "resource-ldap-roleonly"; + String resourceName = "resource-ldap-grouponly"; ResourceTO newResourceTO = null; try { @@ -311,7 +311,7 @@ public class PushTaskITCase extends AbstractTaskITCase { final MappingTO rmapping = new MappingTO(); item = new MappingItemTO(); - item.setIntMappingType(IntMappingType.RolePlainSchema); + item.setIntMappingType(IntMappingType.GroupPlainSchema); item.setExtAttrName("cn"); item.setIntAttrName(newPlainSchemaTO.getKey()); item.setAccountid(true); @@ -320,14 +320,14 @@ public class PushTaskITCase extends AbstractTaskITCase { rmapping.setAccountLink("'cn=' + " + newPlainSchemaTO.getKey() + " + ',ou=groups,o=isp'"); - resourceTO.setRmapping(rmapping); + resourceTO.setGmapping(rmapping); Response response = resourceService.create(resourceTO); newResourceTO = getObject(response.getLocation(), ResourceService.class, ResourceTO.class); assertNotNull(newResourceTO); assertNull(newResourceTO.getUmapping()); - assertNotNull(newResourceTO.getRmapping()); + assertNotNull(newResourceTO.getGmapping()); // create push task ad-hoc final PushTaskTO task = new PushTaskTO(); @@ -348,7 +348,7 @@ public class PushTaskITCase extends AbstractTaskITCase { final TaskExecTO pushExec = execSyncTask(push.getKey(), 50, false); assertTrue(PropagationTaskExecStatus.valueOf(pushExec.getStatus()).isSuccessful()); } finally { - roleService.delete(roleTO.getKey()); + groupService.delete(groupTO.getKey()); if (newResourceTO != null) { resourceService.delete(resourceName); } @@ -363,8 +363,8 @@ public class PushTaskITCase extends AbstractTaskITCase { task.setResource(RESOURCE_NAME_LDAP); task.setUserFilter( SyncopeClient.getUserSearchConditionBuilder().is("username").equalTo("_NO_ONE_").query()); - task.setRoleFilter( - SyncopeClient.getRoleSearchConditionBuilder().is("name").equalTo("citizen").query()); + task.setGroupFilter( + SyncopeClient.getGroupSearchConditionBuilder().is("name").equalTo("citizen").query()); task.setMatchingRule(MatchingRule.IGNORE); task.setUnmatchingRule(UnmatchingRule.IGNORE); @@ -375,8 +375,8 @@ public class PushTaskITCase extends AbstractTaskITCase { // 2. Create notification NotificationTO notification = new NotificationTO(); notification.setTraceLevel(TraceLevel.FAILURES); - notification.getEvents().add("[PushTask]:[role]:[resource-ldap]:[matchingrule_ignore]:[SUCCESS]"); - notification.getEvents().add("[PushTask]:[role]:[resource-ldap]:[unmatchingrule_ignore]:[SUCCESS]"); + notification.getEvents().add("[PushTask]:[group]:[resource-ldap]:[matchingrule_ignore]:[SUCCESS]"); + notification.getEvents().add("[PushTask]:[group]:[resource-ldap]:[unmatchingrule_ignore]:[SUCCESS]"); notification.getStaticRecipients().add("[email protected]"); notification.setSelfAsRecipient(false); http://git-wip-us.apache.org/repos/asf/syncope/blob/4095f1e8/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java index f3618d3..90664b0 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java @@ -182,13 +182,13 @@ public class ResourceITCase extends AbstractITCase { MappingTO rmapping = new MappingTO(); item = new MappingItemTO(); - item.setIntMappingType(IntMappingType.RoleId); - item.setExtAttrName("roleId"); + item.setIntMappingType(IntMappingType.GroupId); + item.setExtAttrName("groupId"); item.setAccountid(true); item.setPurpose(MappingPurpose.SYNCHRONIZATION); rmapping.setAccountIdItem(item); - resourceTO.setRmapping(rmapping); + resourceTO.setGmapping(rmapping); Response response = resourceService.create(resourceTO); ResourceTO actual = getObject(response.getLocation(), ResourceService.class, ResourceTO.class); @@ -196,9 +196,9 @@ public class ResourceITCase extends AbstractITCase { assertNotNull(actual); assertNotNull(actual.getUmapping()); assertNotNull(actual.getUmapping().getItems()); - assertNotNull(actual.getRmapping()); - assertNotNull(actual.getRmapping().getItems()); - assertEquals(MappingPurpose.SYNCHRONIZATION, actual.getRmapping().getAccountIdItem().getPurpose()); + assertNotNull(actual.getGmapping()); + assertNotNull(actual.getGmapping().getItems()); + assertEquals(MappingPurpose.SYNCHRONIZATION, actual.getGmapping().getAccountIdItem().getPurpose()); assertEquals(MappingPurpose.PROPAGATION, actual.getUmapping().getAccountIdItem().getPurpose()); } @@ -489,22 +489,22 @@ public class ResourceITCase extends AbstractITCase { MappingTO mapping = new MappingTO(); MappingItemTO item = new MappingItemTO(); - item.setIntMappingType(IntMappingType.RoleName); + item.setIntMappingType(IntMappingType.GroupName); item.setExtAttrName("cn"); item.setPurpose(MappingPurpose.BOTH); mapping.setAccountIdItem(item); item = new MappingItemTO(); - item.setIntMappingType(IntMappingType.RoleOwnerSchema); + item.setIntMappingType(IntMappingType.GroupOwnerSchema); item.setExtAttrName("owner"); item.setPurpose(MappingPurpose.BOTH); mapping.addItem(item); - resourceTO.setRmapping(mapping); + resourceTO.setGmapping(mapping); resourceTO = createResource(resourceTO); assertNotNull(resourceTO); - assertEquals(2, resourceTO.getRmapping().getItems().size()); + assertEquals(2, resourceTO.getGmapping().getItems().size()); } @Test
