diff --git a/.github/workflows/quickstart_ejb_security_context_propagation_ci.yml b/.github/workflows/quickstart_ejb_security_context_propagation_ci.yml new file mode 100644 index 0000000000..4a4213da52 --- /dev/null +++ b/.github/workflows/quickstart_ejb_security_context_propagation_ci.yml @@ -0,0 +1,214 @@ +name: WildFly ejb-security-context-propagation Quickstart CI + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths: + - 'ejb-security-context-propagation/**' + - '.github/workflows/quickstart_ci.yml' + +# Only run the latest job +concurrency: + group: '${{ github.workflow }} @ ${{ github.ref || github.run_id }}' + cancel-in-progress: true + +env: + QUICKSTART_PATH: ejb-security-context-propagation + TEST_PROVISIONED_SERVER: true + TEST_OPENSHIFT: false + +jobs: + Matrix-Setup: + runs-on: ubuntu-latest + outputs: + os: ${{ steps.setup-os-matrix.outputs.os }} + steps: + - id: setup-os-matrix + run: echo 'os=[${{ env.MATRIX_OS }}]' >> $GITHUB_OUTPUT + + Test-build-default-matrix: + name: BUILD DEFAULT - JDK${{ matrix.jdk }} - ${{ matrix.os }} + runs-on: ${{ matrix.os }} + needs: Matrix-Setup + strategy: + fail-fast: false + matrix: + jdk: [11, 17] + os: ${{ fromJSON(needs.Matrix-Setup.outputs.os) }} + steps: + - uses: actions/checkout@v4 + with: + path: quickstarts + - name: Set up JDK ${{ matrix.jdk }} + uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.jdk }} + distribution: 'temurin' + cache: 'maven' + - name: Run before script + env: + FILE: "./quickstarts/.github/workflows/quickstart_${{ env.QUICKSTART_PATH }}_ci_before.sh" + run: | + if test -f $FILE; + then + chmod +x $FILE + bash $FILE + fi + shell: bash + - name: Build ${{ env.QUICKSTART_PATH }} Quickstart for Release + run: | + cd quickstarts + cd ${{ env.QUICKSTART_PATH }} + mvn -U -B -fae clean install -Drelease + shell: bash + - name: Build, run & test ${{ env.QUICKSTART_PATH }} Quickstart with provisioned-server profile + if: ${{ env.TEST_PROVISIONED_SERVER }} + run: | + cd quickstarts + cd ${{ env.QUICKSTART_PATH }} + echo "Building provisioned server..." + mvn -U -B -fae clean package -Pprovisioned-server + echo "Starting provisioned server..." + mvn -U -B -fae wildfly:start -DjbossHome=target/server -Dstartup-timeout=120 + echo "Testing provisioned server..." + mvn -U -B -fae verify -Dserver.host=${{ env.SERVER_PROVISIONING_SERVER_HOST }} -Pintegration-testing + echo "Shutting down provisioned server..." + mvn -U -B -fae wildfly:shutdown + shell: bash + - name: Build, run & test ${{ env.QUICKSTART_PATH }} Quickstart with bootable-jar profile + if: ${{ env.TEST_BOOTABLE_JAR }} + run: | + cd quickstarts + cd ${{ env.QUICKSTART_PATH }} + echo "Building bootable jar..." + mvn -U -B -fae clean package -Pbootable-jar + echo "Starting bootable jar..." + mvn -U -B -fae wildfly-jar:start -Djar-file-name=target/${{ env.QUICKSTART_PATH }}-bootable.jar -Dstartup-timeout=120 + echo "Testing bootable jar..." + mvn -U -B -fae verify -Dserver.host=${{ env.SERVER_PROVISIONING_SERVER_HOST }} -Pintegration-testing + echo "Shutting down bootable jar..." + mvn -U -B -fae wildfly-jar:shutdown + shell: bash + - name: Build ${{ env.QUICKSTART_PATH }} Quickstart with openshift profile + if: ${{ env.TEST_OPENSHIFT }} + run: | + cd quickstarts + cd ${{ env.QUICKSTART_PATH }} + mvn -U -B -fae clean package -Popenshift + shell: bash + - name: Run after script + env: + FILE: "./quickstarts/.github/workflows/quickstart_${{ env.QUICKSTART_PATH }}_ci_after.sh" + run: | + if test -f $FILE; + then + chmod +x $FILE + bash $FILE + fi + shell: bash + - uses: actions/upload-artifact@v3 + if: failure() + with: + name: surefire-reports-JDK${{ matrix.jdk }}-${{ matrix.os }} + path: 'quickstarts/${{ env.QUICKSTART_PATH }}/**/surefire-reports/*.txt' + + # Use the shared-wildfly-build workflow to have a consistent WildFly build. Note the branch names MUST match what + # is used in WildFly. + WildFly-build: + uses: wildfly/wildfly/.github/workflows/shared-wildfly-build.yml@main + with: + wildfly-branch: ${{ github.base_ref }} + wildfly-repo: "wildfly/wildfly" + + Test-build-with-deps-matrix: + name: BUILD WITH DEPS - JDK${{ matrix.jdk }} - ${{ matrix.os }} + runs-on: ${{ matrix.os }} + needs: [Matrix-Setup, WildFly-build] + strategy: + fail-fast: false + matrix: + jdk: [11, 17] + os: ${{ fromJSON(needs.Matrix-Setup.outputs.os) }} + steps: + - uses: actions/checkout@v4 + with: + path: quickstarts + - uses: actions/download-artifact@v3 + with: + name: wildfly-maven-repository + path: . + - name: Extract Maven Repo + shell: bash + run: tar -xzf wildfly-maven-repository.tar.gz -C ~ + - name: Set up JDK ${{ matrix.jdk }} + uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.jdk }} + distribution: 'temurin' + cache: 'maven' + - name: Run before script + env: + FILE: "./quickstarts/.github/workflows/quickstart_${{ env.QUICKSTART_PATH }}_ci_before.sh" + run: | + if test -f $FILE; + then + chmod +x $FILE + bash $FILE + fi + shell: bash + - name: Build Quickstart for Release with built Server version + run: | + cd quickstarts + cd ${{ env.QUICKSTART_PATH }} + mvn -U -B -fae clean package -Drelease -Dversion.server=${{ needs.wildfly-build.outputs.wildfly-version }} + shell: bash + - name: Build, run & test ${{ env.QUICKSTART_PATH }} Quickstart with provisioned-server profile, and built Server version + if: ${{ env.TEST_PROVISIONED_SERVER }} + run: | + cd quickstarts + cd ${{ env.QUICKSTART_PATH }} + echo "Building provisioned server..." + mvn -U -B -fae clean package -Pprovisioned-server -Dversion.server=${{ needs.wildfly-build.outputs.wildfly-version }} + echo "Starting provisioned server..." + mvn -U -B -fae wildfly:start -DjbossHome=target/server -Dstartup-timeout=120 + echo "Testing provisioned server..." + mvn -U -B -fae verify -Dserver.host=${{ env.SERVER_PROVISIONING_SERVER_HOST }} -Pintegration-testing + echo "Shutting down provisioned server..." + mvn -U -B -fae wildfly:shutdown + shell: bash + - name: Build, run & test ${{ env.QUICKSTART_PATH }} Quickstart with bootable-jar profile, and built Server version + if: ${{ env.TEST_BOOTABLE_JAR }} + run: | + cd quickstarts + cd ${{ env.QUICKSTART_PATH }} + echo "Building bootable jar..." + mvn -U -B -fae clean package -Pbootable-jar -Dversion.server=${{ needs.wildfly-build.outputs.wildfly-version }} + echo "Starting bootable jar..." + mvn -U -B -fae wildfly-jar:start -Djar-file-name=target/${{ env.QUICKSTART_PATH }}-bootable.jar -Dstartup-timeout=120 + echo "Testing bootable jar..." + mvn -U -B -fae verify -Dserver.host=${{ env.SERVER_PROVISIONING_SERVER_HOST }} -Pintegration-testing + echo "Shutting down bootable jar..." + mvn -U -B -fae wildfly-jar:shutdown + shell: bash + - name: Build ${{ env.QUICKSTART_PATH }} Quickstart with openshift profile, and built Server version + if: ${{ env.TEST_OPENSHIFT }} + run: | + cd quickstarts + cd ${{ env.QUICKSTART_PATH }} + mvn -U -B -fae clean package -Popenshift -Dversion.server=${{ needs.wildfly-build.outputs.wildfly-version }} + shell: bash + - name: Run after script + env: + FILE: "./quickstarts/.github/workflows/quickstart_${{ env.QUICKSTART_PATH }}_ci_after.sh" + run: | + if test -f $FILE; + then + chmod +x $FILE + bash $FILE + fi + shell: bash + - uses: actions/upload-artifact@v3 + if: failure() + with: + name: surefire-reports-JDK${{ matrix.jdk }}-${{ matrix.os }} + path: 'quickstarts/**/surefire-reports/*.txt' diff --git a/ejb-security-context-propagation/README.adoc b/ejb-security-context-propagation/README.adoc index ef5f414e11..6a134920c8 100644 --- a/ejb-security-context-propagation/README.adoc +++ b/ejb-security-context-propagation/README.adoc @@ -322,6 +322,10 @@ This quickstart requires additional configuration and deploys and runs different // Debug the Application include::../shared-doc/debug-the-application.adoc[leveloffset=+1] +// Build and run sections for other environments/builds +ifndef::ProductRelease,EAPXPRelease[] +include::../shared-doc/build-and-run-the-quickstart-with-provisioned-server.adoc[leveloffset=+1] +endif::[] //************************************************* // Product Release content only diff --git a/ejb-security-context-propagation/pom.xml b/ejb-security-context-propagation/pom.xml index e46d57892c..56e9ddeedf 100644 --- a/ejb-security-context-propagation/pom.xml +++ b/ejb-security-context-propagation/pom.xml @@ -43,10 +43,14 @@ + + 30.0.0.Beta1 jdt_apt - 30.0.0.Beta1 + ${version.server} + 5.0.0.Beta1 + 4.2.0.Final @@ -110,7 +114,7 @@ org.wildfly.bom wildfly-ee-with-tools - ${version.server.bom} + ${version.bom.ee} pom import @@ -143,45 +147,114 @@ jakarta.ejb jakarta.ejb-api - + + + + junit + junit + test + ${project.artifactId} - - - - org.apache.maven.plugins - maven-ejb-plugin - - 3.2 - true - - - - - org.codehaus.mojo - exec-maven-plugin - - java - ${project.build.directory}/exec-working-directory - - - -classpath - - org.jboss.as.quickstarts.ejb_security_context_propagation.RemoteClient - - - - - - exec - - - - - + + + + org.apache.maven.plugins + maven-ejb-plugin + + 3.2 + true + + + + + org.codehaus.mojo + exec-maven-plugin + + java + ${project.build.directory}/exec-working-directory + + + -classpath + + org.jboss.as.quickstarts.ejb_security_context_propagation.RemoteClient + + + + + + exec + + + + + + org.wildfly.plugins + wildfly-maven-plugin + ${version.plugin.wildfly} + + + + + + provisioned-server + + + + org.wildfly.plugins + wildfly-maven-plugin + + + + org.wildfly:wildfly-galleon-pack:${version.server} + + + + + cloud-server + + + ROOT.war + + + + + package + + + + + + + + + integration-testing + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + **/*IT + + + + + + integration-test + verify + + + + + + + + diff --git a/ejb-security-context-propagation/src/test/java/org/wildfly/quickstarts/ejb_security_context_propagation/BasicRuntimeIT.java b/ejb-security-context-propagation/src/test/java/org/wildfly/quickstarts/ejb_security_context_propagation/BasicRuntimeIT.java new file mode 100644 index 0000000000..7bedcd3dda --- /dev/null +++ b/ejb-security-context-propagation/src/test/java/org/wildfly/quickstarts/ejb_security_context_propagation/BasicRuntimeIT.java @@ -0,0 +1,58 @@ +/* + * Copyright 2023 JBoss by Red Hat. + * + * 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.wildfly.quickstarts.ejb_security_context_propagation; + +import org.junit.Test; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; + +import static org.junit.Assert.assertEquals; + +/** + * The very basic runtime integration testing. + * @author Prarthona Paul + * @author emartins + */ +public class BasicRuntimeIT { + private static final String DEFAULT_SERVER_HOST = "http://localhost:8080"; + + @Test + public void testHTTPEndpointIsAvailable() throws IOException, InterruptedException, URISyntaxException { + String serverHost = System.getenv("SERVER_HOST"); + if (serverHost == null) { + serverHost = System.getProperty("server.host"); + } + if (serverHost == null) { + serverHost = DEFAULT_SERVER_HOST; + } + final HttpRequest request = HttpRequest.newBuilder() + .uri(new URI(serverHost+"/")) + .GET() + .build(); + final HttpClient client = HttpClient.newBuilder() + .followRedirects(HttpClient.Redirect.ALWAYS) + .connectTimeout(Duration.ofMinutes(1)) + .build(); + final HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); + assertEquals(200, response.statusCode()); + } +}