From 6163b318c1d410550ec8f064a18dc882a8dc5f57 Mon Sep 17 00:00:00 2001 From: Prarthona Paul Date: Fri, 20 Oct 2023 12:54:51 -0400 Subject: [PATCH] [WFLY-18481] http-custom-mechanism Quickstart Common Enhancements CY2023Q3 --- .../quickstart_http-custom-mechanism_ci.yml | 17 +++ http-custom-mechanism/README.adoc | 124 ++++-------------- http-custom-mechanism/add-custom-module.cli | 3 + http-custom-mechanism/configure-elytron.cli | 3 - .../custom-module/add-custom-module.cli | 3 - http-custom-mechanism/pom.xml | 52 +++----- .../remove-custom-module.cli | 0 http-custom-mechanism/webapp/pom.xml | 66 ++++++++++ .../http_custom_mechanism/SecuredServlet.java | 7 +- .../http_custom_mechanism/BasicRuntimeIT.java | 63 +++++++++ .../add-application-and-management-users.adoc | 5 +- shared-doc/add-application-user.adoc | 5 +- ...he-quickstart-with-provisioned-server.adoc | 18 ++- ...gration-tests-with-provisioned-server.adoc | 57 ++++++-- 14 files changed, 257 insertions(+), 166 deletions(-) create mode 100644 .github/workflows/quickstart_http-custom-mechanism_ci.yml create mode 100644 http-custom-mechanism/add-custom-module.cli delete mode 100644 http-custom-mechanism/custom-module/add-custom-module.cli rename http-custom-mechanism/{custom-module => }/remove-custom-module.cli (100%) create mode 100644 http-custom-mechanism/webapp/src/test/java/org/jboss/as/quickstart/http_custom_mechanism/BasicRuntimeIT.java diff --git a/.github/workflows/quickstart_http-custom-mechanism_ci.yml b/.github/workflows/quickstart_http-custom-mechanism_ci.yml new file mode 100644 index 0000000000..3c8579034b --- /dev/null +++ b/.github/workflows/quickstart_http-custom-mechanism_ci.yml @@ -0,0 +1,17 @@ +name: WildFly http-custom-mechanism Quickstart CI + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths: + - 'http-custom-mechanism/**' + - .github/workflows/quickstart_ci.yml + +jobs: + call-quickstart_ci: + uses: ./.github/workflows/quickstart_ci.yml + with: + QUICKSTART_PATH: http-custom-mechanism + DEPLOYMENT_DIR: webapp + TEST_PROVISIONED_SERVER: true + TEST_OPENSHIFT: false \ No newline at end of file diff --git a/http-custom-mechanism/README.adoc b/http-custom-mechanism/README.adoc index 069e4d6bea..b37bfed011 100644 --- a/http-custom-mechanism/README.adoc +++ b/http-custom-mechanism/README.adoc @@ -12,6 +12,7 @@ The `http-custom-mechanism` quickstart demonstrates how to implement a custom HT :archiveType: war :archiveName: {artifactId}-webapp :app-user-groups: Users +:deploymentDir: webapp == What is it? @@ -40,54 +41,31 @@ a| This project contains the source for a custom HTTP authentication module that ** `badRequest` - The authentication for this mechanism failed validation of the request. ** `noAuthenticationInProgress` - The mechanism did not attempt any stage of authentication. - * `org.wildfly.security.examples.CustomMechanismFactory`: This resource file contains a single line of text that names the custom mechanism factory class, which in this case is `org.jboss.as.quickstart.http_custom_mechanism.CustomMechanismFactory`. |=== -You will follow these basic steps to test this quickstart: - -. xref:add_the_application_user[Add] the application user. -. xref:back_up_standalone_server_configuration[Back up] the server configuration before xref:start_the_eap_standalone_server[starting] the server. -. xref:build_and_deploy_the_quickstart[Build and deploy] the application. -. xref:test_the_secured_servlet[Test] the secured servlet deployment. -. xref:build_the_custom_http_mechanism[Build] the custom HTTP mechanism module and xref:add_the_custom_module_to_the_server[add] it to the server. -. xref:configure_the_server_to_use_the_custom_module[Configure] the server to override the deployment and use the custom module. -. xref:test_the_secured_servlet_using_the_custom_mechnism[Test] the secured servlet using the custom mechanism - // System Requirements include::../shared-doc/system-requirements.adoc[leveloffset=+1] // Use of {jbossHomeName} include::../shared-doc/use-of-jboss-home-name.adoc[leveloffset=+1] -// Add the Authorized Application User -include::../shared-doc/add-application-user.adoc[leveloffset=+1] -// Back Up the {productName} Standalone Server Configuration -include::../shared-doc/back-up-server-standalone-configuration.adoc[leveloffset=+1] -// Start the {productName} Standalone Server -include::../shared-doc/start-the-standalone-server.adoc[leveloffset=+1] -[[add_the_application_user]] -== Add the application user -include::../shared-doc/add-application-user.adoc[leveloffset=+1] +// build and run with standard server distribution +[[build_and_run_the_quickstart_with_server_dist]] +== Building and running the quickstart application with a {productName} server distribution -[[back_up_standalone_server_configuration]] -== Back up the server configuration -include::../shared-doc/back-up-server-standalone-configuration.adoc[leveloffset=+1] +// Back Up the {productName} Standalone Server Configuration +include::../shared-doc/back-up-server-standalone-configuration.adoc[leveloffset=+2] -[[build_and_deploy_the_quickstart]] -== Build and deploy the application -// Build and Deploy the Quickstart -include::../shared-doc/build-and-deploy-the-quickstart.adoc[leveloffset=+1] +include::../shared-doc/add-application-user.adoc[leveloffset=+2] -// These messages appear in the server log. +// Start the {productName} Standalone Server +include::../shared-doc/start-the-standalone-server.adoc[leveloffset=+2] -[source,options="nowrap"] ----- -WFLYUT0021: Registered web context: '/http-custom-mechanism-webapp' for server 'default-server' -WFLYSRV0010: Deployed "http-custom-mechanism-webapp.war" (runtime-name : "http-custom-mechanism-webapp.war") ----- +// Build and Deploy the Quickstart +include::../shared-doc/build-and-deploy-the-quickstart.adoc[leveloffset=+2] [[test_the_secured_servlet]] -== Test the Secured Servlet +=== Test the Secured Servlet Before you continue, you must test the secured servlet deployment to make sure it is working. Since this application uses a standard mechanism, it could be tested using a browser. However, after you implement the custom HTTP mechanism, the browser will not understand the request, so it is better to test the call using a client that will allow you to manipulate the headers yourself. @@ -106,35 +84,17 @@ You should see the HTTP result `HTTP/1.1 200 OK`, along with some header informa Secured Servlet

