From 15247b716c732cae519907f33a8bd306658cd4ed Mon Sep 17 00:00:00 2001 From: dhaura Date: Mon, 12 Aug 2024 18:48:48 +0530 Subject: [PATCH 1/3] Add integration tests to support restrictedToPublished query param in branding resolver endpoint. --- ...andingPreferenceManagementSuccessTest.java | 119 +++++++++++++++++- .../BrandingPreferenceManagementTestBase.java | 3 + pom.xml | 4 +- 3 files changed, 118 insertions(+), 8 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/AppBrandingPreferenceManagementSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/AppBrandingPreferenceManagementSuccessTest.java index 0b09831290..551cc8572c 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/AppBrandingPreferenceManagementSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/AppBrandingPreferenceManagementSuccessTest.java @@ -271,7 +271,7 @@ public void testResolveL2AppBrandingAfterRootAppBrandingAddition() throws Except } @Test(dependsOnMethods = {"testResolveL2AppBrandingAfterRootAppBrandingAddition"}) - public void testUpdateRootAppBrandingPreference() throws Exception { + public void testUpdateUnpublishedRootAppBrandingPreference() throws Exception { String body = readResource(UPDATE_ROOT_APP_BRANDING_RESOURCE_FILE) .replace(APP_ID_PLACEHOLDER, rootAppId); @@ -288,7 +288,7 @@ public void testUpdateRootAppBrandingPreference() throws Exception { assertBrandingPreferences(UPDATE_ROOT_APP_BRANDING_RESOURCE_FILE, response); } - @Test(dependsOnMethods = {"testUpdateRootAppBrandingPreference"}) + @Test(dependsOnMethods = {"testUpdateUnpublishedRootAppBrandingPreference"}) public void testGetRootAppBrandingAfterRootAppBrandingUpdate() throws Exception { Response response = getResponseOfGet(BRANDING_PREFERENCE_API_BASE_PATH + String.format @@ -322,6 +322,24 @@ public void testResolveRootAppBrandingAfterRootAppBrandingUpdate() throws Except } @Test(dependsOnMethods = {"testResolveRootAppBrandingAfterRootAppBrandingUpdate"}) + public void testResolveRootAppBrandingRestrictedToPublishedAfterRootAppBrandingUpdate() throws Exception { + + // Resolve the branding preference by setting the restrictToPublished query parameter to true. + Response response = getResponseOfGet(BRANDING_PREFERENCE_RESOLVE_PATH + + String.format(PREFERENCE_COMPONENT_WITH_QUERY_PARAM + "&" + RESTRICTED_TO_PUBLISHED_QUERY_PARAM, + APPLICATION_TYPE, rootAppId, DEFAULT_LOCALE, TRUE)); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_OK) + .body("type", equalTo(ORGANIZATION_TYPE)) + .body("name", equalTo(tenant)) + .body("locale", equalTo(DEFAULT_LOCALE)); + + assertBrandingPreferences(ADD_ROOT_ORG_BRANDING_RESOURCE_FILE, response); + } + + @Test(dependsOnMethods = {"testResolveRootAppBrandingRestrictedToPublishedAfterRootAppBrandingUpdate"}) public void testResolveL1AppBrandingAfterRootAppBrandingUpdate() throws Exception { Response response = getResolvedAppBrandingInOrg(level1OrgId, level1AppId); @@ -337,6 +355,22 @@ public void testResolveL1AppBrandingAfterRootAppBrandingUpdate() throws Exceptio } @Test(dependsOnMethods = {"testResolveL1AppBrandingAfterRootAppBrandingUpdate"}) + public void testResolveL1AppBrandingRestrictedToPublishedAfterRootAppBrandingUpdate() throws Exception { + + // Resolve the branding preference without setting the restrictToPublished query parameter. + Response response = getResolvedAppBrandingRestrictedToPublishedInOrg(level1OrgId, level1AppId); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_OK) + .body("type", equalTo(ORGANIZATION_TYPE)) + .body("name", equalTo(tenant)) + .body("locale", equalTo(DEFAULT_LOCALE)); + + assertBrandingPreferences(ADD_ROOT_ORG_BRANDING_RESOURCE_FILE, response); + } + + @Test(dependsOnMethods = {"testResolveL1AppBrandingRestrictedToPublishedAfterRootAppBrandingUpdate"}) public void testResolveL2AppBrandingAfterRootAppBrandingUpdate() throws Exception { Response response = getResolvedAppBrandingInOrg(level2OrgId, level2AppId); @@ -352,6 +386,22 @@ public void testResolveL2AppBrandingAfterRootAppBrandingUpdate() throws Exceptio } @Test(dependsOnMethods = {"testResolveL2AppBrandingAfterRootAppBrandingUpdate"}) + public void testResolveL2AppBrandingRestrictedToPublishedAfterRootAppBrandingUpdate() throws Exception { + + // Resolve the branding preference without setting the restrictToPublished query parameter. + Response response = getResolvedAppBrandingRestrictedToPublishedInOrg(level2OrgId, level2AppId); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_OK) + .body("type", equalTo(ORGANIZATION_TYPE)) + .body("name", equalTo(tenant)) + .body("locale", equalTo(DEFAULT_LOCALE)); + + assertBrandingPreferences(ADD_ROOT_ORG_BRANDING_RESOURCE_FILE, response); + } + + @Test(dependsOnMethods = {"testResolveL2AppBrandingRestrictedToPublishedAfterRootAppBrandingUpdate"}) public void testResolveL1AppBrandingAfterL1OrgBrandingAddition() throws Exception { addOrgBrandingPreference(level1OrgId, ADD_L1_ORG_BRANDING_RESOURCE_FILE); @@ -437,7 +487,7 @@ public void testResolveL2AppBrandingAfterL1AppBrandingAddition() throws Exceptio } @Test(dependsOnMethods = {"testResolveL2AppBrandingAfterL1AppBrandingAddition"}) - public void testUpdateL1AppBrandingPreference() throws Exception { + public void testUpdateUnpublishedL1AppBrandingPreference() throws Exception { RestAssured.basePath = buildTenantedBasePathForOrg(tenant); String body = readResource(UPDATE_L1_APP_BRANDING_RESOURCE_FILE) @@ -455,7 +505,7 @@ public void testUpdateL1AppBrandingPreference() throws Exception { assertBrandingPreferences(UPDATE_L1_APP_BRANDING_RESOURCE_FILE, response); } - @Test(dependsOnMethods = {"testUpdateL1AppBrandingPreference"}) + @Test(dependsOnMethods = {"testUpdateUnpublishedL1AppBrandingPreference"}) public void testResolveL1AppBrandingAfterL1AppBrandingUpdate() throws Exception { Response response = getResolvedAppBrandingInOrg(level1OrgId, level1AppId); @@ -470,6 +520,22 @@ public void testResolveL1AppBrandingAfterL1AppBrandingUpdate() throws Exception assertBrandingPreferences(UPDATE_L1_APP_BRANDING_RESOURCE_FILE, response); } + @Test(dependsOnMethods = {"testResolveL1AppBrandingAfterL1AppBrandingUpdate"}) + public void testResolveL1AppBrandingRestrictedToPublishedAfterL1AppBrandingUpdate() throws Exception { + + // Resolve the branding preference without setting the restrictToPublished query parameter. + Response response = getResolvedAppBrandingRestrictedToPublishedInOrg(level1OrgId, level1AppId); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_OK) + .body("type", equalTo(ORGANIZATION_TYPE)) + .body("name", equalTo(level1OrgId)) + .body("locale", equalTo(DEFAULT_LOCALE)); + + assertBrandingPreferences(ADD_L1_ORG_BRANDING_RESOURCE_FILE, response); + } + @Test(dependsOnMethods = {"testResolveL1AppBrandingAfterL1AppBrandingUpdate"}) public void testResolveL2AppBrandingAfterL1AppBrandingUpdate() throws Exception { @@ -486,6 +552,22 @@ public void testResolveL2AppBrandingAfterL1AppBrandingUpdate() throws Exception } @Test(dependsOnMethods = {"testResolveL2AppBrandingAfterL1AppBrandingUpdate"}) + public void testResolveL2AppBrandingRestrictedToPublishedAfterL1AppBrandingUpdate() throws Exception { + + // Resolve the branding preference without setting the restrictToPublished query parameter. + Response response = getResolvedAppBrandingRestrictedToPublishedInOrg(level2OrgId, level2AppId); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_OK) + .body("type", equalTo(ORGANIZATION_TYPE)) + .body("name", equalTo(level1OrgId)) + .body("locale", equalTo(DEFAULT_LOCALE)); + + assertBrandingPreferences(ADD_L1_ORG_BRANDING_RESOURCE_FILE, response); + } + + @Test(dependsOnMethods = {"testResolveL2AppBrandingRestrictedToPublishedAfterL1AppBrandingUpdate"}) public void testResolveL2AppBrandingAfterL2OrgBrandingAddition() throws Exception { addOrgBrandingPreference(level2OrgId, ADD_L2_ORG_BRANDING_RESOURCE_FILE); @@ -541,7 +623,7 @@ public void testResolveL2AppBrandingAfterL2AppBrandingAddition() throws Exceptio } @Test(dependsOnMethods = {"testResolveL2AppBrandingAfterL2AppBrandingAddition"}) - public void testUpdateL2AppBrandingPreference() throws Exception { + public void testUpdateUnpublishedL2AppBrandingPreference() throws Exception { RestAssured.basePath = buildTenantedBasePathForOrg(tenant); String body = readResource(UPDATE_L2_APP_BRANDING_RESOURCE_FILE) @@ -560,7 +642,7 @@ public void testUpdateL2AppBrandingPreference() throws Exception { assertBrandingPreferences(UPDATE_L2_APP_BRANDING_RESOURCE_FILE, response); } - @Test(dependsOnMethods = {"testUpdateL2AppBrandingPreference"}) + @Test(dependsOnMethods = {"testUpdateUnpublishedL2AppBrandingPreference"}) public void testResolveL2AppBrandingAfterL2AppBrandingUpdate() throws Exception { Response response = getResolvedAppBrandingInOrg(level2OrgId, level2AppId); @@ -576,6 +658,22 @@ public void testResolveL2AppBrandingAfterL2AppBrandingUpdate() throws Exception } @Test(dependsOnMethods = {"testResolveL2AppBrandingAfterL2AppBrandingUpdate"}) + public void testResolveL2AppBrandingRestrictedToPublishedAfterL2AppBrandingUpdate() throws Exception { + + // Resolve the branding preference without setting the restrictToPublished query parameter. + Response response = getResolvedAppBrandingRestrictedToPublishedInOrg(level2OrgId, level2AppId); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_OK) + .body("type", equalTo(ORGANIZATION_TYPE)) + .body("name", equalTo(level2OrgId)) + .body("locale", equalTo(DEFAULT_LOCALE)); + + assertBrandingPreferences(ADD_L2_ORG_BRANDING_RESOURCE_FILE, response); + } + + @Test(dependsOnMethods = {"testResolveL2AppBrandingRestrictedToPublishedAfterL2AppBrandingUpdate"}) public void testDeleteL2AppBrandingPreference() throws Exception { RestAssured.basePath = buildTenantedBasePathForOrg(tenant); @@ -875,6 +973,15 @@ private Response getResolvedAppBrandingInOrg(String orgId, String appId) DEFAULT_LOCALE), orgMgtRestClient.switchM2MToken(orgId)); } + private Response getResolvedAppBrandingRestrictedToPublishedInOrg(String orgId, String appId) + throws Exception { + + RestAssured.basePath = PATH_SEPARATOR + ORGANIZATION_PATH + orgId + PATH_SEPARATOR + API_SERVER_BASE_PATH; + return getResponseOfGetWithOAuth2(BRANDING_PREFERENCE_RESOLVE_PATH + + String.format(PREFERENCE_COMPONENT_WITH_QUERY_PARAM + AMPERSAND + RESTRICTED_TO_PUBLISHED_QUERY_PARAM, + APPLICATION_TYPE, appId, DEFAULT_LOCALE, TRUE), orgMgtRestClient.switchM2MToken(orgId)); + } + private String buildTenantedBasePathForOrg(String tenantDomain) { if (tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/BrandingPreferenceManagementTestBase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/BrandingPreferenceManagementTestBase.java index b39613c8af..6ed4ae7d1e 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/BrandingPreferenceManagementTestBase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/BrandingPreferenceManagementTestBase.java @@ -54,9 +54,12 @@ public class BrandingPreferenceManagementTestBase extends RESTAPIServerTestBase public static final String TYPE_QUERY_PARAM = "type=%s"; public static final String LOCALE_QUERY_PARAM = "locale=%s"; public static final String SCREEN_QUERY_PARAM = "screen=%s"; + public static final String RESTRICTED_TO_PUBLISHED_QUERY_PARAM = "restrictToPublished=%s"; public static final String CONTENT_TYPE_ATTRIBUTE = "Content-Type"; public static final String AUTHORIZATION_ATTRIBUTE = "Authorization"; public static final String ORG_NAME_PLACEHOLDER = "organization-name"; + public static final String TRUE = "true"; + public static final String AMPERSAND = "&"; public static final String ADD_ROOT_ORG_BRANDING_RESOURCE_FILE = "add-root-org-branding-preference.json"; public static final String UPDATE_ROOT_ORG_BRANDING_RESOURCE_FILE = "update-root-org-branding-preference.json"; diff --git a/pom.xml b/pom.xml index e2971c94aa..2849f37024 100755 --- a/pom.xml +++ b/pom.xml @@ -2311,7 +2311,7 @@ - 7.3.65 + 7.3.68 [5.14.67, 8.0.0) @@ -2424,7 +2424,7 @@ 2.0.17 1.3.38 - 1.2.215 + 1.2.217 5.5.9 5.5.8 From bf8e403fbb6661ab42274fecdd554087a2a104c6 Mon Sep 17 00:00:00 2001 From: dhaura Date: Mon, 12 Aug 2024 19:54:22 +0530 Subject: [PATCH 2/3] Update test comments. --- .../v1/AppBrandingPreferenceManagementSuccessTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/AppBrandingPreferenceManagementSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/AppBrandingPreferenceManagementSuccessTest.java index 551cc8572c..66513a673e 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/AppBrandingPreferenceManagementSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/AppBrandingPreferenceManagementSuccessTest.java @@ -357,7 +357,7 @@ public void testResolveL1AppBrandingAfterRootAppBrandingUpdate() throws Exceptio @Test(dependsOnMethods = {"testResolveL1AppBrandingAfterRootAppBrandingUpdate"}) public void testResolveL1AppBrandingRestrictedToPublishedAfterRootAppBrandingUpdate() throws Exception { - // Resolve the branding preference without setting the restrictToPublished query parameter. + // Resolve the branding preference by setting the restrictToPublished query parameter to true. Response response = getResolvedAppBrandingRestrictedToPublishedInOrg(level1OrgId, level1AppId); response.then() .log().ifValidationFails() @@ -388,7 +388,7 @@ public void testResolveL2AppBrandingAfterRootAppBrandingUpdate() throws Exceptio @Test(dependsOnMethods = {"testResolveL2AppBrandingAfterRootAppBrandingUpdate"}) public void testResolveL2AppBrandingRestrictedToPublishedAfterRootAppBrandingUpdate() throws Exception { - // Resolve the branding preference without setting the restrictToPublished query parameter. + // Resolve the branding preference by setting the restrictToPublished query parameter to true. Response response = getResolvedAppBrandingRestrictedToPublishedInOrg(level2OrgId, level2AppId); response.then() .log().ifValidationFails() @@ -523,7 +523,7 @@ public void testResolveL1AppBrandingAfterL1AppBrandingUpdate() throws Exception @Test(dependsOnMethods = {"testResolveL1AppBrandingAfterL1AppBrandingUpdate"}) public void testResolveL1AppBrandingRestrictedToPublishedAfterL1AppBrandingUpdate() throws Exception { - // Resolve the branding preference without setting the restrictToPublished query parameter. + // Resolve the branding preference by setting the restrictToPublished query parameter to true. Response response = getResolvedAppBrandingRestrictedToPublishedInOrg(level1OrgId, level1AppId); response.then() .log().ifValidationFails() @@ -554,7 +554,7 @@ public void testResolveL2AppBrandingAfterL1AppBrandingUpdate() throws Exception @Test(dependsOnMethods = {"testResolveL2AppBrandingAfterL1AppBrandingUpdate"}) public void testResolveL2AppBrandingRestrictedToPublishedAfterL1AppBrandingUpdate() throws Exception { - // Resolve the branding preference without setting the restrictToPublished query parameter. + // Resolve the branding preference by setting the restrictToPublished query parameter to true. Response response = getResolvedAppBrandingRestrictedToPublishedInOrg(level2OrgId, level2AppId); response.then() .log().ifValidationFails() @@ -660,7 +660,7 @@ public void testResolveL2AppBrandingAfterL2AppBrandingUpdate() throws Exception @Test(dependsOnMethods = {"testResolveL2AppBrandingAfterL2AppBrandingUpdate"}) public void testResolveL2AppBrandingRestrictedToPublishedAfterL2AppBrandingUpdate() throws Exception { - // Resolve the branding preference without setting the restrictToPublished query parameter. + // Resolve the branding preference by setting the restrictToPublished query parameter to true. Response response = getResolvedAppBrandingRestrictedToPublishedInOrg(level2OrgId, level2AppId); response.then() .log().ifValidationFails() From 38e6465a84ffa90b8d9b8e021a0c8a618ef56a8d Mon Sep 17 00:00:00 2001 From: dhaura Date: Mon, 12 Aug 2024 19:56:03 +0530 Subject: [PATCH 3/3] Replace ampersand with a constant. --- .../v1/AppBrandingPreferenceManagementSuccessTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/AppBrandingPreferenceManagementSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/AppBrandingPreferenceManagementSuccessTest.java index 66513a673e..4669440bf5 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/AppBrandingPreferenceManagementSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/AppBrandingPreferenceManagementSuccessTest.java @@ -326,7 +326,7 @@ public void testResolveRootAppBrandingRestrictedToPublishedAfterRootAppBrandingU // Resolve the branding preference by setting the restrictToPublished query parameter to true. Response response = getResponseOfGet(BRANDING_PREFERENCE_RESOLVE_PATH + - String.format(PREFERENCE_COMPONENT_WITH_QUERY_PARAM + "&" + RESTRICTED_TO_PUBLISHED_QUERY_PARAM, + String.format(PREFERENCE_COMPONENT_WITH_QUERY_PARAM + AMPERSAND + RESTRICTED_TO_PUBLISHED_QUERY_PARAM, APPLICATION_TYPE, rootAppId, DEFAULT_LOCALE, TRUE)); response.then() .log().ifValidationFails()