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

Fix custom claims not being outbound provisioned #31

Merged
merged 1 commit into from
Jan 9, 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 @@ -87,6 +87,10 @@
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.application.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.inbound.provisioning.scim2</groupId>
<artifactId>org.wso2.carbon.identity.scim2.common</artifactId>
</dependency>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
Expand Down Expand Up @@ -115,6 +119,11 @@
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.role.v2.mgt.core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
Expand Down Expand Up @@ -204,6 +213,10 @@
org.osgi.service.component; version="${osgi.service.component.imp.pkg.version.range}",
org.wso2.carbon.identity.application.common.model;
version="${carbon.identity.framework.import.version.range}",
org.wso2.carbon.identity.scim2.common.impl;
version="${identity.inbound.provisioning.scim2.import.version.range}",
org.wso2.carbon.identity.scim2.common.utils;
version="${identity.inbound.provisioning.scim2.import.version.range}",
org.wso2.carbon.identity.provisioning;
version="${carbon.identity.framework.import.version.range}",
org.wso2.charon3.core.*; version="${charon.wso2.import.version.range}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.wso2.carbon.identity.provisioning.ProvisioningOperation;
import org.wso2.carbon.identity.provisioning.ProvisioningUtil;
import org.wso2.carbon.identity.provisioning.connector.scim2.util.SCIMClaimResolver;
import org.wso2.carbon.identity.scim2.common.utils.SCIMCommonUtils;
import org.wso2.carbon.user.core.UserCoreConstants;
import org.wso2.carbon.user.core.UserStoreException;
import org.wso2.charon3.core.attributes.ComplexAttribute;
Expand Down Expand Up @@ -361,7 +362,8 @@ public String[] getClaimDialectUris() {

return new String[]{SCIM2ProvisioningConnectorConstants.DEFAULT_SCIM2_CORE_DIALECT,
SCIM2ProvisioningConnectorConstants.DEFAULT_SCIM2_USER_DIALECT,
SCIM2ProvisioningConnectorConstants.DEFAULT_SCIM2_ENTERPRISE_DIALECT};
SCIM2ProvisioningConnectorConstants.DEFAULT_SCIM2_ENTERPRISE_DIALECT,
SCIMCommonUtils.getCustomSchemaURI()};
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.identity.provisioning.connector.scim2.SCIM2ProvisioningConnectorConstants;
import org.wso2.carbon.identity.scim2.common.impl.IdentitySCIMManager;
import org.wso2.charon3.core.attributes.Attribute;
import org.wso2.charon3.core.attributes.ComplexAttribute;
import org.wso2.charon3.core.attributes.MultiValuedAttribute;
Expand All @@ -29,6 +30,8 @@
import org.wso2.charon3.core.exceptions.BadRequestException;
import org.wso2.charon3.core.exceptions.CharonException;
import org.wso2.charon3.core.exceptions.NotFoundException;
import org.wso2.charon3.core.exceptions.NotImplementedException;
import org.wso2.charon3.core.extensions.UserManager;
import org.wso2.charon3.core.objects.AbstractSCIMObject;
import org.wso2.charon3.core.objects.Group;
import org.wso2.charon3.core.objects.SCIMObject;
Expand Down Expand Up @@ -638,7 +641,13 @@ private static ResourceTypeSchema getResourceSchema(int scimObjectType) {
ResourceTypeSchema resourceSchema = null;
switch (scimObjectType) {
case 1:
resourceSchema = SCIMResourceSchemaManager.getInstance().getUserResourceSchema();
try {
UserManager userManager = IdentitySCIMManager.getInstance().getUserManager();
resourceSchema = SCIMResourceSchemaManager.getInstance().getUserResourceSchema(userManager);
} catch (CharonException | BadRequestException | NotImplementedException e) {
log.debug("Error in getting user resource schema with user manager.", e);
resourceSchema = SCIMResourceSchemaManager.getInstance().getUserResourceSchema();
}
break;
case 2:
resourceSchema = SCIMSchemaDefinitions.SCIM_GROUP_SCHEMA;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,36 @@
*/
package org.wso2.carbon.identity.provisioning.connector.scim2.test;

import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.reflect.Whitebox;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.wso2.carbon.identity.provisioning.connector.scim2.util.SCIMClaimResolver;
import org.wso2.carbon.identity.scim2.common.impl.IdentitySCIMManager;
import org.wso2.charon3.core.extensions.UserManager;
import org.wso2.charon3.core.schema.SCIMResourceSchemaManager;
import org.wso2.charon3.core.schema.SCIMSchemaDefinitions;

import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;

@PrepareForTest(IdentitySCIMManager.class)
public class SCIMClaimResolverTest {

private SCIMClaimResolver scimClaimResolver;
private IdentitySCIMManager identitySCIMManager;
private UserManager userManager;

@BeforeMethod
public void setUp() throws Exception {

scimClaimResolver = new SCIMClaimResolver();
identitySCIMManager = Mockito.mock(IdentitySCIMManager.class);
userManager = Mockito.mock(UserManager.class);
initMocks(this);
}

Expand All @@ -57,6 +67,9 @@ public void testGetResourceSchemaforGroup() throws Exception {
public void testGetResourceSchemaforUser() throws Exception {

SCIMClaimResolver s = PowerMockito.spy(scimClaimResolver);
PowerMockito.mockStatic(IdentitySCIMManager.class);
when(IdentitySCIMManager.getInstance()).thenReturn(identitySCIMManager);
when(identitySCIMManager.getUserManager()).thenReturn(userManager);
Assert.assertEquals(Whitebox.invokeMethod(s, "getResourceSchema", 1),
SCIMResourceSchemaManager.getInstance().getUserResourceSchema());
}
Expand Down
17 changes: 15 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@
<artifactId>org.wso2.carbon.identity.application.common</artifactId>
<version>${identity.framework.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.role.v2.mgt.core</artifactId>
<version>${identity.framework.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.user.core</artifactId>
Expand Down Expand Up @@ -128,6 +133,11 @@
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.inbound.provisioning.scim2</groupId>
<artifactId>org.wso2.carbon.identity.scim2.common</artifactId>
<version>${identity.inbound.provisioning.scim2.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -309,18 +319,21 @@
<properties>
<!--Carbon framework version-->
<carbon.identity.framework.import.version.range>[5.0.0, 8.0.0)</carbon.identity.framework.import.version.range>
<identity.framework.version>5.21.37</identity.framework.version>
<identity.framework.version>7.0.78</identity.framework.version>
<identity.inbound.provisioning.scim.version>5.1.3</identity.inbound.provisioning.scim.version>
<identity.inbound.provisioning.scim.import.version.range>[5.0.0, 6.0.0)
</identity.inbound.provisioning.scim.import.version.range>
<identity.inbound.provisioning.scim2.version>3.4.67</identity.inbound.provisioning.scim2.version>
<identity.inbound.provisioning.scim2.import.version.range>[3.0.0, 4.0.0)
</identity.inbound.provisioning.scim2.import.version.range>
<identity.outbound.provisioning.scim2.export.version>${project.version}
</identity.outbound.provisioning.scim2.export.version>
<!-- Carbon kernel version -->
<carbon.kernel.version>4.4.7</carbon.kernel.version>
<osgi.framework.imp.pkg.version.range>[1.7.0, 2.0.0)</osgi.framework.imp.pkg.version.range>
<osgi.service.component.imp.pkg.version.range>[1.2.0, 2.0.0)</osgi.service.component.imp.pkg.version.range>
<!-- Charon version -->
<charon.wso2.version.identity>4.0.1</charon.wso2.version.identity>
<charon.wso2.version.identity>4.0.17</charon.wso2.version.identity>
<charon.wso2.import.version.range>[3.0.0, 4.1.0)</charon.wso2.import.version.range>
<!-- Commons -->
<commons-lang.wso2.osgi.version.range>[2.6.0,3.0.0)</commons-lang.wso2.osgi.version.range>
Expand Down
Loading