use of org.apache.cxf.systest.ws.policy.javafirst.BindingSimpleService in project cxf by apache.
the class JavaFirstPolicyServiceTest method testBindingNoClientCertAlternativePolicy.
@Test
public void testBindingNoClientCertAlternativePolicy() {
System.setProperty("testutil.ports.JavaFirstPolicyServer", PORT);
ClassPathXmlApplicationContext clientContext = new ClassPathXmlApplicationContext(new String[] { "org/apache/cxf/systest/ws/policy/sslnocertclient.xml" });
BindingSimpleService simpleService = clientContext.getBean("BindingSimpleServiceClient", BindingSimpleService.class);
try {
simpleService.doStuff();
fail("Expected exception as no credentials");
} catch (SOAPFaultException e) {
assertTrue(true);
}
WSS4JOutInterceptor wssOut = addToClient(simpleService);
wssOut.setProperties(getNoPasswordProperties("alice"));
try {
simpleService.doStuff();
fail("Expected exception as no password and no client cert");
} catch (SOAPFaultException e) {
assertTrue(true);
}
wssOut.setProperties(getPasswordProperties("alice", "password"));
simpleService.doStuff();
clientContext.close();
}
use of org.apache.cxf.systest.ws.policy.javafirst.BindingSimpleService in project cxf by apache.
the class JavaFirstPolicyServiceTest method testBindingClientCertAlternativePolicy.
@Test
public void testBindingClientCertAlternativePolicy() {
System.setProperty("testutil.ports.JavaFirstPolicyServer.3", PORT3);
ClassPathXmlApplicationContext clientContext = new ClassPathXmlApplicationContext(new String[] { "org/apache/cxf/systest/ws/policy/sslcertclient.xml" });
BindingSimpleService simpleService = clientContext.getBean("BindingSimpleServiceClient", BindingSimpleService.class);
try {
simpleService.doStuff();
fail("Expected exception as no credentials");
} catch (SOAPFaultException e) {
assertTrue(true);
}
WSS4JOutInterceptor wssOut = addToClient(simpleService);
wssOut.setProperties(getNoPasswordProperties("alice"));
simpleService.doStuff();
wssOut.setProperties(getPasswordProperties("alice", "password"));
// this is successful because the alternative policy allows a password to be specified.
simpleService.doStuff();
clientContext.close();
}
Aggregations