Secured Servlet

-

-Current Principal 'quickstartUser'

+

Current Principal 'quickstartUser'

---- -[[build_the_custom_http_mechanism]] -== Build the Custom HTTP Mechanism JAR - -Once the secured servlet is deployed and you have tested it to make sure it is working, you need to build the module for the custom HTTP mechanism. - -. Open a terminal and navigate to the `custom-module/` folder located in the root directory of this quickstart. -. Type the following command to build the custom HTTP mechanism. -+ -[source,subs="attributes+",options="nowrap"] ----- -$ mvn clean install ----- - -This creates the `target/{artifactId}.jar` file in the quickstart `custom-module/` directory. - -You should see `[INFO] BUILD SUCCESS` in the console output. - [[add_the_custom_module_to_the_server]] -== Add the Custom Module to the Server +=== Add the Custom Module to the Server -Now you must add the `{artifactId}.jar` as a custom module to the {productName} server. For your convenience, this quickstart includes the command to add the module in the `add-custom-module.cli` script located in the `custom-module/` directory of this quickstart. +Now you must add the jar built by `custom-module`, as a custom module to the {productName} server. For your convenience, this quickstart includes the command to add the module in the `add-custom-module.cli` script, provided in the root directory of this quickstart. -In a terminal, navigate to the `custom-module/` folder located in the root directory of this quickstart, and run the following command, replacing `__{jbossHomeName}__` with the path to your server. +In a terminal, navigate to the root directory of this quickstart, and run the following command, replacing `__{jbossHomeName}__` with the path to your server. [source,subs="+quotes,attributes+",options="nowrap"] ---- @@ -143,7 +103,7 @@ $ __{jbossHomeName}__/bin/jboss-cli.sh --connect --file=add-custom-module.cli NOTE: For Windows, use the `__{jbossHomeName}__\bin\jboss-cli.bat` script. -This creates the custom `__{jbossHomeName}__/modules/modules/org/jboss/as/quickstart/http_custom_mechanism/main` folder, then copies in the `{artifactId}.jar` file and creates the required `module.xml` file. +This creates the custom `__{jbossHomeName}__/modules/modules/org/jboss/as/quickstart/http_custom_mechanism/main` folder, then copies in the `custom-module/target/custom-module.jar` file and creates the required `module.xml` file. You can verify the module structure in your file manager. @@ -158,14 +118,14 @@ You can verify the module structure in your file manager. └── quickstart └── http_custom_mechanism └── main - ├── {artifactId}.jar + ├── custom-module.jar └── module.xml ---- [[configure_the_server_to_use_the_custom_module]] -== Configure the Server to Use the Custom Module +=== Configure the Server to Use the Custom Module -You configure the server to use the custom module by running CLI commands. For your convenience, this quickstart batches the commands into a `configure-elytron.cli` script provided in the root directory of this quickstart. +You configure the server to use the custom module by running CLI commands. For your convenience, this quickstart batches the commands into a `configure-elytron.cli` script, provided in the root directory of this quickstart. . Before you begin, make sure you have done the following: @@ -194,7 +154,7 @@ process-state: reload-required . Stop the {productName} server. [[review_the_modified_server_configuration]] -== Review the Modified Server Configuration +=== Review the Modified Server Configuration After stopping the server, open the `__{jbossHomeName}__/standalone/configuration/standalone.xml` file and review the changes. @@ -225,7 +185,7 @@ After stopping the server, open the `__{jbossHomeName}__/standalone/configuratio [[test_the_secured_servlet_using_the_custom_mechnism]] == Test the Secured Servlet Using the Custom Mechanism -Now you need to test the override of the deployment with the custom HTTP mechanism. +Now you need to test the override of the deployment with the custom HTTP mechanism, please start the server as previously described. If you use the same `curl` command as when you xref:test_the_secured_servlet[tested the servlet before implementing the custom HTTP mechanism], it will fail with the following error. [source,options="nowrap"] @@ -237,11 +197,9 @@ If you use the same `curl` command as when you xref:test_the_secured_servlet[tes This is because the authentication mechanism rejected the call and subsequently added a header describing how to do authentication. You must modify the curl command to the following. - [source,options="nowrap"] ---- curl -v http://localhost:8080/http-custom-mechanism-webapp/secured -H "X-USERNAME:quickstartUser" -H "X-PASSWORD:password" - ---- You should see the HTTP result `HTTP/1.1 200 OK`, along with some header information, then followed by this output. @@ -252,14 +210,13 @@ You should see the HTTP result `HTTP/1.1 200 OK`, along with some header informa Secured Servlet

Secured Servlet

-

-Current Principal 'quickstartUser'

+

Current Principal 'quickstartUser'

---- // Undeploy the Quickstart -include::../shared-doc/undeploy-the-quickstart.adoc[leveloffset=+1] +include::../shared-doc/undeploy-the-quickstart.adoc[leveloffset=+2] // Restore the {productName} Standalone Server Configuration Manually :restoreScriptName: restore-configuration.cli include::../shared-doc/restore-standalone-server-configuration-manual.adoc[leveloffset=+2] @@ -275,34 +232,11 @@ process-state: reload-required // Restore the {productName} Standalone Server Configuration Manually include::../shared-doc/restore-standalone-server-configuration-manual.adoc[leveloffset=+2] -//// -Not how to do curl commands in JBDS -// include::../shared-doc/run-the-quickstart-in-jboss-developer-studio.adoc[leveloffset=+1] - -// Additional Red Hat CodeReady Studio instructions -* Make sure you xref:add_the_application_user[Add the application user] as described above. -* Make sure you configure the security domain on the server by running the JBoss CLI script as described above under xref:configure_the_application_security_domain[Configure the Application Security Domain]. -* Right-click on the *{artifactId}* project and choose *Run As* -> *Maven build*. -Enter `clean package wildfly:deploy` for the *Goals* and click *Run*. This deploys the `{artifactId}` JAR to the {productName} server. -* BUILD AND ADD the MODULE, configure, test ----- - -* To undeploy the project, right-click on the *{artifactId}* project and choose *Run As* -> *Maven build*. Enter `wildfly:undeploy` for the *Goals* and click *Run*. - -* Make sure you xref:restore_the_server_configuration[restore the {productName} standalone server configuration] when you have completed testing this quickstart. - -//// - -// Debug the Application -include::../shared-doc/debug-the-application.adoc[leveloffset=+1] - -//************************************************* -// Product Release content only -//************************************************* -ifdef::ProductRelease[] +// 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::[] // Quickstart not compatible with OpenShift -include::../shared-doc/openshift-incompatibility.adoc[leveloffset=+1] - -endif::[] \ No newline at end of file +include::../shared-doc/openshift-incompatibility.adoc[leveloffset=+1] \ No newline at end of file diff --git a/http-custom-mechanism/add-custom-module.cli b/http-custom-mechanism/add-custom-module.cli new file mode 100644 index 0000000000..c238411dca --- /dev/null +++ b/http-custom-mechanism/add-custom-module.cli @@ -0,0 +1,3 @@ +# Add the custom module to the server + +module add --name=org.jboss.as.quickstart.http_custom_mechanism.custom-http-mechanism --resources=custom-module/target/custom-module.jar --dependencies=org.wildfly.security.elytron diff --git a/http-custom-mechanism/configure-elytron.cli b/http-custom-mechanism/configure-elytron.cli index 1728676278..4e66645e28 100644 --- a/http-custom-mechanism/configure-elytron.cli +++ b/http-custom-mechanism/configure-elytron.cli @@ -20,6 +20,3 @@ batch # Run the batch commands run-batch - -# Reload the server configuration -reload diff --git a/http-custom-mechanism/custom-module/add-custom-module.cli b/http-custom-mechanism/custom-module/add-custom-module.cli deleted file mode 100644 index 7743d94fdf..0000000000 --- a/http-custom-mechanism/custom-module/add-custom-module.cli +++ /dev/null @@ -1,3 +0,0 @@ -# Add the custom module to the server - -module add --name=org.jboss.as.quickstart.http_custom_mechanism.custom-http-mechanism --resources=target/custom-module.jar --dependencies=org.wildfly.security.elytron,javax.api diff --git a/http-custom-mechanism/pom.xml b/http-custom-mechanism/pom.xml index c41b19921f..8a77e7bce4 100644 --- a/http-custom-mechanism/pom.xml +++ b/http-custom-mechanism/pom.xml @@ -44,13 +44,17 @@ - webapp custom-module + webapp - - 30.0.0.Final + + 30.0.0.Final + + ${version.server} + 5.0.0.Final + 4.2.0.Final @@ -114,44 +118,22 @@ org.wildfly.bom wildfly-ee-with-tools - ${version.server.bom} + ${version.bom.ee} pom import - - - - org.wildfly.security - wildfly-elytron - - - org.wildfly.common - wildfly-common - - - jakarta.servlet - jakarta.servlet-api - provided - - - - junit - junit - test - - - - ${project.artifactId} - - - org.wildfly.plugins - wildfly-maven-plugin - - + + + + org.wildfly.plugins + wildfly-maven-plugin + ${version.plugin.wildfly} + + + - diff --git a/http-custom-mechanism/custom-module/remove-custom-module.cli b/http-custom-mechanism/remove-custom-module.cli similarity index 100% rename from http-custom-mechanism/custom-module/remove-custom-module.cli rename to http-custom-mechanism/remove-custom-module.cli diff --git a/http-custom-mechanism/webapp/pom.xml b/http-custom-mechanism/webapp/pom.xml index 8854a9cb2f..10a7dfc63c 100644 --- a/http-custom-mechanism/webapp/pom.xml +++ b/http-custom-mechanism/webapp/pom.xml @@ -62,4 +62,70 @@ + + + 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 + + + **/BasicRuntimeIT + + + + + + integration-test + verify + + + + + + + + + diff --git a/http-custom-mechanism/webapp/src/main/java/org/jboss/as/quickstart/http_custom_mechanism/SecuredServlet.java b/http-custom-mechanism/webapp/src/main/java/org/jboss/as/quickstart/http_custom_mechanism/SecuredServlet.java index 9318379962..98c164c662 100644 --- a/http-custom-mechanism/webapp/src/main/java/org/jboss/as/quickstart/http_custom_mechanism/SecuredServlet.java +++ b/http-custom-mechanism/webapp/src/main/java/org/jboss/as/quickstart/http_custom_mechanism/SecuredServlet.java @@ -44,12 +44,11 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se writer.println(" Secured Servlet"); writer.println(" "); writer.println("

Secured Servlet

"); - writer.println("

"); - writer.print(" Current Principal '"); + writer.print("

"); + writer.print("Current Principal '"); Principal user = req.getUserPrincipal(); writer.print(user != null ? user.getName() : "NO AUTHENTICATED USER"); - writer.print("'"); - writer.println("

"); + writer.println("'

"); writer.println(" "); writer.println(""); } diff --git a/http-custom-mechanism/webapp/src/test/java/org/jboss/as/quickstart/http_custom_mechanism/BasicRuntimeIT.java b/http-custom-mechanism/webapp/src/test/java/org/jboss/as/quickstart/http_custom_mechanism/BasicRuntimeIT.java new file mode 100644 index 0000000000..4ccc6d5882 --- /dev/null +++ b/http-custom-mechanism/webapp/src/test/java/org/jboss/as/quickstart/http_custom_mechanism/BasicRuntimeIT.java @@ -0,0 +1,63 @@ +/* + * Copyright 2022 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.jboss.as.quickstart.http_custom_mechanism; + +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 java.util.logging.Logger; + +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/http-custom-mechanism-webapp"; + + @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+"/secured")) + .header("X-USERNAME", "quickstartUser") + .header("X-PASSWORD", "quickstartPwd1") + .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()); + Logger.getLogger(getClass().getName()).info("\n"+response.body()); + } +} diff --git a/shared-doc/add-application-and-management-users.adoc b/shared-doc/add-application-and-management-users.adoc index cf911acf79..7da5b3aca7 100644 --- a/shared-doc/add-application-and-management-users.adoc +++ b/shared-doc/add-application-and-management-users.adoc @@ -48,7 +48,4 @@ To add the application user, open a terminal and type the following command: $ __{jbossHomeName}__/bin/add-user.sh -a -u 'quickstartUser' -p 'quickstartPwd1!' {app-group-command} $ __{jbossHomeName}__/bin/add-user.sh -a -u 'quickstartAdmin' -p 'adminPwd1!' {admin-group-command} ---- -NOTE: For Windows, use the `__{jbossHomeName}__\bin\add-user.bat` script. - -If you prefer, you can use the `add-user` utility interactively. -For an example of how to use the add-user utility, see the instructions located here: link:{addApplicationUserDocUrl}[Add an Application User]. +NOTE: For Windows, use the `__{jbossHomeName}__\bin\add-user.bat` script. \ No newline at end of file diff --git a/shared-doc/add-application-user.adoc b/shared-doc/add-application-user.adoc index 406fc7e1d8..02529ddb2c 100644 --- a/shared-doc/add-application-user.adoc +++ b/shared-doc/add-application-user.adoc @@ -34,7 +34,4 @@ To add the application user, open a terminal and type the following command: ---- $ __{jbossHomeName}__/bin/add-user.sh -a -u 'quickstartUser' -p 'quickstartPwd1!' {app-group-command} ---- -NOTE: For Windows, use the `__{jbossHomeName}__\bin\add-user.bat` script. - -If you prefer, you can use the `add-user` utility interactively. -For an example of how to use the add-user utility, see the instructions located here: link:{addApplicationUserDocUrl}[Add an Application User]. +NOTE: For Windows, use the `__{jbossHomeName}__\bin\add-user.bat` script. \ No newline at end of file diff --git a/shared-doc/build-and-run-the-quickstart-with-provisioned-server.adoc b/shared-doc/build-and-run-the-quickstart-with-provisioned-server.adoc index 82119b6dbf..d35cd7d420 100644 --- a/shared-doc/build-and-run-the-quickstart-with-provisioned-server.adoc +++ b/shared-doc/build-and-run-the-quickstart-with-provisioned-server.adoc @@ -1,33 +1,37 @@ [[build_and_run_the_quickstart_with_provisioned_server]] = Building and running the quickstart application with provisioned {productName} server -Instead of using a standard {productName} server distribution, you can alternatively provision a {productName} server to deploy and run the quickstart, by activating the Maven profile named `provisioned-server` when building the quickstart: - ifndef::mavenServerProvisioningCommand[] ifeval::["{archiveType}"=="ear"] :mavenServerProvisioningCommand: clean install endif::[] - ifeval::["{archiveType}"=="war"] :mavenServerProvisioningCommand: clean package endif::[] - ifeval::["{archiveType}"=="jar"] :mavenServerProvisioningCommand: clean install endif::[] +endif::mavenServerProvisioningCommand[] + +ifndef::deploymentTargetDir[] +ifndef::deploymentDir[:deploymentTargetDir: target] +ifdef::deploymentDir[:deploymentTargetDir: {deploymentDir}/target] +endif::deploymentTargetDir[] + +Instead of using a standard {productName} server distribution, you can alternatively provision a {productName} server to deploy and run the quickstart, by activating the Maven profile named `provisioned-server` when building the quickstart: [source,subs="attributes+",options="nowrap"] ---- $ mvn {mavenServerProvisioningCommand} -Pprovisioned-server ---- -The provisioned {productName} server, with the quickstart deployed, can then be found in the `target/server` directory, and its usage is similar to a standard server distribution, with the simplification that there is never the need to specify the server configuration to be started. +The provisioned {productName} server, with the quickstart deployed, can then be found in the `{deploymentTargetDir}/server` directory, and its usage is similar to a standard server distribution, with the simplification that there is never the need to specify the server configuration to be started. ifdef::addQuickstartUser[] The quickstart user should be added before running the provisioned server: [source,subs="+quotes,attributes+",options="nowrap"] ---- -$ target/server/bin/add-user.sh -a -u 'quickstartUser' -p 'quickstartPwd1!' {app-group-command} +$ {deploymentTargetDir}/server/bin/add-user.sh -a -u 'quickstartUser' -p 'quickstartPwd1!' {app-group-command} ---- [NOTE] ==== @@ -39,7 +43,7 @@ ifdef::addQuickstartAdmin[] The quickstart admin should be added before running the provisioned server: [source,subs="+quotes,attributes+",options="nowrap"] ---- -$ target/server/bin/add-user.sh -a -u 'quickstartAdmin' -p 'adminPwd1!' {admin-group-command} +$ {deploymentTargetDir}/server/bin/add-user.sh -a -u 'quickstartAdmin' -p 'adminPwd1!' {admin-group-command} ---- [NOTE] ==== diff --git a/shared-doc/run-integration-tests-with-provisioned-server.adoc b/shared-doc/run-integration-tests-with-provisioned-server.adoc index 2aaa9082b3..ebfe7da9f6 100644 --- a/shared-doc/run-integration-tests-with-provisioned-server.adoc +++ b/shared-doc/run-integration-tests-with-provisioned-server.adoc @@ -3,6 +3,27 @@ include::define-standalone-server-attributes.adoc[] +ifndef::mavenServerProvisioningCommand[] +ifeval::["{archiveType}"=="ear"] +:mavenServerProvisioningCommand: clean install +endif::[] +ifeval::["{archiveType}"=="war"] +:mavenServerProvisioningCommand: clean package +endif::[] +ifeval::["{archiveType}"=="jar"] +:mavenServerProvisioningCommand: clean install +endif::[] +endif::mavenServerProvisioningCommand[] + +ifndef::deploymentTargetDir[] +ifndef::deploymentDir[:deploymentTargetDir: target] +ifdef::deploymentDir[:deploymentTargetDir: {deploymentDir}/target] +endif::deploymentTargetDir[] + +ifndef::server_provisioning_server_host[] +:server_provisioning_server_host: http://localhost:8080 +endif::server_provisioning_server_host[] + The integration tests included with this quickstart, which verify that the quickstart runs correctly, may also be run with a provisioned server. Follow these steps to run the integration tests. @@ -11,22 +32,24 @@ Follow these steps to run the integration tests. + [source,subs="attributes+",options="nowrap"] ---- -$ mvn clean package -Pprovisioned-server +$ mvn {mavenServerProvisioningCommand} -Pprovisioned-server ---- ifdef::addQuickstartUser[] -Add the quickstart user: +. Add the quickstart user: ++ [source,subs="+quotes,attributes+",options="nowrap"] ---- -$ target/server/bin/add-user.sh -a -u 'quickstartUser' -p 'quickstartPwd1!' {app-group-command} +$ {deploymentTargetDir}/server/bin/add-user.sh -a -u 'quickstartUser' -p 'quickstartPwd1!' {app-group-command} ---- endif::[] ifdef::addQuickstartAdmin[] -Add the quickstart admin: +. Add the quickstart admin: ++ [source,subs="+quotes,attributes+",options="nowrap"] ---- -$ target/server/bin/add-user.sh -a -u 'quickstartAdmin' -p 'adminPwd1!' {admin-group-command} +$ {deploymentTargetDir}/server/bin/add-user.sh -a -u 'quickstartAdmin' -p 'adminPwd1!' {admin-group-command} ---- [NOTE] ==== @@ -34,17 +57,21 @@ For Windows, use the `__{jbossHomeName}__\bin\add-user.bat` script. ==== endif::[] - . Start the {productName} provisioned server, this time using the {productName} Maven Plugin, which is recommended for testing due to simpler automation. The path to the provisioned server should be specified using the `server.host` system property. + +ifndef::deploymentDir[] [source,subs="attributes+",options="nowrap"] ---- $ mvn wildfly:start -DjbossHome=target/server ---- +endif::[] +ifdef::deploymentDir[] +[source,subs="attributes+",options="nowrap"] +---- +$ mvn -f {deploymentDir}/pom.xml wildfly:start -DjbossHome={deploymentDir}/target/server +---- +endif::[] -ifndef::server_provisioning_server_host[] -:server_provisioning_server_host: http://localhost:8080 -endif::server_provisioning_server_host[] . Type the following command to run the `verify` goal with the `integration-testing` profile activated, and specifying the quickstart's URL using the `server.host` system property, which for a provisioned server by default is `{server_provisioning_server_host}`. + [source,subs="attributes+",options="nowrap"] @@ -54,7 +81,15 @@ $ mvn verify -Pintegration-testing -Dserver.host={server_provisioning_server_hos . Shutdown the {productName} provisioned server, this time using the {productName} Maven Plugin too. + -[source,options="nowrap"] +ifndef::deploymentDir[] +[source,subs="attributes+",options="nowrap"] ---- $ mvn wildfly:shutdown ----- \ No newline at end of file +---- +endif::[] +ifdef::deploymentDir[] +[source,subs="attributes+",options="nowrap"] +---- +$ mvn -f {deploymentDir}/pom.xml wildfly:shutdown +---- +endif::[] \ No newline at end of file