You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ba...@apache.org on 2006/09/09 01:47:59 UTC

svn commit: r441693 - in /james/server/trunk/src/test/org/apache/james: smtpserver/ transport/matchers/

Author: bago
Date: Fri Sep  8 16:47:58 2006
New Revision: 441693

URL: http://svn.apache.org/viewvc?view=rev&rev=441693
Log:
Update tests to pass even if the default search domain include a wildcard/catchall configuration

Modified:
    james/server/trunk/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java
    james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java
    james/server/trunk/src/test/org/apache/james/smtpserver/SMTPTestConfiguration.java
    james/server/trunk/src/test/org/apache/james/smtpserver/URIRBLHandlerTest.java
    james/server/trunk/src/test/org/apache/james/transport/matchers/AbstractRemoteAddrInNetworkTest.java

Modified: james/server/trunk/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java?view=diff&rev=441693&r1=441692&r2=441693
==============================================================================
--- james/server/trunk/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java (original)
+++ james/server/trunk/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java Fri Sep  8 16:47:58 2006
@@ -94,7 +94,7 @@
                     return res;
                 }
                 ;
-                if ("2.0.0.127.bl.spamcop.net".equals(hostname)) {
+                if ("2.0.0.127.bl.spamcop.net.".equals(hostname)) {
                     res.add("Blocked - see http://www.spamcop.net/bl.shtml?127.0.0.2");
                 }
                 return res;
@@ -111,14 +111,14 @@
 
             public InetAddress getByName(String host)
                     throws UnknownHostException {
-                if ("2.0.0.127.bl.spamcop.net".equals(host)) {
+                if ("2.0.0.127.bl.spamcop.net.".equals(host)) {
                     return InetAddress.getByName("127.0.0.1");
-                } else if ("3.0.0.127.bl.spamcop.net".equals(host)) {
+                } else if ("3.0.0.127.bl.spamcop.net.".equals(host)) {
                     return InetAddress.getByName("127.0.0.1");
-                } else if ("192.168.0.1.bl.spamcop.net".equals(host)) {
-                    return InetAddress.getByName("fesdgaeg.deger");
+                } else if ("1.0.168.192.bl.spamcop.net.".equals(host)) {
+                    throw new UnknownHostException(host);
                 }
-                return InetAddress.getByName(host);
+                throw new UnsupportedOperationException("getByName("+host+") not implemented in DNSRBLHandlerTest mock");
             }
         };
     }
@@ -180,7 +180,7 @@
         setupMockedSMTPSession();
         rbl.setDNSServer(mockedDnsServer);
 
-        rbl.setBlacklist(new String[] { "bl.spamcop.net" });
+        rbl.setBlacklist(new String[] { "bl.spamcop.net." });
         rbl.setGetDetail(true);
         rbl.onConnect(mockedSMTPSession);
         assertEquals("Details","Blocked - see http://www.spamcop.net/bl.shtml?127.0.0.2",
@@ -197,7 +197,7 @@
         setupMockedSMTPSession();
         rbl.setDNSServer(mockedDnsServer);
 
-        rbl.setBlacklist(new String[] { "bl.spamcop.net" });
+        rbl.setBlacklist(new String[] { "bl.spamcop.net." });
         rbl.setGetDetail(false);
         rbl.onConnect(mockedSMTPSession);
         assertNull("No details",mockedSMTPSession.getConnectionState().get(RBL_DETAIL_MAIL_ATTRIBUTE_NAME));
@@ -215,7 +215,7 @@
 
         rbl.setDNSServer(mockedDnsServer);
 
-        rbl.setBlacklist(new String[] { "bl.spamcop.net" });
+        rbl.setBlacklist(new String[] { "bl.spamcop.net." });
         rbl.setGetDetail(true);
         rbl.onConnect(mockedSMTPSession);
         assertNull("No details",mockedSMTPSession.getConnectionState().get(RBL_DETAIL_MAIL_ATTRIBUTE_NAME));
@@ -232,7 +232,7 @@
 
         rbl.setDNSServer(mockedDnsServer);
 
-        rbl.setBlacklist(new String[] { "bl.spamcop.net" });
+        rbl.setBlacklist(new String[] { "bl.spamcop.net." });
         rbl.setGetDetail(true);
         rbl.onConnect(mockedSMTPSession);
         assertNull("No details",mockedSMTPSession.getConnectionState().get(RBL_DETAIL_MAIL_ATTRIBUTE_NAME));
@@ -249,7 +249,7 @@
 
         rbl.setDNSServer(mockedDnsServer);
 
-        rbl.setBlacklist(new String[] { "bl.spamcop.net" });
+        rbl.setBlacklist(new String[] { "bl.spamcop.net." });
         rbl.setGetDetail(true);
         rbl.onConnect(mockedSMTPSession);
         assertNull(mockedSMTPSession.getConnectionState().get(RBL_DETAIL_MAIL_ATTRIBUTE_NAME));
@@ -266,7 +266,7 @@
 
         rbl.setDNSServer(mockedDnsServer);
 
-        rbl.setWhitelist(new String[] { "bl.spamcop.net" });
+        rbl.setWhitelist(new String[] { "bl.spamcop.net." });
         rbl.setGetDetail(true);
         rbl.onConnect(mockedSMTPSession);
         assertNull(mockedSMTPSession.getConnectionState().get(RBL_DETAIL_MAIL_ATTRIBUTE_NAME));

Modified: james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java?view=diff&rev=441693&r1=441692&r2=441693
==============================================================================
--- james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java (original)
+++ james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java Fri Sep  8 16:47:58 2006
@@ -99,12 +99,24 @@
                 if ("127.0.0.1".equals(host)) return getLocalhostByName();
             }
             
