Skip to content

Commit

Permalink
test: Fix a test failure
Browse files Browse the repository at this point in the history
JWT generator test needs the feature to be enabled. by default this is
not enabled.
  • Loading branch information
praminda committed Feb 23, 2021
1 parent 4d7826c commit 12bf289
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,26 @@
import org.wso2am.micro.gw.tests.common.BaseTestCase;
import org.wso2am.micro.gw.tests.common.model.API;
import org.wso2am.micro.gw.tests.common.model.ApplicationDTO;
import org.wso2am.micro.gw.tests.mockbackend.MockBackendServer;
import org.wso2am.micro.gw.tests.util.*;

import java.io.File;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;

/**
* Jwt generator test cases.
*/
public class jwtGeneratorTestCase extends BaseTestCase {
public class JwtGeneratorTestCase extends BaseTestCase {
private static String JWT_GENERATOR_ISSUER = "wso2.org/products/am";

protected String jwtTokenProd;

@BeforeClass(description = "initialise the setup")
void start() throws Exception {
super.startMGW();
String confPath = TestConstant.BASE_RESOURCE_DIR
+ File.separator + "jwtGenerator" + File.separator + "config.toml";
super.startMGW(confPath);

//deploy the api
//api yaml file should put to the resources/apis/openApis folder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package org.wso2am.micro.gw.tests.util;

import java.io.File;

/**
* Constants used in test cases.
*/
Expand Down Expand Up @@ -61,6 +63,9 @@ public class TestConstant {
public static final int ADAPTER_IMPORT_API_PORT = 9843;
public final static int MOCK_SERVER_PORT = 2383;


public static final String BASE_RESOURCE_DIR = "src" + File.separator + "test" + File.separator + "resources";

public static final int INVALID_CREDENTIALS_CODE = 900901;

public static final String LINE = "\r\n";
Expand Down
107 changes: 107 additions & 0 deletions test/test-integration/src/test/resources/jwtGenerator/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
[adapter]
# The configuration file for mgw
[adapter.server]
host = "0.0.0.0"
port = "9843"

[[adapter.server.users]]
username = "admin"
password = "admin"

[adapter.keystore]
certPath = "/home/wso2/security/keystore/mg.pem"
keyPath = "/home/wso2/security/keystore/mg.key"

[adapter.truststore]
location = "/home/wso2/security/truststore"

[adapter.consul]
# todo rumesh check whether we need to have certPath and KeyPath
enable = false
url = "https://169.254.1.1:8501" # scheme + host ip + port
pollInterval = 5 # seconds
aclTokenFilePath = ""
# certs for tls
caCertPath = "/home/wso2/security/truststore/consul/consul-agent-ca.pem"
certPath = "/home/wso2/security/truststore/consul/local-dc-client-consul-0.pem"
keyPath = "/home/wso2/security/truststore/consul/local-dc-client-consul-0-key.pem"

[envoy]
listenerHost = "0.0.0.0"
listenerPort = 9095
clusterTimeoutInSeconds = 20
listenerTLSEnabled = true

[envoy.keystore]
certPath = "/home/wso2/security/keystore/mg.pem"
keyPath = "/home/wso2/security/keystore/mg.key"

[envoy.upstream]
[envoy.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"
# the default endpoint certificates
trustedCertPath = "/etc/ssl/certs/ca-certificates.crt"
verifyHostName = true
disableSslVerification = false

[enforcer]
[enforcer.authService]
port = 8081
maxMessageSize = 1000000000
maxHeaderLimit = 8192
#keep alive time of the external authz connection
keepAliveTime = 600
[enforcer.authService.threadPool]
coreSize = 400
maxSize = 500
#keep alive time of threads in seconds
keepAliveTime = 600
queueSize = 1000

# JWT token authorization configurations. You can provide multiple JWT issuers
# Issuer 1
[[enforcer.jwtTokenConfig]]
name="Resident Key Manager"
issuer = "https://localhost:9443/oauth2/token"
certificateAlias = "wso2carbon"
# URL of the JWKs endpoint
jwksURL = ""
# Validate subscribed APIs
validateSubscription = false
# The claim in which the consumer key of the application is coming
consumerKeyClaim = "azp"
# Certificate Filepath within enforcer
certificateFilePath = "/home/wso2/security/truststore/wso2carbon.pem"

[enforcer.apimCredentials]
username="admin"
password="admin"

[enforcer.jwtGenerator]
enable = true
encoding = "base64" # base64,base64url
claimDialect = "http://wso2.org/claims"
convertDialect = false
header = "X-JWT-Assertion"
signingAlgorithm = "SHA256withRSA"
enableUserClaims = false
gatewayGeneratorImpl = "org.wso2.carbon.apimgt.common.gateway.jwtgenerator.APIMgtGatewayJWTGeneratorImpl"
claimsExtractorImpl = "org.wso2.carbon.apimgt.impl.token.ExtendedDefaultClaimsRetriever"
publicCertificatePath = "/home/wso2/security/truststore/mg.pem"
privateKeyPath = "/home/wso2/security/keystore/mg.key"

[controlPlane]
# Control plane's eventHub details
[controlPlane.eventHub]
enabled = false
serviceUrl = "https://localhost:9443/"
username="admin"
password="admin"
environmentLabels = ["Production and Sandbox"]
retryInterval = 5
skipSSLVerification=true
# Message broker connection URL of the control plane
[controlPlane.eventHub.jmsConnectionParameters]
eventListeningEndpoints = "amqp://admin:admin@localhost:5672/"
2 changes: 1 addition & 1 deletion test/test-integration/src/test/resources/testng.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<class name="org.wso2am.micro.gw.tests.apiDeploy.APiDeployTestCase"/>
<class name="org.wso2am.micro.gw.tests.security.CorsTestCase"/>
<class name="org.wso2am.micro.gw.tests.jwtValidator.ScopeTest"/>
<class name="org.wso2am.micro.gw.tests.jwtGenerator.jwtGeneratorTestCase"/>
<class name="org.wso2am.micro.gw.tests.jwtGenerator.JwtGeneratorTestCase"/>
<class name="org.wso2am.micro.gw.tests.backendtls.BackendTLSTestcase"/>
<class name="org.wso2am.micro.gw.tests.endpoints.ProductionSandboxTestCase"/>
</classes>
Expand Down

0 comments on commit 12bf289

Please sign in to comment.