From 81b38542b2573d92e3f4e220b44331e8a7777467 Mon Sep 17 00:00:00 2001 From: dinusha92 Date: Thu, 8 Apr 2021 21:27:18 +0530 Subject: [PATCH 1/2] Enabling default CORS + tweak configs to work with APIM. --- distribution/src/main/assembly/assembly.xml | 10 +++------- .../tests/testCaseBefore/MgwWithBackendTls.java | 9 +++++++-- .../src/test/resources/cors/cors-disabled-config.toml | 2 +- resources/conf/config-for-eventhub.toml | 4 ++-- resources/conf/config.toml | 4 ++-- resources/docker-compose/apim/conf/deployment.toml | 4 ++-- resources/k8s-artifacts/apim/apim-config.yaml | 8 ++++---- .../config-toml-configmap-for-eventhub.yaml | 4 ++-- 8 files changed, 23 insertions(+), 22 deletions(-) rename resources/docker-compose/apim/conf/config.toml => integration/test-integration/src/test/resources/cors/cors-disabled-config.toml (99%) diff --git a/distribution/src/main/assembly/assembly.xml b/distribution/src/main/assembly/assembly.xml index c15393b44f..d5967dc664 100644 --- a/distribution/src/main/assembly/assembly.xml +++ b/distribution/src/main/assembly/assembly.xml @@ -116,12 +116,7 @@ ../resources/docker-compose/apim/conf/deployment.toml choreo-connect-${project.version}/docker-compose/choreo-connect-with-apim/conf - - - ../resources/docker-compose/apim/conf/config.toml - choreo-connect-${project.version}/docker-compose/choreo-connect-with-apim/conf - - + testPreflightReqResourceWithoutCors ../resources/conf/log4j2.properties choreo-connect-${project.version}/docker-compose/choreo-connect/conf @@ -146,7 +141,8 @@ ../resources/conf/config-for-eventhub.toml - choreo-connect-${project.version}/docker-compose/choreo-connect/conf + choreo-connect-${project.version}/docker-compose/choreo-connect-with-apim/conf + config.toml diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/testCaseBefore/MgwWithBackendTls.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/testCaseBefore/MgwWithBackendTls.java index e9815b7183..922c8fac72 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/testCaseBefore/MgwWithBackendTls.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/testCaseBefore/MgwWithBackendTls.java @@ -17,6 +17,7 @@ */ package org.wso2.choreo.connect.tests.testCaseBefore; +import java.io.File; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.wso2.choreo.connect.tests.common.BaseTestCase; @@ -24,13 +25,17 @@ import org.wso2.choreo.connect.tests.util.ApictlUtils; import java.util.concurrent.TimeUnit; +import org.wso2.choreo.connect.tests.util.TestConstant; +import org.wso2.choreo.connect.tests.util.Utils; public class MgwWithBackendTls extends BaseTestCase { @BeforeTest(description = "initialise the setup") void start() throws Exception { - super.startMGW(null, true); - + String targetDir = Utils.getTargetDirPath(); + String confPath = targetDir + TestConstant.TEST_RESOURCES_PATH + File.separator + "cors" + File.separator + + "cors-disabled-config.toml"; + super.startMGW(confPath, true); ApictlUtils.createProject("backend_tsl_openAPI.yaml", "backend_tsl_petstore", "backend_tls.crt"); ApictlUtils.createProject( "cors_openAPI.yaml", "cors_petstore", null); diff --git a/resources/docker-compose/apim/conf/config.toml b/integration/test-integration/src/test/resources/cors/cors-disabled-config.toml similarity index 99% rename from resources/docker-compose/apim/conf/config.toml rename to integration/test-integration/src/test/resources/cors/cors-disabled-config.toml index 34544ee5a8..2d1442b454 100644 --- a/resources/docker-compose/apim/conf/config.toml +++ b/integration/test-integration/src/test/resources/cors/cors-disabled-config.toml @@ -55,7 +55,7 @@ allowCredentials = false [router.upstream.tls] minimumProtocolVersion = "TLS1_1" maximumProtocolVersion = "TLS1_2" - ciphers = "ECDHE-ECDSA-AES128-GCM-SHA256, ECDHE-RSA-AES128-GCM-SHA256, ECDHE-ECDSA-AES128-SHA, ECDHE-RSA-AES128-SHA, AES128-GCM-SHA256, AES128-SHA, ECDHE-ECDSA-AES256-GCM-SHA384, ECDHE-RSA-AES256-GCM-SHA384, ECDHE-ECDSA-AES256-SHA, ECDHE-RSA-AES256-SHA, AES256-GCM-SHA384, AES256-SHA" + ciphers = "ECDHE-ECDSA-AES128-GCM-SHA256, ECDHE-RSA-AES128-GCM-SHA256, ECDHE-ECDSA-AES128-SHA, ECDHE-RSA-AES128-SHA, AES128-GCM-SHA256, AES128-SHA, ECDHE-ECDSA-AES256-GCM-SHA384, ECDHE-RSA-AES256-GCM-SHA384, ECDHE-ECDSA-AES256-SHA, ECDHE-RSA-AES256-SHA, AES256-GCM-SHA384, AES256-SHA" # the default endpoint certificates trustedCertPath = "/etc/ssl/certs/ca-certificates.crt" verifyHostName = true diff --git a/resources/conf/config-for-eventhub.toml b/resources/conf/config-for-eventhub.toml index c900edf3b9..f7ba6a0e13 100644 --- a/resources/conf/config-for-eventhub.toml +++ b/resources/conf/config-for-eventhub.toml @@ -44,7 +44,7 @@ keyPath = "/home/wso2/security/keystore/mg.key" [router.cors] -enabled = false +enabled = true allowOrigins = ["*"] allowMethods = ["GET","PUT","POST","DELETE","PATCH","OPTIONS"] allowHeaders = ["authorization","Access-Control-Allow-Origin","Content-Type","SOAPAction","apikey", "testKey", "Internal-Key"] @@ -114,7 +114,7 @@ allowCredentials = false # Throttling configurations [enforcer.throttling] # Connect with the central traffic manager - enableGlobalEventPublishing = false + enableGlobalEventPublishing = true # Enable global advanced throttling based on request header conditions enableHeaderConditions = false # Enable global advanced throttling based on request query parameter conditions diff --git a/resources/conf/config.toml b/resources/conf/config.toml index ef0702463d..9e6297fd54 100644 --- a/resources/conf/config.toml +++ b/resources/conf/config.toml @@ -44,7 +44,7 @@ keyPath = "/home/wso2/security/keystore/mg.key" [router.cors] -enabled = false +enabled = true allowOrigins = ["*"] allowMethods = ["GET","PUT","POST","DELETE","PATCH","OPTIONS"] allowHeaders = ["authorization","Access-Control-Allow-Origin","Content-Type","SOAPAction","apikey", "testKey", "Internal-Key"] @@ -114,7 +114,7 @@ allowCredentials = false # Throttling configurations [enforcer.throttling] # Connect with the central traffic manager - enableGlobalEventPublishing = false + enableGlobalEventPublishing = true # Enable global advanced throttling based on request header conditions enableHeaderConditions = false # Enable global advanced throttling based on request query parameter conditions diff --git a/resources/docker-compose/apim/conf/deployment.toml b/resources/docker-compose/apim/conf/deployment.toml index bc2864218d..316d473a8c 100644 --- a/resources/docker-compose/apim/conf/deployment.toml +++ b/resources/docker-compose/apim/conf/deployment.toml @@ -129,8 +129,8 @@ service_url = "https://apim:${mgt.transport.https.port}/services/" #enable_token_encryption = false #enable_token_hashing = false -#[apim.devportal] -#url = "https://localhost:${mgt.transport.https.port}/devportal" +[apim.devportal] +url = "https://apim:${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 diff --git a/resources/k8s-artifacts/apim/apim-config.yaml b/resources/k8s-artifacts/apim/apim-config.yaml index 75ac9ea6dc..1241f6ce82 100644 --- a/resources/k8s-artifacts/apim/apim-config.yaml +++ b/resources/k8s-artifacts/apim/apim-config.yaml @@ -79,8 +79,8 @@ data: password= "${admin.password}" ws_endpoint = "ws://localhost:9099" wss_endpoint = "wss://localhost:8099" - http_endpoint = "http://localhost:${http.nio.port}" - https_endpoint = "https://localhost:${https.nio.port}" + http_endpoint = "http://gw.wso2.com:30201" + https_endpoint = "https://gw.wso2.com:30201" #[apim.cache.gateway_token] #enable = true @@ -149,8 +149,8 @@ data: #enable_token_encryption = false #enable_token_hashing = false - #[apim.devportal] - #url = "https://localhost:${mgt.transport.https.port}/devportal" + [apim.devportal] + url = "https://wso2apim:32001/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 diff --git a/resources/k8s-artifacts/choreo-connect/config-toml-configmap-for-eventhub.yaml b/resources/k8s-artifacts/choreo-connect/config-toml-configmap-for-eventhub.yaml index 9db524fe9f..d8e21a781c 100644 --- a/resources/k8s-artifacts/choreo-connect/config-toml-configmap-for-eventhub.yaml +++ b/resources/k8s-artifacts/choreo-connect/config-toml-configmap-for-eventhub.yaml @@ -67,7 +67,7 @@ data: keyPath = "/home/wso2/security/keystore/mg.key" [router.cors] - enabled = false + enabled = true allowOrigins = ["*"] allowMethods = ["GET","PUT","POST","DELETE","PATCH","OPTIONS"] allowHeaders = ["authorization","Access-Control-Allow-Origin","Content-Type","SOAPAction","apikey", "testKey", "Internal-Key"] @@ -147,7 +147,7 @@ data: # The message broker context factory jmsConnectionInitialContextFactory = "org.wso2.andes.jndi.PropertiesFileInitialContextFactory" # The message broker connection URL - jmsConnectionProviderUrl = "amqp://admin:admin@carbon/carbon?brokerlist='tcp://localhost:5672'" + jmsConnectionProviderUrl = "amqp://admin:admin@carbon/carbon?brokerlist='tcp://wso2apim:5672'" # Throttling configurations related to event publishing using a binary connection [enforcer.throttling.publisher] # Credentials required to establish connection between Traffic Manager From bd37f82837c9019cb96b9159a22ed47517470894 Mon Sep 17 00:00:00 2001 From: dinusha92 Date: Thu, 8 Apr 2021 22:42:58 +0530 Subject: [PATCH 2/2] Fixing a typo issue. --- distribution/src/main/assembly/assembly.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distribution/src/main/assembly/assembly.xml b/distribution/src/main/assembly/assembly.xml index d5967dc664..4d8d2b08b2 100644 --- a/distribution/src/main/assembly/assembly.xml +++ b/distribution/src/main/assembly/assembly.xml @@ -116,7 +116,7 @@ ../resources/docker-compose/apim/conf/deployment.toml choreo-connect-${project.version}/docker-compose/choreo-connect-with-apim/conf - testPreflightReqResourceWithoutCors + ../resources/conf/log4j2.properties choreo-connect-${project.version}/docker-compose/choreo-connect/conf