Skip to content

Commit

Permalink
Merge pull request #592 from AnuradhaSK/shared-user-update
Browse files Browse the repository at this point in the history
Return SharedProfileValueResolvingMethod property value for each claim in /scim2/Schemas API
  • Loading branch information
AnuradhaSK authored Jan 10, 2025
2 parents 3aa63db + b8df5a5 commit 84a3995
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ public class SCIMUserManager implements UserManager {
private static final String DISPLAY_ORDER_PROPERTY = "displayOrder";
private static final String REGULAR_EXPRESSION_PROPERTY = "regEx";
private static final String EXCLUDED_USER_STORES_PROPERTY = "excludedUserStores";
private static final String SHARED_PROFILE_VALUE_RESOLVING_METHOD_PROPERTY = "sharedProfileValueResolvingMethod";
private static final String LOCATION_CLAIM = "http://wso2.org/claims/location";
private static final String LAST_MODIFIED_CLAIM = "http://wso2.org/claims/modified";
private static final String RESOURCE_TYPE_CLAIM = "http://wso2.org/claims/resourceType";
Expand Down Expand Up @@ -6036,6 +6037,10 @@ private void populateBasicAttributes(LocalClaim mappedLocalClaim, AbstractAttrib
attribute.addAttributeProperty(EXCLUDED_USER_STORES_PROPERTY,
mappedLocalClaim.getClaimProperty(ClaimConstants.EXCLUDED_USER_STORES_PROPERTY));
}
if (mappedLocalClaim.getClaimProperty(ClaimConstants.SHARED_PROFILE_VALUE_RESOLVING_METHOD) != null) {
attribute.addAttributeProperty(SHARED_PROFILE_VALUE_RESOLVING_METHOD_PROPERTY,
mappedLocalClaim.getClaimProperty(ClaimConstants.SHARED_PROFILE_VALUE_RESOLVING_METHOD));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.wso2.carbon.identity.claim.metadata.mgt.model.AttributeMapping;
import org.wso2.carbon.identity.claim.metadata.mgt.model.ExternalClaim;
import org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim;
import org.wso2.carbon.identity.claim.metadata.mgt.util.ClaimConstants;
import org.wso2.carbon.identity.configuration.mgt.core.ConfigurationManager;
import org.wso2.carbon.identity.core.util.IdentityTenantUtil;
import org.wso2.carbon.identity.core.util.IdentityUtil;
Expand Down Expand Up @@ -124,6 +125,7 @@
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;

Expand All @@ -147,6 +149,7 @@ public class SCIMUserManagerTest {
private static final String USER_SCHEMA_ADDRESS_HOME = "urn:ietf:params:scim:schemas:core:2.0:User:addresses.home";
private static final String USER_SCHEMA_ADDRESS_WORK= "urn:ietf:params:scim:schemas:core:2.0:User:addresses.work";
private static final String MAX_LIMIT_RESOURCE_NAME = "user-response-limit";
private static final String SHARED_PROFILE_VALUE_RESOLVING_METHOD_PROPERTY = "sharedProfileValueResolvingMethod";

@Mock
private AbstractUserStoreManager mockedUserStoreManager;
Expand Down Expand Up @@ -1242,6 +1245,8 @@ public void testGetUserSchema() throws Exception {
Map<String, String> supportedByDefaultProperties = new HashMap<String, String>() {{
put("SupportedByDefault", "true");
put("ReadOnly", "true");
put(ClaimConstants.SHARED_PROFILE_VALUE_RESOLVING_METHOD,
ClaimConstants.SharedProfileValueResolvingMethod.FROM_ORIGIN.getName());
}};

List<LocalClaim> localClaimList = new ArrayList<LocalClaim>() {{
Expand All @@ -1266,6 +1271,19 @@ public void testGetUserSchema() throws Exception {
mockClaimMetadataManagementService, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
List<Attribute> list = scimUserManager.getUserSchema();
assertEquals(list.size(), 3);
// First item is emails claim.
assertEquals(list.get(0).getName(), "emails");
assertEquals(list.get(0).getAttributeProperties().get(SHARED_PROFILE_VALUE_RESOLVING_METHOD_PROPERTY),
ClaimConstants.SharedProfileValueResolvingMethod.FROM_ORIGIN.getName());
// Second item is name claim.
assertEquals(list.get(1).getName(), "name");
assertFalse(list.get(1).getAttributeProperties().containsKey(SHARED_PROFILE_VALUE_RESOLVING_METHOD_PROPERTY));
assertEquals(list.get(1).getSubAttribute("givenName").getAttributeProperties()
.get(SHARED_PROFILE_VALUE_RESOLVING_METHOD_PROPERTY),
ClaimConstants.SharedProfileValueResolvingMethod.FROM_ORIGIN.getName());
// Third item is userName claim.
assertEquals(list.get(2).getName(), "userName");
assertFalse(list.get(2).getAttributeProperties().containsKey(SHARED_PROFILE_VALUE_RESOLVING_METHOD_PROPERTY));
}

@Test(dataProvider = "groupPermission")
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
<inbound.auth.oauth.version>6.5.3</inbound.auth.oauth.version>
<commons-collections.version>3.2.0.wso2v1</commons-collections.version>
<carbon.kernel.version>4.10.24</carbon.kernel.version>
<identity.framework.version>7.7.40</identity.framework.version>
<identity.framework.version>7.7.85</identity.framework.version>
<junit.version>4.13.1</junit.version>
<commons.lang.version>20030203.000129</commons.lang.version>
<identity.governance.version>1.8.12</identity.governance.version>
Expand Down

0 comments on commit 84a3995

Please sign in to comment.