james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r385088 - in /james/server/trunk/src: java/org/apache/james/remotemanager/ test/org/apache/james/ test/org/apache/james/pop3server/ test/org/apache/james/remotemanager/ test/org/apache/james/smtpserver/ test/org/apache/james/test/mock/james...
Date Sat, 11 Mar 2006 14:48:52 GMT
Author: bago
Date: Sat Mar 11 06:48:50 2006
New Revision: 385088

URL: http://svn.apache.org/viewcvs?rev=385088&view=rev
Log:
Removed dependencies on DefaultJamesUser in the RemoteManager.
Moved MockUsersRepository to the same package of UsersRepository to be able to test correctness
of User handing.
All unit-tests passes again.

Added:
    james/server/trunk/src/test/org/apache/james/userrepository/
    james/server/trunk/src/test/org/apache/james/userrepository/MockUsersRepository.java
      - copied, changed from r367429, james/server/trunk/src/test/org/apache/james/test/mock/james/MockUsersRepository.java
Removed:
    james/server/trunk/src/test/org/apache/james/test/mock/james/MockUsersRepository.java
Modified:
    james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java
    james/server/trunk/src/test/org/apache/james/JamesTest.java
    james/server/trunk/src/test/org/apache/james/pop3server/POP3ServerTest.java
    james/server/trunk/src/test/org/apache/james/remotemanager/RemoteManagerTest.java
    james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java
    james/server/trunk/src/test/org/apache/james/test/mock/james/MockMailServer.java

Modified: james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java?rev=385088&r1=385087&r2=385088&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java (original)
+++ james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java Sat
Mar 11 06:48:50 2006
@@ -680,11 +680,18 @@
             writeLoggedFlushedResponse("Usage: setalias [username] [alias]");
             return true;
         }
