From d5062fb3d1fcfdffb2bbb4105d9c6645f04c3bf6 Mon Sep 17 00:00:00 2001 From: lashinie Date: Tue, 19 Nov 2024 16:25:29 +0530 Subject: [PATCH] fix unit tests --- .../pom.xml | 4 + .../dcr/endpoint/util/DCRMUtilsTest.java | 19 + .../test/resources/repository/conf/carbon.xml | 684 ++++++++++++++++++ 3 files changed, 707 insertions(+) create mode 100644 components/org.wso2.carbon.identity.api.server.dcr/src/test/resources/repository/conf/carbon.xml diff --git a/components/org.wso2.carbon.identity.api.server.dcr/pom.xml b/components/org.wso2.carbon.identity.api.server.dcr/pom.xml index c64de87007d..3d9edb60a70 100644 --- a/components/org.wso2.carbon.identity.api.server.dcr/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.dcr/pom.xml @@ -146,6 +146,10 @@ jaxp-ri test + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.testutil + diff --git a/components/org.wso2.carbon.identity.api.server.dcr/src/test/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/util/DCRMUtilsTest.java b/components/org.wso2.carbon.identity.api.server.dcr/src/test/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/util/DCRMUtilsTest.java index 0a1a17abe24..a04c10a3823 100644 --- a/components/org.wso2.carbon.identity.api.server.dcr/src/test/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/util/DCRMUtilsTest.java +++ b/components/org.wso2.carbon.identity.api.server.dcr/src/test/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/util/DCRMUtilsTest.java @@ -19,10 +19,14 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.testng.Assert; +import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.identity.common.testng.WithCarbonHome; import org.wso2.carbon.identity.oauth.dcr.exception.DCRMException; +import org.wso2.carbon.identity.oauth.dcr.service.DCRMService; import org.wso2.carbon.identity.oauth2.dcr.endpoint.dto.RegistrationRequestDTO; import org.wso2.carbon.identity.oauth2.dcr.endpoint.dto.UpdateRequestDTO; import org.wso2.carbon.identity.oauth2.dcr.endpoint.exceptions.DCRMEndpointException; @@ -32,12 +36,27 @@ import javax.ws.rs.core.Response; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.mockStatic; +import static org.mockito.Mockito.when; + +@WithCarbonHome public class DCRMUtilsTest { private List redirectUris = new ArrayList<>(); private List grantTypes = new ArrayList<>(); private final String clientName = "Application"; + @BeforeClass + public void setup() { + + mockStatic(PrivilegedCarbonContext.class); + PrivilegedCarbonContext privilegedCarbonContext = mock(PrivilegedCarbonContext.class); + when(PrivilegedCarbonContext.getThreadLocalCarbonContext()).thenReturn(privilegedCarbonContext); + when(PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(DCRMService.class, null)) + .thenReturn(mock(DCRMService.class)); + } + @BeforeMethod public void setUp() throws Exception { diff --git a/components/org.wso2.carbon.identity.api.server.dcr/src/test/resources/repository/conf/carbon.xml b/components/org.wso2.carbon.identity.api.server.dcr/src/test/resources/repository/conf/carbon.xml new file mode 100644 index 00000000000..faae9528f41 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.dcr/src/test/resources/repository/conf/carbon.xml @@ -0,0 +1,684 @@ + + + + + + + + WSO2 Identity Server + + + IS + + + 5.3.0 + + + localhost + + + localhost + + + local:/${carbon.context}/services/ + + + + + + + IdentityServer + + + + + + + org.wso2.carbon + + + / + + + + + + + + + 15 + + + + + + + + + 0 + + + + + 9999 + + 11111 + + + + + + 10389 + + 8000 + + + + + + 10500 + + + + + + + + + org.wso2.carbon.tomcat.jndi.CarbonJavaURLContextFactory + + + + + + + + + java + + + + + + + + + + false + + + false + + + 600 + + + + false + + + + + + + + 30 + + + + + + + + + 15 + + + + + + ${carbon.home}/repository/deployment/server/ + + + 15 + + + ${carbon.home}/repository/conf/axis2/axis2.xml + + + 30000 + + + ${carbon.home}/repository/deployment/client/ + + ${carbon.home}/repository/conf/axis2/axis2_client.xml + + false + + + + + + + + + + admin + Default Administrator Role + + + user + Default User Role + + + + + false + + + + + + + ${carbon.home}/repository/resources/security/wso2carbon.jks + + JKS + + wso2carbon + + wso2carbon + + wso2carbon + + + + + + ${carbon.home}/repository/resources/security/client-truststore.jks + + JKS + + wso2carbon + + + + + + + + + + + + + + + + + + + UserManager + + + false + + org.wso2.carbon.identity.provider.AttributeCallbackHandler + + + org.wso2.carbon.identity.sts.store.DBTokenStore + + + true + allow + + + + + + +claim_mgt_menu +identity_mgt_emailtemplate_menu +identity_security_questions_menu + + + + ${carbon.home}/tmp/work + + + + + + true + + + 10 + + + 30 + + + + + + 100 + + + + keystore + certificate + * + + org.wso2.carbon.ui.transports.fileupload.AnyFileUploadExecutor + + + + + jarZip + + org.wso2.carbon.ui.transports.fileupload.JarZipUploadExecutor + + + + dbs + + org.wso2.carbon.ui.transports.fileupload.DBSFileUploadExecutor + + + + tools + + org.wso2.carbon.ui.transports.fileupload.ToolsFileUploadExecutor + + + + toolsAny + + org.wso2.carbon.ui.transports.fileupload.ToolsAnyFileUploadExecutor + + + + + + + + + + info + org.wso2.carbon.core.transports.util.InfoProcessor + + + wsdl + org.wso2.carbon.core.transports.util.Wsdl11Processor + + + wsdl2 + org.wso2.carbon.core.transports.util.Wsdl20Processor + + + xsd + org.wso2.carbon.core.transports.util.XsdProcessor + + + + + + false + false + true + svn + http://svnrepo.example.com/repos/ + username + password + true + + + + + + + + + + + + + + + ${require.carbon.servlet} + + + + + true + + + + + + + default repository + http://product-dist.wso2.com/p2/carbon/releases/wilkes/ + + + + + + + + true + + + + + + true + +