Author: rsearls
Date: 2015-01-03 16:46:18 -0500 (Sat, 03 Jan 2015)
New Revision: 19318
Modified:
stack/cxf/branches/arquillian/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/PermitAllTestCase.java
stack/cxf/branches/arquillian/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecurityDomainTestCase.java
Log:
arquillian migration securityDomain test
Modified:
stack/cxf/branches/arquillian/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/PermitAllTestCase.java
===================================================================
---
stack/cxf/branches/arquillian/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/PermitAllTestCase.java 2015-01-03
21:28:08 UTC (rev 19317)
+++
stack/cxf/branches/arquillian/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/PermitAllTestCase.java 2015-01-03
21:46:18 UTC (rev 19318)
@@ -31,7 +31,15 @@
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Service;
-import junit.framework.Test;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.jboss.arquillian.container.test.api.Deployment;
+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.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.wsf.test.JBossWSTest;
import org.jboss.wsf.test.JBossWSTestHelper;
@@ -53,38 +61,27 @@
* @author alessio.soldano(a)jboss.com
*
*/
+(a)RunWith(Arquillian.class)
public class PermitAllTestCase extends JBossWSTest
{
- public final String TARGET_ENDPOINT_ADDRESS_1 = "http://" + getServerHost()
+ ":8080/jaxws-securityDomain-permitall/one";
- public final String TARGET_ENDPOINT_ADDRESS_2 = "http://" + getServerHost()
+ ":8080/jaxws-securityDomain-permitall/two";
+ @ArquillianResource
+ private URL baseURL;
- public static BaseDeployment<?>[] createDeployments() {
- List<BaseDeployment<?>> list = new
LinkedList<BaseDeployment<?>>();
- list.add(new
JBossWSTestHelper.JarDeployment("jaxws-samples-securityDomain-permitall.jar") {
{
+ @Deployment(name="jaxws-samples-securityDomain-permitall", testable =
false)
+ public static JavaArchive createDeployment() {
+ JavaArchive archive = ShrinkWrap.create(JavaArchive.class,
"jaxws-samples-securityDomain-permitall.jar");
archive
.addManifest()
.addClass(org.jboss.test.ws.jaxws.samples.securityDomain.PermitAllSecureEndpoint1Impl.class)
.addClass(org.jboss.test.ws.jaxws.samples.securityDomain.PermitAllSecureEndpoint2Impl.class);
- }
- });
- return list.toArray(new BaseDeployment<?>[list.size()]);
+ return archive;
}
- public static Test suite()
- {
- JBossWSTestSetup testSetup = new JBossWSTestSetup(PermitAllTestCase.class,
JBossWSTestHelper.writeToFile(createDeployments()));
- Map<String, String> authenticationOptions = new HashMap<String,
String>();
- authenticationOptions.put("usersProperties",
-
getResourceFile("jaxws/samples/securityDomain/jbossws-users.properties").getAbsolutePath());
- authenticationOptions.put("rolesProperties",
-
getResourceFile("jaxws/samples/securityDomain/jbossws-roles.properties").getAbsolutePath());
-
testSetup.addSecurityDomainRequirement("JBossWSSecurityDomainPermitAllTest",
authenticationOptions);
- return testSetup;
- }
-
+ @Test
+ @RunAsClient
public void testPortOne() throws Exception
{
- URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS_1 + "?wsdl");
+ URL wsdlURL = new URL(baseURL + "/jaxws-securityDomain-permitall/one" +
"?wsdl");
QName serviceName = new QName("http://org.jboss.ws/securityDomain",
"PermitAllSecureEndpoint1Service");
QName portName = new QName("http://org.jboss.ws/securityDomain",
"PermitAllSecureEndpoint1Port");
PermitAllSecureEndpoint port = Service.create(wsdlURL,
serviceName).getPort(portName, PermitAllSecureEndpoint.class);
@@ -106,10 +103,12 @@
((BindingProvider)port).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
"bar");
assertEquals("Hello", port.echo("Hello"));
}
-
+
+ @Test
+ @RunAsClient
public void testPortTwo() throws Exception
{
- URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS_2 + "?wsdl");
+ URL wsdlURL = new URL(baseURL + "/jaxws-securityDomain-permitall/two" +
"?wsdl");
QName serviceName = new QName("http://org.jboss.ws/securityDomain",
"PermitAllSecureEndpoint2Service");
QName portName = new QName("http://org.jboss.ws/securityDomain",
"PermitAllSecureEndpoint2Port");
PermitAllSecureEndpoint port = Service.create(wsdlURL,
serviceName).getPort(portName, PermitAllSecureEndpoint.class);
Modified:
stack/cxf/branches/arquillian/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecurityDomainTestCase.java
===================================================================
---
stack/cxf/branches/arquillian/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecurityDomainTestCase.java 2015-01-03
21:28:08 UTC (rev 19317)
+++
stack/cxf/branches/arquillian/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecurityDomainTestCase.java 2015-01-03
21:46:18 UTC (rev 19318)
@@ -31,7 +31,15 @@
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Service;
-import junit.framework.Test;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.jboss.arquillian.container.test.api.Deployment;
+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.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.wsf.test.JBossWSTest;
import org.jboss.wsf.test.JBossWSTestHelper;
@@ -53,39 +61,30 @@
* @author alessio.soldano(a)jboss.com
* @author <a href="mailto:richard.opalka@jboss.org">Richard
Opalka</a>
*/
+(a)RunWith(Arquillian.class)
public class SecurityDomainTestCase extends JBossWSTest
{
- public static BaseDeployment<?>[] createDeployments() {
- List<BaseDeployment<?>> list = new
LinkedList<BaseDeployment<?>>();
- list.add(new
JBossWSTestHelper.JarDeployment("jaxws-samples-securityDomain.jar") { {
+ @ArquillianResource
+ private URL baseURL;
+
+ @Deployment(name="jaxws-samples-securityDomain", testable = false)
+ public static JavaArchive createDeployment() {
+ JavaArchive archive = ShrinkWrap.create(JavaArchive.class,
"jaxws-samples-securityDomain.jar");
archive
.addManifest()
.addClass(org.jboss.test.ws.jaxws.samples.securityDomain.SecureEndpointImpl.class);
- }
- });
- return list.toArray(new BaseDeployment<?>[list.size()]);
+ return archive;
}
- public static Test suite()
- {
- JBossWSTestSetup testSetup = new JBossWSTestSetup(SecurityDomainTestCase.class,
JBossWSTestHelper.writeToFile(createDeployments()));
- Map<String, String> authenticationOptions = new HashMap<String,
String>();
- authenticationOptions.put("usersProperties",
-
getResourceFile("jaxws/samples/securityDomain/jbossws-users.properties").getAbsolutePath());
- authenticationOptions.put("rolesProperties",
-
getResourceFile("jaxws/samples/securityDomain/jbossws-roles.properties").getAbsolutePath());
- testSetup.addSecurityDomainRequirement("JBossWSSecurityDomainTest",
authenticationOptions);
- return testSetup;
- }
-
private SecureEndpoint getAuthzPort() throws Exception
{
- URL wsdlURL = new URL("http://" + getServerHost() +
":8080/jaxws-securityDomain/authz?wsdl");
+ URL wsdlURL = new URL(baseURL + "/jaxws-securityDomain/authz?wsdl");
QName serviceName = new QName("http://org.jboss.ws/securityDomain",
"SecureEndpointService");
return Service.create(wsdlURL, serviceName).getPort(SecureEndpoint.class);
}
-
+ @Test
+ @RunAsClient
public void testUnauthenticated() throws Exception
{
SecureEndpoint port1 = getAuthzPort();
@@ -117,7 +116,9 @@
assertTrue("Exception Cause message: " + e.getCause().getMessage(),
e.getCause().getMessage().contains("401: Unauthorized"));
}
}
-
+
+ @Test
+ @RunAsClient
public void testUnauthorized() throws Exception
{
SecureEndpoint port2 = getAuthzPort();
@@ -131,8 +132,9 @@
assertTrue("Exception message: " + e.getMessage(),
e.getMessage().contains("not allowed"));
}
}
-
-
+
+ @Test
+ @RunAsClient
public void testAuthorizedAccess() throws Exception
{
SecureEndpoint port = getAuthzPort();
@@ -148,7 +150,9 @@
assertEquals("Greetings", port.echo("Greetings"));
assertEquals("Greetings", port.restrictedEcho("Greetings"));
}
-
+
+ @Test
+ @RunAsClient
public void testUndeclaredRole() throws Exception
{
SecureEndpoint port = getAuthzPort();