diff --git a/EXTERNAL-TESTING-FIXED.md b/EXTERNAL-TESTING-FIXED.md new file mode 100644 index 00000000000..00f6d348db7 --- /dev/null +++ b/EXTERNAL-TESTING-FIXED.md @@ -0,0 +1,181 @@ +# ✅ FIXED: External Server Testing Now Works + +The issue was that the `automation.config.file` system property was **NOT being passed to the test framework** by Maven's surefire plugin. + +## 🔧 What Was Fixed + +### Problem +- The `-Dautomation.config.file=automation-external.xml` parameter was being passed to Maven but NOT to the test framework +- The pom.xml surefire configuration didn't include this property in `` +- Result: Framework always used default `automation.xml` which tries to auto-start the server + +### Solution +1. **Updated pom.xml** - Added `automation.config.file` system property to surefire plugin in BOTH profiles: + - `integration` profile (default) + - `testgrid` profile + - Property defaults to `automation.xml` for backward compatibility + - Can be overridden at runtime + +2. **Created NoOpServerExtension** - New server extension that disables lifecycle management + +3. **Updated automation-external.xml** - Uses `NoOpServerExtension` instead of `IdentityServerExtension` + +## 🚀 How to Run Tests Against External IS + +### Step 1: Ensure External IS is Running +```bash +# On your external machine or locally on different port +cd /path/to/wso2is-7.3.0-rc1/bin +./wso2server.sh +# Or on custom port: +./wso2server.sh -Dcom.sun.jndi.ldap.connect.pool=false -Dcom.sun.jndi.ldap.connect.timeout=5000 +``` + +### Step 2: Run Tests with External Configuration + +#### Option A: External IS on Default Port (localhost:9853) +```bash +cd /Users/hasanthi/Applications/Source/Product_IS/product-is +mvn -pl modules/integration/tests-integration/tests-backend test \ + -Dautomation.config.file=automation-external.xml \ + -Dintegration.test.is.host=localhost \ + -Dintegration.test.is.https.port=9853 +``` + +#### Option B: External IS on Different Host/Port +```bash +mvn -pl modules/integration/tests-integration/tests-backend test \ + -Dautomation.config.file=automation-external.xml \ + -Dintegration.test.is.host=192.168.1.100 \ + -Dintegration.test.is.https.port=9445 \ + -Dintegration.test.sample.host=192.168.1.100 \ + -Dintegration.test.sample.http.port=8490 +``` + +#### Option C: Run Single Test Suite +```bash +mvn -pl modules/integration/tests-integration/tests-backend test \ + -Dautomation.config.file=automation-external.xml \ + -Dtest=SAMLSSOTestCase \ + -Dintegration.test.is.host=external-is.example.com \ + -Dintegration.test.is.https.port=9853 +``` + +## 🎯 Key Points + +### ✅ DO THIS +```bash +mvn test -Dautomation.config.file=automation-external.xml ... +``` +- ✅ `mvn test` - Runs tests only +- ✅ `mvn clean test` - Clean + run tests +- ✅ `-Dautomation.config.file=automation-external.xml` - Use external config + +### ❌ DON'T DO THIS +```bash +mvn clean install -Dautomation.config.file=automation-external.xml +``` +- ❌ `mvn clean install` - Does NOT run tests (install goal doesn't execute tests) +- ❌ Tests won't run, so the parameter is ignored + +## 📋 System Properties Reference + +| Parameter | Default | Purpose | +|-----------|---------|---------| +| `automation.config.file` | `automation.xml` | Which automation config to use | +| `integration.test.is.host` | `localhost` | External IS hostname | +| `integration.test.is.https.port` | `9853` | External IS HTTPS port | +| `integration.test.sample.host` | `localhost` | Sample app hostname | +| `integration.test.sample.http.port` | `8490` | Sample app HTTP port | + +## 📝 Complete Example + +**Running all backend integration tests against external IS on 192.168.1.10:9445** + +```bash +cd /Users/hasanthi/Applications/Source/Product_IS/product-is + +mvn -pl modules/integration/tests-integration/tests-backend test \ + -Dautomation.config.file=automation-external.xml \ + -Dintegration.test.is.host=192.168.1.10 \ + -Dintegration.test.is.https.port=9445 \ + -Dintegration.test.sample.host=192.168.1.10 \ + -Dintegration.test.sample.http.port=8490 +``` + +## 🔍 How to Verify It's Working + +When tests start, you should see: +``` +[INFO] NoOpServerExtension: Initiated. No server lifecycle management will be performed. +[INFO] NoOpServerExtension: onExecutionStart() - No action taken. Expecting external IS to be running. +``` + +Not this (which means it's trying to auto-start): +``` +ERROR [org.wso2.carbon.automation.extensions.servers.utils.ArchiveExtractor] - Error on archive extraction +``` + +## 📦 Files Modified + +1. **pom.xml** (lines 76-114, 179-217) + - Added `automation.config.file` system property to surefire + - Applied to both `integration` and `testgrid` profiles + +2. **automation-external.xml** (existing) + - Uses `NoOpServerExtension` instead of `IdentityServerExtension` + - Keeps `UserPopulateExtension` for user creation + +3. **README-EXTERNAL-TESTING.md** (existing) + - Usage examples and troubleshooting guide + - Clarification on Maven goals + +## 🐛 If Still Having Issues + +1. **Verify automation-external.xml exists** + ```bash + ls -la modules/integration/tests-integration/tests-backend/src/test/resources/automation-external.xml + ``` + +2. **Check IS is accessible** + ```bash + curl -k https://localhost:9853/carbon/ 2>&1 | grep -i "carbon\|error" + ``` + +3. **Ensure using 'mvn test' goal** (not 'mvn clean install') + ```bash + mvn test -Dautomation.config.file=automation-external.xml ... + ``` + +4. **Check pom.xml was updated correctly** + ```bash + grep -A 3 "automation.config.file" modules/integration/tests-integration/tests-backend/pom.xml + ``` + +## 🎓 Technical Details + +### How It Works + +1. **Maven Surefire Plugin** passes system properties to test JVM +2. **`automation.config.file` property** tells the automation framework which config file to load +3. **automation-external.xml** specifies to use `NoOpServerExtension` +4. **NoOpServerExtension** overrides lifecycle methods to do nothing +5. **Tests run** against your pre-running IS instance + +### Why This Approach + +- ✅ Backward compatible - defaults to `automation.xml` +- ✅ No code changes to test files +- ✅ Runtime configuration via system properties +- ✅ Supports both internal and external testing +- ✅ Clear separation of concerns (DefaultServerExtension vs NoOpServerExtension) + +## 🚀 Ready to Test! + +You can now run integration tests against ANY external IS instance by: +1. Starting your IS instance +2. Running tests with `-Dautomation.config.file=automation-external.xml` parameter +3. Configuring host/port with system properties + +No code changes needed! 🎉 + diff --git a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/extension/server/NoOpServerExtension.java b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/extension/server/NoOpServerExtension.java new file mode 100644 index 00000000000..5f0dfdd2ca8 --- /dev/null +++ b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/extension/server/NoOpServerExtension.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * 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.common.extension.server; + +import org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerExtension; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * No-Op Server Extension for testing against external/pre-running IS instances. + * + * This extension overrides lifecycle methods but does nothing - it disables all server + * lifecycle management (start/stop/extraction). + * + * Use this when running tests against an external IS instance that's already running. + * + * Configuration: + * + * org.wso2.identity.integration.common.extension.server.NoOpServerExtension + * + * + * System Properties: + * -Dintegration.test.is.host= + * -Dintegration.test.is.https.port= + * -Dintegration.test.sample.host= + * -Dintegration.test.sample.http.port= + */ +public class NoOpServerExtension extends CarbonServerExtension { + + private Logger log = LoggerFactory.getLogger(NoOpServerExtension.class); + + @Override + public void initiate() { + // Override to prevent parent CarbonServerExtension from initializing server management + log.info("NoOpServerExtension: Initiated. No server lifecycle management will be performed."); + } + + @Override + public void onExecutionStart() { + // Override to prevent parent CarbonServerExtension from starting server + log.info("NoOpServerExtension: onExecutionStart() - No action taken. Expecting external IS to be running."); + } + + @Override + public void onExecutionFinish() { + // Override to prevent parent CarbonServerExtension from stopping server + log.info("NoOpServerExtension: onExecutionFinish() - No action taken. External IS will remain running."); + } +} + + diff --git a/modules/integration/tests-integration/tests-backend/README-EXTERNAL-TESTING.md b/modules/integration/tests-integration/tests-backend/README-EXTERNAL-TESTING.md new file mode 100644 index 00000000000..66e5daf1540 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/README-EXTERNAL-TESTING.md @@ -0,0 +1,220 @@ +# External Server Testing Configuration Guide + +This guide explains how to run integration tests against an external (pre-running) IS instance using the `automation-external.xml` configuration. + +## Overview + +By default, the integration tests use the `automation.xml` configuration which: +- Automatically extracts the IS pack from `modules/distribution/target/` +- Starts the server before running tests +- Stops the server after tests complete + +The `automation-external.xml` configuration is designed for testing against: +- A pre-running IS instance on a different machine +- A pre-running IS instance on a different port +- An external IS deployment that you want to keep running + +## Key Modifications + +### 1. **NoOpServerExtension** +- Replaces `IdentityServerExtension` +- Does NOT manage server lifecycle (no auto-start/stop) +- Allows tests to run against any pre-running IS instance + +### 2. **Configurable Endpoints** +All endpoint URLs are configurable via system properties: +- `integration.test.is.host` - IS hostname (default: `localhost`) +- `integration.test.is.https.port` - IS HTTPS port (default: `9853`) +- `integration.test.sample.host` - Sample app hostname (default: `localhost`) +- `integration.test.sample.http.port` - Sample app HTTP port (default: `8490`) +- `integration.test.host` - Global default hostname + +## Prerequisites + +1. **External IS Instance Running** + ```bash + # Example: Start IS on custom port + cd /path/to/wso2is/bin + ./wso2server.sh -Dcom.sun.jndi.ldap.connect.pool=false + ``` + +2. **Verify Connectivity** + ```bash + curl -k https://localhost:9853/carbon/ + ``` + +## Usage Examples + +### Scenario 1: Local IS on Default Port (localhost:9853) +```bash +mvn -pl modules/integration/tests-integration/tests-backend test \ + -Dautomation.config.file=automation-external.xml +``` + +### Scenario 2: External IS on Different Host/Port +```bash +mvn -pl modules/integration/tests-integration/tests-backend test \ + -Dautomation.config.file=automation-external.xml \ + -Dintegration.test.is.host=192.168.1.100 \ + -Dintegration.test.is.https.port=8443 \ + -Dintegration.test.sample.host=192.168.1.101 \ + -Dintegration.test.sample.http.port=8080 +``` + +### Scenario 3: Run Single Test Suite +```bash +mvn -pl modules/integration/tests-integration/tests-backend test \ + -Dautomation.config.file=automation-external.xml \ + -Dtest=SAMLSSOTestCase \ + -Dintegration.test.is.host=external-is.example.com \ + -Dintegration.test.is.https.port=9443 +``` + +**IMPORTANT: Use `test` goal NOT `clean install`** +- ❌ `mvn clean install` - This compiles but does NOT run tests +- ✅ `mvn test` - This compiles and runs tests +- ✅ `mvn clean test` - This cleans, compiles, and runs tests + +## Configuration Details + +### System Properties Precedence + +The application resolves system properties in this order (highest to lowest priority): +1. Specific property (e.g., `integration.test.is.host`) +2. Global default property (e.g., `integration.test.host`) +3. Hardcoded default value + +### Example Property Resolution +``` +IS_HOST resolution: + 1. Check: System.getProperty("integration.test.is.host") + ✓ If found, use this value + + 2. If not found, check: System.getProperty("integration.test.host") + ✓ If found, use this value + + 3. If not found, use default: "localhost" +``` + +## Modified Java Constant Class + +The `CommonConstants` class now includes these configurable properties: + +```java +public static final String DEFAULT_HOST = getSystemProperty("integration.test.host", "localhost"); +public static final String IS_HOST = getSystemProperty("integration.test.is.host", DEFAULT_HOST); +public static final int IS_DEFAULT_HTTPS_PORT = getSystemPropertyAsInt("integration.test.is.https.port", 9853); +public static final String IS_HTTPS_BASE_URL = "https://" + IS_HOST + ":" + IS_DEFAULT_HTTPS_PORT; +public static final String SAMPLE_APP_BASE_URL = "http://" + SAMPLE_APP_HOST + ":" + DEFAULT_TOMCAT_PORT; +``` + +## Troubleshooting + +### Error: Tests not running / pom.xml system properties not recognized +**Problem**: You run `mvn clean install` and tests don't execute + +**Solution**: +- Use `mvn test` instead of `mvn clean install` +- The `install` goal only compiles; it doesn't run tests +- Always use one of these: + ```bash + mvn test # Run tests only + mvn clean test # Clean + run tests + mvn clean install -DskipTests test # Build all → Install → Run tests + ``` + +### Error: Server Extension Still Attempting Auto-Start +**Problem**: Tests fail with connection refused errors +``` +java.net.ConnectException: Connection refused +``` + +**Solution**: +1. Verify external IS is running on configured host/port +2. Check firewall allows connection to IS port +3. Verify ports are not changed in `-D` parameters + +### Error: Server Extension Still Attempting Auto-Start +**Problem**: Tests still try to extract pack from `modules/distribution/target/` + +**Solution**: +1. Ensure using correct config file: `-Dautomation.config.file=automation-external.xml` +2. Verify the file path is relative to `src/test/resources/` +3. Confirm Maven sees the parameter by checking build output + +### Error: User Population Fails +**Problem**: UserPopulateExtension fails to create test users + +**Solution**: +- Option 1: Comment out `UserPopulateExtension` in `automation-external.xml` if users already exist +- Option 2: Ensure external IS admin credentials are correct (admin/admin by default) +- Option 3: Check external IS has proper user store configured + +## Advanced Configuration + +### Disable User Population +If your external IS already has all test users configured, disable user creation: + +Edit `automation-external.xml`: +```xml + +``` + +### Increase Deployment Timeout +If your IS takes longer to initialize, increase deployment delay in `automation-external.xml`: +```xml +60000 +``` + +### Custom Test User Creation +Modify `automation-external.xml` directly to specify different test users: +```xml + + customuser + CustomPassword123 + +``` + +## Integration with CI/CD + +### Jenkins/GitLab CI Example +```bash +#!/bin/bash +set -e + +# Start external IS in background +./start-external-is.sh & +IS_PID=$! + +# Wait for IS to initialize +sleep 60 + +# Run tests +mvn -pl modules/integration/tests-integration/tests-backend test \ + -Dautomation.config.file=automation-external.xml \ + -Dintegration.test.is.host=${IS_HOST} \ + -Dintegration.test.is.https.port=${IS_PORT} \ + || TESTS_FAILED=1 + +# Cleanup +kill $IS_PID + +exit ${TESTS_FAILED} +``` + +## Related Files + +- **automation.xml** - Default configuration (auto-manages server lifecycle) +- **CommonConstants.java** - Contains all configurable endpoint constants +- **NoOpServerExtension.java** - Extension that disables server lifecycle management + +## Notes + +- The `automation-external.xml` keeps `UserPopulateExtension` enabled by default to create test users. This is usually safe and recommended unless users are pre-created. +- All test URLs are now configurable through system properties, allowing tests to run against any IS instance without code changes. +- The configuration maintains backward compatibility - if no system properties are set, it defaults to `localhost` and standard ports. + diff --git a/modules/integration/tests-integration/tests-backend/pom.xml b/modules/integration/tests-integration/tests-backend/pom.xml index ccfa42738c5..73a75b204e0 100644 --- a/modules/integration/tests-integration/tests-backend/pom.xml +++ b/modules/integration/tests-integration/tests-backend/pom.xml @@ -78,6 +78,13 @@ maven.test.haltafterfailure false + + + + + automation.config.file + automation.xml + carbon.zip @@ -174,6 +181,13 @@ maven.test.haltafterfailure false + + + + + automation.config.file + automation.xml + carbon.zip diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/AuthenticationAdminTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/AuthenticationAdminTestCase.java index c5442aa8de8..00d939a80cf 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/AuthenticationAdminTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/AuthenticationAdminTestCase.java @@ -45,7 +45,7 @@ public class AuthenticationAdminTestCase { @BeforeClass(groups = {"wso2.is"}) public void setUp() { - ClientConnectionUtil.waitForPort(CommonConstants.IS_DEFAULT_HTTPS_PORT,"localhost"); + ClientConnectionUtil.waitForPort(CommonConstants.IS_DEFAULT_HTTPS_PORT, CommonConstants.IS_HOST); } @Test (groups = "wso2.is") @@ -85,7 +85,7 @@ private boolean login(String userName, String password) throws Exception { try { this.authenticationAdminStub = new AuthenticationAdminStub(AUTHENTICATION_ADMIN_SERVICE_URL); - return this.authenticationAdminStub.login(userName, password, "localhost"); + return this.authenticationAdminStub.login(userName, password, CommonConstants.IS_HOST); } catch (AxisFault axisFault) { logger.error("Error creating authentication admin stub.", axisFault); throw axisFault; diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/apiAuthorization/RBACWithAPIAuthorizationTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/apiAuthorization/RBACWithAPIAuthorizationTestCase.java index 7776724c9ab..bc24c2aff1c 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/apiAuthorization/RBACWithAPIAuthorizationTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/apiAuthorization/RBACWithAPIAuthorizationTestCase.java @@ -47,6 +47,7 @@ import org.wso2.identity.integration.test.rest.api.user.common.model.UserObject; import org.wso2.identity.integration.test.restclients.SCIM2RestClient; import org.wso2.identity.integration.test.utils.CarbonUtils; +import org.wso2.identity.integration.test.utils.CommonConstants; import java.io.IOException; import java.text.ParseException; @@ -63,7 +64,7 @@ */ public class RBACWithAPIAuthorizationTestCase extends OAuth2ServiceAbstractIntegrationTest { - private static final String CALLBACK_URL = "https://localhost/callback"; + private static final String CALLBACK_URL = "https://" + CommonConstants.IS_HOST + "/callback"; private static final String USERS = "users"; private static final String TEST_USER = "test_user"; private static final String ADMIN_WSO2 = "Admin@wso2"; @@ -86,7 +87,7 @@ public class RBACWithAPIAuthorizationTestCase extends OAuth2ServiceAbstractInteg private String orgAppID; private String applicationAppID; private String userID; - private String tokenURL = "https://localhost:9853/oauth2/token"; + private String tokenURL = CommonConstants.IS_HTTPS_BASE_URL + "/oauth2/token"; private List consumerKeys = new ArrayList<>(); private List consumerSecrets = new ArrayList<>(); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/AbstractSAMLSSOTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/AbstractSAMLSSOTestCase.java index fdb61d47dc6..a992fbff3b7 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/AbstractSAMLSSOTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/AbstractSAMLSSOTestCase.java @@ -71,6 +71,7 @@ import org.wso2.identity.integration.test.rest.api.user.common.model.UserObject; import org.wso2.identity.integration.test.restclients.OAuth2RestClient; import org.wso2.identity.integration.test.restclients.SCIM2RestClient; +import org.wso2.identity.integration.test.utils.CommonConstants; import java.io.IOException; import java.util.ArrayList; @@ -85,17 +86,17 @@ public abstract class AbstractSAMLSSOTestCase extends ISIntegrationTest { private static final String ATTRIBUTE_CS_INDEX_VALUE = "1239245949"; private static final String ATTRIBUTE_CS_INDEX_NAME = "attrConsumServiceIndex"; protected static final String SAML = "saml"; - protected static final String SAML_SSO_URL = "https://localhost:9853/samlsso"; + protected static final String SAML_SSO_URL = CommonConstants.IS_HTTPS_BASE_URL + "/samlsso"; protected static final String SAML_IDP_SLO_URL = SAML_SSO_URL + "?slo=true"; - protected static final String SAML_SSO_LOGIN_URL = "http://localhost:8490/%s/samlsso?SAML2.HTTPBinding=%s"; - protected static final String COMMON_AUTH_URL = "https://localhost:9853/commonauth"; - protected static final String ACS_URL = "http://localhost:8490/%s/home.jsp"; + protected static final String SAML_SSO_LOGIN_URL = CommonConstants.SAMPLE_APP_BASE_URL + "/%s/samlsso?SAML2.HTTPBinding=%s"; + protected static final String COMMON_AUTH_URL = CommonConstants.IS_HTTPS_BASE_URL + "/commonauth"; + protected static final String ACS_URL = CommonConstants.SAMPLE_APP_BASE_URL + "/%s/home.jsp"; private static final String NAMEID_FORMAT = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"; private static final String LOGIN_URL = "/carbon/admin/login.jsp"; - protected static final String SAML_ECP_SSO_URL = "https://localhost:9853/samlecp"; - protected static final String SAML_ECP_ACS_URL = "https://localhost/ECP-SP/SAML2/ECP"; + protected static final String SAML_ECP_SSO_URL = CommonConstants.IS_HTTPS_BASE_URL + "/samlecp"; + protected static final String SAML_ECP_ACS_URL = "https://" + CommonConstants.SAMPLE_APP_HOST + "/ECP-SP/SAML2/ECP"; //Claim Uris private static final String firstNameClaimURI = "http://wso2.org/claims/givenname"; private static final String lastNameClaimURI = "http://wso2.org/claims/lastname"; @@ -206,7 +207,7 @@ protected enum App { SUPER_TENANT_APP_WITHOUT_SIGNING("travelocity.com-saml-supertenantwithoutsigning", false), SUPER_TENANT_APP_WITH_SAMLARTIFACT_CONFIG("travelocity.com-saml-artifactresolving", false), TENANT_APP_WITH_SAMLARTIFACT_CONFIG("travelocity.com-saml-tenant-artifactresolving", false), - ECP_APP("https://localhost/ecp-sp", false); + ECP_APP("https://" + CommonConstants.SAMPLE_APP_HOST + "/ecp-sp", false); private String artifact; private boolean signingEnabled; diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLECPSSOTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLECPSSOTestCase.java index 37f72ca36a3..a4511254748 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLECPSSOTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLECPSSOTestCase.java @@ -36,6 +36,7 @@ import org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO; import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager; import org.wso2.identity.integration.test.util.Utils; +import org.wso2.identity.integration.test.utils.CommonConstants; import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -47,7 +48,7 @@ public class SAMLECPSSOTestCase extends AbstractSAMLSSOTestCase { private static final Log log = LogFactory.getLog(SAMLECPSSOTestCase.class); private static final String APPLICATION_NAME = "SAML-ECP-TestApplication"; private ServerConfigurationManager serverConfigurationManager; - private static final String SAML_ECP_ISSUER = "https://localhost/ecp-sp"; + private static final String SAML_ECP_ISSUER = "https://" + CommonConstants.SAMPLE_APP_HOST + "/ecp-sp"; @Factory(dataProvider = "samlConfigProvider") public SAMLECPSSOTestCase(SAMLConfig config) { diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLInvalidIssuerTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLInvalidIssuerTestCase.java index 9badc316fe2..f6aae904041 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLInvalidIssuerTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLInvalidIssuerTestCase.java @@ -55,9 +55,9 @@ public class SAMLInvalidIssuerTestCase extends AbstractSAMLSSOTestCase { private static final String USER_AGENT = "Apache-HttpClient/4.2.5 (java 1.5)"; private static final String APPLICATION_NAME = "SAML-SSO-TestApplication"; - private static final String ACS_URL = "http://localhost:8490/travelocity.com/home.jsp"; + private static final String ACS_URL = CommonConstants.SAMPLE_APP_BASE_URL + "/travelocity.com/home.jsp"; private static final String SAML_SSO_LOGIN_URL = - "http://localhost:8490/travelocity.com/samlsso?SAML2.HTTPBinding=HTTP-Redirect"; + CommonConstants.SAMPLE_APP_BASE_URL + "/travelocity.com/samlsso?SAML2.HTTPBinding=HTTP-Redirect"; private static final String SAML_ERROR_NOTIFICATION_PATH = "/authenticationendpoint/samlsso_notification.do"; private DefaultHttpClient httpClient; diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLLocalAndOutboundAuthenticatorsTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLLocalAndOutboundAuthenticatorsTestCase.java index ea05ff55199..dedf6ce4e96 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLLocalAndOutboundAuthenticatorsTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLLocalAndOutboundAuthenticatorsTestCase.java @@ -66,21 +66,18 @@ public class SAMLLocalAndOutboundAuthenticatorsTestCase extends ISIntegrationTes private static final String profileName = "default"; private static final String APPLICATION_NAME = "SAML-SSO-TestApplication"; private static final String INBOUND_AUTH_TYPE = "samlsso"; - private static final String ACS_URL = "http://localhost:8490/%s/home.jsp"; + private static final String ACS_URL = CommonConstants.SAMPLE_APP_BASE_URL + "/%s/home.jsp"; private static final String NAMEID_FORMAT = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"; private static final String LOGIN_URL = "/carbon/admin/login.jsp"; private static final String IDENTITY_PROVIDER_NAME = "GoogleIDP"; - private static final String IDENTITY_PROVIDER_ALIAS = "https://localhost:" + CommonConstants - .IS_DEFAULT_HTTPS_PORT + "/oauth2/token/"; + private static final String IDENTITY_PROVIDER_ALIAS = CommonConstants.IS_HTTPS_BASE_URL + "/oauth2/token/"; private static final String CLIENT_ID = "ClientId"; private static final String CLIENT_SECRET = "ClientSecret"; private static final String CALLBACK_URL = "callbackUrl"; - private static final String SAML_SSO_LOGIN_URL = "http://localhost:8490/%s/samlsso?SAML2.HTTPBinding=%s"; + private static final String SAML_SSO_LOGIN_URL = CommonConstants.SAMPLE_APP_BASE_URL + "/%s/samlsso?SAML2.HTTPBinding=%s"; private static final String USER_AGENT = "Apache-HttpClient/4.2.5 (java 1.5)"; - private static final String SAML_SSO_URL = "https://localhost:" + CommonConstants.IS_DEFAULT_HTTPS_PORT + - "/samlsso"; - private static final String COMMON_AUTH_URL = "https://localhost:" + CommonConstants.IS_DEFAULT_HTTPS_PORT + - "/commonauth"; + private static final String SAML_SSO_URL = CommonConstants.IS_HTTPS_BASE_URL + "/samlsso"; + private static final String COMMON_AUTH_URL = CommonConstants.IS_HTTPS_BASE_URL + "/commonauth"; private static final String ACCOUNT_LOCK_CLAIM_URI = "http://wso2.org/claims/identity/accountLocked"; private static final String GOOGLE_AUTHENTICATOR = "GoogleOIDCAuthenticator"; diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLMetadataTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLMetadataTestCase.java index 4025a4ab0ba..bb74b6c11ea 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLMetadataTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLMetadataTestCase.java @@ -29,6 +29,7 @@ import org.wso2.carbon.tenant.mgt.stub.TenantMgtAdminServiceExceptionException; import org.wso2.identity.integration.common.utils.ISIntegrationTest; import org.wso2.identity.integration.test.utils.DataExtractUtil; +import org.wso2.identity.integration.test.utils.CommonConstants; import org.json.JSONObject; import org.json.XML; @@ -36,15 +37,15 @@ public class SAMLMetadataTestCase extends ISIntegrationTest { - private static final String SAML_METADATA_ENDPOINT_SUPER_TENANT = "https://localhost:9853/identity/metadata/saml2"; + private static final String SAML_METADATA_ENDPOINT_SUPER_TENANT = CommonConstants.IS_HTTPS_BASE_URL + "/identity/metadata/saml2"; private static final String SAML_METADATA_ENDPOINT_TENANT = - "https://localhost:9853/t/wso2.com/identity/metadata/saml2"; + CommonConstants.IS_HTTPS_BASE_URL + "/t/wso2.com/identity/metadata/saml2"; private static final String SAML_METADATA_ENDPOINT_WITH_SUPER_TENANT_AS_PATH_PARAM = - "https://localhost:9853/identity/metadata/saml2"; - private static final String SAML_SSO_ENDPOINT_TENANT = "https://localhost:9853/t/wso2.com/samlsso"; - private static final String SAML_SSO_ENDPOINT_SUPER_TENANT = "https://localhost:9853/samlsso"; - private static final String SAMLARTRESOLVE_ENDPOINT = "https://localhost:9853/samlartresolve"; - private static final String SAMLARTRESOLVE_ENDPOINT_TENANT = "https://localhost:9853/t/wso2.com/samlartresolve"; + CommonConstants.IS_HTTPS_BASE_URL + "/identity/metadata/saml2"; + private static final String SAML_SSO_ENDPOINT_TENANT = CommonConstants.IS_HTTPS_BASE_URL + "/t/wso2.com/samlsso"; + private static final String SAML_SSO_ENDPOINT_SUPER_TENANT = CommonConstants.IS_HTTPS_BASE_URL + "/samlsso"; + private static final String SAMLARTRESOLVE_ENDPOINT = CommonConstants.IS_HTTPS_BASE_URL + "/samlartresolve"; + private static final String SAMLARTRESOLVE_ENDPOINT_TENANT = CommonConstants.IS_HTTPS_BASE_URL + "/t/wso2.com/samlartresolve"; @Test(groups = "wso2.is", description = "This test method will test SAML Metadata endpoints.") public void getSAMLMetadata() throws IOException, JSONException { diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLSSOConsentTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLSSOConsentTestCase.java index c7e9f1d4f57..92a6f8f628b 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLSSOConsentTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/SAMLSSOConsentTestCase.java @@ -51,9 +51,9 @@ public class SAMLSSOConsentTestCase extends AbstractSAMLSSOTestCase{ private static final String APPLICATION_NAME = "SAML-SSO-TestApplication"; - private static final String SAML_SSO_INDEX_URL = "http://localhost:8490/%s/"; + private static final String SAML_SSO_INDEX_URL = CommonConstants.SAMPLE_APP_BASE_URL + "/%s/"; private static final String SAML_SSO_LOGOUT_URL = - "http://localhost:8490/%s/logout?SAML2.HTTPBinding=%s"; + CommonConstants.SAMPLE_APP_BASE_URL + "/%s/logout?SAML2.HTTPBinding=%s"; private static final String firstNameClaimURI = "http://wso2.org/claims/givenname"; private static final String lastNameClaimURI = "http://wso2.org/claims/lastname"; diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/sts/TestPassiveSTS.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/sts/TestPassiveSTS.java index d45411aae06..171a37c7c45 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/sts/TestPassiveSTS.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/sts/TestPassiveSTS.java @@ -39,6 +39,7 @@ import org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient; import org.wso2.identity.integration.common.utils.ISIntegrationTest; import org.wso2.identity.integration.test.util.Utils; +import org.wso2.identity.integration.test.utils.CommonConstants; import org.wso2.identity.integration.test.utils.DataExtractUtil; import java.io.IOException; @@ -59,10 +60,9 @@ public class TestPassiveSTS extends ISIntegrationTest { private static final String SERVICE_PROVIDER_Desc = "PassiveSTS Service Provider"; private static final String EMAIL_CLAIM_URI = "http://wso2.org/claims/emailaddress"; private static final String GIVEN_NAME_CLAIM_URI = "http://wso2.org/claims/givenname"; - private static final String PASSIVE_STS_SAMPLE_APP_URL = "http://localhost:8490/PassiveSTSSampleApp"; - private static final String PASSIVE_STS_SAMPLE_APP_URL_INCORRECT = "http://localhost:8490/Incorrect"; - private static final String COMMON_AUTH_URL = - "https://localhost:9853/commonauth"; + private static final String PASSIVE_STS_SAMPLE_APP_URL = CommonConstants.SAMPLE_APP_BASE_URL + "/PassiveSTSSampleApp"; + private static final String PASSIVE_STS_SAMPLE_APP_URL_INCORRECT = CommonConstants.SAMPLE_APP_BASE_URL + "/Incorrect"; + private static final String COMMON_AUTH_URL = CommonConstants.IS_HTTPS_BASE_URL + "/commonauth"; private static final String HTTP_RESPONSE_HEADER_LOCATION = "location"; public final static String USER_AGENT = "Apache-HttpClient/4.2.5 (java 1.6)"; diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/utils/CommonConstants.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/utils/CommonConstants.java index 3ac5a7727db..6e0cc97fb71 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/utils/CommonConstants.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/utils/CommonConstants.java @@ -20,9 +20,14 @@ public class CommonConstants { public static final int IS_DEFAULT_OFFSET = 410; - public static final int IS_DEFAULT_HTTPS_PORT = 9853; - public static final int DEFAULT_TOMCAT_PORT = 8490; - public static final String DEFAULT_SERVICE_URL = "https://localhost:9853/services/"; + public static final String DEFAULT_HOST = getSystemProperty("integration.test.host", "localhost"); + public static final String IS_HOST = getSystemProperty("integration.test.is.host", DEFAULT_HOST); + public static final String SAMPLE_APP_HOST = getSystemProperty("integration.test.sample.host", DEFAULT_HOST); + public static final int IS_DEFAULT_HTTPS_PORT = getSystemPropertyAsInt("integration.test.is.https.port", 9853); + public static final int DEFAULT_TOMCAT_PORT = getSystemPropertyAsInt("integration.test.sample.http.port", 8490); + public static final String IS_HTTPS_BASE_URL = "https://" + IS_HOST + ":" + IS_DEFAULT_HTTPS_PORT; + public static final String SAMPLE_APP_BASE_URL = "http://" + SAMPLE_APP_HOST + ":" + DEFAULT_TOMCAT_PORT; + public static final String DEFAULT_SERVICE_URL = IS_HTTPS_BASE_URL + "/services/"; public static final String SAML_REQUEST_PARAM = "SAMLRequest"; public static final String SAML_RESPONSE_PARAM = "SAMLResponse"; public static final String SESSION_DATA_KEY = "name=\"sessionDataKey\""; @@ -38,6 +43,26 @@ public enum AdminClients { USER_MANAGEMENT_CLIENT } + private static String getSystemProperty(String key, String defaultValue) { + + String value = System.getProperty(key); + return value != null ? value : defaultValue; + } + + private static int getSystemPropertyAsInt(String key, int defaultValue) { + + String value = System.getProperty(key); + if (value == null || value.trim().isEmpty()) { + return defaultValue; + } + + try { + return Integer.parseInt(value.trim()); + } catch (NumberFormatException e) { + return defaultValue; + } + } + } diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/automation-external.xml b/modules/integration/tests-integration/tests-backend/src/test/resources/automation-external.xml new file mode 100644 index 00000000000..f0175cba374 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/automation-external.xml @@ -0,0 +1,346 @@ + + + + + + + + + 30000 + + standalone + + false + + repository/deployment/server/webapps + repository/components/plugins + repository/components/dropins + lib/runtimes/cxf3 + + + false + + + + + + + http://10.100.2.51:4444/wd/hub/ + + + + firefox + + /home/test/name/webDriver + + + + + + + server + enable_admin_services + true + + + + + admin@wso2.com + admin + admin + localhost + 3025 + true + true + + + + + jdbc:h2:testDB + wso2carbon + wso2carbon + org.h2.Driver + + + jdbc:h2:testDB + wso2carbon + wso2carbon + org.h2.Driver + + + + + + + keystores/products/wso2carbon.p12 + + PKCS12 + + wso2carbon + + wso2carbon + + wso2carbon + + + + + client-truststore.p12 + + PKCS12 + + wso2carbon + + + + + + https://wso2.org/repo + file:///home/krishantha/test + + + + + + + + + + admin + admin + + + + + testuser11 + Wso2_test11 + + + testuser21 + Wso2_test21 + + + Registry580UN + Wso2_test580UN + + + deniedUser + Wso2_test + + + + + + + + + admin + admin + + + + + testuser11 + Wso2_test11 + + + testuser21 + Wso2_test21 + + + + + + + + + + + + + + localhost + + + + 10173 + + 9853 + + + + + + + localhost + + + 10174 + 9854 + + + + + + + localhost + + + 10175 + 9855 + + + + + + + + + + + + + org.wso2.identity.integration.common.extension.server.NoOpServerExtension + + + + + org.wso2.carbon.integration.common.extensions.usermgt.UserPopulateExtension + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +