diff --git a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java index d6bae817266..fc324c23f77 100644 --- a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java +++ b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java @@ -179,7 +179,7 @@ public String getTenantQualifiedURL(String endpointURL, String tenantDomain) { * @param tenantDomain Tenanted domain. * @return Tenant qualified URL without hostname. */ - public String getTenantedRelativePath(String endpointURLWithHostname, String tenantDomain) { + public static String getTenantedRelativePath(String endpointURLWithHostname, String tenantDomain) { if(!tenantDomain.isBlank() && !tenantDomain.equalsIgnoreCase(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { endpointURLWithHostname = TENANTED_URL_PATH_SPECIFIER + tenantDomain + endpointURLWithHostname; diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceJWTGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceJWTGrantTestCase.java index ae23976d628..b662c569337 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceJWTGrantTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceJWTGrantTestCase.java @@ -97,7 +97,7 @@ public class OAuth2ServiceJWTGrantTestCase extends OAuth2ServiceAbstractIntegrat private static final String USERS_PATH = "users"; private static final String BEGIN_CERTIFICATE = "-----BEGIN CERTIFICATE-----\n"; private static final String END_CERTIFICATE = "\n-----END CERTIFICATE-----"; - private static final String JWKS_BASE_PATH = "t/%s/oauth2/jwks"; + private static final String JWKS_BASE_PATH = "/oauth2/jwks"; private static final String COUNTRY_CLAIM_VALUE = "USA"; private static final String COUNTRY_OIDC_CLAIM = "country"; private static final String COUNTRY_NEW_OIDC_CLAIM = "customclaim"; @@ -517,7 +517,7 @@ private void addFederatedIdentityProvider() throws Exception { */ private String getEncodedCertificate() throws Exception { CloseableHttpClient client = HttpClients.createDefault(); - String jwksEndpoint = serverURL + String.format(JWKS_BASE_PATH, tenantInfo.getDomain()); + String jwksEndpoint = serverURL + getTenantedRelativePath(JWKS_BASE_PATH, tenantInfo.getDomain()); String certificate = BEGIN_CERTIFICATE + getPublicCertificate(client, jwksEndpoint) + END_CERTIFICATE; return new String(Base64.getEncoder().encode(certificate.getBytes(StandardCharsets.UTF_8)), diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v1/UserAuthorizedAppsBaseTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v1/UserAuthorizedAppsBaseTest.java index 882c6102c5c..8b92e4ff60f 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v1/UserAuthorizedAppsBaseTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v1/UserAuthorizedAppsBaseTest.java @@ -38,7 +38,7 @@ public class UserAuthorizedAppsBaseTest extends RESTAPIUserTestBase { static String API_PACKAGE_NAME = "org.wso2.carbon.identity.rest.api.user.authorized.apps.v1"; public static final String AUTHORIZED_APPS_ENDPOINT_URI = "/%s/authorized-apps/"; - public static final String DCR_ENDPOINT_PATH_URI = "/t/%s/api/identity/oauth2/dcr/v1.1/register/"; + public static final String DCR_ENDPOINT_PATH_URI = "/api/identity/oauth2/dcr/v1.1/register/"; protected String userAuthorizedAppsEndpointUri; protected String dcrEndpointUri; @@ -58,7 +58,7 @@ public class UserAuthorizedAppsBaseTest extends RESTAPIUserTestBase { void initUrls(String pathParam) { this.userAuthorizedAppsEndpointUri = String.format(AUTHORIZED_APPS_ENDPOINT_URI, pathParam); - this.dcrEndpointUri = String.format(DCR_ENDPOINT_PATH_URI, tenant); + this.dcrEndpointUri = getTenantedRelativePath(DCR_ENDPOINT_PATH_URI, tenant); this.tokenEndpointUri = getTenantedRelativePath("/oauth2/token", tenant); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/UserAuthorizedAppsBaseTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/UserAuthorizedAppsBaseTest.java index 054864ff691..3778c874545 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/UserAuthorizedAppsBaseTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/authorized/apps/v2/UserAuthorizedAppsBaseTest.java @@ -42,7 +42,7 @@ public class UserAuthorizedAppsBaseTest extends RESTAPIUserTestBase { public static final String AUTHORIZED_APPS_ENDPOINT_URI = "/%s/authorized-apps/"; public static final String APPLICATION_ENDPOINT_URI = "/authorized-apps/%s/tokens"; - public static final String DCR_ENDPOINT_PATH_URI = "/t/%s/api/identity/oauth2/dcr/v1.1/register/"; + public static final String DCR_ENDPOINT_PATH_URI = "/api/identity/oauth2/dcr/v1.1/register/"; protected String userAuthorizedAppsEndpointUri; protected String userApplicationEndpointUri; @@ -64,7 +64,7 @@ void initUrls(String pathParam) { this.userAuthorizedAppsEndpointUri = String.format(AUTHORIZED_APPS_ENDPOINT_URI, pathParam); this.userApplicationEndpointUri = APPLICATION_ENDPOINT_URI; - this.dcrEndpointUri = String.format(DCR_ENDPOINT_PATH_URI, tenant); + this.dcrEndpointUri = getTenantedRelativePath(DCR_ENDPOINT_PATH_URI, tenant); this.tokenEndpointUri = getTenantedRelativePath("/oauth2/token", tenant); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/IdpMgtRestClient.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/IdpMgtRestClient.java index 8088e4a6b09..2816ae60c64 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/IdpMgtRestClient.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/IdpMgtRestClient.java @@ -27,6 +27,7 @@ import org.json.simple.JSONObject; import org.testng.Assert; import org.wso2.carbon.automation.engine.context.beans.Tenant; +import org.wso2.identity.integration.common.utils.ISIntegrationTest; import org.wso2.identity.integration.test.rest.api.server.idp.v1.model.Claims; import org.wso2.identity.integration.test.rest.api.server.idp.v1.model.IdentityProviderPOSTRequest; import org.wso2.identity.integration.test.utils.OAuth2Constant; @@ -38,7 +39,7 @@ public class IdpMgtRestClient extends RestBaseClient { private static final String CLAIMS_PATH = "/claims"; private static final String FEDERATED_AUTHENTICATORS_PATH = "/federated-authenticators/"; private final String serverUrl; - private final String IDENTITY_PROVIDER_BASE_PATH = "t/%s/api/server/v1/identity-providers"; + private final String IDENTITY_PROVIDER_BASE_PATH = "/api/server/v1/identity-providers"; private final String tenantDomain; private final String username; private final String password; @@ -58,7 +59,7 @@ public IdpMgtRestClient(String serverUrl, Tenant tenantInfo) { */ public String createIdentityProvider(IdentityProviderPOSTRequest idpCreateReqObj) throws Exception { String jsonRequest = toJSONString(idpCreateReqObj); - String endPointUrl = serverUrl + String.format(IDENTITY_PROVIDER_BASE_PATH, tenantDomain); + String endPointUrl = serverUrl + ISIntegrationTest.getTenantedRelativePath(IDENTITY_PROVIDER_BASE_PATH, tenantDomain); try (CloseableHttpResponse response = getResponseOfHttpPost(endPointUrl, jsonRequest, getHeaders())) { Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpServletResponse.SC_CREATED, @@ -76,8 +77,8 @@ public String createIdentityProvider(IdentityProviderPOSTRequest idpCreateReqObj * @return JSONObject with Federated Authenticator details. */ public JSONObject getIdpFederatedAuthenticator(String idpId, String federatedAuthenticatorId) throws Exception { - String endPointUrl = serverUrl + String.format(IDENTITY_PROVIDER_BASE_PATH, tenantDomain)+ PATH_SEPARATOR + - idpId + FEDERATED_AUTHENTICATORS_PATH + federatedAuthenticatorId; + String endPointUrl = serverUrl + ISIntegrationTest.getTenantedRelativePath(IDENTITY_PROVIDER_BASE_PATH, + tenantDomain) + PATH_SEPARATOR + idpId + FEDERATED_AUTHENTICATORS_PATH + federatedAuthenticatorId; try (CloseableHttpResponse response = getResponseOfHttpGet(endPointUrl, getHeaders())) { String responseBody = EntityUtils.toString(response.getEntity()); @@ -93,8 +94,8 @@ public JSONObject getIdpFederatedAuthenticator(String idpId, String federatedAut */ public void updateIdpClaimConfig(String idpId, Claims idpClaims) throws IOException { String jsonRequest = toJSONString(idpClaims); - String endPointUrl = serverUrl + String.format(IDENTITY_PROVIDER_BASE_PATH, tenantDomain) + PATH_SEPARATOR + - idpId + CLAIMS_PATH; + String endPointUrl = serverUrl + ISIntegrationTest.getTenantedRelativePath(IDENTITY_PROVIDER_BASE_PATH, + tenantDomain) + PATH_SEPARATOR + idpId + CLAIMS_PATH; try (CloseableHttpResponse response = getResponseOfHttpPut(endPointUrl, jsonRequest, getHeaders())) { Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpServletResponse.SC_OK, @@ -108,8 +109,8 @@ public void updateIdpClaimConfig(String idpId, Claims idpClaims) throws IOExcept * @param idpId Identity Provider Id */ public void deleteIdp(String idpId) throws IOException { - String endPointUrl = serverUrl + String.format(IDENTITY_PROVIDER_BASE_PATH, tenantDomain) + PATH_SEPARATOR + - idpId; + String endPointUrl = serverUrl + ISIntegrationTest.getTenantedRelativePath(IDENTITY_PROVIDER_BASE_PATH, + tenantDomain) + PATH_SEPARATOR + idpId; try (CloseableHttpResponse response = getResponseOfHttpDelete(endPointUrl, getHeaders())) { Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpServletResponse.SC_NO_CONTENT, diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/KeystoreMgtRestClient.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/KeystoreMgtRestClient.java index ab4fe92ee69..f53eb179674 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/KeystoreMgtRestClient.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/KeystoreMgtRestClient.java @@ -25,6 +25,7 @@ import org.apache.http.message.BasicHeader; import org.testng.Assert; import org.wso2.carbon.automation.engine.context.beans.Tenant; +import org.wso2.identity.integration.common.utils.ISIntegrationTest; import org.wso2.identity.integration.test.rest.api.server.keystore.management.v1.model.CertificateRequest; import javax.servlet.http.HttpServletResponse; @@ -32,7 +33,7 @@ public class KeystoreMgtRestClient extends RestBaseClient { - private static final String KEYSTORE_BASE_PATH = "t/%s/api/server/v1/keystores/certs"; + private static final String KEYSTORE_BASE_PATH = "/api/server/v1/keystores/certs"; private final String serverUrl; private final String tenantDomain; private final String username; @@ -53,7 +54,7 @@ public KeystoreMgtRestClient(String serverUrl, Tenant tenantInfo) { */ public void importCertToStore(CertificateRequest certificateRequest) throws Exception { String jsonRequest = toJSONString(certificateRequest); - String endPointUrl = serverUrl + String.format(KEYSTORE_BASE_PATH, tenantDomain); + String endPointUrl = serverUrl + ISIntegrationTest.getTenantedRelativePath(KEYSTORE_BASE_PATH, tenantDomain); try (CloseableHttpResponse response = getResponseOfHttpPost(endPointUrl, jsonRequest, getHeaders())) { Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpServletResponse.SC_CREATED, @@ -68,7 +69,8 @@ public void importCertToStore(CertificateRequest certificateRequest) throws Exce * @return Boolean status of certificate availability in tenant keystore. */ public Boolean checkCertInStore(String alias) throws Exception { - String endPointUrl = serverUrl + String.format(KEYSTORE_BASE_PATH, tenantDomain) + PATH_SEPARATOR + alias; + String endPointUrl = serverUrl + ISIntegrationTest.getTenantedRelativePath(KEYSTORE_BASE_PATH, tenantDomain) + + PATH_SEPARATOR + alias; try (CloseableHttpResponse response = getResponseOfHttpGet(endPointUrl, getHeaders())) { return response.getStatusLine().getStatusCode() == HttpServletResponse.SC_OK; diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/OIDCScopeMgtRestClient.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/OIDCScopeMgtRestClient.java index 9456df3d312..7cb33c692d8 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/OIDCScopeMgtRestClient.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/OIDCScopeMgtRestClient.java @@ -29,6 +29,7 @@ import org.json.simple.JSONObject; import org.testng.Assert; import org.wso2.carbon.automation.engine.context.beans.Tenant; +import org.wso2.identity.integration.common.utils.ISIntegrationTest; import org.wso2.identity.integration.test.rest.api.server.oidc.scope.management.v1.model.ScopeUpdateRequest; import org.wso2.identity.integration.test.utils.OAuth2Constant; @@ -37,7 +38,7 @@ public class OIDCScopeMgtRestClient extends RestBaseClient { private final String serverUrl; - private final String OIDC_SCOPE_MGT_BASE_PATH = "t/%s/api/server/v1/oidc/scopes"; + private final String OIDC_SCOPE_MGT_BASE_PATH = "/api/server/v1/oidc/scopes"; private final String tenantDomain; private final String username; private final String password; @@ -57,8 +58,8 @@ public OIDCScopeMgtRestClient(String serverUrl, Tenant tenantInfo) { * @return Scope object. */ public JSONObject getScope(String scopeId) throws Exception { - String endPointUrl = serverUrl + String.format(OIDC_SCOPE_MGT_BASE_PATH, tenantDomain) + - PATH_SEPARATOR + scopeId; + String endPointUrl = serverUrl + ISIntegrationTest.getTenantedRelativePath(OIDC_SCOPE_MGT_BASE_PATH, + tenantDomain) + PATH_SEPARATOR + scopeId; try (CloseableHttpResponse response = getResponseOfHttpGet(endPointUrl, getHeaders())) { return getJSONObject(EntityUtils.toString(response.getEntity())); @@ -73,8 +74,8 @@ public JSONObject getScope(String scopeId) throws Exception { */ public void updateScope(String scopeId, ScopeUpdateRequest scopeUpdateObj) throws Exception { String jsonRequest = toJSONString(scopeUpdateObj); - String endPointUrl = serverUrl + String.format(OIDC_SCOPE_MGT_BASE_PATH, tenantDomain) + - PATH_SEPARATOR + scopeId; + String endPointUrl = serverUrl + ISIntegrationTest.getTenantedRelativePath(OIDC_SCOPE_MGT_BASE_PATH, + tenantDomain) + PATH_SEPARATOR + scopeId; try (CloseableHttpResponse response = getResponseOfHttpPut(endPointUrl, jsonRequest, getHeaders())) { Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpServletResponse.SC_OK,