From 12696a02e7f0c2a754e6e5dccd7ea8b3e204e15c Mon Sep 17 00:00:00 2001 From: Tareq Abedrabbo Date: Tue, 12 Jan 2010 19:28:55 +0000 Subject: [PATCH] SWS-582 - tests for Soap 1.2 --- ...jMessageInterceptorSoapActionTestCase.java | 38 ++++++++++++++++--- .../ws/soap/security/wss4j/empty-soap12.xml | 5 +++ .../wss4j/usernameTokenPlainText-soap12.xml | 19 ++++++++++ 3 files changed, 57 insertions(+), 5 deletions(-) create mode 100755 security/src/test/resources/org/springframework/ws/soap/security/wss4j/empty-soap12.xml create mode 100755 security/src/test/resources/org/springframework/ws/soap/security/wss4j/usernameTokenPlainText-soap12.xml diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSoapActionTestCase.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSoapActionTestCase.java index ee6ade1a..9c387226 100644 --- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSoapActionTestCase.java +++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSoapActionTestCase.java @@ -24,16 +24,18 @@ import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.security.wss4j.callback.SimplePasswordValidationCallbackHandler; +import org.springframework.ws.WebServiceMessageFactory; public abstract class Wss4jMessageInterceptorSoapActionTestCase extends Wss4jTestCase { private static final String SOAP_ACTION = "\"http://test\""; - private Properties users = new Properties(); + private Properties users; private Wss4jSecurityInterceptor interceptor; protected void onSetup() throws Exception { + users = new Properties(); users.setProperty("Bert", "Ernie"); interceptor = new Wss4jSecurityInterceptor(); interceptor.setValidationActions("UsernameToken"); @@ -47,9 +49,20 @@ public abstract class Wss4jMessageInterceptorSoapActionTestCase extends Wss4jTes } public void testPreserveSoapActionOnValidation() throws Exception { - SoapMessage message = loadMessage("usernameTokenPlainText-soap.xml"); + SoapMessage message = loadSoap11Message("usernameTokenPlainText-soap.xml"); message.setSoapAction(SOAP_ACTION); - MessageContext messageContext = new DefaultMessageContext(message, getMessageFactory()); + MessageContext messageContext = new DefaultMessageContext(message, getSoap11MessageFactory()); + interceptor.validateMessage(message, messageContext); + + assertNotNull("Soap Action must not be null", message.getSoapAction()); + assertEquals("Soap Action is different from expected", SOAP_ACTION, message.getSoapAction()); + } + + public void testPreserveSoap12ActionOnValidation() throws Exception { + SoapMessage message = loadSoap12Message("usernameTokenPlainText-soap12.xml"); + message.setSoapAction(SOAP_ACTION); + WebServiceMessageFactory messageFactory = getSoap12MessageFactory(); + MessageContext messageContext = new DefaultMessageContext(message, messageFactory); interceptor.validateMessage(message, messageContext); assertNotNull("Soap Action must not be null", message.getSoapAction()); @@ -57,15 +70,30 @@ public abstract class Wss4jMessageInterceptorSoapActionTestCase extends Wss4jTes } public void testPreserveSoapActionOnSecurement() throws Exception { - SoapMessage message = loadMessage("empty-soap.xml"); + SoapMessage message = loadSoap11Message("empty-soap.xml"); message.setSoapAction(SOAP_ACTION); interceptor.setSecurementUsername("Bert"); interceptor.setSecurementPassword("Ernie"); - MessageContext messageContext = getMessageContext(message); + MessageContext messageContext = getSoap11MessageContext(message); interceptor.secureMessage(message, messageContext); assertNotNull("Soap Action must not be null", message.getSoapAction()); assertEquals("Soap Action is different from expected", SOAP_ACTION, message.getSoapAction()); } + + public void testPreserveSoap12ActionOnSecurement() throws Exception { + SoapMessage message = loadSoap12Message("empty-soap12.xml"); + message.setSoapAction(SOAP_ACTION); + interceptor.setSecurementUsername("Bert"); + interceptor.setSecurementPassword("Ernie"); + MessageContext messageContext = getSoap12MessageContext(message); + interceptor.secureMessage(message, messageContext); + + assertNotNull("Soap Action must not be null", message.getSoapAction()); + assertEquals("Soap Action is different from expected", SOAP_ACTION, message.getSoapAction()); + + } + + } diff --git a/security/src/test/resources/org/springframework/ws/soap/security/wss4j/empty-soap12.xml b/security/src/test/resources/org/springframework/ws/soap/security/wss4j/empty-soap12.xml new file mode 100755 index 00000000..3805b39c --- /dev/null +++ b/security/src/test/resources/org/springframework/ws/soap/security/wss4j/empty-soap12.xml @@ -0,0 +1,5 @@ + + + QQQ + + diff --git a/security/src/test/resources/org/springframework/ws/soap/security/wss4j/usernameTokenPlainText-soap12.xml b/security/src/test/resources/org/springframework/ws/soap/security/wss4j/usernameTokenPlainText-soap12.xml new file mode 100755 index 00000000..b0d687c2 --- /dev/null +++ b/security/src/test/resources/org/springframework/ws/soap/security/wss4j/usernameTokenPlainText-soap12.xml @@ -0,0 +1,19 @@ + + + + + Bert + Ernie + + + + + QQQ + + \ No newline at end of file