You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2015/11/12 11:39:40 UTC

svn commit: r1714010 - /tomcat/tc7.0.x/trunk/test/org/apache/catalina/realm/TestJNDIRealm.java

Author: markt
Date: Thu Nov 12 10:39:40 2015
New Revision: 1714010

URL: http://svn.apache.org/viewvc?rev=1714010&view=rev
Log:
Correct back-port of unit test. Tomcat 7.0.x does not use CredentialHandler.

Modified:
    tomcat/tc7.0.x/trunk/test/org/apache/catalina/realm/TestJNDIRealm.java

Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/realm/TestJNDIRealm.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/realm/TestJNDIRealm.java?rev=1714010&r1=1714009&r2=1714010&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/realm/TestJNDIRealm.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/realm/TestJNDIRealm.java Thu Nov 12 10:39:40 2015
@@ -18,7 +18,6 @@ package org.apache.catalina.realm;
 
 import java.lang.reflect.Field;
 import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
 import java.security.Principal;
 
 import javax.naming.NamingEnumeration;
@@ -62,7 +61,7 @@ public class TestJNDIRealm {
     @Test
     public void testAuthenticateWithoutUserPassword() throws Exception {
         // GIVEN
-        JNDIRealm realm = buildRealm(PASSWORD);
+        JNDIRealm realm = buildRealm(PASSWORD, null);
 
         // WHEN
         String expectedResponse =
@@ -77,7 +76,7 @@ public class TestJNDIRealm {
     @Test
     public void testAuthenticateWithUserPassword() throws Exception {
         // GIVEN
-        JNDIRealm realm = buildRealm(PASSWORD);
+        JNDIRealm realm = buildRealm(PASSWORD, null);
         realm.setUserPassword(USER_PASSWORD_ATTR);
 
         // WHEN
@@ -92,10 +91,9 @@ public class TestJNDIRealm {
     }
 
     @Test
-    public void testAuthenticateWithUserPasswordAndCredentialHandler() throws Exception {
+    public void testAuthenticateWithUserPasswordAndDigest() throws Exception {
         // GIVEN
-        JNDIRealm realm = buildRealm(ha1());
-        realm.setCredentialHandler(buildCredentialHandler());
+        JNDIRealm realm = buildRealm(ha1(), "MD5");
         realm.setUserPassword(USER_PASSWORD_ATTR);
 
         // WHEN
@@ -110,12 +108,13 @@ public class TestJNDIRealm {
     }
 
 
-    private JNDIRealm buildRealm(String password) throws javax.naming.NamingException,
+    private JNDIRealm buildRealm(String password, String digest) throws javax.naming.NamingException,
             NoSuchFieldException, IllegalAccessException, LifecycleException {
         Context context = new TesterContext();
         JNDIRealm realm = new JNDIRealm();
         realm.setContainer(context);
         realm.setUserSearch("");
+        realm.setDigest(digest);
 
         Field field = JNDIRealm.class.getDeclaredField("context");
         field.setAccessible(true);
@@ -126,13 +125,6 @@ public class TestJNDIRealm {
         return realm;
     }
 
-    private MessageDigestCredentialHandler buildCredentialHandler()
-            throws NoSuchAlgorithmException {
-        MessageDigestCredentialHandler credentialHandler = new MessageDigestCredentialHandler();
-        credentialHandler.setAlgorithm(ALGORITHM);
-        return credentialHandler;
-    }
-
     private NamingEnumeration<SearchResult> mockSearchResults(String password)
             throws NamingException {
         @SuppressWarnings("unchecked")



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org