cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r1326956 - /cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JOutInterceptorTest.java
Date Tue, 17 Apr 2012 07:11:51 GMT
Author: ffang
Date: Tue Apr 17 07:11:51 2012
New Revision: 1326956

URL: http://svn.apache.org/viewvc?rev=1326956&view=rev
Log:
[CXF-4126]add testcase to demonstrate add new custom action on WSS4JOutInterceptor also works

Modified:
    cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JOutInterceptorTest.java

Modified: cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JOutInterceptorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JOutInterceptorTest.java?rev=1326956&r1=1326955&r2=1326956&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JOutInterceptorTest.java
(original)
+++ cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JOutInterceptorTest.java
Tue Apr 17 07:11:51 2012
@@ -179,7 +179,7 @@ public class WSS4JOutInterceptorTest ext
     }
     
     @Test
-    public void testCustomAction() throws Exception {
+    public void testOverrideCustomAction() throws Exception {
         SOAPMessage saaj = readSAAJDocument("wsse-request-clean.xml");
 
         WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor();
@@ -226,6 +226,41 @@ public class WSS4JOutInterceptorTest ext
         }
     }
     
+    
+    @Test
+    public void testAddCustomAction() throws Exception {
+        SOAPMessage saaj = readSAAJDocument("wsse-request-clean.xml");
+
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor();
+        PhaseInterceptor<SoapMessage> handler = ohandler.createEndingInterceptor();
+
+        SoapMessage msg = new SoapMessage(new MessageImpl());
+        Exchange ex = new ExchangeImpl();
+        ex.setInMessage(msg);
+
+        msg.setContent(SOAPMessage.class, saaj);
+        
+        CountingUsernameTokenAction action = new CountingUsernameTokenAction();
+        Map<Object, Object> customActions = new HashMap<Object, Object>(1);
+        customActions.put(12345, action);
+                
+        msg.put(WSHandlerConstants.ACTION, "12345");
+        msg.put(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties");
+        msg.put(WSHandlerConstants.USER, "username");
+        msg.put("password", "myAliasPassword");
+        msg.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
+        msg.put(WSS4JOutInterceptor.WSS4J_ACTION_MAP, customActions);
+        handler.handleMessage(msg);
+
+        SOAPPart doc = saaj.getSOAPPart();
+        assertValid("//wsse:Security", doc);
+        assertValid("//wsse:Security/wsse:UsernameToken", doc);
+        assertValid("//wsse:Security/wsse:UsernameToken/wsse:Username[text()='username']",
doc);
+        // Test to see that the plaintext password is used in the header
+        assertValid("//wsse:Security/wsse:UsernameToken/wsse:Password[text()='myAliasPassword']",
doc);
+        assertEquals(1, action.getExecutions());
+    }
+    
     private static class CountingUsernameTokenAction extends UsernameTokenAction {
 
         private int executions;
@@ -235,6 +270,7 @@ public class WSS4JOutInterceptorTest ext
                 RequestData reqData) throws WSSecurityException {
             
             this.executions++;
+            reqData.setPwType(WSConstants.PW_TEXT);
             super.execute(handler, actionToDo, doc, reqData);
         }
 



Mime
View raw message