Author: norman
Date: Tue Jan 2 00:34:47 2007
New Revision: 491761
URL: http://svn.apache.org/viewvc?view=rev&rev=491761
Log:
Move the abuse/postmaster tests to SMTPServerTest
Fix a bug which added the fastfail hooks before the core hooks. Now the
fastfail hooks get added to the end of the hook List
Modified:
james/server/sandbox/handlerapi-experiment/TODO
james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPHandlerChain.java
james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AbstractHookableCmdHandler.java
james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/UsersRepositoryAuthHook.java
james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/SMTPServerTest.java
Modified: james/server/sandbox/handlerapi-experiment/TODO
URL:
http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/TODO?view=diff&rev=491761&r1=491760&r2=491761
==============================================================================
--- james/server/sandbox/handlerapi-experiment/TODO (original)
+++ james/server/sandbox/handlerapi-experiment/TODO Tue Jan 2 00:34:47 2007
@@ -1,7 +1,6 @@
- Enable From/Sender and Date checks on message received
- Find a way to handle the old JunkHandlerScore stuff
- Check DataCmdHandler for correct clean-up on every exceptions
-- Move abuse/postmaster tests from ResolvableEhloHeloHandlerTest to a generic
SMTPServer compliance test
- on Rcpt message reject, the original code was logging a lot of informations.
Maybe we should change the Hook callers to do something similar (in
RcptCmdHandler create a log string including context() call)
- Check AuthRequiredToRelayRcptHook to see if it is correct to return
different SMTP codes if Auth is announced (for relaying denied)
- Remove CURRENT_RECIPIENT key from state usage: I think we don't use it
anymore but in tests.
Modified:
james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPHandlerChain.java
URL:
http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPHandlerChain.java?view=diff&rev=491761&r1=491760&r2=491761
==============================================================================
---
james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPHandlerChain.java
(original)
+++
james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPHandlerChain.java
Tue Jan 2 00:34:47 2007
@@ -104,6 +104,11 @@
// load the configured handlers
if (children != null) {
+
+ // load the core handlers
+ loadClass(classLoader, CoreCmdHandlerLoader.class.getName(),
+ addHandler(null,
CoreCmdHandlerLoader.class.getName()));
+
for (int i = 0; i < children.length; i++) {
String className = children[i].getAttribute("class");
if (className != null) {
@@ -118,9 +123,6 @@
}
}
- // load the BaseCmdHandler and SendMailHandler
- loadClass(classLoader, CoreCmdHandlerLoader.class.getName(),
- addHandler(null,
CoreCmdHandlerLoader.class.getName()));
}
}
}
Modified:
james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AbstractHookableCmdHandler.java
URL:
http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AbstractHookableCmdHandler.java?view=diff&rev=491761&r1=491760&r2=491761
==============================================================================
---
james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AbstractHookableCmdHandler.java
(original)
+++
james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AbstractHookableCmdHandler.java
Tue Jan 2 00:34:47 2007
@@ -82,10 +82,10 @@
List hooks = getHooks();
if (hooks != null) {
- getLogger().debug("executing hooks");
int count = hooks.size();
for (int i = 0; i < count; i++) {
Object rawHook = hooks.get(i);
+ getLogger().debug("executing hook " +
rawHook.getClass().getName());
SMTPResponse res = callHook(rawHook, session, parameters);
if (res != null) {
return res;
Modified:
james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/UsersRepositoryAuthHook.java
URL:
http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/UsersRepositoryAuthHook.java?view=diff&rev=491761&r1=491760&r2=491761
==============================================================================
---
james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/UsersRepositoryAuthHook.java
(original)
+++
james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/UsersRepositoryAuthHook.java
Tue Jan 2 00:34:47 2007
@@ -34,4 +34,4 @@
}
return new HookResult(HookReturnCode.DECLINED);
}
-}
\ No newline at end of file
+}
Modified:
james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/SMTPServerTest.java
URL:
http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/SMTPServerTest.java?view=diff&rev=491761&r1=491760&r2=491761
==============================================================================
---
james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/SMTPServerTest.java
(original)
+++
james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/SMTPServerTest.java
Tue Jan 2 00:34:47 2007
@@ -406,6 +406,9 @@
// this should give a 501 code cause the helo could not resolved
assertEquals("expected error: helo could not resolved", 501,
smtpProtocol1.getReplyCode());
+
+ // check if not rejected on postmaster and abuse
+ testNotRejectOnPostmasterAbuse(smtpProtocol1);
smtpProtocol1.sendCommand("helo", helo2);
smtpProtocol1.setSender(mail);
@@ -459,6 +462,9 @@
// this should give a 501 code cause the helo not equal reverse of
ip
assertEquals("expected error: helo not equals reverse of ip", 501,
smtpProtocol1.getReplyCode());
+
+ // check if not rejected on postmaster and abuse
+ testNotRejectOnPostmasterAbuse(smtpProtocol1);
smtpProtocol1.sendCommand("helo", helo2);
smtpProtocol1.setSender(mail);
@@ -593,6 +599,9 @@
smtpProtocol1.addRecipient(rcpt2);
assertEquals("expected 452 error", 452, smtpProtocol1.getReplyCode());
+ // check if not rejected on postmaster and abuse
+ testNotRejectOnPostmasterAbuse(smtpProtocol1);
+
smtpProtocol1.sendShortMessageData("Subject: test\r\n\r\nTest body
testMaxRcpt1\r\n");
// After the data is send the rcpt count is set back to 0.. So a new
mail with rcpt should be accepted
@@ -652,6 +661,9 @@
// this should give a 501 code cause the ehlo could not resolved
assertEquals("expected error: ehlo could not resolved", 501,
smtpProtocol1.getReplyCode());
+
+ // check if not rejected on postmaster and abuse
+ testNotRejectOnPostmasterAbuse(smtpProtocol1);
smtpProtocol1.sendCommand("ehlo", ehlo2);
smtpProtocol1.setSender(mail);
@@ -701,6 +713,9 @@
// this should give a 501 code cause the ehlo could not resolved
assertEquals("expected error: ehlo could not resolved", 501,
smtpProtocol1.getReplyCode());
+
+ // check if not rejected on postmaster and abuse
+ testNotRejectOnPostmasterAbuse(smtpProtocol1);
smtpProtocol1.sendCommand("ehlo", ehlo2);
smtpProtocol1.setSender(mail);
@@ -740,6 +755,9 @@
// this should give a 501 code cause the ehlo not equals reverse
of ip
assertEquals("expected error: ehlo not equals reverse of ip", 501,
smtpProtocol1.getReplyCode());
+
+ // check if not rejected on postmaster and abuse
+ testNotRejectOnPostmasterAbuse(smtpProtocol1);
smtpProtocol1.sendCommand("ehlo", ehlo2);
smtpProtocol1.setSender(mail);
@@ -1464,9 +1482,12 @@
smtpProtocol.setSender(sender);
- smtpProtocol.addRecipient("[EMAIL PROTECTED]");
+ smtpProtocol.addRecipient("[EMAIL PROTECTED]");
assertEquals("reject: "+smtpProtocol.getReplyString(), 554,
smtpProtocol
.getReplyCode());
+
+ // check if not rejected on postmaster and abuse
+ testNotRejectOnPostmasterAbuse(smtpProtocol);
smtpProtocol.sendShortMessageData("Subject: test\r\n\r\nTest body
testDNSRBLRejectWorks\r\n");
@@ -1657,5 +1678,22 @@
in.close();
out.close();
client.close();
+ }
+
+
+ /**
+ * Testmethod which should get called in all fastfail tests after a reject
+ *
+ * @param smtpProtocol
+ * @throws Exception
+ */
+ private void testNotRejectOnPostmasterAbuse(SMTPClient smtpProtocol)
throws Exception {
+ smtpProtocol.addRecipient("postmaster");
+ assertEquals("Not reject emails to postmaster"+
smtpProtocol.getReplyString(), 250, smtpProtocol
+ .getReplyCode());
+
+ smtpProtocol.addRecipient("abuse");
+ assertEquals("Not reject emails to abuse"+
smtpProtocol.getReplyString(), 250, smtpProtocol
+ .getReplyCode());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]