Author: alessio.soldano(a)jboss.com
Date: 2012-08-30 05:50:40 -0400 (Thu, 30 Aug 2012)
New Revision: 16684
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/httpauth/HelloBasicSecTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/httpauth/HelloDigestTestCase.java
Log:
[JBWS-2932] Adding negative testcases + removing unrequired module dependency to Apache
CXF impl
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2012-08-30
09:33:06 UTC (rev 16683)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2012-08-30
09:50:40 UTC (rev 16684)
@@ -164,9 +164,6 @@
<zipfileset
dir="${tests.output.dir}/test-resources/jaxws/cxf/httpauth/basic"
prefix="WEB-INF/"/>
- <manifest>
- <attribute name="Dependencies"
value="org.apache.cxf.impl"/> <!-- cxf impl required due to custom
interceptor in deployment -->
- </manifest>
</war>
<!-- jaxws-cxf-http-digest -->
@@ -181,9 +178,6 @@
<zipfileset
dir="${tests.output.dir}/test-resources/jaxws/cxf/httpauth/digest"
prefix="WEB-INF/"/>
- <manifest>
- <attribute name="Dependencies"
value="org.apache.cxf.impl"/> <!-- cxf impl required due to custom
interceptor in deployment -->
- </manifest>
</war>
<!-- jaxws-cxf-jaxbintros -->
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/httpauth/HelloBasicSecTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/httpauth/HelloBasicSecTestCase.java 2012-08-30
09:33:06 UTC (rev 16683)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/httpauth/HelloBasicSecTestCase.java 2012-08-30
09:50:40 UTC (rev 16684)
@@ -35,6 +35,7 @@
import org.jboss.wsf.test.JBossWSTest;
/**
* @author ema(a)redhat.com
+ * @author alessio.soldano(a)jboss.com
*/
public class HelloBasicSecTestCase extends JBossWSTest
{
@@ -67,4 +68,36 @@
assertEquals(100, result);
}
+
+ public void testBasicAuthFail() throws Exception
+ {
+ QName serviceName = new
QName("http://jboss.org/http/security",
"HelloService");
+ URL wsdlURL =
getResourceURL("jaxws/cxf/httpauth/WEB-INF/wsdl/hello.wsdl");
+ Service service = Service.create(wsdlURL, serviceName);
+ Hello proxy = (Hello)service.getPort(Hello.class);
+
((BindingProvider)proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
serviceURL);
+ ((BindingProvider)proxy).getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
"jbossws");
+ ((BindingProvider)proxy).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
"wrongPwd");
+ try {
+ proxy.helloRequest("number");
+ fail("Authorization exception expected!");
+ } catch (Exception e) {
+ assertTrue(e.getCause().getMessage().contains("401: Unauthorized"));
+ }
+ }
+
+ public void testBasicNoAuth() throws Exception
+ {
+ QName serviceName = new
QName("http://jboss.org/http/security",
"HelloService");
+ URL wsdlURL =
getResourceURL("jaxws/cxf/httpauth/WEB-INF/wsdl/hello.wsdl");
+ Service service = Service.create(wsdlURL, serviceName);
+ Hello proxy = (Hello)service.getPort(Hello.class);
+
((BindingProvider)proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
serviceURL);
+ try {
+ proxy.helloRequest("number");
+ fail("Authorization exception expected!");
+ } catch (Exception e) {
+ assertTrue(e.getCause().getMessage().contains("401: Unauthorized"));
+ }
+ }
}
\ No newline at end of file
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/httpauth/HelloDigestTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/httpauth/HelloDigestTestCase.java 2012-08-30
09:33:06 UTC (rev 16683)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/httpauth/HelloDigestTestCase.java 2012-08-30
09:50:40 UTC (rev 16684)
@@ -37,6 +37,10 @@
import org.jboss.wsf.test.JBossWSCXFTestSetup;
import org.jboss.wsf.test.JBossWSTest;
+/**
+ * @author ema(a)redhat.com
+ * @author alessio.soldano(a)jboss.com
+ */
public class HelloDigestTestCase extends JBossWSTest
{
private final String serviceURL = "http://" + getServerHost() +
":8080/jaxws-cxf-digest-sec";
@@ -74,4 +78,38 @@
assertEquals(100, result);
}
+
+ public void testDigestAuthFail() throws Exception
+ {
+ QName serviceName = new
QName("http://jboss.org/http/security",
"HelloService");
+ URL wsdlURL =
getResourceURL("jaxws/cxf/httpauth/WEB-INF/wsdl/hello.wsdl");
+ Service service = Service.create(wsdlURL, serviceName);
+ Hello proxy = (Hello)service.getPort(Hello.class);
+
((BindingProvider)proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
serviceURL);
+ ((BindingProvider)proxy).getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
"jbossws");
+ ((BindingProvider)proxy).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
"wrongPwd");
+ HTTPConduit cond = (HTTPConduit)ClientProxy.getClient(proxy).getConduit();
+ cond.setAuthSupplier(new DigestAuthSupplier());
+ try {
+ proxy.helloRequest("number");
+ fail("Authorization exception expected!");
+ } catch (Exception e) {
+ assertTrue(e.getCause().getMessage().contains("Authorization"));
+ }
+ }
+
+ public void testDigestNoAuth() throws Exception
+ {
+ QName serviceName = new
QName("http://jboss.org/http/security",
"HelloService");
+ URL wsdlURL =
getResourceURL("jaxws/cxf/httpauth/WEB-INF/wsdl/hello.wsdl");
+ Service service = Service.create(wsdlURL, serviceName);
+ Hello proxy = (Hello)service.getPort(Hello.class);
+
((BindingProvider)proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
serviceURL);
+ try {
+ proxy.helloRequest("number");
+ fail("Authorization exception expected!");
+ } catch (Exception e) {
+ assertTrue(e.getCause().getMessage().contains("401: Unauthorized"));
+ }
+ }
}
\ No newline at end of file