diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/java/org/wso2/carbon/identity/application/authentication/framework/session/extender/processor/SessionExtenderProcessorTest.java b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/java/org/wso2/carbon/identity/application/authentication/framework/session/extender/processor/SessionExtenderProcessorTest.java index da1228886d81..f1bfcd46bec9 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/java/org/wso2/carbon/identity/application/authentication/framework/session/extender/processor/SessionExtenderProcessorTest.java +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/java/org/wso2/carbon/identity/application/authentication/framework/session/extender/processor/SessionExtenderProcessorTest.java @@ -25,24 +25,12 @@ import org.testng.annotations.Test; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.identity.application.authentication.framework.cache.SessionContextCache; -import org.wso2.carbon.identity.application.authentication.framework.cache.SessionContextCacheEntry; -import org.wso2.carbon.identity.application.authentication.framework.cache.SessionContextCacheKey; -import org.wso2.carbon.identity.application.authentication.framework.context.SessionContext; import org.wso2.carbon.identity.application.authentication.framework.session.extender.request.SessionExtenderRequest; -import org.wso2.carbon.identity.application.authentication.framework.session.extender.response.SessionExtenderResponse; import org.wso2.carbon.identity.application.authentication.framwork.test.utils.CommonTestUtils; -import static org.mockito.ArgumentMatchers.anyObject; -import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.MockitoAnnotations.initMocks; import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.when; -import static org.powermock.api.mockito.PowerMockito.whenNew; -import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; -import static org.wso2.carbon.identity.application.authentication.framework.session.extender.SessionExtenderTestConstants.IDP_SESSION_KEY; -import static org.wso2.carbon.identity.application.authentication.framework.session.extender.SessionExtenderTestConstants.TENANT_DOMAIN; /** * Unit test cases for SessionExtenderProcessor. @@ -71,29 +59,4 @@ public void testCanHandle() { assertTrue(sessionExtenderProcessor.canHandle(sessionExtenderRequest), "Cannot handle valid " + "SessionExtenderRequest."); } - - @Test(expectedExceptions = NullPointerException.class) - public void testProcessWithSessionKey() throws Exception { - - mockStatic(SessionContextCache.class); - SessionExtenderRequest sessionExtenderRequest = mock(SessionExtenderRequest.class); - SessionContextCache sessionContextCache = mock(SessionContextCache.class); - SessionContextCacheKey sessionContextCacheKey = mock(SessionContextCacheKey.class); - SessionContextCacheEntry sessionContextCacheEntry = mock(SessionContextCacheEntry.class); - SessionContext sessionContext = mock(SessionContext.class); - - whenNew(SessionContextCacheKey.class).withArguments(anyString()).thenReturn(sessionContextCacheKey); - when(sessionExtenderRequest.getTenantDomain()).thenReturn(TENANT_DOMAIN); - when(sessionExtenderRequest.getSessionKey()).thenReturn(IDP_SESSION_KEY); - when(SessionContextCache.getInstance()).thenReturn(sessionContextCache); - when(sessionContextCache.getSessionContextCacheEntry(anyObject(), anyString())) - .thenReturn(sessionContextCacheEntry); - when(sessionContextCacheEntry.getContext()).thenReturn(sessionContext); - - SessionExtenderResponse.SessionExtenderResponseBuilder responseBuilder = - (SessionExtenderResponse.SessionExtenderResponseBuilder) sessionExtenderProcessor - .process(sessionExtenderRequest); - SessionExtenderResponse response = responseBuilder.build(); - assertNotNull(response.getTraceId(), "Error creating successful response."); - } } diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/testng.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/testng.xml index 7711b011eb30..3ebffde07bc3 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/testng.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/testng.xml @@ -59,7 +59,7 @@ - + diff --git a/components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/dao/IdPManagementDAO.java b/components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/dao/IdPManagementDAO.java index 6a1f785021e8..c4d1e71a9460 100644 --- a/components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/dao/IdPManagementDAO.java +++ b/components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/dao/IdPManagementDAO.java @@ -2211,7 +2211,8 @@ public IdentityProvider getIdPByName(Connection dbConnection, String idPName, in return idp; } - private String resolveAbsoluteURL(String defaultUrlContext, String urlFromConfig, String tenantDomain) throws IdentityProviderManagementServerException { + private String resolveAbsoluteURL(String defaultUrlContext, String urlFromConfig, String tenantDomain) + throws IdentityProviderManagementServerException { if (!IdentityTenantUtil.isTenantQualifiedUrlsEnabled() && StringUtils.isNotBlank(urlFromConfig)) { if (log.isDebugEnabled()) { @@ -2458,6 +2459,10 @@ private String getOIDCResidentIdPEntityId() { private void fillResidentIdpProperties(IdentityProvider identityProvider, String tenantDomain) throws IdentityProviderManagementException { + if (identityProvider == null) { + return; + } + String openIdUrl; String oauth1RequestTokenUrl; String oauth1AuthorizeUrl; @@ -2583,11 +2588,6 @@ private void fillResidentIdpProperties(IdentityProvider identityProvider, String log.error("SCIM 2.0 Groups endpoint is malformed"); } - if (identityProvider == null) { - String message = "Could not find Resident Identity Provider for tenant " + tenantDomain; - throw new IdentityProviderManagementException(message); - } - int tenantId; try { tenantId = IdPManagementServiceComponent.getRealmService().getTenantManager().getTenantId(tenantDomain); diff --git a/components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/internal/IdPManagementServiceComponent.java b/components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/internal/IdPManagementServiceComponent.java index 8437ac7dc06b..585feda6e5ae 100644 --- a/components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/internal/IdPManagementServiceComponent.java +++ b/components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/internal/IdPManagementServiceComponent.java @@ -206,13 +206,10 @@ protected void activate(ComponentContext ctxt) { setIdentityProviderMgtListenerService(new IdPMgtValidationListener()); CacheBackedIdPMgtDAO dao = new CacheBackedIdPMgtDAO(new IdPManagementDAO()); - try { - dao.getIdPByName(null, - IdentityApplicationConstants.RESIDENT_IDP_RESERVED_NAME, - IdentityTenantUtil.getTenantId(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME), - MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); - } catch (IdentityProviderManagementException e) { - // If the resident IDP is not in the database, add it. + if (dao.getIdPByName(null, + IdentityApplicationConstants.RESIDENT_IDP_RESERVED_NAME, + IdentityTenantUtil.getTenantId(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME), + MultitenantConstants.SUPER_TENANT_DOMAIN_NAME) == null) { addSuperTenantIdp(); } bundleCtx.registerService(IdpManager.class, IdentityProviderManager.getInstance(), null);