Author: jim.ma
Date: 2015-03-09 04:50:21 -0400 (Mon, 09 Mar 2015)
New Revision: 19536
Added:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointImpl2.java
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/jaxws/samples/securityDomain/jboss-ejb3.xml
Modified:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpoint.java
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointImpl.java
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecurityDomainTestCase.java
Log:
Add more tests for [WFLY-2129][WFLY-3988][WFLY-4289]
Modified:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpoint.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpoint.java 2015-03-06
20:18:55 UTC (rev 19535)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpoint.java 2015-03-09
08:50:21 UTC (rev 19536)
@@ -21,6 +21,7 @@
*/
package org.jboss.test.ws.jaxws.samples.securityDomain;
+import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
@@ -37,7 +38,11 @@
@WebResult(targetNamespace = "http://org.jboss.ws/securityDomain", partName
= "return")
public String echoForAll(@WebParam(name = "arg0", partName =
"arg0") String arg0);
+ @Oneway
@WebMethod
+ public void helloOneWay(@WebParam(name = "arg0", partName =
"arg0")String arg0);
+
+ @WebMethod
@WebResult(targetNamespace = "http://org.jboss.ws/securityDomain", partName
= "return")
public String echo(@WebParam(name = "arg0", partName = "arg0")
String arg0);
@@ -45,4 +50,8 @@
@WebResult(targetNamespace = "http://org.jboss.ws/securityDomain", partName
= "return")
public String restrictedEcho(@WebParam(name = "arg0", partName =
"arg0") String arg0);
+ @WebMethod
+ @WebResult(targetNamespace = "http://org.jboss.ws/securityDomain", partName
= "return")
+ public String defaultAccess(@WebParam(name = "arg0", partName =
"arg0") String arg0);
+
}
Modified:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointImpl.java 2015-03-06
20:18:55 UTC (rev 19535)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointImpl.java 2015-03-09
08:50:21 UTC (rev 19536)
@@ -25,6 +25,7 @@
import javax.annotation.security.RolesAllowed;
import javax.annotation.security.PermitAll;
import javax.ejb.Stateless;
+import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
@@ -66,9 +67,14 @@
log.info(input);
return input;
}
-
@RolesAllowed("friend")
+ @Oneway
@WebMethod
+ public void helloOneWay(String input) {
+ log.info(input);
+ }
+ @RolesAllowed("friend")
+ @WebMethod
public String echo(String input)
{
log.info(input);
Added:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointImpl2.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointImpl2.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointImpl2.java 2015-03-09
08:50:21 UTC (rev 19536)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.securityDomain;
+
+import javax.annotation.security.DeclareRoles;
+import javax.annotation.security.RolesAllowed;
+import javax.annotation.security.PermitAll;
+import javax.ejb.Stateless;
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.Style;
+
+import org.jboss.ejb3.annotation.SecurityDomain;
+import org.jboss.logging.Logger;
+import org.jboss.ws.api.annotation.AuthMethod;
+import org.jboss.ws.api.annotation.TransportGuarantee;
+import org.jboss.ws.api.annotation.WebContext;
+
+@Stateless(name = "SecureEndpoint")
+@SOAPBinding(style = Style.RPC)
+@WebService
+(
+ name = "SecureEndpoint",
+ serviceName = "SecureEndpointService2",
+ targetNamespace = "http://org.jboss.ws/securityDomain"
+)
+@WebContext
+(
+ contextRoot="/jaxws-securityDomain2",
+ urlPattern="/authz",
+ authMethod = AuthMethod.BASIC,
+ transportGuarantee = TransportGuarantee.NONE,
+ secureWSDLAccess = false
+)
+@SecurityDomain("JBossWSSecurityDomainTest")
+public class SecureEndpointImpl2
+{
+ // Provide logging
+ private static Logger log = Logger.getLogger(SecureEndpointImpl2.class);
+
+ @WebMethod
+ @PermitAll
+ public String echoForAll(String input)
+ {
+ log.info(input);
+ return input;
+ }
+
+ @RolesAllowed("friend")
+ @WebMethod
+ public String echo(String input)
+ {
+ log.info(input);
+ return input;
+ }
+
+ @RolesAllowed("royal")
+ @WebMethod
+ public String restrictedEcho(String input)
+ {
+ log.info(input);
+ return input;
+ }
+
+ @WebMethod
+ public String defaultAccess(String input)
+ {
+ log.info(input);
+ return input;
+ }
+}
\ No newline at end of file
Property changes on:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointImpl2.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Modified:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecurityDomainTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecurityDomainTestCase.java 2015-03-06
20:18:55 UTC (rev 19535)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecurityDomainTestCase.java 2015-03-09
08:50:21 UTC (rev 19536)
@@ -21,19 +21,24 @@
*/
package org.jboss.test.ws.jaxws.samples.securityDomain;
+import java.io.File;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Service;
+import org.jboss.arquillian.container.test.api.Deployer;
import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OperateOnDeployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestHelper;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -51,14 +56,19 @@
*
* @author alessio.soldano(a)jboss.com
* @author <a href="mailto:richard.opalka@jboss.org">Richard
Opalka</a>
+ * @author <a href="mailto:ema@redhat.com">Jim Ma</a>
*/
@RunWith(Arquillian.class)
public class SecurityDomainTestCase extends JBossWSTest
{
+ private final static String DEPLOYMENT1 = "jaxws-samples-securityDomain";
+ private final static String DEPLOYMENT2 = "jaxws-samples-securityDomain2";
@ArquillianResource
private URL baseURL;
+ @ArquillianResource
+ Deployer deployer;
- @Deployment(name="jaxws-samples-securityDomain", testable = false)
+ @Deployment(name= DEPLOYMENT1, testable = false)
public static JavaArchive createDeployment() {
JavaArchive archive = ShrinkWrap.create(JavaArchive.class,
"jaxws-samples-securityDomain.jar");
archive
@@ -66,6 +76,15 @@
.addClass(org.jboss.test.ws.jaxws.samples.securityDomain.SecureEndpointImpl.class);
return archive;
}
+ @Deployment(name= DEPLOYMENT2, testable = false)
+ public static JavaArchive createDeployment2() {
+ JavaArchive archive = ShrinkWrap.create(JavaArchive.class,
"jaxws-samples-securityDomain2.jar");
+ archive
+ .addManifest()
+
.addClass(org.jboss.test.ws.jaxws.samples.securityDomain.SecureEndpointImpl2.class)
+ .addAsManifestResource(new File(JBossWSTestHelper.getTestResourcesDir() +
"/jaxws/samples/securityDomain/jboss-ejb3.xml"), "jboss-ejb3.xml");
+ return archive;
+ }
private SecureEndpoint getAuthzPort() throws Exception
{
@@ -76,6 +95,7 @@
@Test
@RunAsClient
+ @OperateOnDeployment(DEPLOYMENT1)
public void testUnauthenticated() throws Exception
{
SecureEndpoint port1 = getAuthzPort();
@@ -110,9 +130,18 @@
@Test
@RunAsClient
+ @OperateOnDeployment(DEPLOYMENT1)
public void testUnauthorized() throws Exception
{
SecureEndpoint port2 = getAuthzPort();
+ try {
+ port2.restrictedEcho("Hello");
+ fail("Authentication exception expected!");
+ } catch (Exception e) {
+ //expected web layer exception
+ assertTrue(e.getMessage().contains("Could not send Message"));
+ assertTrue("Exception Cause message: " + e.getCause().getMessage(),
e.getCause().getMessage().contains("401: Unauthorized"));
+ }
((BindingProvider)port2).getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
"john");
((BindingProvider)port2).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
"bar");
try {
@@ -123,9 +152,12 @@
assertTrue("Exception message: " + e.getMessage(),
e.getMessage().contains("not allowed"));
}
}
+
+
@Test
@RunAsClient
+ @OperateOnDeployment(DEPLOYMENT1)
public void testAuthorizedAccess() throws Exception
{
SecureEndpoint port = getAuthzPort();
@@ -144,6 +176,7 @@
@Test
@RunAsClient
+ @OperateOnDeployment(DEPLOYMENT1)
public void testUndeclaredRole() throws Exception
{
SecureEndpoint port = getAuthzPort();
@@ -174,5 +207,74 @@
assertTrue("Exception Cause message: " + e.getCause().getMessage(),
e.getCause().getMessage().contains("403: Forbidden"));
}
}
+ @Test
+ @RunAsClient
+ @OperateOnDeployment(DEPLOYMENT1)
+ @Ignore(value="Wait for [WFLY-2129][WFLY-3988] merge")
+ public void testOneWay() throws Exception
+ {
+ //test unthenticated
+ SecureEndpoint port2 = getAuthzPort();
+ try
+ {
+ port2.helloOneWay("Hello");
+ fail("Authentication exception expected!");
+ }
+ catch (Exception e)
+ {
+ //expected web layer exception
+ assertTrue(e.getMessage().contains("Could not send Message"));
+ assertTrue("Exception Cause message: " + e.getCause().getMessage(),
e.getCause().getMessage().contains("401: Unauthorized"));
+ }
+ ((BindingProvider)port2).getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
"bob");
+ ((BindingProvider)port2).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
"foo");
+ try {
+ port2.helloOneWay("Hello");
+ fail("Authorization exception expected!");
+ } catch (Exception e) {
+ //expected weblayer layer authorization exception
+ assertTrue("Unexpected cause: " + e.getCause().getMessage(),
e.getCause().getMessage().contains("403: Forbidden"));
+ }
+
+ ((BindingProvider)port2).getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
"john");
+ ((BindingProvider)port2).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
"bar");
+ port2.helloOneWay("Hello");
+ }
+
+ @Test
+ @RunAsClient
+ @OperateOnDeployment(DEPLOYMENT2)
+ @Ignore(value="Wait for [WFLY-2129][WFLY-3988] merge")
+ public void testEjbSecurityAuth() throws Exception
+ {
+ URL wsdlURL = new URL(baseURL + "/jaxws-securityDomain2/authz?wsdl");
+ QName serviceName = new QName("http://org.jboss.ws/securityDomain",
"SecureEndpointService2");
+ SecureEndpoint port = Service.create(wsdlURL,
serviceName).getPort(SecureEndpoint.class);
+ try {
+ port.echoForAll("Hello");
+ fail("Authorization exception expected!");
+ } catch (Exception e) {
+ //expected web layer exception
+ assertTrue(e.getMessage().contains("Could not send Message"));
+ assertTrue("Exception Cause message: " + e.getCause().getMessage(),
e.getCause().getMessage().contains("401: Unauthorized"));
+ }
+ ((BindingProvider)port).getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
"bob");
+ ((BindingProvider)port).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
"foo");
+ port.echoForAll("Hello");
+ try {
+ port.restrictedEcho("Hello");
+ fail("Authorization exception expected!");
+ } catch (Exception e) {
+ //expected EJB3 layer authorization exception
+ assertTrue("Exception message: " + e.getMessage(),
e.getMessage().contains("not allowed"));
+ }
+
+ ((BindingProvider)port).getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
"kate");
+ ((BindingProvider)port).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
"theprincess");
+ assertEquals("Greetings", port.echoForAll("Greetings"));
+ assertEquals("Greetings", port.echo("Greetings"));
+ assertEquals("Greetings", port.restrictedEcho("Greetings"));
+ assertEquals("Greetings", port.defaultAccess("Greetings"));
+ }
}
\ No newline at end of file
Added:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/jaxws/samples/securityDomain/jboss-ejb3.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/jaxws/samples/securityDomain/jboss-ejb3.xml
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/jaxws/samples/securityDomain/jboss-ejb3.xml 2015-03-09
08:50:21 UTC (rev 19536)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jboss:jboss
+
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:jboss="http://www.jboss.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:s="urn:security:1.1"
+ version="3.1" impl-version="2.0">
+ <assembly-descriptor>
+ <s:security>
+ <ejb-name>*</ejb-name>
+
<s:missing-method-permissions-deny-access>false</s:missing-method-permissions-deny-access>
+ </s:security>
+ </assembly-descriptor>
+</jboss:jboss>
+
+
\ No newline at end of file
Property changes on:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/jaxws/samples/securityDomain/jboss-ejb3.xml
___________________________________________________________________
Added: svn:mime-type
+ text/xml
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native