diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index c4fde90f19..ae1464757b 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -57,6 +57,55 @@ jobs: - uses: ./.github/actions/teardown + CITestsModulithUnknownHostnames: + needs: PublishJibContainers + runs-on: ubuntu-latest + container: ubuntu:latest + timeout-minutes: 15 + + services: + apiml: + image: ghcr.io/balhar-jakub/apiml:${{ github.run_id }}-${{ github.run_number }} + env: + APIML_SECURITY_SSL_VERIFYSSLCERTIFICATESOFSERVICES: true + APIML_SECURITY_SSL_NONSTRICTVERIFYSSLCERTIFICATESOFSERVICES: true + APIML_DISCOVERY_STATICAPIDEFINITIONSDIRECTORIES: /docker/api-defs-unknown-host + + discoverable-client-unknown: + image: ghcr.io/balhar-jakub/discoverable-client:${{ github.run_id }}-${{ github.run_number }} + env: + APIML_SERVICE_HOSTNAME: discoverable-client-unknown + APIML_SERVICE_DISCOVERYSERVICEURLS: https://apiml:10011/eureka + SPRING_SERVLET_MULTIPART_MAXFILESIZE: 1024MB + SPRING_SERVLET_MULTIPART_MAXREQUESTSIZE: 1024MB + mock-services-unknown: + image: ghcr.io/balhar-jakub/mock-services:${{ github.run_id }}-${{ github.run_number }} + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + + - uses: ./.github/actions/setup + + - name: Run CI Tests with Unknown Hostnames + timeout-minutes: 4 + run: > + ENV_CONFIG=docker-modulith ./gradlew runStartUpCheck :integration-tests:runUnknownHostnamesTests --info + -Ddiscoverableclient.instances=1 -Denvironment.config=-docker-modulith -Denvironment.modulith=true + - uses: ./.github/actions/dump-jacoco + if: always() + - name: Store results + uses: actions/upload-artifact@v4 + if: always() + with: + name: CITestsModulithUnknownHostnames-${{ env.JOB_ID }} + path: | + integration-tests/build/reports/** + results/** + integration-tests/build/test-results/runUnknownHostnamesTests/binary/** + integration-tests/build/test-results/runStartUpCheck/binary/** + - uses: ./.github/actions/teardown CITestsModulith: needs: PublishJibContainers runs-on: ubuntu-latest diff --git a/config/docker/api-defs-unknown-host/mock-services.yml b/config/docker/api-defs-unknown-host/mock-services.yml new file mode 100644 index 0000000000..21eb1a057c --- /dev/null +++ b/config/docker/api-defs-unknown-host/mock-services.yml @@ -0,0 +1,46 @@ +services: + - serviceId: mockzosmf # unique lowercase ID of the service + catalogUiTileId: zosmf # ID of the API Catalog UI tile (visual grouping of the services) + title: Mock zOSMF # Title of the service in the API catalog + description: Mock ZOSMF service # Description of the service in the API catalog + instanceBaseUrls: # list of base URLs for each instance + - https://mock-services-unknown:10013/ # scheme://hostname:port/contextPath + homePageRelativeUrl: # Normally used for informational purposes for other services to use it as a landing page + routes: + - gatewayUrl: api # [api/ui/ws]/v{majorVersion} + serviceRelativeUrl: # relativePath that is added to baseUrl of an instance + # List of APIs provided by the service (currently only one is supported): + authentication: + scheme: zosmf # This service expects z/OSMF LTPA token + apiInfo: + - apiId: ibm.zosmf + gatewayUrl: api/v1 + version: 2.4.0 + documentationUrl: https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.4.0/com.ibm.zos.v2r4.izua700/IZUHPINFO_RESTServices.htm + swaggerUrl: https://mock-services-unknown:10013/zosmf/api/docs + - serviceId: zss # unique lowercase ID of the service + catalogUiTileId: zss # ID of the API Catalog UI tile (visual grouping of the services) + title: Statically Defined ZSS # Title of the service in the API catalog + description: Mock ZSS # Description of the service in the API catalog + instanceBaseUrls: # list of base URLs for each instance + - https://mock-services-unknown:10013/ # scheme://hostname:port/contextPath + homePageRelativeUrl: # Normally used for informational purposes for other services to use it as a landing page + routes: + - gatewayUrl: api/v1 # [api/ui/ws]/v{majorVersion} + serviceRelativeUrl: # relativePath that is added to baseUrl of an instance + # List of APIs provided by the service (currently only one is supported): + apiInfo: + - apiId: ibm.zosmf + gatewayUrl: api + version: 2.4.0 + documentationUrl: https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.4.0/com.ibm.zos.v2r4.izua700/IZUHPINFO_RESTServices.htm + + +# List of tiles that can be used by services defined in the YAML file: +catalogUiTiles: + zosmf: + title: zOSMF + description: zOSMF + zss: + title: ZSS + description: ZSS diff --git a/integration-tests/build.gradle b/integration-tests/build.gradle index a323367d7c..9ee7b14b19 100644 --- a/integration-tests/build.gradle +++ b/integration-tests/build.gradle @@ -108,6 +108,16 @@ task runStartUpCheck(type: Test) { outputs.upToDateWhen { false } } +task runUnknownHostnamesTests(type: Test) { + group 'integration tests' + description "Run integration tests where hostnames validation is disabled" + + systemProperties System.properties + useJUnitPlatform { + includeTags 'UnknownHostnamesTest' + } + outputs.upToDateWhen { false } +} task runLocalIntegrationTests(type: Test) { group "Integration tests" description "Run integration tests that are not dependent on mainframe" diff --git a/integration-tests/src/test/java/org/zowe/apiml/integration/proxy/CertificateValidationDisabledTest.java b/integration-tests/src/test/java/org/zowe/apiml/integration/proxy/CertificateValidationDisabledTest.java new file mode 100644 index 0000000000..b08a683c12 --- /dev/null +++ b/integration-tests/src/test/java/org/zowe/apiml/integration/proxy/CertificateValidationDisabledTest.java @@ -0,0 +1,37 @@ +/* + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + */ + +package org.zowe.apiml.integration.proxy; + +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import org.zowe.apiml.util.http.HttpRequestUtils; +import java.net.URI; +import org.zowe.apiml.util.requests.Endpoints; + +import io.restassured.RestAssured; + +import static io.restassured.RestAssured.given; + +@Tag("UnknownHostnamesTest") +public class CertificateValidationDisabledTest { + @Test + void givenRequestToServiceWithInvalidHostname_thenRequestIsSuccessful() { + RestAssured.useRelaxedHTTPSValidation(); + URI uri = HttpRequestUtils.getUriFromGateway(Endpoints.DISCOVERABLE_GREET); + given() + .log().ifValidationFails() + .get(uri) + .then() + .log().ifValidationFails() + .statusCode(200); + } +}