You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2018/03/22 12:50:47 UTC
[cxf] 01/02: CXF-7687 - Adding a test
This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a commit to branch 3.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 478d77704b0a035cf5ee5efbf4bd263f8467eaf4
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Thu Mar 22 12:46:15 2018 +0000
CXF-7687 - Adding a test
(cherry picked from commit 535dae33d115154fff71761306ae28b61b187ee5)
---
.../cxf/systest/ws/basicauth/BasicAuthTest.java | 35 ++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/basicauth/BasicAuthTest.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/basicauth/BasicAuthTest.java
index 0dceda6..a8621bf 100644
--- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/basicauth/BasicAuthTest.java
+++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/basicauth/BasicAuthTest.java
@@ -26,8 +26,12 @@ import javax.xml.ws.Service;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.configuration.security.AuthorizationPolicy;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.systest.ws.common.SecurityTestUtil;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.transport.http.HTTPConduit;
import org.example.contract.doubleit.DoubleItPortType;
import org.junit.BeforeClass;
@@ -83,6 +87,37 @@ public class BasicAuthTest extends AbstractBusClientServerTestBase {
}
@org.junit.Test
+ public void testBasicAuthViaAuthorizationPolicy() throws Exception {
+
+ SpringBusFactory bf = new SpringBusFactory();
+ URL busFile = BasicAuthTest.class.getResource("client.xml");
+
+ Bus bus = bf.createBus(busFile.toString());
+ BusFactory.setDefaultBus(bus);
+ BusFactory.setThreadDefaultBus(bus);
+
+ URL wsdl = BasicAuthTest.class.getResource("DoubleItBasicAuth.wsdl");
+ Service service = Service.create(wsdl, SERVICE_QNAME);
+ QName portQName = new QName(NAMESPACE, "DoubleItBasicAuthPort2");
+ DoubleItPortType utPort =
+ service.getPort(portQName, DoubleItPortType.class);
+ updateAddressPort(utPort, PORT);
+
+ Client client = ClientProxy.getClient(utPort);
+ HTTPConduit http = (HTTPConduit) client.getConduit();
+ AuthorizationPolicy authorizationPolicy = new AuthorizationPolicy();
+ authorizationPolicy.setUserName("Alice");
+ authorizationPolicy.setPassword("ecilA");
+ authorizationPolicy.setAuthorizationType("Basic");
+ http.setAuthorization(authorizationPolicy);
+
+ assertEquals(50, utPort.doubleIt(25));
+
+ ((java.io.Closeable)utPort).close();
+ bus.shutdown(true);
+ }
+
+ @org.junit.Test
public void testNoBasicAuthCredentials() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
--
To stop receiving notification emails like this one, please contact
coheigea@apache.org.