You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ru...@apache.org on 2006/03/18 09:08:48 UTC

svn commit: r386822 - in /webservices/axis2/trunk/java/modules/security: src/org/apache/axis2/security/trust/ test-resources/trust/ test/org/apache/axis2/security/trust/

Author: ruchithf
Date: Sat Mar 18 00:08:46 2006
New Revision: 386822

URL: http://svn.apache.org/viewcvs?rev=386822&view=rev
Log:
some more tests to dispatcher config testcase

Added:
    webservices/axis2/trunk/java/modules/security/test-resources/trust/dispatcher.config.invalid.1.xml
    webservices/axis2/trunk/java/modules/security/test-resources/trust/dispatcher.config.invalid.2.xml
Modified:
    webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/TokenRequestDispatcherConfig.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/TrustException.java
    webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/TempIssuer.java
    webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/TokenRequestDispatcherConfigTest.java

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/TokenRequestDispatcherConfig.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/TokenRequestDispatcherConfig.java?rev=386822&r1=386821&r2=386822&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/TokenRequestDispatcherConfig.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/TokenRequestDispatcherConfig.java Sat Mar 18 00:08:46 2006
@@ -68,7 +68,7 @@
             while (tokenTypes.hasNext()) {
                 OMElement type = (OMElement) tokenTypes.next();
                 String value = type.getText();
-                if(value == null) {
+                if(value == null || "".equals(value)) {
                     throw new TrustException("invalidTokenTypeDefinition",
                             new String[] { "Issuer", classAttr });
                 }

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/TrustException.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/TrustException.java?rev=386822&r1=386821&r2=386822&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/TrustException.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/TrustException.java Sat Mar 18 00:08:46 2006
@@ -76,7 +76,7 @@
      *
      * @return the message translated from the property (message) file.
      */
-    private static String getMessage(String faultCode, Object[] args) {
+    protected static String getMessage(String faultCode, Object[] args) {
         String msg = null;
         try {
             msg = MessageFormat.format(resources.getString(faultCode), args);

Added: webservices/axis2/trunk/java/modules/security/test-resources/trust/dispatcher.config.invalid.1.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/test-resources/trust/dispatcher.config.invalid.1.xml?rev=386822&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/test-resources/trust/dispatcher.config.invalid.1.xml (added)
+++ webservices/axis2/trunk/java/modules/security/test-resources/trust/dispatcher.config.invalid.1.xml Sat Mar 18 00:08:46 2006
@@ -0,0 +1,6 @@
+<token-dispatcher-configuration>
+	<issuer class="org.apache.axis2.security.trust.TempIssuer">
+		<tokenType>http://example.org/mySpecialToken1</tokenType>
+		<tokenType>http://example.org/mySpecialToken2</tokenType>
+	</issuer>
+</token-dispatcher-configuration>

Added: webservices/axis2/trunk/java/modules/security/test-resources/trust/dispatcher.config.invalid.2.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/test-resources/trust/dispatcher.config.invalid.2.xml?rev=386822&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/test-resources/trust/dispatcher.config.invalid.2.xml (added)
+++ webservices/axis2/trunk/java/modules/security/test-resources/trust/dispatcher.config.invalid.2.xml Sat Mar 18 00:08:46 2006
@@ -0,0 +1,6 @@
+<token-dispatcher-configuration>
+	<issuer class="org.apache.axis2.security.trust.TempIssuer" default="true">
+		<tokenType></tokenType>
+		<tokenType>http://example.org/mySpecialToken2</tokenType>
+	</issuer>
+</token-dispatcher-configuration>

Modified: webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/TempIssuer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/TempIssuer.java?rev=386822&r1=386821&r2=386822&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/TempIssuer.java (original)
+++ webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/TempIssuer.java Sat Mar 18 00:08:46 2006
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2004,2005 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.axis2.security.trust;
 
 import org.apache.axis2.context.MessageContext;

Modified: webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/TokenRequestDispatcherConfigTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/TokenRequestDispatcherConfigTest.java?rev=386822&r1=386821&r2=386822&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/TokenRequestDispatcherConfigTest.java (original)
+++ webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/TokenRequestDispatcherConfigTest.java Sat Mar 18 00:08:46 2006
@@ -28,24 +28,58 @@
         super(arg0);
     }
 
+    /**
+     * Testing a valid config file
+     */
     public void testWithConfigFile() {
         try {
             TokenRequestDispatcherConfig config = TokenRequestDispatcherConfig
                     .load("test-resources/trust/dispatcher.config.xml");
-            
+
             assertEquals("Incorrect default issuer class name",
                     "org.apache.axis2.security.trust.TempIssuer", config
                             .getDefaultIssuerName());
-            
-            TokenIssuer issuer = config.getIssuer("http://example.org/mySpecialToken1");
-            
-            assertEquals(
-                    "Incorrect issuer for token type : " +
-                    "http://example.org/mySpecialToken1",
-                    TempIssuer.class.getName(), issuer.getClass().getName());
-            
+
+            TokenIssuer issuer = config
+                    .getIssuer("http://example.org/mySpecialToken1");
+
+            assertEquals("Incorrect issuer for token type : "
+                    + "http://example.org/mySpecialToken1", TempIssuer.class
+                    .getName(), issuer.getClass().getName());
+
         } catch (TrustException e) {
             fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Testing expected faliure when the default issuer is not specified
+     */
+    public void testInvalidCOnfigWithMissingDefaultIssuer() {
+        try {
+            TokenRequestDispatcherConfig
+                .load("test-resources/trust/dispatcher.config.invalid.1.xml");
+            fail("This should fail since there's no default isser specified");
+        } catch (TrustException e) {
+            assertEquals("Incorrect error", TrustException.getMessage(
+                    "defaultIssuerMissing", null), e.getMessage());
+        }
+    }
+
+    /**
+     * Testing expected faliure when the tokenType value is missing from a 
+     * tokenType definition
+     */
+    public void testInvalidRequestTypeDef() {
+        try {
+            TokenRequestDispatcherConfig
+                .load("test-resources/trust/dispatcher.config.invalid.2.xml");
+            fail("This should fail since there is an invalid " +
+                    "requestType definition");
+        } catch (TrustException e) {
+            assertEquals("Incorrect error", TrustException.getMessage(
+                    "invalidTokenTypeDefinition", new String[] { "Issuer",
+                            TempIssuer.class.getName() }), e.getMessage());
         }
     }
 }