servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r412799 - in /incubator/servicemix/trunk/servicemix-soap/src/test: java/org/apache/servicemix/soap/handlers/ java/org/apache/servicemix/soap/handlers/security/ resources/ resources/org/apache/servicemix/soap/handlers/ resources/org/apache/s...
Date Thu, 08 Jun 2006 16:58:09 GMT
Author: gnodet
Date: Thu Jun  8 09:58:08 2006
New Revision: 412799

URL: http://svn.apache.org/viewvc?rev=412799&view=rev
Log:
Fix juFix ws-sec unit tests

Added:
    incubator/servicemix/trunk/servicemix-soap/src/test/java/org/apache/servicemix/soap/handlers/security/
    incubator/servicemix/trunk/servicemix-soap/src/test/java/org/apache/servicemix/soap/handlers/security/WSSecurityHandlerTest.java
    incubator/servicemix/trunk/servicemix-soap/src/test/resources/groups.properties
    incubator/servicemix/trunk/servicemix-soap/src/test/resources/login.properties
    incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/handlers/security/
    incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/handlers/security/sample-wsse-request.xml
      - copied, changed from r412730, incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/handlers/sample-wsse-request.xml
    incubator/servicemix/trunk/servicemix-soap/src/test/resources/users.properties
Removed:
    incubator/servicemix/trunk/servicemix-soap/src/test/java/org/apache/servicemix/soap/handlers/WSSecurityHandlerTest.java
    incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/handlers/sample-wsse-request.xml

Added: incubator/servicemix/trunk/servicemix-soap/src/test/java/org/apache/servicemix/soap/handlers/security/WSSecurityHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-soap/src/test/java/org/apache/servicemix/soap/handlers/security/WSSecurityHandlerTest.java?rev=412799&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/test/java/org/apache/servicemix/soap/handlers/security/WSSecurityHandlerTest.java
(added)
+++ incubator/servicemix/trunk/servicemix-soap/src/test/java/org/apache/servicemix/soap/handlers/security/WSSecurityHandlerTest.java
Thu Jun  8 09:58:08 2006
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.soap.handlers.security;
+
+import java.io.File;
+import java.net.URL;
+import java.security.Principal;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.servicemix.soap.Context;
+import org.apache.servicemix.soap.marshalers.SoapMarshaler;
+import org.apache.servicemix.soap.marshalers.SoapMessage;
+import org.apache.servicemix.soap.marshalers.SoapReader;
+import org.apache.ws.security.WSSecurityEngineResult;
+import org.apache.ws.security.WSUsernameTokenPrincipal;
+import org.apache.ws.security.handler.WSHandlerConstants;
+import org.apache.ws.security.handler.WSHandlerResult;
+
+public class WSSecurityHandlerTest extends TestCase {
+    
+    static {
+        String path = System.getProperty("java.security.auth.login.config");
+        if (path == null) {
+            URL resource = WSSecurityHandlerTest.class.getClassLoader().getResource("login.properties");
+            if (resource != null) {
+                path = new File(resource.getFile()).getAbsolutePath();
+                System.setProperty("java.security.auth.login.config", path);
+            }
+        }
+        System.out.println("Path to login config: " + path);
+    }
+
+    public void testUserNameToken() throws Exception {
+        SoapMarshaler marshaler = new SoapMarshaler(true, true);
+        SoapReader reader = marshaler.createReader();
+        SoapMessage msg = reader.read(getClass().getResourceAsStream("sample-wsse-request.xml"));
+        Context ctx = new Context();
+        ctx.setInMessage(msg);
+        
+        WSSecurityHandler handler = new WSSecurityHandler();
+        handler.setReceiveAction(WSHandlerConstants.USERNAME_TOKEN);
+        handler.onReceive(ctx);
+        List l = (List) ctx.getProperty(WSHandlerConstants.RECV_RESULTS);
+        assertNotNull(l);
+        assertEquals(1, l.size());
+        WSHandlerResult result = (WSHandlerResult) l.get(0);
+        assertNotNull(result);
+        assertNotNull(result.getResults());
+        assertEquals(1, result.getResults().size());
+        WSSecurityEngineResult engResult = (WSSecurityEngineResult) result.getResults().get(0);
+        assertNotNull(engResult);
+        Principal principal = engResult.getPrincipal();
+        assertNotNull(principal);
+        assertTrue(principal instanceof WSUsernameTokenPrincipal);
+        assertEquals("first", ((WSUsernameTokenPrincipal) principal).getName());
+        assertEquals("secret", ((WSUsernameTokenPrincipal) principal).getPassword());
+        assertNotNull(ctx.getInMessage().getSubject());
+        assertNotNull(ctx.getInMessage().getSubject().getPrincipals());
+        assertTrue(ctx.getInMessage().getSubject().getPrincipals().size() > 0);
+    }
+    
+}

Added: incubator/servicemix/trunk/servicemix-soap/src/test/resources/groups.properties
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-soap/src/test/resources/groups.properties?rev=412799&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/test/resources/groups.properties (added)
+++ incubator/servicemix/trunk/servicemix-soap/src/test/resources/groups.properties Thu Jun
 8 09:58:08 2006
@@ -0,0 +1,4 @@
+programmers=first
+accounting=second
+employees=first,second
+testers=third
\ No newline at end of file

Added: incubator/servicemix/trunk/servicemix-soap/src/test/resources/login.properties
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-soap/src/test/resources/login.properties?rev=412799&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/test/resources/login.properties (added)
+++ incubator/servicemix/trunk/servicemix-soap/src/test/resources/login.properties Thu Jun
 8 09:58:08 2006
@@ -0,0 +1,6 @@
+servicemix-domain {
+    org.apache.servicemix.jbi.security.PropertiesLoginModule required
+        debug=true
+        org.apache.servicemix.security.properties.user="users.properties"
+        org.apache.servicemix.security.properties.group="groups.properties";
+};
\ No newline at end of file

Copied: incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/handlers/security/sample-wsse-request.xml
(from r412730, incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/handlers/sample-wsse-request.xml)
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/handlers/security/sample-wsse-request.xml?p2=incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/handlers/security/sample-wsse-request.xml&p1=incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/handlers/sample-wsse-request.xml&r1=412730&r2=412799&rev=412799&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/handlers/sample-wsse-request.xml
(original)
+++ incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/handlers/security/sample-wsse-request.xml
Thu Jun  8 09:58:08 2006
@@ -7,8 +7,8 @@
   <soapenv:Header>
     <wsse:Security soapenv:mustUnderstand="1">
       <wsse:UsernameToken>
-        <wsse:Username>cupareq</wsse:Username>
-        <wsse:Password>cupareq1</wsse:Password>
+        <wsse:Username>first</wsse:Username>
+        <wsse:Password>secret</wsse:Password>
       </wsse:UsernameToken>
     </wsse:Security>
   </soapenv:Header>

Added: incubator/servicemix/trunk/servicemix-soap/src/test/resources/users.properties
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-soap/src/test/resources/users.properties?rev=412799&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/test/resources/users.properties (added)
+++ incubator/servicemix/trunk/servicemix-soap/src/test/resources/users.properties Thu Jun
 8 09:58:08 2006
@@ -0,0 +1,3 @@
+first=secret
+second=password
+third=another
\ No newline at end of file



Mime
View raw message