From d9fd39dccf1442fa10aed08d81a36c42395624d5 Mon Sep 17 00:00:00 2001 From: BLasan Date: Fri, 21 Apr 2023 13:41:34 +0530 Subject: [PATCH 1/7] Add: Scope update validation with http client configs --- .../other/SharedScopeTestWIthRestart.java | 128 ++++++++ .../AM/operationPolicy/deployment.toml | 286 ++++++++++++++++++ .../src/test/resources/testng.xml | 7 + 3 files changed, 421 insertions(+) create mode 100644 modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java create mode 100644 modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/operationPolicy/deployment.toml diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java new file mode 100644 index 0000000000..4746cd8cbb --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2020, WSO2 Inc. (http://wso2.com) All Rights Reserved. + * + * Licensed 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.am.integration.tests.other; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Factory; +import org.testng.annotations.Test; +import org.wso2.am.integration.clients.publisher.api.v1.dto.ScopeDTO; +import org.wso2.am.integration.test.utils.base.APIMIntegrationConstants; +import org.wso2.am.integration.tests.api.lifecycle.APIManagerLifecycleBaseTest; +import org.wso2.carbon.automation.engine.context.AutomationContext; +import org.wso2.carbon.automation.engine.context.TestUserMode; +import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +public class SharedScopeTestWIthRestart extends APIManagerLifecycleBaseTest { + private final Log log = LogFactory.getLog(SharedScopeTestCase.class); + + private String sharedScopeName = "TestSharedScopeWithRestart"; + private String sharedScopeDisplayName = "Test Shared Scope with Restart"; + private String description = "This is a test shared scope with Restart"; + private String updatedDescription = "This is a updated test shared scope with Restart"; + private String updatedDescription1 = "This is a updated test shared scope with Restart(2)"; + private String updatedDescription2 = "This is a updated test shared scope with Restart(3)"; + private List roles = new ArrayList<>(); + private String sharedScopeId; + private ServerConfigurationManager serverConfigurationManager; + + @Factory(dataProvider = "userModeDataProvider") + public SharedScopeTestWIthRestart(TestUserMode userMode) { + this.userMode = userMode; + } + + @DataProvider + public static Object[][] userModeDataProvider() { + return new Object[][] { new Object[] { TestUserMode.SUPER_TENANT_ADMIN }}; + } + + @BeforeClass(alwaysRun = true) + public void setEnvironment() throws Exception { + super.init(userMode); + superTenantKeyManagerContext = new AutomationContext(APIMIntegrationConstants.AM_PRODUCT_GROUP_NAME, + APIMIntegrationConstants.AM_KEY_MANAGER_INSTANCE, + TestUserMode.SUPER_TENANT_ADMIN); + serverConfigurationManager = new ServerConfigurationManager(superTenantKeyManagerContext); + serverConfigurationManager.applyConfiguration(new File( + getAMResourceLocation() + File.separator + "operationPolicy" + + File.separator + "deployment.toml")); + serverConfigurationManager.restartGracefully(); + } + + @Test(groups = { "wso2.am" }, description = "Test add shared scope") + public void testAddSharedScope() throws Exception { + ScopeDTO scopeDTO = new ScopeDTO(); + scopeDTO.setName(sharedScopeName); + scopeDTO.setDisplayName(sharedScopeDisplayName); + scopeDTO.setDescription(description); + + roles.add("Internal/publisher"); + roles.add("admin"); + scopeDTO.setBindings(roles); + + ScopeDTO addedScopeDTO = restAPIPublisher.addSharedScope(scopeDTO); + sharedScopeId = addedScopeDTO.getId(); + Assert.assertNotNull(sharedScopeId, "The scope ID cannot be null or empty"); + } + + @Test(groups = { "wso2.am" }, description = "Test get and update shared scope", + dependsOnMethods = "testAddSharedScope") + public void testGetAndUpdateSharedScope() throws Exception { + ScopeDTO sharedScopeDTO = restAPIPublisher.getSharedScopeById(sharedScopeId); + Assert.assertEquals(sharedScopeDTO.getName(), sharedScopeName, + "Shared scope name does not match with the expected name"); + Assert.assertEquals(sharedScopeDTO.getDisplayName(), sharedScopeDisplayName, + "Shared scope display name does not match with the expected display name"); + Assert.assertTrue(sharedScopeDTO.getBindings().contains("admin"), + "Shared scope does not include the expected role"); + + sharedScopeDTO.setDescription(updatedDescription); + ScopeDTO updateScopeDTO = restAPIPublisher.updateSharedScope(sharedScopeId, sharedScopeDTO); + Assert.assertEquals(updateScopeDTO.getDescription(), updatedDescription, + "Shared scope description does not match with the expected description"); + + sharedScopeDTO.setDescription(updatedDescription1); + updateScopeDTO = restAPIPublisher.updateSharedScope(sharedScopeId, sharedScopeDTO); + Assert.assertEquals(updateScopeDTO.getDescription(), updatedDescription1, + "Shared scope description does not match with the expected description"); + + sharedScopeDTO.setDescription(updatedDescription2); + updateScopeDTO = restAPIPublisher.updateSharedScope(sharedScopeId, sharedScopeDTO); + Assert.assertEquals(updateScopeDTO.getDescription(), updatedDescription2, + "Shared scope description does not match with the expected description"); + } + + @Test(groups = { "wso2.am" }, description = "Test get and update shared scope", + dependsOnMethods = "testGetAndUpdateSharedScope") + public void testDeleteSharedScope() throws Exception { + restAPIPublisher.deleteSharedScope(sharedScopeId); + } + + @AfterClass(alwaysRun = true) + public void destroy() throws Exception { + serverConfigurationManager = new ServerConfigurationManager(superTenantKeyManagerContext); + serverConfigurationManager.restoreToLastConfiguration(); + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/operationPolicy/deployment.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/operationPolicy/deployment.toml new file mode 100644 index 0000000000..f94c4f503a --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/operationPolicy/deployment.toml @@ -0,0 +1,286 @@ +[server] +hostname = "localhost" +#offset=0 +base_path = "${carbon.protocol}://${carbon.host}:${carbon.management.port}" +server_role = "default" +enable_shutdown_from_api = true +enable_restart_from_api = true + +[super_admin] +username = "admin" +password = "admin" +create_admin_account = true + +[user_store] +type = "database_unique_id" + +[database.apim_db] +driver = "$env{API_MANAGER_DATABASE_DRIVER}" +url = "$env{API_MANAGER_DATABASE_URL}" +username = "$env{API_MANAGER_DATABASE_USERNAME}" +password = "$env{API_MANAGER_DATABASE_PASSWORD}" +validationQuery = "$env{API_MANAGER_DATABASE_VALIDATION_QUERY}" + +[database.shared_db] +driver = "$env{SHARED_DATABASE_DRIVER}" +url = "$env{SHARED_DATABASE_URL}" +username = "$env{SHARED_DATABASE_USERNAME}" +password = "$env{SHARED_DATABASE_PASSWORD}" +validationQuery = "$env{SHARED_DATABASE_VALIDATION_QUERY}" + +[keystore.tls] +file_name = "wso2carbon.jks" +type = "JKS" +password = "wso2carbon" +alias = "wso2carbon" +key_password = "wso2carbon" + +[[apim.gateway.environment]] +name = "Default" +type = "hybrid" +provider = "wso2" +display_in_api_console = true +description = "This is a hybrid gateway that handles both production and sandbox token traffic." +show_as_token_endpoint_url = true +service_url = "https://localhost:${mgt.transport.https.port}/services/" +username = "admin" +password = "admin" +ws_endpoint = "ws://localhost:9099" +http_endpoint = "http://localhost:${http.nio.port}" +https_endpoint = "https://localhost:${https.nio.port}" + +[[apim.gateway.environment]] +name = "devportalEnv" +display_name = "Developer portal Test Environment" +type = "hybrid" +display_in_api_console = false +description = "development api gateway broker" +provider = "solace" +service_url = "http://localhost:9960" +username = "testUser" +ws_endpoint = "ws://localhost:9960/" +wss_endpoint = "wss://localhost:9960/" +http_endpoint = "http://localhost:9960" +https_endpoint = "https://localhost:9960/" +password = "testPassword" +show_as_token_endpoint_url = false + +[apim.gateway.environment.properties] +Organization = "TestWSO2" +DisplayName = "Developer portal Test Environment" +DevAccountName = "devPortTestEnv" + +#[apim.cache.gateway_token] +#enable = true +#expiry_time = "15m" + +#[apim.cache.resource] +#enable = true + +#[apim.cache.km_token] +#enable = false +#expiry_time = "15m" + +#[apim.cache.recent_apis] +#enable = false + +#[apim.cache.scopes] +#enable = true + +#[apim.cache.publisher_roles] +#enable = true + +#[apim.cache.jwt_claim] +#enable = true +#expiry_time = "15m" + +#[apim.cache.tags] +#expiry_time = "2m" + +#[apim.analytics] +#enable = false +#store_api_url = "https://localhost:7444" +#username = "$ref{super_admin.username}" +#password = "$ref{super_admin.password}" +#event_publisher_type = "default" +#event_publisher_type = "custom" +#event_publisher_impl = "org.wso2.carbon.apimgt.usage.publisher.APIMgtUsageDataBridgeDataPublisher" +#publish_response_size = true + +#[[apim.analytics.url_group]] +#analytics_url =["tcp://analytics1:7611","tcp://analytics2:7611"] +#analytics_auth_url =["ssl://analytics1:7711","ssl://analytics2:7711"] +#type = "loadbalance" + +#[[apim.analytics.url_group]] +#analytics_url =["tcp://analytics1:7612","tcp://analytics2:7612"] +#analytics_auth_url =["ssl://analytics1:7712","ssl://analytics2:7712"] +#type = "failover" + + +#[apim.key_manager] +#service_url = "https://localhost:${mgt.transport.https.port}/services/" +#username = "$ref{super_admin.username}" +#password = "$ref{super_admin.password}" +#pool.init_idle_capacity = 50 +#pool.max_idle = 100 +#key_validation_handler_type = "default" +#key_validation_handler_type = "custom" +#key_validation_handler_impl = "org.wso2.carbon.apimgt.keymgt.handlers.DefaultKeyValidationHandler" + +#[apim.jwt] +#enable = true +#encoding = "base64" # base64,base64url +#generator_impl = "org.wso2.carbon.apimgt.keymgt.token.JWTGenerator" +#claim_dialect = "http://wso2.org/claims" +#header = "X-JWT-Assertion" +#signing_algorithm = "SHA256withRSA" +#enable_user_claims = true +#claims_extractor_impl = "org.wso2.carbon.apimgt.impl.token.DefaultClaimsRetriever" + +#[apim.oauth_config] +#enable_outbound_auth_header = false +#auth_header = "Authorization" +#revoke_endpoint = "https://localhost:${https.nio.port}/revoke" +#enable_token_encryption = false +#enable_token_hashing = false + +#[apim.devportal] +#url = "https://localhost:${mgt.transport.https.port}/devportal" +#enable_application_sharing = false +#if application_sharing_type, application_sharing_impl both defined priority goes to application_sharing_impl +#application_sharing_type = "default" #changed type, saml, default #todo: check the new config for rest api +#application_sharing_impl = "org.wso2.carbon.apimgt.impl.SAMLGroupIDExtractorImpl" +#display_multiple_versions = false +#display_deprecated_apis = false +#enable_comments = true +#enable_ratings = true +#enable_forum = true + +[apim.cors] +allow_origins = "*" +allow_methods = ["GET","PUT","POST","DELETE","PATCH","OPTIONS"] +allow_headers = ["authorization","Access-Control-Allow-Origin","Content-Type","SOAPAction"] +allow_credentials = false + +#[[apim.throttling.url_group]] +#analytics_url = ["tcp://localhost:7611","tcp://localhost:7611"] +#analytics_auth_url = ["ssl://localhost:7711","ssl://localhost:7711"] +#type = "loadbalance" + +#[apim.throttling] +#enable_data_publishing = true +#enable_policy_deploy = true +#enable_blacklist_condition = true + +#throttle_decision_endpoints = ["tcp://localhost:5672","tcp://localhost:5672"] +# +#enable_persistence = true + +#[apim.throttling.blacklist_condition] +#start_delay = "5m" +#period = "1h" + +#[apim.throttling.jms] +#start_delay = "5m" + +#[apim.throttling.event_sync] +#hostName = "0.0.0.0" +#port = 11224 +# +#[apim.throttling.event_management] +#hostName = "0.0.0.0" +#port = 10005 + +#[[apim.throttling.url_group]] +#traffic_manager_urls = ["tcp://localhost:9611","tcp://localhost:9611"] +#traffic_manager_auth_urls = ["ssl://localhost:9711","ssl://localhost:9711"] +#type = "loadbalance" +# +#[[apim.throttling.url_group]] +#traffic_manager_urls = ["tcp://localhost:9611","tcp://localhost:9611"] +#traffic_manager_auth_urls = ["ssl://localhost:9711","ssl://localhost:9711"] +#type = "failover" + +#[apim.workflow] +#enable = false +#service_url = "https://localhost:9445/bpmn" +#username = "$ref{super_admin.username}" +#password = "$ref{super_admin.password}" +#callback_endpoint = "https://localhost:${mgt.transport.https.port}/api/am/publisher/v0.16/workflows/update-workflow-status" +#token_endpoint = "https://localhost:${https.nio.port}/token" +#client_registration_endpoint = "https://localhost:${mgt.transport.https.port}/client-registration/v0.17/register" +#client_registration_username = "$ref{super_admin.username}" +#client_registration_password = "$ref{super_admin.password}" + +#data bridge config +#[transport.receiver] +#type = "binary" +#worker_threads = 10 +#session_timeout = "30m" +#keystore.file_name = "$ref{keystore.tls.file_name}" +#keystore.password = "$ref{keystore.tls.password}" +#tcp_port = 9611 +#ssl_port = 9711 +#ssl_receiver_thread_pool_size = 100 +#tcp_receiver_thread_pool_size = 100 +#ssl_enabled_protocols = ["TLSv1","TLSv1.1","TLSv1.2"] +#ciphers = ["SSL_RSA_WITH_RC4_128_MD5","SSL_RSA_WITH_RC4_128_SHA"] + +#[apim.notification] +#from_address = "APIM.com" +#username = "APIM" +#password = "APIM+123" +#hostname = "localhost" +#port = 3025 +#enable_start_tls = false +#enable_authentication = true + +#[apim.token.revocation] +#notifier_impl = "org.wso2.carbon.apimgt.keymgt.events.TokenRevocationNotifierImpl" +#enable_realtime_notifier = true +#realtime_notifier.ttl = 5000 +#enable_persistent_notifier = true +#persistent_notifier.hostname = "https://localhost:2379/v2/keys/jti/" +#persistent_notifier.ttl = 5000 +#persistent_notifier.username = "root" +#persistent_notifier.password = "root" + +[[event_handler]] +name="userPostSelfRegistration" +subscriptions=["POST_ADD_USER"] + +[transport] +passthru_https.listener.ssl_profile_interval = 6000 +passthru_https.sender.ssl_profile.interval = 6000 + +[security_audit] +api_token="b57973cf-b74c-4ade-921d-ece83251eceb" +collection_id="f73b8171-4f71-499b-891a-d34aa71f2d45" +base_url="https://localhost:9943/am-auditApi-sample/api/auditapi" +global=true + +[apim.certificate_reloader] +period = "1m" + +[database.local] +url = "jdbc:h2:./repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE" + +[[event_listener]] +id = "token_revocation" +type = "org.wso2.carbon.identity.core.handler.AbstractIdentityHandler" +name = "org.wso2.is.notification.ApimOauthEventInterceptor" +order = 1 +[event_listener.properties] +notification_endpoint = "https://localhost:${mgt.transport.https.port}/internal/data/v1/notify" +username = "${admin.username}" +password = "${admin.password}" +'header.X-WSO2-KEY-MANAGER' = "default" + +[apim.sync_runtime_artifacts.gateway.skip_list] +apis = ["admin--git2231head_v1.0.0.xml","admin--PizzaShackAPI_v1.0.0.xml","admin--ScriptMediatorAPI_v1.0.xml", + "APIThrottleBackendAPI.xml","BackEndSecurity.xml","DigestAuth_API.xml","git2231.xml","HttpPATCHSupport_API.xml","JWKS-Backend.xml","JWTBackendAPI.xml","multiVSR_v1.0.0.xml","Response_API_1.xml","Response_API_2.xml","Response_Custom_API.xml","Response_Error_API.xml","Response_Loc_API.xml","SpecialCRN_v1.0.0.xml","status_code_204_API.xml","stockquote.xml","XML_API.xml","Version1.xml","Version2.xml","schemaValidationAPI.xml"] + +[apim.http_client] +max_total= "200" +default_max_per_route= "2" 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 cb3a4edd6b..f70ea8e238 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 @@ -198,6 +198,13 @@ + + + + + + + From 718c68ad318032a4d12639da8f424609f02b8595 Mon Sep 17 00:00:00 2001 From: BLasan Date: Wed, 14 Jun 2023 10:05:21 +0530 Subject: [PATCH 2/7] Fix: Test description --- .../am/integration/tests/other/SharedScopeTestWIthRestart.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java index 4746cd8cbb..4942b558ff 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java @@ -114,7 +114,7 @@ public void testGetAndUpdateSharedScope() throws Exception { "Shared scope description does not match with the expected description"); } - @Test(groups = { "wso2.am" }, description = "Test get and update shared scope", + @Test(groups = { "wso2.am" }, description = "Test delete shared scope", dependsOnMethods = "testGetAndUpdateSharedScope") public void testDeleteSharedScope() throws Exception { restAPIPublisher.deleteSharedScope(sharedScopeId); From 60a5c02a74e5754a72885ac2ced97a2139b77a56 Mon Sep 17 00:00:00 2001 From: BLasan Date: Thu, 15 Jun 2023 07:12:39 +0530 Subject: [PATCH 3/7] Fix: Minor issues --- .../other/SharedScopeTestWIthRestart.java | 4 +- .../AM/operationPolicy/deployment.toml | 286 ------------------ .../artifacts/AM/scopes/deployment.toml | 116 +++++++ 3 files changed, 118 insertions(+), 288 deletions(-) delete mode 100644 modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/operationPolicy/deployment.toml create mode 100644 modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/scopes/deployment.toml diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java index 4942b558ff..92f7544ef7 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, WSO2 Inc. (http://wso2.com) All Rights Reserved. + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,7 +66,7 @@ public void setEnvironment() throws Exception { TestUserMode.SUPER_TENANT_ADMIN); serverConfigurationManager = new ServerConfigurationManager(superTenantKeyManagerContext); serverConfigurationManager.applyConfiguration(new File( - getAMResourceLocation() + File.separator + "operationPolicy" + getAMResourceLocation() + File.separator + "scopes" + File.separator + "deployment.toml")); serverConfigurationManager.restartGracefully(); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/operationPolicy/deployment.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/operationPolicy/deployment.toml deleted file mode 100644 index f94c4f503a..0000000000 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/operationPolicy/deployment.toml +++ /dev/null @@ -1,286 +0,0 @@ -[server] -hostname = "localhost" -#offset=0 -base_path = "${carbon.protocol}://${carbon.host}:${carbon.management.port}" -server_role = "default" -enable_shutdown_from_api = true -enable_restart_from_api = true - -[super_admin] -username = "admin" -password = "admin" -create_admin_account = true - -[user_store] -type = "database_unique_id" - -[database.apim_db] -driver = "$env{API_MANAGER_DATABASE_DRIVER}" -url = "$env{API_MANAGER_DATABASE_URL}" -username = "$env{API_MANAGER_DATABASE_USERNAME}" -password = "$env{API_MANAGER_DATABASE_PASSWORD}" -validationQuery = "$env{API_MANAGER_DATABASE_VALIDATION_QUERY}" - -[database.shared_db] -driver = "$env{SHARED_DATABASE_DRIVER}" -url = "$env{SHARED_DATABASE_URL}" -username = "$env{SHARED_DATABASE_USERNAME}" -password = "$env{SHARED_DATABASE_PASSWORD}" -validationQuery = "$env{SHARED_DATABASE_VALIDATION_QUERY}" - -[keystore.tls] -file_name = "wso2carbon.jks" -type = "JKS" -password = "wso2carbon" -alias = "wso2carbon" -key_password = "wso2carbon" - -[[apim.gateway.environment]] -name = "Default" -type = "hybrid" -provider = "wso2" -display_in_api_console = true -description = "This is a hybrid gateway that handles both production and sandbox token traffic." -show_as_token_endpoint_url = true -service_url = "https://localhost:${mgt.transport.https.port}/services/" -username = "admin" -password = "admin" -ws_endpoint = "ws://localhost:9099" -http_endpoint = "http://localhost:${http.nio.port}" -https_endpoint = "https://localhost:${https.nio.port}" - -[[apim.gateway.environment]] -name = "devportalEnv" -display_name = "Developer portal Test Environment" -type = "hybrid" -display_in_api_console = false -description = "development api gateway broker" -provider = "solace" -service_url = "http://localhost:9960" -username = "testUser" -ws_endpoint = "ws://localhost:9960/" -wss_endpoint = "wss://localhost:9960/" -http_endpoint = "http://localhost:9960" -https_endpoint = "https://localhost:9960/" -password = "testPassword" -show_as_token_endpoint_url = false - -[apim.gateway.environment.properties] -Organization = "TestWSO2" -DisplayName = "Developer portal Test Environment" -DevAccountName = "devPortTestEnv" - -#[apim.cache.gateway_token] -#enable = true -#expiry_time = "15m" - -#[apim.cache.resource] -#enable = true - -#[apim.cache.km_token] -#enable = false -#expiry_time = "15m" - -#[apim.cache.recent_apis] -#enable = false - -#[apim.cache.scopes] -#enable = true - -#[apim.cache.publisher_roles] -#enable = true - -#[apim.cache.jwt_claim] -#enable = true -#expiry_time = "15m" - -#[apim.cache.tags] -#expiry_time = "2m" - -#[apim.analytics] -#enable = false -#store_api_url = "https://localhost:7444" -#username = "$ref{super_admin.username}" -#password = "$ref{super_admin.password}" -#event_publisher_type = "default" -#event_publisher_type = "custom" -#event_publisher_impl = "org.wso2.carbon.apimgt.usage.publisher.APIMgtUsageDataBridgeDataPublisher" -#publish_response_size = true - -#[[apim.analytics.url_group]] -#analytics_url =["tcp://analytics1:7611","tcp://analytics2:7611"] -#analytics_auth_url =["ssl://analytics1:7711","ssl://analytics2:7711"] -#type = "loadbalance" - -#[[apim.analytics.url_group]] -#analytics_url =["tcp://analytics1:7612","tcp://analytics2:7612"] -#analytics_auth_url =["ssl://analytics1:7712","ssl://analytics2:7712"] -#type = "failover" - - -#[apim.key_manager] -#service_url = "https://localhost:${mgt.transport.https.port}/services/" -#username = "$ref{super_admin.username}" -#password = "$ref{super_admin.password}" -#pool.init_idle_capacity = 50 -#pool.max_idle = 100 -#key_validation_handler_type = "default" -#key_validation_handler_type = "custom" -#key_validation_handler_impl = "org.wso2.carbon.apimgt.keymgt.handlers.DefaultKeyValidationHandler" - -#[apim.jwt] -#enable = true -#encoding = "base64" # base64,base64url -#generator_impl = "org.wso2.carbon.apimgt.keymgt.token.JWTGenerator" -#claim_dialect = "http://wso2.org/claims" -#header = "X-JWT-Assertion" -#signing_algorithm = "SHA256withRSA" -#enable_user_claims = true -#claims_extractor_impl = "org.wso2.carbon.apimgt.impl.token.DefaultClaimsRetriever" - -#[apim.oauth_config] -#enable_outbound_auth_header = false -#auth_header = "Authorization" -#revoke_endpoint = "https://localhost:${https.nio.port}/revoke" -#enable_token_encryption = false -#enable_token_hashing = false - -#[apim.devportal] -#url = "https://localhost:${mgt.transport.https.port}/devportal" -#enable_application_sharing = false -#if application_sharing_type, application_sharing_impl both defined priority goes to application_sharing_impl -#application_sharing_type = "default" #changed type, saml, default #todo: check the new config for rest api -#application_sharing_impl = "org.wso2.carbon.apimgt.impl.SAMLGroupIDExtractorImpl" -#display_multiple_versions = false -#display_deprecated_apis = false -#enable_comments = true -#enable_ratings = true -#enable_forum = true - -[apim.cors] -allow_origins = "*" -allow_methods = ["GET","PUT","POST","DELETE","PATCH","OPTIONS"] -allow_headers = ["authorization","Access-Control-Allow-Origin","Content-Type","SOAPAction"] -allow_credentials = false - -#[[apim.throttling.url_group]] -#analytics_url = ["tcp://localhost:7611","tcp://localhost:7611"] -#analytics_auth_url = ["ssl://localhost:7711","ssl://localhost:7711"] -#type = "loadbalance" - -#[apim.throttling] -#enable_data_publishing = true -#enable_policy_deploy = true -#enable_blacklist_condition = true - -#throttle_decision_endpoints = ["tcp://localhost:5672","tcp://localhost:5672"] -# -#enable_persistence = true - -#[apim.throttling.blacklist_condition] -#start_delay = "5m" -#period = "1h" - -#[apim.throttling.jms] -#start_delay = "5m" - -#[apim.throttling.event_sync] -#hostName = "0.0.0.0" -#port = 11224 -# -#[apim.throttling.event_management] -#hostName = "0.0.0.0" -#port = 10005 - -#[[apim.throttling.url_group]] -#traffic_manager_urls = ["tcp://localhost:9611","tcp://localhost:9611"] -#traffic_manager_auth_urls = ["ssl://localhost:9711","ssl://localhost:9711"] -#type = "loadbalance" -# -#[[apim.throttling.url_group]] -#traffic_manager_urls = ["tcp://localhost:9611","tcp://localhost:9611"] -#traffic_manager_auth_urls = ["ssl://localhost:9711","ssl://localhost:9711"] -#type = "failover" - -#[apim.workflow] -#enable = false -#service_url = "https://localhost:9445/bpmn" -#username = "$ref{super_admin.username}" -#password = "$ref{super_admin.password}" -#callback_endpoint = "https://localhost:${mgt.transport.https.port}/api/am/publisher/v0.16/workflows/update-workflow-status" -#token_endpoint = "https://localhost:${https.nio.port}/token" -#client_registration_endpoint = "https://localhost:${mgt.transport.https.port}/client-registration/v0.17/register" -#client_registration_username = "$ref{super_admin.username}" -#client_registration_password = "$ref{super_admin.password}" - -#data bridge config -#[transport.receiver] -#type = "binary" -#worker_threads = 10 -#session_timeout = "30m" -#keystore.file_name = "$ref{keystore.tls.file_name}" -#keystore.password = "$ref{keystore.tls.password}" -#tcp_port = 9611 -#ssl_port = 9711 -#ssl_receiver_thread_pool_size = 100 -#tcp_receiver_thread_pool_size = 100 -#ssl_enabled_protocols = ["TLSv1","TLSv1.1","TLSv1.2"] -#ciphers = ["SSL_RSA_WITH_RC4_128_MD5","SSL_RSA_WITH_RC4_128_SHA"] - -#[apim.notification] -#from_address = "APIM.com" -#username = "APIM" -#password = "APIM+123" -#hostname = "localhost" -#port = 3025 -#enable_start_tls = false -#enable_authentication = true - -#[apim.token.revocation] -#notifier_impl = "org.wso2.carbon.apimgt.keymgt.events.TokenRevocationNotifierImpl" -#enable_realtime_notifier = true -#realtime_notifier.ttl = 5000 -#enable_persistent_notifier = true -#persistent_notifier.hostname = "https://localhost:2379/v2/keys/jti/" -#persistent_notifier.ttl = 5000 -#persistent_notifier.username = "root" -#persistent_notifier.password = "root" - -[[event_handler]] -name="userPostSelfRegistration" -subscriptions=["POST_ADD_USER"] - -[transport] -passthru_https.listener.ssl_profile_interval = 6000 -passthru_https.sender.ssl_profile.interval = 6000 - -[security_audit] -api_token="b57973cf-b74c-4ade-921d-ece83251eceb" -collection_id="f73b8171-4f71-499b-891a-d34aa71f2d45" -base_url="https://localhost:9943/am-auditApi-sample/api/auditapi" -global=true - -[apim.certificate_reloader] -period = "1m" - -[database.local] -url = "jdbc:h2:./repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE" - -[[event_listener]] -id = "token_revocation" -type = "org.wso2.carbon.identity.core.handler.AbstractIdentityHandler" -name = "org.wso2.is.notification.ApimOauthEventInterceptor" -order = 1 -[event_listener.properties] -notification_endpoint = "https://localhost:${mgt.transport.https.port}/internal/data/v1/notify" -username = "${admin.username}" -password = "${admin.password}" -'header.X-WSO2-KEY-MANAGER' = "default" - -[apim.sync_runtime_artifacts.gateway.skip_list] -apis = ["admin--git2231head_v1.0.0.xml","admin--PizzaShackAPI_v1.0.0.xml","admin--ScriptMediatorAPI_v1.0.xml", - "APIThrottleBackendAPI.xml","BackEndSecurity.xml","DigestAuth_API.xml","git2231.xml","HttpPATCHSupport_API.xml","JWKS-Backend.xml","JWTBackendAPI.xml","multiVSR_v1.0.0.xml","Response_API_1.xml","Response_API_2.xml","Response_Custom_API.xml","Response_Error_API.xml","Response_Loc_API.xml","SpecialCRN_v1.0.0.xml","status_code_204_API.xml","stockquote.xml","XML_API.xml","Version1.xml","Version2.xml","schemaValidationAPI.xml"] - -[apim.http_client] -max_total= "200" -default_max_per_route= "2" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/scopes/deployment.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/scopes/deployment.toml new file mode 100644 index 0000000000..fdbecb68de --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/AM/scopes/deployment.toml @@ -0,0 +1,116 @@ +[server] +hostname = "localhost" +#offset=0 +base_path = "${carbon.protocol}://${carbon.host}:${carbon.management.port}" +server_role = "default" +enable_shutdown_from_api = true +enable_restart_from_api = true + +[super_admin] +username = "admin" +password = "admin" +create_admin_account = true + +[user_store] +type = "database_unique_id" + +[database.apim_db] +driver = "$env{API_MANAGER_DATABASE_DRIVER}" +url = "$env{API_MANAGER_DATABASE_URL}" +username = "$env{API_MANAGER_DATABASE_USERNAME}" +password = "$env{API_MANAGER_DATABASE_PASSWORD}" +validationQuery = "$env{API_MANAGER_DATABASE_VALIDATION_QUERY}" + +[database.shared_db] +driver = "$env{SHARED_DATABASE_DRIVER}" +url = "$env{SHARED_DATABASE_URL}" +username = "$env{SHARED_DATABASE_USERNAME}" +password = "$env{SHARED_DATABASE_PASSWORD}" +validationQuery = "$env{SHARED_DATABASE_VALIDATION_QUERY}" + +[keystore.tls] +file_name = "wso2carbon.jks" +type = "JKS" +password = "wso2carbon" +alias = "wso2carbon" +key_password = "wso2carbon" + +[[apim.gateway.environment]] +name = "Default" +type = "hybrid" +provider = "wso2" +display_in_api_console = true +description = "This is a hybrid gateway that handles both production and sandbox token traffic." +show_as_token_endpoint_url = true +service_url = "https://localhost:${mgt.transport.https.port}/services/" +username = "admin" +password = "admin" +ws_endpoint = "ws://localhost:9099" +http_endpoint = "http://localhost:${http.nio.port}" +https_endpoint = "https://localhost:${https.nio.port}" + +[[apim.gateway.environment]] +name = "devportalEnv" +display_name = "Developer portal Test Environment" +type = "hybrid" +display_in_api_console = false +description = "development api gateway broker" +provider = "solace" +service_url = "http://localhost:9960" +username = "testUser" +ws_endpoint = "ws://localhost:9960/" +wss_endpoint = "wss://localhost:9960/" +http_endpoint = "http://localhost:9960" +https_endpoint = "https://localhost:9960/" +password = "testPassword" +show_as_token_endpoint_url = false + +[apim.gateway.environment.properties] +Organization = "TestWSO2" +DisplayName = "Developer portal Test Environment" +DevAccountName = "devPortTestEnv" + +[apim.cors] +allow_origins = "*" +allow_methods = ["GET","PUT","POST","DELETE","PATCH","OPTIONS"] +allow_headers = ["authorization","Access-Control-Allow-Origin","Content-Type","SOAPAction"] +allow_credentials = false + +[[event_handler]] +name="userPostSelfRegistration" +subscriptions=["POST_ADD_USER"] + +[transport] +passthru_https.listener.ssl_profile_interval = 6000 +passthru_https.sender.ssl_profile.interval = 6000 + +[security_audit] +api_token="b57973cf-b74c-4ade-921d-ece83251eceb" +collection_id="f73b8171-4f71-499b-891a-d34aa71f2d45" +base_url="https://localhost:9943/am-auditApi-sample/api/auditapi" +global=true + +[apim.certificate_reloader] +period = "1m" + +[database.local] +url = "jdbc:h2:./repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE" + +[[event_listener]] +id = "token_revocation" +type = "org.wso2.carbon.identity.core.handler.AbstractIdentityHandler" +name = "org.wso2.is.notification.ApimOauthEventInterceptor" +order = 1 +[event_listener.properties] +notification_endpoint = "https://localhost:${mgt.transport.https.port}/internal/data/v1/notify" +username = "${admin.username}" +password = "${admin.password}" +'header.X-WSO2-KEY-MANAGER' = "default" + +[apim.sync_runtime_artifacts.gateway.skip_list] +apis = ["admin--git2231head_v1.0.0.xml","admin--PizzaShackAPI_v1.0.0.xml","admin--ScriptMediatorAPI_v1.0.xml", + "APIThrottleBackendAPI.xml","BackEndSecurity.xml","DigestAuth_API.xml","git2231.xml","HttpPATCHSupport_API.xml","JWKS-Backend.xml","JWTBackendAPI.xml","multiVSR_v1.0.0.xml","Response_API_1.xml","Response_API_2.xml","Response_Custom_API.xml","Response_Error_API.xml","Response_Loc_API.xml","SpecialCRN_v1.0.0.xml","status_code_204_API.xml","stockquote.xml","XML_API.xml","Version1.xml","Version2.xml","schemaValidationAPI.xml"] + +[apim.http_client] +max_total= "200" +default_max_per_route= "2" From 879bb1be889eb72271ca94059d578d2fe07ab306 Mon Sep 17 00:00:00 2001 From: BLasan Date: Thu, 15 Jun 2023 20:58:56 +0530 Subject: [PATCH 4/7] Fix: Test destroy issue --- .../am/integration/tests/other/SharedScopeTestWIthRestart.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java index 92f7544ef7..37afd8755d 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java @@ -36,7 +36,6 @@ import java.util.List; public class SharedScopeTestWIthRestart extends APIManagerLifecycleBaseTest { - private final Log log = LogFactory.getLog(SharedScopeTestCase.class); private String sharedScopeName = "TestSharedScopeWithRestart"; private String sharedScopeDisplayName = "Test Shared Scope with Restart"; @@ -122,7 +121,6 @@ public void testDeleteSharedScope() throws Exception { @AfterClass(alwaysRun = true) public void destroy() throws Exception { - serverConfigurationManager = new ServerConfigurationManager(superTenantKeyManagerContext); serverConfigurationManager.restoreToLastConfiguration(); } } From f0d973ff1796bb2c0dc41ddaf969c88e9957a46e Mon Sep 17 00:00:00 2001 From: BLasan Date: Fri, 16 Jun 2023 06:42:49 +0530 Subject: [PATCH 5/7] Remove: Unwanted restarts --- .../am/integration/tests/other/SharedScopeTestWIthRestart.java | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java index 37afd8755d..19db70e091 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java @@ -67,7 +67,6 @@ public void setEnvironment() throws Exception { serverConfigurationManager.applyConfiguration(new File( getAMResourceLocation() + File.separator + "scopes" + File.separator + "deployment.toml")); - serverConfigurationManager.restartGracefully(); } @Test(groups = { "wso2.am" }, description = "Test add shared scope") From e7de29d6964daf535c2d1b257288ed3bc57b8e06 Mon Sep 17 00:00:00 2001 From: BLasan Date: Fri, 16 Jun 2023 14:18:19 +0530 Subject: [PATCH 6/7] Rename: Scope test name --- ...TestWIthRestart.java => SharedScopeTestWithRestart.java} | 6 ++---- .../tests-backend/src/test/resources/testng.xml | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) rename modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/{SharedScopeTestWIthRestart.java => SharedScopeTestWithRestart.java} (96%) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWithRestart.java similarity index 96% rename from modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java rename to modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWithRestart.java index 19db70e091..8dfb2791f2 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWIthRestart.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWithRestart.java @@ -16,8 +16,6 @@ package org.wso2.am.integration.tests.other; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -35,7 +33,7 @@ import java.util.ArrayList; import java.util.List; -public class SharedScopeTestWIthRestart extends APIManagerLifecycleBaseTest { +public class SharedScopeTestWithRestart extends APIManagerLifecycleBaseTest { private String sharedScopeName = "TestSharedScopeWithRestart"; private String sharedScopeDisplayName = "Test Shared Scope with Restart"; @@ -48,7 +46,7 @@ public class SharedScopeTestWIthRestart extends APIManagerLifecycleBaseTest { private ServerConfigurationManager serverConfigurationManager; @Factory(dataProvider = "userModeDataProvider") - public SharedScopeTestWIthRestart(TestUserMode userMode) { + public SharedScopeTestWithRestart(TestUserMode userMode) { this.userMode = userMode; } 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 f70ea8e238..569410771f 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 @@ -201,7 +201,7 @@ - + From 84478cd031ababa67d0738c954cfef65dc15b0f1 Mon Sep 17 00:00:00 2001 From: BLasan Date: Mon, 3 Jul 2023 10:13:11 +0530 Subject: [PATCH 7/7] Add: Cleanup function in destroy function --- .../am/integration/tests/other/SharedScopeTestWithRestart.java | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWithRestart.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWithRestart.java index 8dfb2791f2..22c059377d 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWithRestart.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/SharedScopeTestWithRestart.java @@ -118,6 +118,7 @@ public void testDeleteSharedScope() throws Exception { @AfterClass(alwaysRun = true) public void destroy() throws Exception { + super.cleanUp(); serverConfigurationManager.restoreToLastConfiguration(); } }