From 2aa1e6b892ac679d6ccbe04d88e16d8c06331945 Mon Sep 17 00:00:00 2001 From: Maduranga Siriwardena Date: Fri, 9 Feb 2024 10:29:57 +0530 Subject: [PATCH] Fix test cases --- .../src/test/resources/testng.xml | 2 +- .../wso2/carbon/idp/mgt/dao/IdPManagementDAO.java | 12 ++++++------ .../mgt/internal/IdPManagementServiceComponent.java | 11 ++++------- 3 files changed, 11 insertions(+), 14 deletions(-) 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);