Skip to content

Commit

Permalink
Merge pull request #726 from PrarthonaPaul/ee-security-enhancement
Browse files Browse the repository at this point in the history
[WFLY-18463] ee-security Quickstart Common Enhancements CY2023Q3
  • Loading branch information
emmartins authored Oct 20, 2023
2 parents 05dce9a + 4e2ca0a commit eba0963
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 128 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/ee-security_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: WildFly ee-security Quickstart CI

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- 'ee-security/**'
- .github/workflows/quickstart_ci.yml

jobs:
call-quickstart_ci:
uses: ./.github/workflows/quickstart_ci.yml
with:
QUICKSTART_PATH: ee-security
TEST_PROVISIONED_SERVER: true
4 changes: 2 additions & 2 deletions ee-security/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ Identity as available from injection 'quickstartUser'

The resulting output shows authentication was successful and the correct identity has been established.

// 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]
// Restore the {productName} Standalone Server Configuration
Expand Down
91 changes: 27 additions & 64 deletions ee-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@
</licenses>

<properties>
<!-- The versions for BOMs, Dependencies and Plugins -->
<version.server.bom>30.0.0.Final</version.server.bom>
<!-- Version for the server -->
<version.server>30.0.0.Final</version.server>
<version.wildfly.maven.plugin>4.2.0.Final</version.wildfly.maven.plugin>
<version.cloud.fp>5.0.0.Final</version.cloud.fp>
<!-- The versions for BOMs, Packs and Plugins -->
<version.bom.ee>${version.server}</version.bom.ee>
<version.pack.cloud>5.0.0.Final</version.pack.cloud>
<version.plugin.wildfly>4.2.0.Final</version.plugin.wildfly>
</properties>

<repositories>
Expand Down Expand Up @@ -112,7 +113,7 @@
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>wildfly-ee-with-tools</artifactId>
<version>${version.server.bom}</version>
<version>${version.bom.ee}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -155,49 +156,40 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<!-- Optional, but highly recommended -->
<!-- Arquillian allows you to test enterprise code such as EJBs and Transactional(JTA)
JPA from JUnit/TestNG -->
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet-jakarta</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.plugin.wildfly}</version>
</plugin>
</plugins>
</pluginManagement>
</build>

<profiles>
<profile>
<id>provisioned-server</id>
<dependencies>
<dependency>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.wildfly.maven.plugin}</version>
<configuration>
<feature-packs>
<feature-pack>
<feature-pack>
<location>org.wildfly:wildfly-galleon-pack:${version.server}</location>
</feature-pack>
</feature-packs>
<layers>
<!-- layers may be used to customize the server to provision -->
<layer>cloud-server</layer>
</layers>
<runtimeName>ROOT.war</runtimeName>
<!-- deploys the quickstart on root web context -->
<name>ROOT.war</name>
<packaging-scripts>
<packaging-script>
<scripts>
Expand All @@ -215,30 +207,6 @@
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${version.failsafe.plugin}</version>
<configuration>
<environmentVariables>
<JBOSS_HOME>${project.build.directory}/server</JBOSS_HOME>
</environmentVariables>
<includes>
<include>**/ProvisionedManagedSecureIT</include>
</includes>
<excludes>
<exclude>**/RemoteSecureIT</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand All @@ -250,14 +218,13 @@
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.wildfly.maven.plugin}</version>
<configuration>
<feature-packs>
<feature-pack>
<feature-pack>
<location>org.wildfly:wildfly-galleon-pack:${version.server}</location>
</feature-pack>
<feature-pack>
<location>org.wildfly.cloud:wildfly-cloud-galleon-pack:${version.cloud.fp}</location>
<feature-pack>
<location>org.wildfly.cloud:wildfly-cloud-galleon-pack:${version.pack.cloud}</location>
</feature-pack>
</feature-packs>
<layers>
Expand Down Expand Up @@ -286,20 +253,16 @@
</build>
</profile>
<profile>
<id>arq-remote</id>
<id>integration-testing</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${version.failsafe.plugin}</version>
<configuration>
<includes>
<include>**/RemoteSecureIT</include>
<include>**/*IT</include>
</includes>
<excludes>
<exclude>**/ProvisionedManagedSecureIT</exclude>
</excludes>
</configuration>
<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,28 @@
*/
package org.jboss.as.quickstarts.ee_security;

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 org.junit.Assert;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
*
* @author Emmanuel Hugonnet (c) 2022 Red Hat, Inc.
*/
public class RemoteSecureIT {
public class BasicRuntimeIT {
private static final String DEFAULT_SERVER_HOST = "http://localhost:8080/ee-security";

protected URI getHTTPEndpoint() {
String host = getServerHost();
if (host == null) {
host = "http://localhost:8080/ee-security";
host = DEFAULT_SERVER_HOST;
}
try {
return new URI(host + "/secured");
Expand All @@ -56,23 +59,22 @@ protected static String getServerHost() {
}

@Test
public void testConnectOk() throws IOException, InterruptedException {
public void testHTTPEndpointIsAvailable() throws IOException, InterruptedException, URISyntaxException {
HttpRequest request = HttpRequest.newBuilder(getHTTPEndpoint())
.GET()
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
Assert.assertEquals(401, response.statusCode());
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
assertEquals(401, response.statusCode());
request = HttpRequest.newBuilder(getHTTPEndpoint())
.header("X-Username", "quickstartUser")
.header("X-Password", "quickstartPwd1!")
.GET()
.build();
response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
Assert.assertEquals(200, response.statusCode());
assertEquals(200, response.statusCode());
String[] lines = response.body().toString().split(System.lineSeparator());
Assert.assertEquals("SecuredServlet - doGet()", lines[0].trim());
Assert.assertEquals("Identity as available from SecurityContext 'quickstartUser'", lines[1].trim());
Assert.assertEquals("Identity as available from injection 'quickstartUser'", lines[2].trim());
assertEquals("SecuredServlet - doGet()", lines[0].trim());
assertEquals("Identity as available from SecurityContext 'quickstartUser'", lines[1].trim());
assertEquals("Identity as available from injection 'quickstartUser'", lines[2].trim());
}

}
}

This file was deleted.

0 comments on commit eba0963

Please sign in to comment.