diff --git a/core/org.wso2.carbon.user.core/src/test/java/org/wso2/carbon/user/core/jdbc/UniqueIDJDBCRealmPrimaryUserStoreTest.java b/core/org.wso2.carbon.user.core/src/test/java/org/wso2/carbon/user/core/jdbc/UniqueIDJDBCRealmPrimaryUserStoreTest.java index 40012087c3c..d759da90246 100644 --- a/core/org.wso2.carbon.user.core/src/test/java/org/wso2/carbon/user/core/jdbc/UniqueIDJDBCRealmPrimaryUserStoreTest.java +++ b/core/org.wso2.carbon.user.core/src/test/java/org/wso2/carbon/user/core/jdbc/UniqueIDJDBCRealmPrimaryUserStoreTest.java @@ -555,44 +555,44 @@ public void test194GetUserListWithIDCondition() throws UserStoreException { public void test194GetUserListWithIDConditionCursor() throws Exception { - // Current user list admin, user1WithID, user2, user2WithID, user3, user3WithID, user4, user4WithID + // Current user list admin, user1WithID, user2, user2WithID, user3, user3WithID, user4, user4WithID. - // userName sw use + // userName sw use. ExpressionCondition expressionCondition = new ExpressionCondition(ExpressionOperation.SW.toString(), ExpressionAttribute.USERNAME.toString(), "use"); ExpressionCondition noConditions = new ExpressionCondition(ExpressionOperation.SW.toString(), ExpressionAttribute.USERNAME.toString(), ""); - //Making a List of expressionConditions for multi-attribute filtering - // userName co WithID + //Making a List of expressionConditions for multi-attribute filtering. + // userName co WithID. ExpressionCondition expressionCondition2 = new ExpressionCondition(ExpressionOperation.CO.toString(), ExpressionAttribute.USERNAME.toString(), "WithID"); - // userName sw use and userName co WithID + // userName sw use and userName co WithID. OperationalCondition multiFiltering = new OperationalCondition("AND", expressionCondition, expressionCondition2); - // No filtering + // No filtering. assertEquals(8, admin.getUserListWithID(noConditions, null, null, 10, "", "NEXT", null, null).size()); - // Single userName filtering initial query (no cursor) + // Single userName filtering initial query (no cursor). assertEquals(7, admin.getUserListWithID(expressionCondition, null, null, 10, "", "NEXT", null, null).size()); - // Single userName filtering - Forwards cursor pagination + // Single userName filtering - Forwards cursor pagination. assertEquals(4, admin.getUserListWithID(expressionCondition, null, null, 10, "user2WithID", "NEXT", null, null) .size()); - // Single userName filtering - Backwards cursor pagination + // Single userName filtering - Backwards cursor pagination. assertEquals(2, admin.getUserListWithID(expressionCondition, null, null, 10, "user2WithID", "PREVIOUS", null, null).size()); - // Multiple filter conditions with userName attribute - Forwards cursor pagination + // Multiple filter conditions with userName attribute - Forwards cursor pagination. assertEquals(4, admin.getUserListWithID(multiFiltering, null, null, 10, "", "NEXT", null, null).size()); - // Multiple filter conditions with userName attribute - Backwards cursor pagination + // Multiple filter conditions with userName attribute - Backwards cursor pagination. assertEquals(1, admin.getUserListWithID(multiFiltering, null, null, 10, "user2WithID", "PREVIOUS", null, null) .size()); - // Setup for claim filtering + // Setup for claim filtering. Map claims = new HashMap<>(); claims.put(ClaimTestUtil.CLAIM_URI1, "Alucard"); claims.put(ClaimTestUtil.CLAIM_URI6, "Tepes, Alucard"); @@ -611,98 +611,109 @@ public void test194GetUserListWithIDConditionCursor() throws Exception { admin.addUser("Annie", "pass100", null, claims, null, false); // New user list: admin, Akira, Alphonse, Alucard, Annie, user1WithID, user2, user2WithID, user3, user3WithID, - // user4, user4WithID - // Having claims: Akira, Alphonse, Alucard, Annie + // user4, user4WithID. + // Having claims: Akira, Alphonse, Alucard, Annie. - // givenname sw A + // givenname sw A. ExpressionCondition claimFiltering1 = new ExpressionCondition(ExpressionOperation.SW.toString(), "attr1", "A"); - // fullname sw T + // fullname sw T. ExpressionCondition claimFiltering2 = new ExpressionCondition(ExpressionOperation.SW.toString(), "fullname", "T"); - // givenname sw A and fullname sw T + // givenname sw A and fullname sw T. OperationalCondition multiClaimFiltering = new OperationalCondition("AND", claimFiltering1, claimFiltering2); - // Single claim filtering forward cursor pagination + // Single claim filtering forward cursor pagination. assertEquals(4, admin.getUserListWithID(claimFiltering1, null, null, 10, "", "NEXT", null, null).size()); - // Single claim filtering backwards cursor pagination + // Single claim filtering backwards cursor pagination. assertEquals(2, admin.getUserListWithID(claimFiltering1, null, null, 10, "Alucard", "PREVIOUS", null, null) .size()); - // Multi claim filtering forwards cursor pagination + // Multi claim filtering forwards cursor pagination. assertEquals(2, admin.getUserListWithID(multiClaimFiltering, null, null, 10, "", "NEXT", null, null).size()); - // Multi claim filtering backwards cursor pagination + // Multi claim filtering backwards cursor pagination. assertEquals(1, admin.getUserListWithID(multiClaimFiltering, null, null, 10, "Alucard", "PREVIOUS", null, null) .size()); - // Role configuration for group filtering + // Role configuration for group filtering. -// admin.addUser("user1", "pass1", new String[]{"role1"}, null, null, false); admin.addRole("Manager", new String[]{"Alucard", "Akira", "Alphonse", "Annie", "user2", "user2WithID", "user3", "user3WithID"}, null); admin.addRole("HeadManager", new String[]{"Alucard", "Akira", "Alphonse", "Annie", "user2", "user2WithID", "user3", "user4"}, null); - // New role list: admin, Internal/everyone, role1WithID, role3, role4, Manager, HeadManager + // New role list: admin, Internal/everyone, role1WithID, role3, role4, Manager, HeadManager. - // groups eq Manager + // groups eq Manager. ExpressionCondition groupFiltering = new ExpressionCondition(ExpressionOperation.EQ.toString(), ExpressionAttribute.ROLE.toString(), "Manager"); - // group eq HeadManager + // group eq HeadManager. ExpressionCondition groupFiltering2 = new ExpressionCondition(ExpressionOperation.EQ.toString(), ExpressionAttribute.ROLE.toString(), "HeadManager"); - // groups eq Manager and groups eq HeadManager + // groups eq Manager and groups eq HeadManager. OperationalCondition multiGroupFiltering = new OperationalCondition("AND", groupFiltering, groupFiltering2); - // Group Filtering forwards cursor pagination + // Group Filtering forwards cursor pagination. assertEquals(3, admin.getUserListWithID(groupFiltering, null, null, 10, "user2", "NEXT", null, null).size()); - // Group Filtering backwards cursor pagination + // Group Filtering backwards cursor pagination. assertEquals(6, admin.getUserListWithID(groupFiltering, null, null, 10, "user3", "PREVIOUS", null, null) .size()); - // Multi-group filtering forwards cursor pagination + // Multi-group filtering forwards cursor pagination. assertEquals(2, admin.getUserListWithID(multiGroupFiltering, null, null, 10, "user2", "NEXT", null, null) .size()); - // Multi-group filtering backwards cursor pagination + // Multi-group filtering backwards cursor pagination. assertEquals(3, admin.getUserListWithID(multiGroupFiltering, null, null, 10, "Annie", "PREVIOUS", null, null) .size()); - // groups eq Manager and groups eq HeadManager and userName sw use + // groups eq Manager and groups eq HeadManager and userName sw use. OperationalCondition groupAndUserNameFilter = new OperationalCondition("AND", multiGroupFiltering, expressionCondition); - // Multi-group filtering and userName filtering forward cursor pagination + // Multi-group filtering and userName filtering forward cursor pagination. assertEquals(3, admin.getUserListWithID(groupAndUserNameFilter, null, null, 10, "", "NEXT", null, null).size()); - // Multi-group filtering and userName filtering backwards cursor pagination + // Multi-group filtering and userName filtering backwards cursor pagination. assertEquals(1, admin.getUserListWithID(groupAndUserNameFilter, null, null, 10, "user2WithID", "PREVIOUS", null, null).size()); - // givenname sw A and groups eq Manager + // givenname sw A and groups eq Manager. OperationalCondition singleClaimAndGroupFilter = new OperationalCondition("AND", claimFiltering1, groupFiltering); - // givenname sw A and groups eq Manager and groups eq HeadManager + // givenname sw A and groups eq Manager and groups eq HeadManager. OperationalCondition singleClaimAndMultiGroupFilter = new OperationalCondition("AND", claimFiltering1, multiGroupFiltering); - // givenname sw A and fullname sw T and groups eq Manager and groups eq HeadManager + // givenname sw A and fullname sw T and groups eq Manager and groups eq HeadManager. OperationalCondition multiGroupAndMultiClaimFilter = new OperationalCondition("AND", multiClaimFiltering, multiGroupFiltering); - // Having claims + In the manager and HeadManager groups: Akira, Alphonse, Alucard, Annie + // Having claims + In the manager and HeadManager groups: Akira, Alphonse, Alucard, Annie. - // Single group and claim filtering forward cursor pagination + // Single group and claim filtering forward cursor pagination. assertEquals(3, admin.getUserListWithID(singleClaimAndGroupFilter, null, null, 10, "Akira", "NEXT", null, null) .size()); - // Multi-group filtering and single claim filtering forward cursor pagination + // Single group and claim filtering backward cursor pagination. + assertEquals(0, admin.getUserListWithID(singleClaimAndGroupFilter, null, null, 10, "Akira", "PREVIOUS", null, + null).size()); + + // Multi-group filtering and single claim filtering forward cursor pagination. assertEquals(4, admin.getUserListWithID(singleClaimAndMultiGroupFilter, null, null, 10, "", "NEXT", null, null) .size()); - // Multi-group filtering and multi-claim filtering forward cursor pagination + // Multi-group filtering and single claim filtering backward cursor pagination. + assertEquals(3, admin.getUserListWithID(singleClaimAndMultiGroupFilter, null, null, 10, "Annie", "PREVIOUS", null, + null).size()); + + // Multi-group filtering and multi-claim filtering forward cursor pagination. assertEquals(1, admin.getUserListWithID(multiGroupAndMultiClaimFilter, null, null, 10, "Akira", "NEXT", null, null).size()); + + // Multi-group filtering and multi-claim filtering backward cursor pagination. + assertEquals(1, admin.getUserListWithID(multiGroupAndMultiClaimFilter, null, null, 10, "Alucard", "PREVIOUS", + null, null).size()); } public void test195GetRoleListOfUserWithID() throws UserStoreException { diff --git a/core/org.wso2.carbon.user.core/src/test/java/org/wso2/carbon/user/core/jdbc/UniqueIDJDBCRealmSecondaryUserStoreTest.java b/core/org.wso2.carbon.user.core/src/test/java/org/wso2/carbon/user/core/jdbc/UniqueIDJDBCRealmSecondaryUserStoreTest.java index 0b9722966be..e3f4e12ab61 100644 --- a/core/org.wso2.carbon.user.core/src/test/java/org/wso2/carbon/user/core/jdbc/UniqueIDJDBCRealmSecondaryUserStoreTest.java +++ b/core/org.wso2.carbon.user.core/src/test/java/org/wso2/carbon/user/core/jdbc/UniqueIDJDBCRealmSecondaryUserStoreTest.java @@ -591,45 +591,45 @@ public void test194GetUserListWithIDCondition() throws UserStoreException { public void test194GetUserListWithIDConditionCursor() throws Exception { - // Current user list: user1WithID, user2, user2WithID, user3, user3WithID, user4WithID + // Current user list: user1WithID, user2, user2WithID, user3, user3WithID, user4WithID. - // userName sw use + // userName sw use. ExpressionCondition expressionCondition = new ExpressionCondition(ExpressionOperation.SW.toString(), ExpressionAttribute.USERNAME.toString(), "use"); ExpressionCondition noConditions = new ExpressionCondition(ExpressionOperation.SW.toString(), ExpressionAttribute.USERNAME.toString(), ""); - //Making a List of expressionConditions for multi-attribute filtering - // userName co WithID + //Making a List of expressionConditions for multi-attribute filtering. + // userName co WithID. ExpressionCondition expressionCondition2 = new ExpressionCondition(ExpressionOperation.CO.toString(), ExpressionAttribute.USERNAME.toString(), "WithID"); - // userName sw use and userName co WithID + // userName sw use and userName co WithID. OperationalCondition multiFiltering = new OperationalCondition("AND", expressionCondition, expressionCondition2); - // No filtering + // No filtering. assertEquals(6, admin.getUserListWithID(noConditions, "SECONDARY", null, 10, "", "NEXT", null, null).size()); - // Single userName filtering initial query (no cursor) + // Single userName filtering initial query (no cursor). assertEquals(6, admin.getUserListWithID(expressionCondition, "SECONDARY", null, 10, "", "NEXT", null, null) .size()); - // Single userName filtering - Forwards cursor pagination + // Single userName filtering - Forwards cursor pagination. assertEquals(3, admin.getUserListWithID(expressionCondition, "SECONDARY", null, 10, "user2WithID", "NEXT", null, null).size()); - // Single userName filtering - Backwards cursor pagination + // Single userName filtering - Backwards cursor pagination. assertEquals(2, admin.getUserListWithID(expressionCondition, "SECONDARY", null, 10, "user2WithID", "PREVIOUS", null, null).size()); - // Multi userName filtering - Forwards cursor pagination + // Multi userName filtering - Forwards cursor pagination. assertEquals(4, admin.getUserListWithID(multiFiltering, "SECONDARY", null, 10, "", "NEXT", null, null).size()); - // Multi userName filtering - Backwards cursor pagination + // Multi userName filtering - Backwards cursor pagination. assertEquals(1, admin.getUserListWithID(multiFiltering, "SECONDARY", null, 10, "user2WithID", "PREVIOUS", null, null).size()); - // Setup for claim filtering + // Setup for claim filtering. Map claims = new HashMap<>(); claims.put(ClaimTestUtil.CLAIM_URI1, "Alucard"); claims.put(ClaimTestUtil.CLAIM_URI6, "Tepes, Alucard"); @@ -648,104 +648,115 @@ public void test194GetUserListWithIDConditionCursor() throws Exception { admin.addUser("SECONDARY/Annie", "pass100", null, claims, null, false); // New user list: Akira, Alphonse, Alucard, Annie, user1WithID, user2, user2WithID, user3, user3WithID, - // user4WithID - // Having claims: Akira, Alphonse, Alucard, Annie + // user4WithID. + // Having claims: Akira, Alphonse, Alucard, Annie. - // givenname sw A + // givenname sw A. ExpressionCondition claimFiltering1 = new ExpressionCondition( ExpressionOperation.SW.toString(), "attr1", "A"); - // fullname sw T + // fullname sw T. ExpressionCondition claimFiltering2 = new ExpressionCondition( ExpressionOperation.SW.toString(), "fullname", "T"); - // givenname sw A and fullname sw T + // givenname sw A and fullname sw T. OperationalCondition multiClaimFiltering = new OperationalCondition("AND", claimFiltering1, claimFiltering2); - // Single claim filtering forward cursor pagination + // Single claim filtering forward cursor pagination. assertEquals(4, admin.getUserListWithID(claimFiltering1, "SECONDARY", null, 10, "", "NEXT", null, null).size()); - // Single claim filtering backwards cursor pagination + // Single claim filtering backwards cursor pagination. assertEquals(2, admin.getUserListWithID(claimFiltering1, "SECONDARY", null, 10, "Alucard", "PREVIOUS", null, null).size()); - // Multi claim filtering forwards cursor pagination + // Multi claim filtering forwards cursor pagination. assertEquals(2, admin.getUserListWithID(multiClaimFiltering, "SECONDARY", null, 10, "", "NEXT", null, null) .size()); - // Multi claim filtering backwards cursor pagination + // Multi claim filtering backwards cursor pagination. assertEquals(1, admin.getUserListWithID(multiClaimFiltering, "SECONDARY", null, 10, "Alucard", "PREVIOUS", null, null).size()); - // Role configuration for group filtering + // Role configuration for group filtering. -// admin.addUser("user1", "pass1", new String[]{"role1"}, null, null, false); admin.addRole("SECONDARY/Manager", new String[]{"SECONDARY/Alucard", "SECONDARY/Akira", "SECONDARY/Alphonse", "SECONDARY/Annie", "SECONDARY/user2", "SECONDARY/user2WithID", "SECONDARY/user3", "SECONDARY/user3WithID"}, null); admin.addRole("SECONDARY/HeadManager", new String[]{"SECONDARY/Alucard", "SECONDARY/Akira", "SECONDARY/Alphonse", "SECONDARY/Annie", "SECONDARY/user2", "SECONDARY/user2WithID", "SECONDARY/user3"}, null); - // New role list: admin, Internal/everyone, role1WithID, role3, role4, Manager, HeadManager + // New role list: admin, Internal/everyone, role1WithID, role3, role4, Manager, HeadManager. - // groups eq Manager + // groups eq Manager. ExpressionCondition groupFiltering = new ExpressionCondition( ExpressionOperation.EQ.toString(), ExpressionAttribute.ROLE.toString(), "Manager"); - // group eq HeadManager + // group eq HeadManager. ExpressionCondition groupFiltering2 = new ExpressionCondition( ExpressionOperation.EQ.toString(), ExpressionAttribute.ROLE.toString(), "HeadManager"); - // groups eq Manager and groups eq HeadManager + // groups eq Manager and groups eq HeadManager. OperationalCondition multiGroupFiltering = new OperationalCondition("AND", groupFiltering, groupFiltering2); - // Group Filtering forwards cursor pagination + // Group Filtering forwards cursor pagination. assertEquals(3, admin.getUserListWithID(groupFiltering, "SECONDARY", null, 10, "user2", "NEXT", null, null) .size()); - // Group Filtering backwards cursor pagination + // Group Filtering backwards cursor pagination. assertEquals(6, admin.getUserListWithID(groupFiltering, "SECONDARY", null, 10, "user3", "PREVIOUS", null, null) .size()); - // Multi-group filtering forwards cursor pagination + // Multi-group filtering forwards cursor pagination. assertEquals(2, admin.getUserListWithID(multiGroupFiltering, "SECONDARY", null, 10, "user2", "NEXT", null, null) .size()); - // Multi-group filtering backwards cursor pagination + // Multi-group filtering backwards cursor pagination. assertEquals(3, admin.getUserListWithID(multiGroupFiltering, "SECONDARY", null, 10, "Annie", "PREVIOUS", null, null).size()); - // groups eq Manager and groups eq HeadManager and userName sw use + // groups eq Manager and groups eq HeadManager and userName sw use. OperationalCondition groupAndUserNameFilter = new OperationalCondition("AND", multiGroupFiltering, expressionCondition); - // Multi-group filtering and userName filtering forward cursor pagination + // Multi-group filtering and userName filtering forward cursor pagination. assertEquals(3, admin.getUserListWithID(groupAndUserNameFilter, "SECONDARY", null, 10, "", "NEXT", null, null) .size()); - // Multi-group filtering and userName filtering backwards cursor pagination + // Multi-group filtering and userName filtering backwards cursor pagination. assertEquals(1, admin.getUserListWithID(groupAndUserNameFilter, "SECONDARY", null, 10, "user2WithID", "PREVIOUS", null, null).size()); - // givenname sw A and groups eq Manager + // givenname sw A and groups eq Manager. OperationalCondition singleClaimAndGroupFilter = new OperationalCondition("AND", claimFiltering1, groupFiltering); - // givenname sw A and groups eq Manager and groups eq HeadManager + // givenname sw A and groups eq Manager and groups eq HeadManager. OperationalCondition singleClaimAndMultiGroupFilter = new OperationalCondition("AND", claimFiltering1, multiGroupFiltering); - // givenname sw A and fullname sw T and groups eq Manager and groups eq HeadManager + // givenname sw A and fullname sw T and groups eq Manager and groups eq HeadManager. OperationalCondition multiGroupAndMultiClaimFilter = new OperationalCondition("AND", multiClaimFiltering, multiGroupFiltering); - // Having claims + In the manager and HeadManager groups: Akira, Alphonse, Alucard, Annie + // Having claims + In the manager and HeadManager groups: Akira, Alphonse, Alucard, Annie. - // Single group and claim filtering forward cursor pagination + // Single group and claim filtering forward cursor pagination. assertEquals(3, admin.getUserListWithID(singleClaimAndGroupFilter, "SECONDARY", null, 10, "Akira", "NEXT", null, null).size()); - // Multi-group filtering and single claim filtering forward cursor pagination + // Single group and claim filtering backward cursor pagination. + assertEquals(0, admin.getUserListWithID(singleClaimAndGroupFilter, "SECONDARY", null, 10, "Akira", "PREVIOUS", + null, null).size()); + + // Multi-group filtering and single claim filtering forward cursor pagination. assertEquals(4, admin.getUserListWithID(singleClaimAndMultiGroupFilter, "SECONDARY", null, 10, "", "NEXT", null, null).size()); - // Multi-group filtering and multi-claim filtering forward cursor pagination + // Multi-group filtering and single claim filtering backward cursor pagination. + assertEquals(3, admin.getUserListWithID(singleClaimAndMultiGroupFilter, "SECONDARY", null, 10, "Annie", + "PREVIOUS", null, null).size()); + + // Multi-group filtering and multi-claim filtering forward cursor pagination. assertEquals(1, admin.getUserListWithID(multiGroupAndMultiClaimFilter, "SECONDARY", null, 10, "Akira", "NEXT", null, null).size()); + + // Multi-group filtering and multi-claim filtering backward cursor pagination. + assertEquals(1, admin.getUserListWithID(multiGroupAndMultiClaimFilter, "SECONDARY", null, 10, "Alucard", + "PREVIOUS", null, null).size()); } public void test195GetRoleListOfUserWithID() throws UserStoreException {