diff --git a/.github/workflows/quickstart_servlet-security_ci.yml b/.github/workflows/quickstart_servlet-security_ci.yml new file mode 100644 index 0000000000..96a81bc268 --- /dev/null +++ b/.github/workflows/quickstart_servlet-security_ci.yml @@ -0,0 +1,14 @@ +name: WildFly servlet-security Quickstart CI + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths: + - 'servlet-security/**' + - '.github/workflows/quickstart_ci.yml' +jobs: + call-quickstart_ci: + uses: ./.github/workflows/quickstart_ci.yml + with: + QUICKSTART_PATH: servlet-security + TEST_PROVISIONED_SERVER: true diff --git a/servlet-security/README.adoc b/servlet-security/README.adoc index d1e2af45a2..722372dc59 100644 --- a/servlet-security/README.adoc +++ b/servlet-security/README.adoc @@ -194,8 +194,8 @@ Now close the browser. Open a new browser and log in with username `guest` and p Forbidden ---- -// Testing with Arquillian -include::../shared-doc/run-arquillian-integration-tests-with-server-distribution.adoc[leveloffset=+2] +// Server Distribution Testing +include::../shared-doc/run-integration-tests-with-server-distribution.adoc[leveloffset=+2] // Undeploy the Quickstart include::../shared-doc/undeploy-the-quickstart.adoc[leveloffset=+2] diff --git a/servlet-security/pom.xml b/servlet-security/pom.xml index ca30e3f595..46fac4ae40 100644 --- a/servlet-security/pom.xml +++ b/servlet-security/pom.xml @@ -44,12 +44,15 @@ - - 30.0.0.Final + 30.0.0.Final - 4.2.0.Final - 5.0.0.Final - 6.0.0.Final + + ${version.server} + 5.0.0.Final + 6.0.0.Final + 4.2.0.Final + + 5.9.1 @@ -113,7 +116,7 @@ org.wildfly.bom wildfly-ee-with-tools - ${version.server.bom} + ${version.bom.ee} pom import @@ -150,54 +153,42 @@ provided - + - junit - junit - test - - - - - - org.jboss.arquillian.junit - arquillian-junit-container - test - - - - org.jboss.arquillian.protocol - arquillian-protocol-servlet-jakarta + org.junit.jupiter + junit-jupiter-engine + ${version.org.junit.jupiter} test + + + + + org.wildfly.plugins + wildfly-maven-plugin + ${version.plugin.wildfly} + + + + + provisioned-server - - - org.wildfly.arquillian - wildfly-arquillian-container-managed - test - - org.wildfly.plugins wildfly-maven-plugin - ${version.wildfly.maven.plugin} org.wildfly:wildfly-galleon-pack:${version.server} - org.wildfly - wildfly-datasources-galleon-pack - ${version.wildfly-datasources-galleon-pack} + org.wildfly:wildfly-datasources-galleon-pack:${version.pack.datasources} @@ -223,30 +214,6 @@ - - org.apache.maven.plugins - maven-failsafe-plugin - ${version.failsafe.plugin} - - - ${project.build.directory}/server - - - **/ProvisionedManagedSecureIT - - - **/RemoteSecureIT - - - - - - integration-test - verify - - - - @@ -257,19 +224,16 @@ org.wildfly.plugins wildfly-maven-plugin - ${version.wildfly.maven.plugin} org.wildfly:wildfly-galleon-pack:${version.server} - org.wildfly.cloud:wildfly-cloud-galleon-pack:${version.cloud.fp} + org.wildfly.cloud:wildfly-cloud-galleon-pack:${version.pack.cloud} - org.wildfly - wildfly-datasources-galleon-pack - ${version.wildfly-datasources-galleon-pack} + org.wildfly:wildfly-datasources-galleon-pack:${version.pack.datasources} @@ -299,20 +263,16 @@ - arq-remote + integration-testing org.apache.maven.plugins maven-failsafe-plugin - ${version.failsafe.plugin} - **/RemoteSecureIT + **/*IT - - **/ProvisionedManagedSecureIT - diff --git a/servlet-security/src/test/java/org/jboss/as/quickstarts/servlet_security/RemoteSecureIT.java b/servlet-security/src/test/java/org/jboss/as/quickstarts/servlet_security/BasicRuntimeIT.java similarity index 79% rename from servlet-security/src/test/java/org/jboss/as/quickstarts/servlet_security/RemoteSecureIT.java rename to servlet-security/src/test/java/org/jboss/as/quickstarts/servlet_security/BasicRuntimeIT.java index ddd7426592..8519cb78d2 100644 --- a/servlet-security/src/test/java/org/jboss/as/quickstarts/servlet_security/RemoteSecureIT.java +++ b/servlet-security/src/test/java/org/jboss/as/quickstarts/servlet_security/BasicRuntimeIT.java @@ -20,6 +20,9 @@ */ package org.jboss.as.quickstarts.servlet_security; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + import java.io.IOException; import java.net.Authenticator; import java.net.PasswordAuthentication; @@ -28,20 +31,23 @@ import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; -import org.junit.Assert; -import org.junit.Test; /** * * @author Emmanuel Hugonnet (c) 2022 Red Hat, Inc. + * @author istudens */ +public class BasicRuntimeIT { -public class RemoteSecureIT { + protected static final String DEFAULT_SERVER_HOST = "http://localhost:8080/servlet-security"; protected URI getHTTPEndpoint() { - String host = getServerHost(); + String host = System.getenv("SERVER_HOST"); + if (host == null) { + host = System.getProperty("server.host"); + } if (host == null) { - host = "http://localhost:8080/servlet-security"; + host = DEFAULT_SERVER_HOST; } try { return new URI(host + "/SecuredServlet"); @@ -50,14 +56,6 @@ protected URI getHTTPEndpoint() { } } - protected static String getServerHost() { - String host = System.getenv("SERVER_HOST"); - if (host == null) { - host = System.getProperty("server.host"); - } - return host; - } - @Test public void testConnectOk() throws IOException, InterruptedException { HttpRequest request = HttpRequest.newBuilder(getHTTPEndpoint()) @@ -70,12 +68,12 @@ protected PasswordAuthentication getPasswordAuthentication() { } }).build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); - Assert.assertEquals(200, response.statusCode()); + Assertions.assertEquals(200, response.statusCode()); String[] lines = response.body().toString().split(System.lineSeparator()); - Assert.assertEquals("

