forked from quarkiverse/quarkus-cxf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test WS Security client quarkiverse#498
- Loading branch information
Showing
10 changed files
with
442 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
= Quarkus CXF client tests | ||
|
||
These are pure client tests - i.e. there are intentionally no services implemented in the test application. | ||
All clients access services running in containers. | ||
|
||
== Maintenenance notes | ||
|
||
=== `CalculatorService.wsdl` | ||
|
||
`src/main/cxf-codegen-resources/wsdl/CalculatorService.wsdl` is a static copy of the WSDL served by the testing container. | ||
It is used solely by `cxf-codegen-plugin`. | ||
It would be too complicated to start the container before running the plugin, so we rather keep the static copy. | ||
|
||
There is `io.quarkiverse.cxf.client.it.CxfClientTest.wsdlUpToDate()` to ensure that it is up to date. | ||
|
||
To update `CalculatorService.wsdl` manually, first start the container | ||
|
||
[shource,shell] | ||
---- | ||
$ docker pull quay.io/l2x6/calculator-ws:1.0 | ||
$ docker run -p 8080:8080 quay.io/l2x6/calculator-ws:1.0 | ||
---- | ||
|
||
And then overwrite the existing file with the new content from the container: | ||
|
||
[shource,shell] | ||
---- | ||
curl http://localhost:8080/calculator-ws/CalculatorService?wsdl --output src/main/cxf-codegen-resources/wsdl/CalculatorService.wsdl | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.quarkiverse.cxf</groupId> | ||
<artifactId>quarkus-cxf-integration-tests</artifactId> | ||
<version>1.5.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>quarkus-cxf-integration-test-ws-security-client</artifactId> | ||
|
||
<name>Quarkus CXF Extension - Integration Test - WS Security Client</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkiverse.cxf</groupId> | ||
<artifactId>quarkus-cxf</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkiverse.cxf</groupId> | ||
<artifactId>quarkus-cxf-rt-ws-security</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.rest-assured</groupId> | ||
<artifactId>rest-assured</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>testcontainers</artifactId> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit4-mock</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.cxf</groupId> | ||
<artifactId>cxf-codegen-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>wsdl2java</goal> | ||
</goals> | ||
<configuration> | ||
<wsdlOptions> | ||
<wsdlOption> | ||
<wsdl>${basedir}/src/main/cxf-codegen-resources/wsdl/WssCalculatorService.wsdl</wsdl> | ||
</wsdlOption> | ||
</wsdlOptions> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>native</id> | ||
<activation> | ||
<activeByDefault>false</activeByDefault> | ||
</activation> | ||
<properties> | ||
<quarkus.package.type>native</quarkus.package.type> | ||
<quarkus.native.report-errors-at-runtime>true</quarkus.native.report-errors-at-runtime> | ||
</properties> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
<configuration> | ||
<systemProperties> | ||
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> | ||
</systemProperties> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
|
||
</project> |
57 changes: 57 additions & 0 deletions
57
...on-tests/ws-security-client/src/main/cxf-codegen-resources/wsdl/WssCalculatorService.wsdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?xml version="1.0" ?><wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://www.jboss.org/eap/quickstarts/wscalculator/WssCalculator" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="WssCalculatorService" targetNamespace="http://www.jboss.org/eap/quickstarts/wscalculator/WssCalculator"> | ||
<wsdl:types> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.jboss.org/eap/quickstarts/wscalculator/WssCalculator" elementFormDefault="unqualified" targetNamespace="http://www.jboss.org/eap/quickstarts/wscalculator/WssCalculator" version="1.0"> | ||
|
||
<xs:element name="modulo" type="tns:modulo"></xs:element> | ||
|
||
<xs:element name="moduloResponse" type="tns:moduloResponse"></xs:element> | ||
|
||
<xs:complexType name="modulo"> | ||
<xs:sequence> | ||
<xs:element name="arg0" type="xs:int"></xs:element> | ||
<xs:element name="arg1" type="xs:int"></xs:element> | ||
</xs:sequence> | ||
</xs:complexType> | ||
|
||
<xs:complexType name="moduloResponse"> | ||
<xs:sequence> | ||
<xs:element name="return" type="xs:int"></xs:element> | ||
</xs:sequence> | ||
</xs:complexType> | ||
|
||
</xs:schema> | ||
</wsdl:types> | ||
<wsdl:message name="moduloResponse"> | ||
<wsdl:part element="tns:moduloResponse" name="parameters"> | ||
</wsdl:part> | ||
</wsdl:message> | ||
<wsdl:message name="modulo"> | ||
<wsdl:part element="tns:modulo" name="parameters"> | ||
</wsdl:part> | ||
</wsdl:message> | ||
<wsdl:portType name="WssCalculatorService"> | ||
<wsdl:operation name="modulo"> | ||
<wsdl:input message="tns:modulo" name="modulo"> | ||
</wsdl:input> | ||
<wsdl:output message="tns:moduloResponse" name="moduloResponse"> | ||
</wsdl:output> | ||
</wsdl:operation> | ||
</wsdl:portType> | ||
<wsdl:binding name="WssCalculatorServiceSoapBinding" type="tns:WssCalculatorService"> | ||
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"></soap:binding> | ||
<wsdl:operation name="modulo"> | ||
<soap:operation soapAction="" style="document"></soap:operation> | ||
<wsdl:input name="modulo"> | ||
<soap:body use="literal"></soap:body> | ||
</wsdl:input> | ||
<wsdl:output name="moduloResponse"> | ||
<soap:body use="literal"></soap:body> | ||
</wsdl:output> | ||
</wsdl:operation> | ||
</wsdl:binding> | ||
<wsdl:service name="WssCalculatorService"> | ||
<wsdl:port binding="tns:WssCalculatorServiceSoapBinding" name="WssCalculator"> | ||
<soap:address location="http://localhost:8080/calculator-ws/WssCalculatorService"></soap:address> | ||
</wsdl:port> | ||
</wsdl:service> | ||
</wsdl:definitions> |
28 changes: 28 additions & 0 deletions
28
...-security-client/src/main/java/io/quarkiverse/cxf/it/wss/client/CxfWssClientResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.quarkiverse.cxf.it.wss.client; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.QueryParam; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.jboss.eap.quickstarts.wscalculator.wsscalculator.WssCalculatorService; | ||
|
||
import io.quarkiverse.cxf.annotation.CXFClient; | ||
|
||
@Path("/cxf/wss-client") | ||
public class CxfWssClientResource { | ||
|
||
@Inject | ||
@CXFClient("wss-client") // name used in application.properties | ||
WssCalculatorService calculator; | ||
|
||
@GET | ||
@Path("/calculator/modulo") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public int modulo(@QueryParam("a") int a, @QueryParam("b") int b) { | ||
return calculator.modulo(a, b); | ||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
...ty-client/src/main/java/io/quarkiverse/cxf/it/wss/client/WSS4JOutInterceptorProducer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package io.quarkiverse.cxf.it.wss.client; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.inject.Produces; | ||
import javax.security.auth.callback.Callback; | ||
import javax.security.auth.callback.CallbackHandler; | ||
import javax.security.auth.callback.UnsupportedCallbackException; | ||
|
||
import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; | ||
import org.apache.wss4j.common.ConfigurationConstants; | ||
import org.apache.wss4j.common.ext.WSPasswordCallback; | ||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
|
||
import io.quarkus.arc.Unremovable; | ||
|
||
@ApplicationScoped | ||
public class WSS4JOutInterceptorProducer { | ||
|
||
/** Produced in CxfWssClientTestResource */ | ||
@ConfigProperty(name = "wss.username") | ||
String username; | ||
|
||
/** Produced in CxfWssClientTestResource */ | ||
@ConfigProperty(name = "wss.password") | ||
String password; | ||
|
||
@Produces | ||
@Unremovable | ||
@ApplicationScoped | ||
WSS4JOutInterceptor wssInterceptor() { | ||
|
||
final CallbackHandler passwordCallback = new CallbackHandler() { | ||
@Override | ||
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { | ||
for (Callback callback : callbacks) { | ||
if (callback instanceof WSPasswordCallback) { | ||
((WSPasswordCallback) callback).setPassword(password); | ||
break; | ||
} | ||
} | ||
} | ||
}; | ||
|
||
final Map<String, Object> props = new HashMap<>(); | ||
props.put(ConfigurationConstants.ACTION, "UsernameToken"); | ||
props.put(ConfigurationConstants.PASSWORD_TYPE, "PasswordText"); | ||
props.put(ConfigurationConstants.USER, username); | ||
props.put(ConfigurationConstants.PW_CALLBACK_REF, passwordCallback); | ||
props.put(ConfigurationConstants.ADD_USERNAMETOKEN_NONCE, "true"); | ||
props.put(ConfigurationConstants.ADD_USERNAMETOKEN_CREATED, "true"); | ||
return new WSS4JOutInterceptor(props); | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
integration-tests/ws-security-client/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
quarkus.cxf.client."wss-client".wsdl=${cxf.it.calculator.baseUri}/calculator-ws/WssCalculatorService?wsdl | ||
quarkus.cxf.client."wss-client".client-endpoint-url=${cxf.it.calculator.baseUri}/calculator-ws/WssCalculatorService | ||
quarkus.cxf.client."wss-client".service-interface=org.jboss.as.quickstarts.wsscalculator.WssCalculatorService | ||
quarkus.cxf.client."wss-client".endpoint-namespace=http://www.jboss.org/eap/quickstarts/wscalculator/WssCalculator | ||
quarkus.cxf.client."wss-client".endpoint-name=WssCalculator | ||
quarkus.cxf.client."wss-client".out-interceptors=org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor |
8 changes: 8 additions & 0 deletions
8
...sts/ws-security-client/src/test/java/io/quarkiverse/cxf/it/wss/client/CxfWssClientIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.quarkiverse.cxf.it.wss.client; | ||
|
||
import io.quarkus.test.junit.QuarkusIntegrationTest; | ||
|
||
@QuarkusIntegrationTest | ||
public class CxfWssClientIT extends CxfWssClientTest { | ||
|
||
} |
Oops, something went wrong.