Skip to content

Commit

Permalink
[WFLY-18481] http-custom-mechanism Quickstart Common Enhancements CY2…
Browse files Browse the repository at this point in the history
…023Q3
  • Loading branch information
Prarthona Paul committed Oct 24, 2023
1 parent 0c88976 commit 38bddaf
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 5 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/quickstart_http-custom-mechanism_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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
TEST_PROVISIONED_SERVER: true
TEST_OPENSHIFT: false
5 changes: 5 additions & 0 deletions http-custom-mechanism/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@ Enter `clean package wildfly:deploy` for the *Goals* and click *Run*. This deplo
// 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
//*************************************************
Expand Down
2 changes: 1 addition & 1 deletion http-custom-mechanism/configure-elytron.cli
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
batch

# Add the resource to discover the factory implementation for the custom module.
/subsystem=elytron/service-loader-http-server-mechanism-factory=custom-factory:add(module=org.jboss.as.quickstart.http_custom_mechanism.custom-http-mechanism)
/subsystem=elytron/service-loader-http-server-mechanism-factory=custom-factory:add(module=org.jboss.as.quickstart.http_custom_mechanism)

# Add an `http-authentication-factory` to the mechanism factory to a `security-domain` that will be used for the authentication.
/subsystem=elytron/http-authentication-factory=custom-mechanism:add(http-server-mechanism-factory=custom-factory,security-domain=ApplicationDomain,mechanism-configurations=[{mechanism-name=CUSTOM_MECHANISM}])
Expand Down
78 changes: 74 additions & 4 deletions http-custom-mechanism/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@
</modules>

<properties>
<!-- The versions for BOMs, Dependencies and Plugins -->
<version.server.bom>30.0.0.Final</version.server.bom>
<!-- the version for the Server -->
<version.server>30.0.0.Final</version.server>
<!-- 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 @@ -114,7 +118,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 @@ -150,8 +154,74 @@
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.plugin.wildfly}</version>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>provisioned-server</id>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<feature-packs>
<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>
<!-- deploys the quickstart on root web context -->
<name>ROOT.war</name>
<packaging-scripts>
<packaging-script>
<scripts>
<script>${basedir}/configure-elytron.cli</script>
</scripts>
<!-- Expressions resolved during server execution -->
<resolve-expressions>false</resolve-expressions>
</packaging-script>
</packaging-scripts>
</configuration>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>integration-testing</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<includes>
<include>**/BasicRuntimeIT</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* 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.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.Base64;

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 auth = Base64.getEncoder().encodeToString(("quickstartUser" + ":" + "quickstartPwd1!").getBytes(StandardCharsets.UTF_8));

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("Authorization", "Basic " + auth)
.GET()
.build();
final HttpClient client = HttpClient.newBuilder()
.followRedirects(HttpClient.Redirect.ALWAYS)
.connectTimeout(Duration.ofMinutes(1))
.build();
final HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
assertEquals(200, response.statusCode());
}
}

0 comments on commit 38bddaf

Please sign in to comment.