Successfully called Secured Servlet

", lines[1].trim()); - Assert.assertEquals("

Principal : quickstartUser

", lines[2].trim()); - Assert.assertEquals("

Remote User : quickstartUser

", lines[3].trim()); - Assert.assertEquals("

Authentication Type : BASIC

", lines[4].trim()); + Assertions.assertEquals("

Successfully called Secured Servlet

", lines[1].trim()); + Assertions.assertEquals("

Principal : quickstartUser

", lines[2].trim()); + Assertions.assertEquals("

Remote User : quickstartUser

", lines[3].trim()); + Assertions.assertEquals("

Authentication Type : BASIC

", lines[4].trim()); } @Test @@ -90,6 +88,6 @@ protected PasswordAuthentication getPasswordAuthentication() { } }).build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); - Assert.assertEquals(403, response.statusCode()); + Assertions.assertEquals(403, response.statusCode()); } } diff --git a/servlet-security/src/test/java/org/jboss/as/quickstarts/servlet_security/ProvisionedManagedSecureIT.java b/servlet-security/src/test/java/org/jboss/as/quickstarts/servlet_security/ProvisionedManagedSecureIT.java deleted file mode 100644 index ba24ab246c..0000000000 --- a/servlet-security/src/test/java/org/jboss/as/quickstarts/servlet_security/ProvisionedManagedSecureIT.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2022 Red Hat, Inc. - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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.jboss.as.quickstarts.servlet_security; - -import java.net.URI; -import java.net.URISyntaxException; -import org.jboss.arquillian.container.test.api.RunAsClient; -import org.jboss.arquillian.junit.Arquillian; -import org.junit.runner.RunWith; - -/** - * - * @author Emmanuel Hugonnet (c) 2022 Red Hat, Inc. - */ -@RunWith(Arquillian.class) -@RunAsClient -public class ProvisionedManagedSecureIT extends RemoteSecureIT { - - @Override - protected URI getHTTPEndpoint() { - String host = getServerHost(); - if (host == null) { - host = "http://localhost:8080"; - } - try { - return new URI(host + "/SecuredServlet"); - } catch (URISyntaxException ex) { - throw new RuntimeException(ex); - } - } -}