From b8df5a54392b210851c374365d1d1698b5f38f8e Mon Sep 17 00:00:00 2001 From: AnuradhaSK Date: Fri, 10 Jan 2025 02:06:44 +0530 Subject: [PATCH] return sharedProfileValueResolvingMethod in scim2 schemas response --- .../scim2/common/impl/SCIMUserManager.java | 5 +++++ .../scim2/common/impl/SCIMUserManagerTest.java | 18 ++++++++++++++++++ pom.xml | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManager.java b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManager.java index 33b7c806c..e97a40817 100644 --- a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManager.java +++ b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManager.java @@ -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"; @@ -6031,6 +6032,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)); + } } } diff --git a/components/org.wso2.carbon.identity.scim2.common/src/test/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManagerTest.java b/components/org.wso2.carbon.identity.scim2.common/src/test/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManagerTest.java index 5c6cd4c45..2a5ddf4f5 100644 --- a/components/org.wso2.carbon.identity.scim2.common/src/test/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManagerTest.java +++ b/components/org.wso2.carbon.identity.scim2.common/src/test/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManagerTest.java @@ -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; @@ -122,6 +123,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; @@ -145,6 +147,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; @@ -1199,6 +1202,8 @@ public void testGetUserSchema() throws Exception { Map supportedByDefaultProperties = new HashMap() {{ put("SupportedByDefault", "true"); put("ReadOnly", "true"); + put(ClaimConstants.SHARED_PROFILE_VALUE_RESOLVING_METHOD, + ClaimConstants.SharedProfileValueResolvingMethod.FROM_ORIGIN.getName()); }}; List localClaimList = new ArrayList() {{ @@ -1223,6 +1228,19 @@ public void testGetUserSchema() throws Exception { mockClaimMetadataManagementService, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); List 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") diff --git a/pom.xml b/pom.xml index 49f9abbb3..26f477e1c 100644 --- a/pom.xml +++ b/pom.xml @@ -294,7 +294,7 @@ 6.5.3 3.2.0.wso2v1 4.10.24 - 7.7.40 + 7.7.85 4.13.1 20030203.000129 1.8.12