From 162637f1d1588ffc2a8a37228baf99b7c1e51681 Mon Sep 17 00:00:00 2001 From: UdeshAthukorala Date: Wed, 1 Dec 2021 14:17:47 +0530 Subject: [PATCH] Add Integration tests for Branding Preference Managemnt API. --- ...andingPreferenceManagementFailureTest.java | 170 ++++++++++ ...andingPreferenceManagementSuccessTest.java | 321 ++++++++++++++++++ .../BrandingPreferenceManagementTestBase.java | 79 +++++ .../v1/add-branding-preference.json | 32 ++ .../v1/add-empty-json-preference.json | 6 + .../v1/update-branding-preference.json | 32 ++ .../src/test/resources/testng.xml | 2 + 7 files changed, 642 insertions(+) create mode 100644 modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/BrandingPreferenceManagementFailureTest.java create mode 100644 modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/BrandingPreferenceManagementSuccessTest.java create mode 100644 modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/BrandingPreferenceManagementTestBase.java create mode 100644 modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/add-branding-preference.json create mode 100644 modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/add-empty-json-preference.json create mode 100644 modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/update-branding-preference.json diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/BrandingPreferenceManagementFailureTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/BrandingPreferenceManagementFailureTest.java new file mode 100644 index 00000000000..31cdbad2f58 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/BrandingPreferenceManagementFailureTest.java @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.server.branding.preference.management.v1; + +import io.restassured.RestAssured; +import io.restassured.response.Response; +import org.apache.commons.lang.StringUtils; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpStatus; +import org.testng.annotations.AfterClass; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Factory; +import org.testng.annotations.Test; +import org.wso2.carbon.automation.engine.context.TestUserMode; + +import java.io.IOException; + +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.testng.Assert.assertNotNull; + +/** + * Test class for Branding Preference Management REST APIs failure paths. + */ +public class BrandingPreferenceManagementFailureTest extends BrandingPreferenceManagementTestBase { + + @Factory(dataProvider = "restAPIUserConfigProvider") + public BrandingPreferenceManagementFailureTest(TestUserMode userMode) throws Exception { + + super.init(userMode); + this.context = isServer; + this.authenticatingUserName = context.getContextTenant().getTenantAdmin().getUserName(); + this.authenticatingCredential = context.getContextTenant().getTenantAdmin().getPassword(); + this.tenant = context.getContextTenant().getDomain(); + } + + @DataProvider(name = "restAPIUserConfigProvider") + public static Object[][] restAPIUserConfigProvider() { + + return new Object[][]{ + {TestUserMode.SUPER_TENANT_ADMIN}, + {TestUserMode.TENANT_ADMIN} + }; + } + + @BeforeClass(alwaysRun = true) + public void init() throws IOException { + + super.testInit(API_VERSION, swaggerDefinition, tenant); + } + + @AfterClass(alwaysRun = true) + public void testConclude() { + + super.conclude(); + } + + @BeforeMethod(alwaysRun = true) + public void testInit() { + + RestAssured.basePath = basePath; + } + + @AfterMethod(alwaysRun = true) + public void testFinish() { + + RestAssured.basePath = StringUtils.EMPTY; + } + + @Test + public void testAddBrandingPreferenceWithEmptyJsonPreference() throws IOException { + + String body = readResource("add-empty-json-preference.json"); + Response response = getResponseOfPost(BRANDING_PREFERENCE_API_BASE_PATH, body); + validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "BPM-60001"); + } + + @Test + public void testAddBrandingPreferenceConflict() throws IOException { + + String body = readResource("add-branding-preference.json"); + // Add Branding Preference. + Response response = getResponseOfPost(BRANDING_PREFERENCE_API_BASE_PATH, body); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_CREATED) + .header(HttpHeaders.LOCATION, notNullValue()); + String location = response.getHeader(HttpHeaders.LOCATION); + assertNotNull(location); + + // Add conflicting Branding Preference. + response = getResponseOfPost(BRANDING_PREFERENCE_API_BASE_PATH, body); + validateErrorResponse(response, HttpStatus.SC_CONFLICT, "BPM-60003"); + + // Delete Branding Preference. + response = getResponseOfDelete(BRANDING_PREFERENCE_API_BASE_PATH); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_NO_CONTENT); + } + + @Test + public void testGetNotExistingBrandingPreference() { + + Response response = getResponseOfGet(BRANDING_PREFERENCE_API_BASE_PATH); + validateErrorResponse(response, HttpStatus.SC_NOT_FOUND, "BPM-60002"); + } + + @Test + public void testUpdateNotExistingBrandingPreference() throws IOException { + + String body = readResource("update-branding-preference.json"); + Response response = getResponseOfPut(BRANDING_PREFERENCE_API_BASE_PATH, body); + validateErrorResponse(response, HttpStatus.SC_NOT_FOUND, "BPM-60002"); + } + + @Test + public void testUpdateBrandingPreferenceWithEmptyJsonPreference() throws IOException { + + String body = readResource("add-branding-preference.json"); + // Add Branding Preference. + Response response = getResponseOfPost(BRANDING_PREFERENCE_API_BASE_PATH, body); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_CREATED) + .header(HttpHeaders.LOCATION, notNullValue()); + String location = response.getHeader(HttpHeaders.LOCATION); + assertNotNull(location); + + // Update Branding Preference with empty JSON preference. + body = readResource("add-empty-json-preference.json"); + response = getResponseOfPut(BRANDING_PREFERENCE_API_BASE_PATH, body); + validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "BPM-60001"); + + // Delete Branding Preference. + response = getResponseOfDelete(BRANDING_PREFERENCE_API_BASE_PATH); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_NO_CONTENT); + } + + @Test + public void testDeleteNotExistingBrandingPreference() { + + Response response = getResponseOfDelete(BRANDING_PREFERENCE_API_BASE_PATH); + validateErrorResponse(response, HttpStatus.SC_NOT_FOUND, "BPM-60002"); + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/BrandingPreferenceManagementSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/BrandingPreferenceManagementSuccessTest.java new file mode 100644 index 00000000000..86f0776d3bc --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/BrandingPreferenceManagementSuccessTest.java @@ -0,0 +1,321 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.server.branding.preference.management.v1; + +import io.restassured.RestAssured; +import io.restassured.response.Response; +import org.apache.commons.lang.StringUtils; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpStatus; +import org.json.JSONException; +import org.json.JSONObject; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Factory; +import org.testng.annotations.Test; +import org.wso2.carbon.automation.engine.context.TestUserMode; + +import java.io.IOException; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.testng.Assert.assertNotNull; +import static org.wso2.identity.integration.test.entitlement.EntitlementJSONSupportMultiDecisionProfileTestCase.areJSONObjectsEqual; + +/** + * Test class for Branding Preference Management REST APIs success paths. + */ +public class BrandingPreferenceManagementSuccessTest extends BrandingPreferenceManagementTestBase { + + @Factory(dataProvider = "restAPIUserConfigProvider") + public BrandingPreferenceManagementSuccessTest(TestUserMode userMode) throws Exception { + + super.init(userMode); + this.context = isServer; + this.authenticatingUserName = context.getContextTenant().getTenantAdmin().getUserName(); + this.authenticatingCredential = context.getContextTenant().getTenantAdmin().getPassword(); + this.tenant = context.getContextTenant().getDomain(); + } + + @DataProvider(name = "restAPIUserConfigProvider") + public static Object[][] restAPIUserConfigProvider() { + + return new Object[][]{ + {TestUserMode.SUPER_TENANT_ADMIN}, + {TestUserMode.TENANT_ADMIN} + }; + } + + @BeforeClass(alwaysRun = true) + public void init() throws IOException { + + super.testInit(API_VERSION, swaggerDefinition, tenant); + } + + @AfterClass(alwaysRun = true) + public void testConclude() { + + super.conclude(); + } + + @BeforeMethod(alwaysRun = true) + public void testInit() { + + RestAssured.basePath = basePath; + } + + @AfterMethod(alwaysRun = true) + public void testFinish() { + + RestAssured.basePath = StringUtils.EMPTY; + } + + @Test + public void testAddBrandingPreference() throws IOException, JSONException { + + String body = readResource("add-branding-preference.json"); + Response response = getResponseOfPost(BRANDING_PREFERENCE_API_BASE_PATH, body); + + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_CREATED) + .header(HttpHeaders.LOCATION, notNullValue()); + String location = response.getHeader(HttpHeaders.LOCATION); + assertNotNull(location); + + JSONObject expectedPreference = new JSONObject(new JSONObject(readResource("add-branding-preference.json")). + get("preference").toString()); + JSONObject receivedPreference = new JSONObject(new JSONObject(response.asString()). + get("preference").toString()); + Assert.assertTrue(areJSONObjectsEqual(expectedPreference, receivedPreference), + "The preference schema of the Response is incorrect"); + } + + @Test(dependsOnMethods = {"testAddBrandingPreference"}) + public void testGetBrandingPreference() throws IOException, JSONException { + + Response response = getResponseOfGet(BRANDING_PREFERENCE_API_BASE_PATH); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_OK) + .body("type", equalTo(ORGANIZATION_TYPE)) + .body("name", equalTo(tenant)) + .body("locale", equalTo(DEFAULT_LOCALE)); + + JSONObject expectedPreference = new JSONObject(new JSONObject(readResource("add-branding-preference.json")). + get("preference").toString()); + JSONObject receivedPreference = new JSONObject(new JSONObject(response.asString()). + get("preference").toString()); + Assert.assertTrue(areJSONObjectsEqual(expectedPreference, receivedPreference), + "The preference schema of the Response is incorrect"); + } + + @Test(dependsOnMethods = {"testGetBrandingPreference"}) + public void testGetBrandingPreferenceByQueryParams() throws IOException, JSONException { + + Response response = getResponseOfGet(BRANDING_PREFERENCE_API_BASE_PATH + String.format + (PREFERENCE_COMPONENT_WITH_QUERY_PARAM, ORGANIZATION_TYPE, tenant, DEFAULT_LOCALE)); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_OK) + .body("type", equalTo(ORGANIZATION_TYPE)) + .body("name", equalTo(tenant)) + .body("locale", equalTo(DEFAULT_LOCALE)); + + JSONObject expectedPreference = new JSONObject(new JSONObject(readResource("add-branding-preference.json")). + get("preference").toString()); + JSONObject receivedPreference = new JSONObject(new JSONObject(response.asString()). + get("preference").toString()); + Assert.assertTrue(areJSONObjectsEqual(expectedPreference, receivedPreference), + "The preference schema of the Response is incorrect"); + } + + @Test(dependsOnMethods = {"testGetBrandingPreferenceByQueryParams"}) + public void testGetBrandingPreferenceByTypeQueryParam() throws IOException, JSONException { + + Response response = getResponseOfGet(BRANDING_PREFERENCE_API_BASE_PATH + QUERY_PARAM_SEPARATOR + + String.format(TYPE_QUERY_PARAM, ORGANIZATION_TYPE)); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_OK) + .body("type", equalTo(ORGANIZATION_TYPE)) + .body("name", equalTo(tenant)) + .body("locale", equalTo(DEFAULT_LOCALE)); + + JSONObject expectedPreference = new JSONObject(new JSONObject(readResource("add-branding-preference.json")). + get("preference").toString()); + JSONObject receivedPreference = new JSONObject(new JSONObject(response.asString()). + get("preference").toString()); + Assert.assertTrue(areJSONObjectsEqual(expectedPreference, receivedPreference), + "The preference schema of the Response is incorrect"); + } + + @Test(dependsOnMethods = {"testGetBrandingPreferenceByTypeQueryParam"}) + public void testGetBrandingPreferenceByLocaleQueryParam() throws IOException, JSONException { + + Response response = getResponseOfGet(BRANDING_PREFERENCE_API_BASE_PATH + QUERY_PARAM_SEPARATOR + + String.format(LOCALE_QUERY_PARAM, DEFAULT_LOCALE)); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_OK) + .body("type", equalTo(ORGANIZATION_TYPE)) + .body("name", equalTo(tenant)) + .body("locale", equalTo(DEFAULT_LOCALE)); + + JSONObject expectedPreference = new JSONObject(new JSONObject(readResource("add-branding-preference.json")). + get("preference").toString()); + JSONObject receivedPreference = new JSONObject(new JSONObject(response.asString()). + get("preference").toString()); + Assert.assertTrue(areJSONObjectsEqual(expectedPreference, receivedPreference), + "The preference schema of the Response is incorrect"); + } + + @Test(dependsOnMethods = {"testGetBrandingPreferenceByLocaleQueryParam"}) + public void testUpdateBrandingPreference() throws IOException, JSONException { + + String body = readResource("update-branding-preference.json"); + Response response = getResponseOfPut(BRANDING_PREFERENCE_API_BASE_PATH, body); + + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_OK) + .body("type", equalTo(ORGANIZATION_TYPE)) + .body("name", equalTo(tenant)) + .body("locale", equalTo(DEFAULT_LOCALE)); + + JSONObject expectedPreference = new JSONObject(new JSONObject(readResource("update-branding-preference.json")). + get("preference").toString()); + JSONObject receivedPreference = new JSONObject(new JSONObject(response.asString()). + get("preference").toString()); + Assert.assertTrue(areJSONObjectsEqual(expectedPreference, receivedPreference), + "The preference schema of the Response is incorrect"); + } + + @Test(dependsOnMethods = {"testUpdateBrandingPreference"}) + public void testGetBrandingPreferenceAfterUpdate() throws IOException, JSONException { + + Response response = getResponseOfGet(BRANDING_PREFERENCE_API_BASE_PATH); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_OK) + .body("type", equalTo(ORGANIZATION_TYPE)) + .body("name", equalTo(tenant)) + .body("locale", equalTo(DEFAULT_LOCALE)); + + JSONObject expectedPreference = new JSONObject(new JSONObject(readResource("update-branding-preference.json")). + get("preference").toString()); + JSONObject receivedPreference = new JSONObject(new JSONObject(response.asString()). + get("preference").toString()); + Assert.assertTrue(areJSONObjectsEqual(expectedPreference, receivedPreference), + "The preference schema of the Response is incorrect"); + } + + @Test(dependsOnMethods = {"testGetBrandingPreferenceAfterUpdate"}) + public void testDeleteBrandingPreference() { + + Response response = getResponseOfDelete(BRANDING_PREFERENCE_API_BASE_PATH); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_NO_CONTENT); + } + + @Test(dependsOnMethods = {"testDeleteBrandingPreference"}) + public void testDeleteBrandingPreferenceByQueryParams() throws IOException { + + String body = readResource("add-branding-preference.json"); + // Add Branding preference. + Response response = getResponseOfPost(BRANDING_PREFERENCE_API_BASE_PATH, body); + + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_CREATED) + .header(HttpHeaders.LOCATION, notNullValue()); + String location = response.getHeader(HttpHeaders.LOCATION); + assertNotNull(location); + + // Delete Branding preference. + response = getResponseOfDelete(BRANDING_PREFERENCE_API_BASE_PATH + String.format + (PREFERENCE_COMPONENT_WITH_QUERY_PARAM, ORGANIZATION_TYPE, tenant, DEFAULT_LOCALE)); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_NO_CONTENT); + } + + @Test(dependsOnMethods = {"testDeleteBrandingPreferenceByQueryParams"}) + public void testDeleteBrandingPreferenceByTypeQueryParam() throws IOException { + + String body = readResource("add-branding-preference.json"); + // Add Branding preference. + Response response = getResponseOfPost(BRANDING_PREFERENCE_API_BASE_PATH, body); + + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_CREATED) + .header(HttpHeaders.LOCATION, notNullValue()); + String location = response.getHeader(HttpHeaders.LOCATION); + assertNotNull(location); + + // Delete Branding preference. + response = getResponseOfDelete(BRANDING_PREFERENCE_API_BASE_PATH + QUERY_PARAM_SEPARATOR + + String.format(TYPE_QUERY_PARAM, ORGANIZATION_TYPE)); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_NO_CONTENT); + } + + @Test(dependsOnMethods = {"testDeleteBrandingPreferenceByTypeQueryParam"}) + public void testDeleteBrandingPreferenceByLocaleQueryParam() throws IOException { + + String body = readResource("add-branding-preference.json"); + // Add Branding preference. + Response response = getResponseOfPost(BRANDING_PREFERENCE_API_BASE_PATH, body); + + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_CREATED) + .header(HttpHeaders.LOCATION, notNullValue()); + String location = response.getHeader(HttpHeaders.LOCATION); + assertNotNull(location); + + // Delete Branding preference. + response = getResponseOfDelete(BRANDING_PREFERENCE_API_BASE_PATH + QUERY_PARAM_SEPARATOR + + String.format(LOCALE_QUERY_PARAM, DEFAULT_LOCALE)); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_NO_CONTENT); + } +} 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 new file mode 100644 index 00000000000..a4887208fb7 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/BrandingPreferenceManagementTestBase.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.server.branding.preference.management.v1; + +import io.restassured.RestAssured; +import org.apache.commons.lang.StringUtils; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.wso2.identity.integration.test.rest.api.server.common.RESTAPIServerTestBase; + +import java.io.IOException; + +/** + * Base test class for the Branding Preference Management Rest APIs. + */ +public class BrandingPreferenceManagementTestBase extends RESTAPIServerTestBase { + + public static final String API_DEFINITION_NAME = "branding-preference.yaml"; + public static final String API_VERSION = "v1"; + public static final String API_PACKAGE_NAME = + "org.wso2.carbon.identity.api.server.branding.preference.management.v1"; + public static final String BRANDING_PREFERENCE_API_BASE_PATH = "/branding-preference"; + public static final String PATH_SEPARATOR = "/"; + public static final String QUERY_PARAM_SEPARATOR = "?"; + public static final String ORGANIZATION_TYPE = "ORG"; + public static final String APPLICATION_TYPE = "APP"; + public static final String CUSTOM_TYPE = "CUSTOM"; + public static final String DEFAULT_LOCALE = "en-US"; + public static final String PREFERENCE_COMPONENT_WITH_QUERY_PARAM = "?type=%s&name=%s&locale=%s"; + public static final String TYPE_QUERY_PARAM = "type=%s"; + public static final String LOCALE_QUERY_PARAM = "locale=%s"; + + protected static String swaggerDefinition; + + static { + try { + swaggerDefinition = getAPISwaggerDefinition(API_PACKAGE_NAME, API_DEFINITION_NAME); + } catch (IOException e) { + Assert.fail(String.format("Unable to read the swagger definition %s from %s", API_DEFINITION_NAME, + API_PACKAGE_NAME), e); + } + } + + @AfterClass(alwaysRun = true) + public void testConclude() throws Exception { + + super.conclude(); + } + + @BeforeMethod(alwaysRun = true) + public void testInit() { + + RestAssured.basePath = basePath; + } + + @AfterMethod(alwaysRun = true) + public void testFinish() { + + RestAssured.basePath = StringUtils.EMPTY; + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/add-branding-preference.json b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/add-branding-preference.json new file mode 100644 index 00000000000..828c989e60a --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/add-branding-preference.json @@ -0,0 +1,32 @@ +{ + "type": "ORG", + "name": "organization-name", + "locale": "en-US", + "preference": { + "organizationDetails": { + "siteTitle": "IAM by WSO2", + "copyrightText": "© 2021 WSO2 Inc. All Rights Reserved", + "supportEmail" : "iam-help@asgardeo.io" + }, + "images": { + "logo": { + "imgURL": "https://accounts.iam/asgardeo-logo.svg", + "altText": "IAM Logo" + }, + "favicon": { + "imgURL": "https://iam.io/favicon.ico" + } + }, + "urls": { + "privacyPolicyURL": "https://wso2.com/privacy-policy", + "termsOfUseURL": "https://wso2.com/terms-of-use", + "cookiePolicyURL": "https://wso2.com/cookie-policy" + }, + "stylesheets": { + "accountApp": "https://iam-branding/login-portal.css" + }, + "configs": { + "isBrandingEnabled": true + } + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/add-empty-json-preference.json b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/add-empty-json-preference.json new file mode 100644 index 00000000000..80a83ff64f8 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/add-empty-json-preference.json @@ -0,0 +1,6 @@ +{ + "type": "ORG", + "name": "organization-name", + "locale": "en-US", + "preference": { } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/update-branding-preference.json b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/update-branding-preference.json new file mode 100644 index 00000000000..9c3405f25b7 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/branding/preference/management/v1/update-branding-preference.json @@ -0,0 +1,32 @@ +{ + "type": "ORG", + "name": "organization-name", + "locale": "en-US", + "preference": { + "organizationDetails": { + "siteTitle": "IAM by WSO2 - Update", + "copyrightText": "© 2021 WSO2 Inc. All Rights Reserved. Updated", + "supportEmail" : "iam-help-update@asgardeo.io" + }, + "images": { + "logo": { + "imgURL": "https://accounts.iam/update/asgardeo-logo.svg", + "altText": "IAM Update Logo" + }, + "favicon": { + "imgURL": "https://iam.io/update/favicon.ico" + } + }, + "urls": { + "privacyPolicyURL": "https://wso2.com/update/privacy-policy", + "termsOfUseURL": "https://wso2.com/update/terms-of-use", + "cookiePolicyURL": "https://wso2.com/update/cookie-policy" + }, + "stylesheets": { + "accountApp": "https://iam-branding/update/login-portal.css" + }, + "configs": { + "isBrandingEnabled": false + } + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml b/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml index a4ad3c52ac7..e1b557e66a9 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml @@ -192,6 +192,8 @@ + +