Author: alessio.soldano(a)jboss.com
Date: 2012-11-15 04:45:52 -0500 (Thu, 15 Nov 2012)
New Revision: 16997
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernameTestCase.java
Log:
Adding testcase for UT auth without callbackhandler
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernameTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernameTestCase.java 2012-11-15
09:41:35 UTC (rev 16996)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernameTestCase.java 2012-11-15
09:45:52 UTC (rev 16997)
@@ -77,6 +77,26 @@
}
}
+ public void testNoCBH() throws Exception
+ {
+ QName serviceName = new
QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy",
"SecurityService");
+ URL wsdlURL = new URL(serviceURL + "?wsdl");
+ Service service = Service.create(wsdlURL, serviceName);
+ ServiceIface proxy = (ServiceIface)service.getPort(ServiceIface.class);
+ setupWsseNoCBH((BindingProvider)proxy, "kermit", "thefrog");
+ assertEquals("Secure Hello World!", proxy.sayHello());
+ setupWsseNoCBH((BindingProvider)proxy, "kermit",
"wrongpassword");
+ try
+ {
+ proxy.sayHello();
+ fail("User snoopy shouldn't be authenticated.");
+ }
+ catch (Exception e)
+ {
+ //OK
+ }
+ }
+
public void testJavaFirst() throws Exception
{
QName serviceName = new
QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy",
"JavaFirstSecurityService");
@@ -110,4 +130,10 @@
proxy.getRequestContext().put(SecurityConstants.USERNAME, username);
proxy.getRequestContext().put(SecurityConstants.CALLBACK_HANDLER,
"org.jboss.test.ws.jaxws.samples.wsse.policy.basic.UsernamePasswordCallback");
}
+
+ private void setupWsseNoCBH(BindingProvider proxy, String username, String password)
+ {
+ proxy.getRequestContext().put(SecurityConstants.USERNAME, username);
+ proxy.getRequestContext().put(SecurityConstants.PASSWORD, password);
+ }
}