Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return SharedProfileValueResolvingMethod property value for each claim in /scim2/Schemas API #592

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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";
SujanSanjula96 marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -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));
}
}
}

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 @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -1199,6 +1202,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 @@ -1223,6 +1228,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
Loading