-        JamesUser user = (JamesUser) users.getUserByName(username);
-        if (user == null) {
+        
+        User baseuser = users.getUserByName(username);
+        if (baseuser == null) {
             writeLoggedFlushedResponse("No such user " + username);
             return true;
         }
+        if (! (baseuser instanceof JamesUser ) ) {
+            writeLoggedFlushedResponse("Can't set alias for this user type.");
+            return true;
+        }
+        
+        JamesUser user = (JamesUser) baseuser;
         JamesUser aliasUser = (JamesUser) users.getUserByName(alias);
         if (aliasUser == null) {
             writeLoggedFlushedResponse("Alias unknown to server - create that user first.");
@@ -785,7 +792,17 @@
             return true;
         }
 
-        JamesUser user = (JamesUser)users.getUserByName(username);
+
+        User baseuser = users.getUserByName(username);
+        if (baseuser == null) {
+            writeLoggedFlushedResponse("No such user " + username);
+            return true;
+        } else if (! (baseuser instanceof JamesUser ) ) {
+            writeLoggedFlushedResponse("Can't show aliases for this user type.");
+            return true;
+        }
+
+        JamesUser user = (JamesUser)baseuser;
         if ( user == null ) {
             writeLoggedFlushedResponse("No such user " + username);
             return true;
@@ -821,7 +838,16 @@
             return true;
         }
 
-        JamesUser user = (JamesUser)users.getUserByName(username);
+        // Verify user exists
+        User baseuser = users.getUserByName(username);
+        if (baseuser == null) {
+            writeLoggedFlushedResponse("No such user " + username);
+            return true;
+        } else if (! (baseuser instanceof JamesUser ) ) {
+            writeLoggedFlushedResponse("Can't set forwarding for this user type.");
+            return true;
+        }
+        JamesUser user = (JamesUser)baseuser;
         if ( user == null ) {
             writeLoggedFlushedResponse("No such user " + username);
             return true;

Modified: james/server/trunk/src/test/org/apache/james/JamesTest.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/test/org/apache/james/JamesTest.java?rev=385088&r1=385087&r2=385088&view=diff
==============================================================================
--- james/server/trunk/src/test/org/apache/james/JamesTest.java (original)
+++ james/server/trunk/src/test/org/apache/james/JamesTest.java Sat Mar 11 06:48:50 2006
@@ -27,9 +27,9 @@
 import org.apache.james.test.mock.avalon.MockLogger;
 import org.apache.james.test.mock.avalon.MockServiceManager;
 import org.apache.james.test.mock.avalon.MockStore;
-import org.apache.james.test.mock.james.MockUsersRepository;
 import org.apache.james.test.mock.james.MockUsersStore;
 import org.apache.james.test.mock.james.MockMailRepository;
+import org.apache.james.userrepository.MockUsersRepository;
 
 import java.io.File;
 

Modified: james/server/trunk/src/test/org/apache/james/pop3server/POP3ServerTest.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/test/org/apache/james/pop3server/POP3ServerTest.java?rev=385088&r1=385087&r2=385088&view=diff
==============================================================================
--- james/server/trunk/src/test/org/apache/james/pop3server/POP3ServerTest.java (original)
+++ james/server/trunk/src/test/org/apache/james/pop3server/POP3ServerTest.java Sat Mar 11
06:48:50 2006
@@ -30,8 +30,8 @@
 import org.apache.james.test.mock.avalon.MockThreadManager;
 import org.apache.james.test.mock.james.MockMailRepository;
 import org.apache.james.test.mock.james.MockMailServer;
-import org.apache.james.test.mock.james.MockUsersRepository;
 import org.apache.james.test.util.Util;
+import org.apache.james.userrepository.MockUsersRepository;
 import org.apache.james.util.connection.SimpleConnectionManager;
 import org.apache.mailet.MailAddress;
 import org.columba.ristretto.io.Source;

Modified: james/server/trunk/src/test/org/apache/james/remotemanager/RemoteManagerTest.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/test/org/apache/james/remotemanager/RemoteManagerTest.java?rev=385088&r1=385087&r2=385088&view=diff
==============================================================================
--- james/server/trunk/src/test/org/apache/james/remotemanager/RemoteManagerTest.java (original)
+++ james/server/trunk/src/test/org/apache/james/remotemanager/RemoteManagerTest.java Sat
Mar 11 06:48:50 2006
@@ -31,9 +31,9 @@
 import org.apache.james.test.mock.avalon.MockSocketManager;
 import org.apache.james.test.mock.avalon.MockThreadManager;
 import org.apache.james.test.mock.james.MockMailServer;
-import org.apache.james.test.mock.james.MockUsersRepository;
 import org.apache.james.test.mock.james.MockUsersStore;
 import org.apache.james.test.util.Util;
+import org.apache.james.userrepository.MockUsersRepository;
 import org.apache.james.util.connection.SimpleConnectionManager;
 
 import java.io.BufferedReader;
@@ -359,11 +359,11 @@
         finishSetUp(m_testConfiguration);
         connect();
         login();
-
+        
         // do some tests when parameter users don't exist
         sendCommand("setalias testNonExist1 testNonExist2");
         assertTrue(getLastLine(readAnswer()).equals("No such user testNonExist1"));
-        
+
         sendCommand("adduser testAlias1 test");
         assertTrue(getLastLine(readAnswer()).endsWith(" added"));
 
@@ -372,10 +372,10 @@
 
         sendCommand("setalias testAlias1 testNonExist2");
         assertTrue(getLastLine(readAnswer()).equals("Alias unknown to server - create that
user first."));
-        
+
         sendCommand("setalias testNonExist1 testAlias");
         assertTrue(getLastLine(readAnswer()).equals("No such user testNonExist1"));
-        
+
         sendCommand("adduser testAlias2 test");
         assertTrue(getLastLine(readAnswer()).endsWith(" added"));
 

Modified: james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java?rev=385088&r1=385087&r2=385088&view=diff
==============================================================================
--- james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java (original)
+++ james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java Sat Mar 11
06:48:50 2006
@@ -26,9 +26,9 @@
 import org.apache.james.test.mock.avalon.MockSocketManager;
 import org.apache.james.test.mock.avalon.MockThreadManager;
 import org.apache.james.test.mock.james.MockMailServer;
-import org.apache.james.test.mock.james.MockUsersRepository;
 import org.apache.james.test.mock.mailet.MockMailContext;
 import org.apache.james.test.util.Util;
+import org.apache.james.userrepository.MockUsersRepository;
 import org.apache.james.util.Base64;
 import org.apache.james.util.connection.SimpleConnectionManager;
 import org.apache.mailet.MailAddress;

Modified: james/server/trunk/src/test/org/apache/james/test/mock/james/MockMailServer.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/test/org/apache/james/test/mock/james/MockMailServer.java?rev=385088&r1=385087&r2=385088&view=diff
==============================================================================
--- james/server/trunk/src/test/org/apache/james/test/mock/james/MockMailServer.java (original)
+++ james/server/trunk/src/test/org/apache/james/test/mock/james/MockMailServer.java Sat Mar
11 06:48:50 2006
@@ -19,6 +19,7 @@
 import org.apache.james.services.MailRepository;
 import org.apache.james.services.MailServer;
 import org.apache.james.smtpserver.MessageSizeException;
+import org.apache.james.userrepository.MockUsersRepository;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 

Copied: james/server/trunk/src/test/org/apache/james/userrepository/MockUsersRepository.java
(from r367429, james/server/trunk/src/test/org/apache/james/test/mock/james/MockUsersRepository.java)
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/test/org/apache/james/userrepository/MockUsersRepository.java?p2=james/server/trunk/src/test/org/apache/james/userrepository/MockUsersRepository.java&p1=james/server/trunk/src/test/org/apache/james/test/mock/james/MockUsersRepository.java&r1=367429&r2=385088&rev=385088&view=diff
==============================================================================
--- james/server/trunk/src/test/org/apache/james/test/mock/james/MockUsersRepository.java
(original)
+++ james/server/trunk/src/test/org/apache/james/userrepository/MockUsersRepository.java Sat
Mar 11 06:48:50 2006
@@ -14,18 +14,16 @@
  * implied.  See the License for the specific language governing       *
  * permissions and limitations under the License.                      *
  ***********************************************************************/
-package org.apache.james.test.mock.james;
+package org.apache.james.userrepository;
 
 import org.apache.james.security.DigestUtil;
 import org.apache.james.services.User;
 import org.apache.james.services.UsersRepository;
-import org.apache.james.userrepository.DefaultUser;
-import org.apache.james.userrepository.DefaultJamesUser;
 
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.List;
 import java.util.LinkedList;
+import java.util.List;
 
 public class MockUsersRepository implements UsersRepository {
 
@@ -44,6 +42,14 @@
     }
 
     public boolean addUser(User user) {
+
+        if (m_forceUseJamesUser && user instanceof DefaultUser ) {
+            DefaultUser aUser = (DefaultUser)user;
+            user = new DefaultJamesUser(aUser.getUserName(),
+                                             aUser.getHashedPassword(),
+                                             aUser.getHashAlgorithm());
+        }
+
         String key = user.getUserName();
         if (m_users.containsKey(key)) return false;
         m_users.put(key, user);
@@ -55,6 +61,7 @@
             String passwordHash = DigestUtil.digestString(((String) attributes), "SHA");
 
             User user;
+
             if (m_forceUseJamesUser) {
                 user = new DefaultJamesUser(name, passwordHash, "SHA");
             } else {



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


Mime
View raw message