Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into hard-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
sandushi committed Oct 18, 2024
2 parents f3af659 + f8f6cc5 commit 3377826
Show file tree
Hide file tree
Showing 24 changed files with 743 additions and 668 deletions.
12 changes: 7 additions & 5 deletions components/org.wso2.carbon.identity.scim2.common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<groupId>org.wso2.carbon.identity.inbound.provisioning.scim2</groupId>
<artifactId>identity-inbound-provisioning-scim2</artifactId>
<relativePath>../../pom.xml</relativePath>
<version>3.4.92-SNAPSHOT</version>
<version>3.4.98-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -177,12 +177,14 @@
<artifactId>testng</artifactId>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-testng</artifactId>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<groupId>org.mockito</groupId>
<artifactId>mockito-testng</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jacoco</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.user.core.UserCoreConstants;
import org.wso2.carbon.user.core.common.AbstractUserStoreManager;
import org.wso2.carbon.user.core.util.UserCoreUtil;
import org.wso2.charon3.core.exceptions.BadRequestException;
import org.wso2.charon3.core.exceptions.CharonException;
import org.wso2.charon3.core.exceptions.ConflictException;
Expand Down Expand Up @@ -812,11 +813,9 @@ private void prepareAddedRemovedUserLists(Set<String> addedMembers, Set<String>
userStoreManager.getUserListWithID(SCIMConstants.CommonSchemaConstants.ID_URI,
memberObject.get(SCIMConstants.CommonSchemaConstants.VALUE), null);
if (isNotEmpty(userListWithID)) {
String tempDisplay = userListWithID.get(0).getUsername();
if(StringUtils.isNotBlank(userListWithID.get(0).getUserStoreDomain())) {
tempDisplay = userListWithID.get(0).getUserStoreDomain() + "/" + tempDisplay;
}
memberObject.put(SCIMConstants.RoleSchemaConstants.DISPLAY, tempDisplay);
memberObject.put(SCIMConstants.RoleSchemaConstants.DISPLAY,
UserCoreUtil.addDomainToName(userListWithID.get(0).getUsername(),
userListWithID.get(0).getUserStoreDomain()));
memberOperation.setValues(memberObject);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1474,18 +1474,7 @@ private UsersGetResponse filterUsersBySingleAttribute(ExpressionNode node, Map<S
|| SCIMCommonUtils.isConsiderTotalRecordsForTotalResultOfLDAPEnabled()) {
int maxLimit = getMaxLimit(domainName);
if (!SCIMCommonUtils.isConsiderMaxLimitForTotalResultEnabled()) {
if (StringUtils.isBlank(domainName)) {
String[] userStoreDomainNames = getDomainNames();
boolean canCountTotalUserCount = canCountTotalUserCount(userStoreDomainNames);
if (canCountTotalUserCount) {
for (String userStoreDomainName : userStoreDomainNames) {
maxLimit += getTotalUsers(node, userStoreDomainName);
}
}
} else {
maxLimit = getMaxLimitForTotalResults(domainName);
}
maxLimit = Math.max(maxLimit, limit);
maxLimit = Integer.MAX_VALUE;
}
// Get total users based on the filter query without depending on pagination params.
if (SCIMCommonUtils.isGroupBasedUserFilteringImprovementsEnabled() &&
Expand Down Expand Up @@ -1541,11 +1530,11 @@ private boolean isAllConfiguredUserStoresJDBC() {
return canCountTotalUserCount(userStoreDomainNames);
}

private int getMaxLimitForTotalResults(String domainName) throws CharonException {
private int getMaxLimitForTotalResults(String domainName) {

int maxLimit = getMaxLimit(domainName);
if (isJDBCUSerStore(domainName) && !SCIMCommonUtils.isConsiderMaxLimitForTotalResultEnabled()) {
maxLimit = Math.toIntExact(getTotalUsers(domainName));
maxLimit = Integer.MAX_VALUE;
}
return maxLimit;
}
Expand Down Expand Up @@ -3001,7 +2990,7 @@ public GroupsGetResponse listGroupsWithGET(Node rootNode, Integer startIndex, In
startIndex = handleStartIndexEqualsNULL(startIndex);
if (sortBy != null || sortOrder != null) {
throw new NotImplementedException("Sorting is not supported");
} else if (startIndex != 1 || count != null) {
} else if (startIndex != 1 && count != null) {
throw new NotImplementedException("Pagination is not supported");
} else if (rootNode != null) {
return filterGroups(rootNode, startIndex, count, sortBy, sortOrder, domainName, requiredAttributes);
Expand Down Expand Up @@ -4858,7 +4847,7 @@ private Set<org.wso2.carbon.user.core.common.User> paginateUsers(Set<org.wso2.ca
// If users.length > limit + offset, then return only the users bounded by the offset and the limit.
AbstractSet<org.wso2.carbon.user.core.common.User> usersSorted = new TreeSet<>(
Comparator.comparing(org.wso2.carbon.user.core.common.User::getFullQualifiedUsername));
if (users.size() > limit + offset) {
if (Integer.MAX_VALUE != limit && users.size() > limit + offset) {
usersSorted.addAll(new ArrayList<>(sortedSet).subList(offset - 1, limit + offset - 1));
} else {
// Return all the users from the offset.
Expand Down
Loading

0 comments on commit 3377826

Please sign in to comment.