-            if ("1.0.0.127.bl.spamcop.net".equals(host)) {
+            if ("1.0.0.127.bl.spamcop.net.".equals(host)) {
                 return getLocalhostByName();
             }
             
-            return InetAddress.getByName(host);
-//                throw new UnsupportedOperationException("getByName not implemented in mock for host: "+host);
+            if ("james.apache.org".equals(host)) {
+                return InetAddress.getByName("james.apache.org");
+            }
+            
+            if ("abgsfe3rsf.de".equals(host)) {
+                throw new UnknownHostException();
+            }
+            
+            if ("128.0.0.1".equals(host) || "192.168.0.1".equals(host) || "127.0.0.1".equals(host) || "127.0.0.0".equals(host) || "255.0.0.0".equals(host) || "255.255.255.255".equals(host)) {
+                return InetAddress.getByName(host);
+            }
+            
+            throw new UnsupportedOperationException("getByName not implemented in mock for host: "+host);
+            //return InetAddress.getByName(host);
         }
 
         public Collection findTXTRecords(String hostname) {
@@ -112,7 +124,7 @@
             if (hostname == null) {
                 return res;
             };
-            if ("2.0.0.127.bl.spamcop.net".equals(hostname)) {
+            if ("2.0.0.127.bl.spamcop.net.".equals(hostname)) {
                 res.add("Blocked - see http://www.spamcop.net/bl.shtml?127.0.0.2");
             }
             return res;
@@ -690,7 +702,7 @@
         m_testConfiguration.setReverseEqualsEhlo();
         m_testConfiguration.setAuthorizedAddresses("192.168.0.1");
         // temporary alter the loopback resolution
-        m_dnsServer.setLocalhostByName(InetAddress.getByName("james.apache.org"));
+        m_dnsServer.setLocalhostByName(m_dnsServer.getByName("james.apache.org"));
         try {
             finishSetUp(m_testConfiguration);
     

Modified: james/server/trunk/src/test/org/apache/james/smtpserver/SMTPTestConfiguration.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/smtpserver/SMTPTestConfiguration.java?view=diff&rev=441693&r1=441692&r2=441693
==============================================================================
--- james/server/trunk/src/test/org/apache/james/smtpserver/SMTPTestConfiguration.java (original)
+++ james/server/trunk/src/test/org/apache/james/smtpserver/SMTPTestConfiguration.java Fri Sep  8 16:47:58 2006
@@ -161,7 +161,7 @@
 
             DefaultConfiguration blacklist = new DefaultConfiguration(
                     "blacklist");
-            blacklist.setValue("bl.spamcop.net");
+            blacklist.setValue("bl.spamcop.net.");
             DefaultConfiguration rblServers = new DefaultConfiguration(
                     "rblservers");
             rblServers.addChild(blacklist);

Modified: james/server/trunk/src/test/org/apache/james/smtpserver/URIRBLHandlerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/smtpserver/URIRBLHandlerTest.java?view=diff&rev=441693&r1=441692&r2=441693
==============================================================================
--- james/server/trunk/src/test/org/apache/james/smtpserver/URIRBLHandlerTest.java (original)
+++ james/server/trunk/src/test/org/apache/james/smtpserver/URIRBLHandlerTest.java Fri Sep  8 16:47:58 2006
@@ -47,7 +47,7 @@
     private static final String BAD_DOMAIN1 = "bad.domain.de";
     private static final String BAD_DOMAIN2 = "bad2.domain.de";
     private static final String GOOD_DOMAIN = "good.domain2.de";
-    private static final String URISERVER = "multi.surbl.org";
+    private static final String URISERVER = "multi.surbl.org.";
     private SMTPSession mockedSMTPSession;
 
     private String response = null;
@@ -173,9 +173,9 @@
                 } else if ((BAD_DOMAIN2.substring(4) + "." + URISERVER).equals(host)) {
                     return InetAddress.getByName("127.0.0.1");
                 } else if ((GOOD_DOMAIN.substring(5) + "." + URISERVER).equals(host)) {
-                    return InetAddress.getByName("fesdgaeg.deger");
+                    throw new UnknownHostException();
                 }
-                return InetAddress.getByName(host);
+                throw new UnsupportedOperationException("getByName("+host+") not implemented by this mock");
             }
         };
         

Modified: james/server/trunk/src/test/org/apache/james/transport/matchers/AbstractRemoteAddrInNetworkTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/transport/matchers/AbstractRemoteAddrInNetworkTest.java?view=diff&rev=441693&r1=441692&r2=441693
==============================================================================
--- james/server/trunk/src/test/org/apache/james/transport/matchers/AbstractRemoteAddrInNetworkTest.java (original)
+++ james/server/trunk/src/test/org/apache/james/transport/matchers/AbstractRemoteAddrInNetworkTest.java Fri Sep  8 16:47:58 2006
@@ -215,7 +215,11 @@
 
             public InetAddress getByName(String host)
                     throws UnknownHostException {
-                return InetAddress.getByName(host);
+                if ("192.168.200.0".equals(host) || "255.255.255.0".equals(host) || "192.168.200.1".equals(host) || "192.168.0.1".equals(host) || "192.168.1.1".equals(host)) {
+                    // called with an IP it only check formal validity
+                    return InetAddress.getByName(host);
+                }
+                throw new UnsupportedOperationException("getByName("+host+") unimplemented in AbstractRemoteAddrInNetworkTest");
             }
 
         };



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