harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lvj...@apache.org
Subject svn commit: r594823 - in /harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap: BindOpTest.java sasl/ sasl/SaslBindTest.java
Date Wed, 14 Nov 2007 10:23:09 GMT
Author: lvjing
Date: Wed Nov 14 02:23:05 2007
New Revision: 594823

URL: http://svn.apache.org/viewvc?rev=594823&view=rev
Log:
apply a patch for testcases of Harmony-5072.

Added:
    harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/sasl/
    harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/sasl/SaslBindTest.java
Modified:
    harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/BindOpTest.java

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/BindOpTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/BindOpTest.java?rev=594823&r1=594822&r2=594823&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/BindOpTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/BindOpTest.java
Wed Nov 14 02:23:05 2007
@@ -26,7 +26,7 @@
     public void test_encodeValues_$LObject() {
         String dn = "o=Entry";
         String pwd = "secret";
-        BindOp op = new BindOp(dn, pwd);
+        BindOp op = new BindOp(dn, pwd,null,null);
 
         ASN1TestUtils.checkEncode(op.getRequest(), LdapASN1Constant.BindRequest);
     }

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/sasl/SaslBindTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/sasl/SaslBindTest.java?rev=594823&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/sasl/SaslBindTest.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/sasl/SaslBindTest.java
Wed Nov 14 02:23:05 2007
@@ -0,0 +1,109 @@
+package org.apache.harmony.jndi.provider.ldap.sasl;
+
+import java.util.Hashtable;
+
+import javax.naming.AuthenticationNotSupportedException;
+import javax.naming.Context;
+
+import junit.framework.TestCase;
+
+public class SaslBindTest extends TestCase {
+    private final String DIGEST_MD5 = "DIGEST-MD5";
+
+    private final String CRAM_MD5 = "CRAM-MD5";
+
+    private final String GSSAPI = "GSSAPI";
+
+    private final String EXTERNAL = "EXTERNAL";
+
+    private SaslBind sbind = new SaslBind();
+
+    private Hashtable<String, Object> env = new Hashtable<String, Object>();
+
+    public void setUp() throws Exception {
+        super.setUp();
+
+        env.clear();
+    }
+
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void test_valueAuthMech_none()
+            throws AuthenticationNotSupportedException {
+        sbind.valueAuthMech(env);
+        assertEquals(SaslBind.AuthMech.None, sbind.getAuthMech());
+
+        env.put(Context.SECURITY_CREDENTIALS, "test_credentials");
+        sbind.valueAuthMech(env);
+        assertEquals(SaslBind.AuthMech.None, sbind.getAuthMech());
+
+        env.clear();
+        env.put(Context.SECURITY_AUTHENTICATION, "none");
+        env.put(Context.SECURITY_PRINCIPAL, "test_principal");
+        env.put(Context.SECURITY_CREDENTIALS, "test_credentials");
+        sbind.valueAuthMech(env);
+        assertEquals(SaslBind.AuthMech.None, sbind.getAuthMech());
+
+        env.put(Context.SECURITY_AUTHENTICATION, "NoNe");
+        assertEquals(SaslBind.AuthMech.None, sbind.getAuthMech());
+    }
+
+    public void test_valueAuthMech_simple()
+            throws AuthenticationNotSupportedException {
+        env.put(Context.SECURITY_PRINCIPAL, "test_principal");
+        sbind.valueAuthMech(env);
+        assertEquals(SaslBind.AuthMech.Simple, sbind.getAuthMech());
+
+        env.put(Context.SECURITY_AUTHENTICATION, "simple");
+        sbind.valueAuthMech(env);
+        assertEquals(SaslBind.AuthMech.Simple, sbind.getAuthMech());
+
+        env.put(Context.SECURITY_AUTHENTICATION, "SiMpLe");
+        sbind.valueAuthMech(env);
+        assertEquals(SaslBind.AuthMech.Simple, sbind.getAuthMech());
+    }
+
+    public void test_valueAuthMech_SASL()
+            throws AuthenticationNotSupportedException {
+        env.put(Context.SECURITY_AUTHENTICATION, DIGEST_MD5);
+        sbind.valueAuthMech(env);
+        assertEquals(SaslBind.AuthMech.SASL, sbind.getAuthMech());
+
+        env.put(Context.SECURITY_AUTHENTICATION, CRAM_MD5);
+        sbind.valueAuthMech(env);
+        assertEquals(SaslBind.AuthMech.SASL, sbind.getAuthMech());
+
+        env.put(Context.SECURITY_AUTHENTICATION, GSSAPI);
+        sbind.valueAuthMech(env);
+        assertEquals(SaslBind.AuthMech.SASL, sbind.getAuthMech());
+
+        env.put(Context.SECURITY_AUTHENTICATION, EXTERNAL);
+        sbind.valueAuthMech(env);
+        assertEquals(SaslBind.AuthMech.SASL, sbind.getAuthMech());
+
+        env.put(Context.SECURITY_AUTHENTICATION,
+                " test test2  EXTERNAL  test3 GSSAPI");
+        sbind.valueAuthMech(env);
+        assertEquals(SaslBind.AuthMech.SASL, sbind.getAuthMech());
+    }
+
+    public void test_valueAuthMech_notSupportException() {
+        env.put(Context.SECURITY_AUTHENTICATION, "test");
+        try {
+            sbind.valueAuthMech(env);
+            fail("AuthenticationNotSupportedException expected");
+        } catch (AuthenticationNotSupportedException e) {
+            // expected
+        }
+
+        env.put(Context.SECURITY_AUTHENTICATION, " test test2  test3");
+        try {
+            sbind.valueAuthMech(env);
+            fail("AuthenticationNotSupportedException expected");
+        } catch (AuthenticationNotSupportedException e) {
+            // expected
+        }
+    }
+}



Mime
View raw message