You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2023/03/29 12:42:18 UTC
[camel-quarkus] branch main updated (34bf4efd7d -> f6a6bc6f6c)
This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
from 34bf4efd7d Complete vertx-http test coverage #4658 (#4708)
new 19ca84d78e Upgrade to CXF test container quay.io/l2x6/calculator-ws:1.1
new f6a6bc6f6c Test CXF client with HTTP BASIC authentication #4705
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../cxf/soap/client/it/CxfSoapClientResource.java | 34 +++-
.../cxf/soap/client/it/CxfSoapClientRoutes.java | 20 +++
.../src/main/resources/application.properties | 6 +-
.../wsdl/BasicAuthCalculatorService.wsdl} | 42 ++---
.../src/main/resources/wsdl/CalculatorService.wsdl | 188 +++++++++++++++++----
.../cxf/soap/client/it/CxfClientTestResource.java | 11 +-
.../cxf/soap/client/it/CxfSoapClientTest.java | 57 +++++--
.../soap/wss/client/it/CxfSoapWssClientTest.java | 16 +-
.../wss/client/it/CxfWssClientTestResource.java | 2 +-
9 files changed, 279 insertions(+), 97 deletions(-)
copy integration-test-groups/cxf-soap/{cxf-soap-ws-security-client/src/main/resources/wsdl/WssCalculatorService.wsdl => cxf-soap-client/src/main/resources/wsdl/BasicAuthCalculatorService.wsdl} (54%)
[camel-quarkus] 01/02: Upgrade to CXF test container quay.io/l2x6/calculator-ws:1.1
Posted by pp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 19ca84d78e360dd7f181a1d62e6866f9c839d2b4
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Tue Mar 28 16:30:15 2023 +0200
Upgrade to CXF test container quay.io/l2x6/calculator-ws:1.1
---
.../cxf/soap/client/it/CxfSoapClientResource.java | 34 +++-
.../src/main/resources/wsdl/CalculatorService.wsdl | 188 +++++++++++++++++----
.../cxf/soap/client/it/CxfClientTestResource.java | 2 +-
.../cxf/soap/client/it/CxfSoapClientTest.java | 16 +-
.../soap/wss/client/it/CxfSoapWssClientTest.java | 16 +-
.../wss/client/it/CxfWssClientTestResource.java | 2 +-
6 files changed, 191 insertions(+), 67 deletions(-)
diff --git a/integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientResource.java b/integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientResource.java
index 66ccf1b1a2..0926c578f9 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientResource.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientResource.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.quarkus.component.cxf.soap.client.it;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.net.URI;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -29,7 +31,9 @@ import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
+import org.apache.camel.CamelExecutionException;
import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.cxf.common.message.CxfConstants;
import org.jboss.eap.quickstarts.wscalculator.calculator.Operands;
import org.jboss.eap.quickstarts.wscalculator.calculator.Result;
@@ -44,14 +48,28 @@ public class CxfSoapClientResource {
@POST
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.TEXT_PLAIN)
- public Response sendSimpleRequest(@QueryParam("a") int a,
- @QueryParam("b") int b, @QueryParam("endpointUri") String endpointUri) throws Exception {
- final String response = producerTemplate.requestBody(String.format("direct:%s", endpointUri), new int[] { a, b },
- String.class);
- return Response
- .created(new URI("https://camel.apache.org/"))
- .entity(response)
- .build();
+ public Response sendSimpleRequest(
+ @QueryParam("a") int a,
+ @QueryParam("b") int b,
+ @QueryParam("endpointUri") String endpointUri,
+ @QueryParam("operation") String operation) throws Exception {
+ try {
+ final String response = producerTemplate.requestBodyAndHeader(
+ String.format("direct:%s", endpointUri),
+ new int[] { a, b },
+ CxfConstants.OPERATION_NAME,
+ operation,
+ String.class);
+ return Response
+ .created(new URI("https://camel.apache.org/"))
+ .entity(response)
+ .build();
+ } catch (CamelExecutionException e) {
+ try (StringWriter stackTrace = new StringWriter(); PrintWriter out = new PrintWriter(stackTrace)) {
+ e.printStackTrace(out);
+ return Response.serverError().entity(stackTrace.toString()).build();
+ }
+ }
}
@Path("/simpleAddDataFormat")
diff --git a/integration-test-groups/cxf-soap/cxf-soap-client/src/main/resources/wsdl/CalculatorService.wsdl b/integration-test-groups/cxf-soap/cxf-soap-client/src/main/resources/wsdl/CalculatorService.wsdl
index 2b0be31507..43455b0449 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-client/src/main/resources/wsdl/CalculatorService.wsdl
+++ b/integration-test-groups/cxf-soap/cxf-soap-client/src/main/resources/wsdl/CalculatorService.wsdl
@@ -22,6 +22,18 @@
<xs:element name="add" type="tns:add"></xs:element>
+ <xs:element name="addArray" type="tns:addArray"></xs:element>
+
+ <xs:element name="addArrayResponse" type="tns:addArrayResponse"></xs:element>
+
+ <xs:element name="addList" type="tns:addList"></xs:element>
+
+ <xs:element name="addListResponse" type="tns:addListResponse"></xs:element>
+
+ <xs:element name="addNumberAndOperands" type="tns:addNumberAndOperands"></xs:element>
+
+ <xs:element name="addNumberAndOperandsResponse" type="tns:addNumberAndOperandsResponse"></xs:element>
+
<xs:element name="addOperands" type="tns:addOperands"></xs:element>
<xs:element name="addOperandsResponse" type="tns:addOperandsResponse"></xs:element>
@@ -40,27 +52,26 @@
<xs:element name="subtractResponse" type="tns:subtractResponse"></xs:element>
- <xs:complexType name="divide">
+ <xs:complexType name="add">
<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="divideResponse">
+ <xs:complexType name="addResponse">
<xs:sequence>
<xs:element name="return" type="xs:int"></xs:element>
</xs:sequence>
</xs:complexType>
- <xs:complexType name="add">
+ <xs:complexType name="addArray">
<xs:sequence>
- <xs:element name="arg0" type="xs:int"></xs:element>
- <xs:element name="arg1" type="xs:int"></xs:element>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="arg0" type="xs:int"></xs:element>
</xs:sequence>
</xs:complexType>
- <xs:complexType name="addResponse">
+ <xs:complexType name="addArrayResponse">
<xs:sequence>
<xs:element name="return" type="xs:int"></xs:element>
</xs:sequence>
@@ -79,9 +90,35 @@
</xs:sequence>
</xs:complexType>
- <xs:complexType name="addOperands">
+ <xs:complexType name="divide">
<xs:sequence>
- <xs:element minOccurs="0" name="arg0" type="tns:operands"></xs:element>
+ <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="divideResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:int"></xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="addList">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="arg0" type="xs:int"></xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="addListResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:int"></xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="addNumberAndOperands">
+ <xs:sequence>
+ <xs:element name="arg0" type="xs:int"></xs:element>
+ <xs:element minOccurs="0" name="arg1" type="tns:operands"></xs:element>
</xs:sequence>
</xs:complexType>
@@ -92,6 +129,18 @@
</xs:sequence>
</xs:complexType>
+ <xs:complexType name="addNumberAndOperandsResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:int"></xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="addOperands">
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0" type="tns:operands"></xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
<xs:complexType name="addOperandsResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="tns:result"></xs:element>
@@ -120,6 +169,42 @@
</xs:schema>
</wsdl:types>
+ <wsdl:message name="addListResponse">
+ <wsdl:part element="tns:addListResponse" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="addArray">
+ <wsdl:part element="tns:addArray" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="divide">
+ <wsdl:part element="tns:divide" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="addList">
+ <wsdl:part element="tns:addList" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="addOperandsResponse">
+ <wsdl:part element="tns:addOperandsResponse" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="addNumberAndOperands">
+ <wsdl:part element="tns:addNumberAndOperands" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="addNumberAndOperandsResponse">
+ <wsdl:part element="tns:addNumberAndOperandsResponse" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="addOperands">
+ <wsdl:part element="tns:addOperands" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="multiply">
+ <wsdl:part element="tns:multiply" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
<wsdl:message name="add">
<wsdl:part element="tns:add" name="parameters">
</wsdl:part>
@@ -144,41 +229,47 @@
<wsdl:part element="tns:divideResponse" name="parameters">
</wsdl:part>
</wsdl:message>
- <wsdl:message name="divide">
- <wsdl:part element="tns:divide" name="parameters">
- </wsdl:part>
- </wsdl:message>
- <wsdl:message name="addOperandsResponse">
- <wsdl:part element="tns:addOperandsResponse" name="parameters">
- </wsdl:part>
- </wsdl:message>
- <wsdl:message name="addOperands">
- <wsdl:part element="tns:addOperands" name="parameters">
- </wsdl:part>
- </wsdl:message>
- <wsdl:message name="multiply">
- <wsdl:part element="tns:multiply" name="parameters">
+ <wsdl:message name="addArrayResponse">
+ <wsdl:part element="tns:addArrayResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="CalculatorService">
- <wsdl:operation name="divide">
- <wsdl:input message="tns:divide" name="divide">
- </wsdl:input>
- <wsdl:output message="tns:divideResponse" name="divideResponse">
- </wsdl:output>
- </wsdl:operation>
<wsdl:operation name="add">
<wsdl:input message="tns:add" name="add">
</wsdl:input>
<wsdl:output message="tns:addResponse" name="addResponse">
</wsdl:output>
</wsdl:operation>
+ <wsdl:operation name="addArray">
+ <wsdl:input message="tns:addArray" name="addArray">
+ </wsdl:input>
+ <wsdl:output message="tns:addArrayResponse" name="addArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
<wsdl:operation name="subtract">
<wsdl:input message="tns:subtract" name="subtract">
</wsdl:input>
<wsdl:output message="tns:subtractResponse" name="subtractResponse">
</wsdl:output>
</wsdl:operation>
+ <wsdl:operation name="divide">
+ <wsdl:input message="tns:divide" name="divide">
+ </wsdl:input>
+ <wsdl:output message="tns:divideResponse" name="divideResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="addList">
+ <wsdl:input message="tns:addList" name="addList">
+ </wsdl:input>
+ <wsdl:output message="tns:addListResponse" name="addListResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="addNumberAndOperands">
+ <wsdl:input message="tns:addNumberAndOperands" name="addNumberAndOperands">
+ </wsdl:input>
+ <wsdl:output message="tns:addNumberAndOperandsResponse" name="addNumberAndOperandsResponse">
+ </wsdl:output>
+ </wsdl:operation>
<wsdl:operation name="addOperands">
<wsdl:input message="tns:addOperands" name="addOperands">
</wsdl:input>
@@ -194,21 +285,21 @@
</wsdl:portType>
<wsdl:binding name="CalculatorServiceSoapBinding" type="tns:CalculatorService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"></soap:binding>
- <wsdl:operation name="divide">
+ <wsdl:operation name="add">
<soap:operation soapAction="" style="document"></soap:operation>
- <wsdl:input name="divide">
+ <wsdl:input name="add">
<soap:body use="literal"></soap:body>
</wsdl:input>
- <wsdl:output name="divideResponse">
+ <wsdl:output name="addResponse">
<soap:body use="literal"></soap:body>
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="add">
+ <wsdl:operation name="addArray">
<soap:operation soapAction="" style="document"></soap:operation>
- <wsdl:input name="add">
+ <wsdl:input name="addArray">
<soap:body use="literal"></soap:body>
</wsdl:input>
- <wsdl:output name="addResponse">
+ <wsdl:output name="addArrayResponse">
<soap:body use="literal"></soap:body>
</wsdl:output>
</wsdl:operation>
@@ -221,6 +312,33 @@
<soap:body use="literal"></soap:body>
</wsdl:output>
</wsdl:operation>
+ <wsdl:operation name="divide">
+ <soap:operation soapAction="" style="document"></soap:operation>
+ <wsdl:input name="divide">
+ <soap:body use="literal"></soap:body>
+ </wsdl:input>
+ <wsdl:output name="divideResponse">
+ <soap:body use="literal"></soap:body>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="addList">
+ <soap:operation soapAction="" style="document"></soap:operation>
+ <wsdl:input name="addList">
+ <soap:body use="literal"></soap:body>
+ </wsdl:input>
+ <wsdl:output name="addListResponse">
+ <soap:body use="literal"></soap:body>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="addNumberAndOperands">
+ <soap:operation soapAction="" style="document"></soap:operation>
+ <wsdl:input name="addNumberAndOperands">
+ <soap:body use="literal"></soap:body>
+ </wsdl:input>
+ <wsdl:output name="addNumberAndOperandsResponse">
+ <soap:body use="literal"></soap:body>
+ </wsdl:output>
+ </wsdl:operation>
<wsdl:operation name="addOperands">
<soap:operation soapAction="" style="document"></soap:operation>
<wsdl:input name="addOperands">
@@ -242,7 +360,7 @@
</wsdl:binding>
<wsdl:service name="CalculatorService">
<wsdl:port binding="tns:CalculatorServiceSoapBinding" name="Calculator">
- <soap:address location="http://172.17.0.4:8080/calculator-ws/CalculatorService"></soap:address>
+ <soap:address location="http://172.17.0.3:8080/calculator-ws/CalculatorService"></soap:address>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
\ No newline at end of file
diff --git a/integration-test-groups/cxf-soap/cxf-soap-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfClientTestResource.java b/integration-test-groups/cxf-soap/cxf-soap-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfClientTestResource.java
index d12d2c30ca..d8ff5eba2c 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfClientTestResource.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfClientTestResource.java
@@ -36,7 +36,7 @@ public class CxfClientTestResource implements QuarkusTestResourceLifecycleManage
public Map<String, String> start() {
try {
- calculatorContainer = new GenericContainer<>("quay.io/l2x6/calculator-ws:1.0")
+ calculatorContainer = new GenericContainer<>("quay.io/l2x6/calculator-ws:1.1")
.withExposedPorts(WILDFLY_PORT)
.withLogConsumer(new Slf4jLogConsumer(log))
.waitingFor(Wait.forHttp("/calculator-ws/CalculatorService?wsdl"));
diff --git a/integration-test-groups/cxf-soap/cxf-soap-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientTest.java b/integration-test-groups/cxf-soap/cxf-soap-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientTest.java
index 236c35295f..ad9d1cb0e4 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientTest.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.quarkus.component.cxf.soap.client.it;
import java.io.IOException;
-import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -30,6 +29,7 @@ import org.eclipse.microprofile.config.ConfigProvider;
import org.hamcrest.CoreMatchers;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
@@ -48,6 +48,7 @@ class CxfSoapClientTest {
.queryParam("a", "9")
.queryParam("b", "3")
.queryParam("endpointUri", endpointUri)
+ .queryParam("operation", "divide")
.post("/cxf-soap/client/simple")
.then()
.statusCode(201)
@@ -91,16 +92,9 @@ class CxfSoapClientTest {
.getValue("camel-quarkus.it.calculator.baseUri", String.class);
final String wsdlRelPath = "wsdl/CalculatorService.wsdl";
- final Path staticCopyPath = Paths.get("target/classes/" + wsdlRelPath);
- if (!Files.isRegularFile(staticCopyPath)) {
- /* The test is run inside Quarkus Platform
- * and the resource is not available in the filesystem
- * So let's copy it */
- Files.createDirectories(staticCopyPath.getParent());
- try (InputStream in = getClass().getClassLoader().getResourceAsStream(wsdlRelPath)) {
- Files.copy(in, staticCopyPath);
- }
- }
+ final Path staticCopyPath = Paths.get("src/main/resources/" + wsdlRelPath);
+ Assumptions.assumeTrue(Files.isRegularFile(staticCopyPath),
+ staticCopyPath + " does not exist - we probably run inside Quarkus Platform");
/* The changing Docker IP address in the WSDL should not matter */
final String sanitizerRegex = "<soap:address location=\"http://[^/]*/calculator-ws/CalculatorService\"></soap:address>";
diff --git a/integration-test-groups/cxf-soap/cxf-soap-ws-security-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/wss/client/it/CxfSoapWssClientTest.java b/integration-test-groups/cxf-soap/cxf-soap-ws-security-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/wss/client/it/CxfSoapWssClientTest.java
index ca35e586f8..24f0d3ced6 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-ws-security-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/wss/client/it/CxfSoapWssClientTest.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-ws-security-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/wss/client/it/CxfSoapWssClientTest.java
@@ -17,7 +17,6 @@
package org.apache.camel.quarkus.component.cxf.soap.wss.client.it;
import java.io.IOException;
-import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -28,6 +27,7 @@ import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import org.eclipse.microprofile.config.ConfigProvider;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import static org.hamcrest.Matchers.equalTo;
@@ -59,16 +59,10 @@ class CxfSoapWssClientTest {
.getValue("camel-quarkus.it.wss.client.baseUri", String.class);
final String wsdlRelPath = "wsdl/WssCalculatorService.wsdl";
- final Path staticCopyPath = Paths.get("target/classes/" + wsdlRelPath);
- if (!Files.isRegularFile(staticCopyPath)) {
- /* The test is run inside Quarkus Platform
- * and the resource is not available in the filesystem
- * So let's copy it */
- Files.createDirectories(staticCopyPath.getParent());
- try (InputStream in = getClass().getClassLoader().getResourceAsStream(wsdlRelPath)) {
- Files.copy(in, staticCopyPath);
- }
- }
+ final Path staticCopyPath = Paths.get("src/main/resources/" + wsdlRelPath);
+ Assumptions.assumeTrue(Files.isRegularFile(staticCopyPath),
+ staticCopyPath + " does not exist - we probably run inside Quarkus Platform");
+
/* The changing Docker IP address in the WSDL should not matter */
final String sanitizerRegex = "<soap:address location=\"http://[^/]*/calculator-ws/WssCalculatorService\"></soap:address>";
final String staticCopyContent = Files
diff --git a/integration-test-groups/cxf-soap/cxf-soap-ws-security-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/wss/client/it/CxfWssClientTestResource.java b/integration-test-groups/cxf-soap/cxf-soap-ws-security-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/wss/client/it/CxfWssClientTestResource.java
index 94412b124d..3e70613e19 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-ws-security-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/wss/client/it/CxfWssClientTestResource.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-ws-security-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/wss/client/it/CxfWssClientTestResource.java
@@ -40,7 +40,7 @@ public class CxfWssClientTestResource implements QuarkusTestResourceLifecycleMan
try {
try {
- calculatorContainer = new GenericContainer<>("quay.io/l2x6/calculator-ws:1.0")
+ calculatorContainer = new GenericContainer<>("quay.io/l2x6/calculator-ws:1.1")
.withEnv("WSS_USER", user)
.withEnv("WSS_PASSWORD", password)
.withLogConsumer(new Slf4jLogConsumer(log))
[camel-quarkus] 02/02: Test CXF client with HTTP BASIC authentication #4705
Posted by pp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit f6a6bc6f6c7f7da836995a250346777f9036f1eb
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Tue Mar 28 17:58:37 2023 +0200
Test CXF client with HTTP BASIC authentication #4705
---
.../cxf/soap/client/it/CxfSoapClientRoutes.java | 20 ++++++
.../src/main/resources/application.properties | 6 +-
.../resources/wsdl/BasicAuthCalculatorService.wsdl | 75 ++++++++++++++++++++++
.../cxf/soap/client/it/CxfClientTestResource.java | 9 ++-
.../cxf/soap/client/it/CxfSoapClientTest.java | 41 ++++++++++--
5 files changed, 142 insertions(+), 9 deletions(-)
diff --git a/integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientRoutes.java b/integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientRoutes.java
index bfd1ec1963..7b81ad4782 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientRoutes.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientRoutes.java
@@ -35,6 +35,7 @@ import org.apache.camel.component.cxf.common.message.CxfConstants;
import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
import org.apache.cxf.ext.logging.LoggingFeature;
import org.eclipse.microprofile.config.inject.ConfigProperty;
+import org.jboss.eap.quickstarts.wscalculator.basicauthcalculator.BasicAuthCalculatorService;
import org.jboss.eap.quickstarts.wscalculator.calculator.CalculatorService;
@ApplicationScoped
@@ -89,6 +90,13 @@ public class CxfSoapClientRoutes extends RouteBuilder {
from("direct:operandsAdd")
.setHeader(CxfConstants.OPERATION_NAME).constant("addOperands")
.to("cxf:bean:soapClientEndpoint?dataFormat=POJO");
+
+ from("direct:basicAuthAdd")
+ .to("cxf:bean:basicAuthClientEndpoint?dataFormat=POJO&username={{cq.cxf.it.calculator.auth.basic.user}}&password={{cq.cxf.it.calculator.auth.basic.password}}");
+
+ from("direct:basicAuthAddAnonymous")
+ .to("cxf:bean:basicAuthClientEndpoint?dataFormat=POJO");
+
}
@Produces
@@ -112,6 +120,18 @@ public class CxfSoapClientRoutes extends RouteBuilder {
return result;
}
+ @Produces
+ @SessionScoped
+ @Named
+ CxfEndpoint basicAuthClientEndpoint() {
+ final CxfEndpoint result = new CxfEndpoint();
+ result.setServiceClass(BasicAuthCalculatorService.class);
+ result.setAddress(serviceBaseUri + "/calculator-ws/BasicAuthCalculatorService");
+ result.setWsdlURL("wsdl/BasicAuthCalculatorService.wsdl");
+ result.getFeatures().add(loggingFeature);
+ return result;
+ }
+
private String calculatorServiceAddress() {
return serviceBaseUri + "/calculator-ws/CalculatorService";
}
diff --git a/integration-test-groups/cxf-soap/cxf-soap-client/src/main/resources/application.properties b/integration-test-groups/cxf-soap/cxf-soap-client/src/main/resources/application.properties
index 6657c53d3c..10af40d4a9 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-client/src/main/resources/application.properties
+++ b/integration-test-groups/cxf-soap/cxf-soap-client/src/main/resources/application.properties
@@ -20,5 +20,7 @@ quarkus.native.resources.includes = wsdl/*.wsdl
# disable the root config
quarkus.cxf.codegen.wsdl2java.includes = none.wsdl
# ... and do everything with named parameter sets so that it works in the grouped module
-quarkus.cxf.codegen.wsdl2java.client.includes = wsdl/CalculatorService.wsdl
-quarkus.cxf.codegen.wsdl2java.client.additional-params = -wsdlLocation,classpath:wsdl/CalculatorService.wsdl
+quarkus.cxf.codegen.wsdl2java.CalculatorService.includes = wsdl/CalculatorService.wsdl
+quarkus.cxf.codegen.wsdl2java.CalculatorService.additional-params = -wsdlLocation,classpath:wsdl/CalculatorService.wsdl
+quarkus.cxf.codegen.wsdl2java.BasicAuthCalculatorService.includes = wsdl/BasicAuthCalculatorService.wsdl
+quarkus.cxf.codegen.wsdl2java.BasicAuthCalculatorService.additional-params = -wsdlLocation,classpath:wsdl/BasicAuthCalculatorService.wsdl
diff --git a/integration-test-groups/cxf-soap/cxf-soap-client/src/main/resources/wsdl/BasicAuthCalculatorService.wsdl b/integration-test-groups/cxf-soap/cxf-soap-client/src/main/resources/wsdl/BasicAuthCalculatorService.wsdl
new file mode 100644
index 0000000000..10ffef8a1d
--- /dev/null
+++ b/integration-test-groups/cxf-soap/cxf-soap-client/src/main/resources/wsdl/BasicAuthCalculatorService.wsdl
@@ -0,0 +1,75 @@
+<?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/BasicAuthCalculator" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="BasicAuthCalculatorService" targetNamespace="http://www.jboss.org/eap/quickstarts/wscalculator/BasicAuthCalculator">
+<!--
+
+ 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.
+
+-->
+ <wsdl:types>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.jboss.org/eap/quickstarts/wscalculator/BasicAuthCalculator" elementFormDefault="unqualified" targetNamespace="http://www.jboss.org/eap/quickstarts/wscalculator/BasicAuthCalculator" version="1.0">
+
+ <xs:element name="securedAdd" type="tns:securedAdd"></xs:element>
+
+ <xs:element name="securedAddResponse" type="tns:securedAddResponse"></xs:element>
+
+ <xs:complexType name="securedAdd">
+ <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="securedAddResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:int"></xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+</xs:schema>
+ </wsdl:types>
+ <wsdl:message name="securedAddResponse">
+ <wsdl:part element="tns:securedAddResponse" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="securedAdd">
+ <wsdl:part element="tns:securedAdd" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="BasicAuthCalculatorService">
+ <wsdl:operation name="securedAdd">
+ <wsdl:input message="tns:securedAdd" name="securedAdd">
+ </wsdl:input>
+ <wsdl:output message="tns:securedAddResponse" name="securedAddResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="BasicAuthCalculatorServiceSoapBinding" type="tns:BasicAuthCalculatorService">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"></soap:binding>
+ <wsdl:operation name="securedAdd">
+ <soap:operation soapAction="" style="document"></soap:operation>
+ <wsdl:input name="securedAdd">
+ <soap:body use="literal"></soap:body>
+ </wsdl:input>
+ <wsdl:output name="securedAddResponse">
+ <soap:body use="literal"></soap:body>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="BasicAuthCalculatorService">
+ <wsdl:port binding="tns:BasicAuthCalculatorServiceSoapBinding" name="BasicAuthCalculator">
+ <soap:address location="http://192.168.122.1:8080/calculator-ws/BasicAuthCalculatorService"></soap:address>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
\ No newline at end of file
diff --git a/integration-test-groups/cxf-soap/cxf-soap-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfClientTestResource.java b/integration-test-groups/cxf-soap/cxf-soap-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfClientTestResource.java
index d8ff5eba2c..2d08a62502 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfClientTestResource.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfClientTestResource.java
@@ -18,6 +18,7 @@
package org.apache.camel.quarkus.component.cxf.soap.client.it;
import java.util.Map;
+import java.util.UUID;
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
import org.slf4j.Logger;
@@ -34,10 +35,14 @@ public class CxfClientTestResource implements QuarkusTestResourceLifecycleManage
@Override
public Map<String, String> start() {
+ final String BASIC_AUTH_USER = "tester";
+ final String BASIC_AUTH_PASSWORD = UUID.randomUUID().toString();
try {
calculatorContainer = new GenericContainer<>("quay.io/l2x6/calculator-ws:1.1")
.withExposedPorts(WILDFLY_PORT)
+ .withEnv("BASIC_AUTH_USER", BASIC_AUTH_USER)
+ .withEnv("BASIC_AUTH_PASSWORD", BASIC_AUTH_PASSWORD)
.withLogConsumer(new Slf4jLogConsumer(log))
.waitingFor(Wait.forHttp("/calculator-ws/CalculatorService?wsdl"));
@@ -46,7 +51,9 @@ public class CxfClientTestResource implements QuarkusTestResourceLifecycleManage
return Map.of(
"camel-quarkus.it.calculator.baseUri",
"http://" + calculatorContainer.getHost() + ":" +
- calculatorContainer.getMappedPort(WILDFLY_PORT));
+ calculatorContainer.getMappedPort(WILDFLY_PORT),
+ "cq.cxf.it.calculator.auth.basic.user", BASIC_AUTH_USER,
+ "cq.cxf.it.calculator.auth.basic.password", BASIC_AUTH_PASSWORD);
} catch (Exception e) {
throw new RuntimeException(e);
}
diff --git a/integration-test-groups/cxf-soap/cxf-soap-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientTest.java b/integration-test-groups/cxf-soap/cxf-soap-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientTest.java
index ad9d1cb0e4..f17e279f7c 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientTest.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientTest.java
@@ -34,6 +34,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
@QuarkusTest
@@ -81,23 +82,51 @@ class CxfSoapClientTest {
.body(equalTo("7"));
}
+ @Test
+ public void basicAuthClient() {
+ RestAssured.given()
+ .queryParam("a", "7")
+ .queryParam("b", "8")
+ .queryParam("endpointUri", "basicAuthAdd")
+ .queryParam("operation", "securedAdd")
+ .post("/cxf-soap/client/simple")
+ .then()
+ .statusCode(201)
+ .body(equalTo("15"));
+ }
+
+ @Test
+ public void basicAuthClientAnonymous() {
+ RestAssured.given()
+ .queryParam("a", "7")
+ .queryParam("b", "8")
+ .queryParam("endpointUri", "basicAuthAddAnonymous")
+ .queryParam("operation", "securedAdd")
+ .post("/cxf-soap/client/simple")
+ .then()
+ .statusCode(500)
+ .body(containsString("HTTP response '401: Unauthorized'"));
+ }
+
/**
- * Make sure that our static copy is the same as the WSDL served by the container
+ * Make sure that our static copies are the same as the WSDLs served by the container
*
* @throws IOException
*/
- @Test
- void wsdlUpToDate() throws IOException {
+ @ParameterizedTest
+ @ValueSource(strings = { "CalculatorService", "BasicAuthCalculatorService" })
+ void wsdlUpToDate(String serviceName) throws IOException {
final String wsdlUrl = ConfigProvider.getConfig()
.getValue("camel-quarkus.it.calculator.baseUri", String.class);
- final String wsdlRelPath = "wsdl/CalculatorService.wsdl";
+ final String wsdlRelPath = "wsdl/" + serviceName + ".wsdl";
final Path staticCopyPath = Paths.get("src/main/resources/" + wsdlRelPath);
Assumptions.assumeTrue(Files.isRegularFile(staticCopyPath),
staticCopyPath + " does not exist - we probably run inside Quarkus Platform");
/* The changing Docker IP address in the WSDL should not matter */
- final String sanitizerRegex = "<soap:address location=\"http://[^/]*/calculator-ws/CalculatorService\"></soap:address>";
+ final String sanitizerRegex = "<soap:address location=\"http://[^/]*/calculator-ws/" + serviceName
+ + "\"></soap:address>";
final String staticCopyContent = Files
.readString(staticCopyPath, StandardCharsets.UTF_8)
.replaceAll(sanitizerRegex, "")
@@ -107,7 +136,7 @@ class CxfSoapClientTest {
.replaceAll("\\s", "");
final String expected = RestAssured.given()
- .get(wsdlUrl + "/calculator-ws/CalculatorService?wsdl")
+ .get(wsdlUrl + "/calculator-ws/" + serviceName + "?wsdl")
.then()
.statusCode(200)
.extract().body().asString();