Examples of SMTPSession


Examples of org.apache.james.protocols.smtp.SMTPSession

        Collection bNetworks = new ArrayList();
        bNetworks.add("127.0.0.1");
       
        DNSService dns = setupMockedDNSServer();
        MailAddress mailAddress = new MailAddress("test@" + INVALID_HOST);
        SMTPSession session = setupMockedSMTPSession(mailAddress);
        ValidRcptMX handler = new ValidRcptMX();

        handler.setDNSService(dns);
        handler.setBannedNetworks(bNetworks, dns);
        int rCode = handler.doRcpt(session, null, mailAddress).getResult();
View Full Code Here

Examples of org.apache.james.protocols.smtp.SMTPSession


    private SMTPSession setupMockSession(final String argument,
             final boolean relaying, final boolean authRequired, final String user, final MailAddress recipient) {
       
        SMTPSession session = new BaseFakeSMTPSession() {

            HashMap<String,Object> connectionMap = new HashMap<String,Object>();
            HashMap<String,Object> map = new HashMap<String,Object>();
           
            public boolean isAuthSupported() {
View Full Code Here

Examples of org.apache.james.protocols.smtp.SMTPSession

        return dns;
    }
   
    public void testRejectInvalidHelo() throws MailAddressException {
        MailAddress mailAddress = new MailAddress("test@localhost");
        SMTPSession session = setupMockSession(INVALID_HOST,false,false,null,mailAddress);
        ResolvableEhloHeloHandler handler = new ResolvableEhloHeloHandler();
        handler.setDNSService(setupMockDNSServer());
       
        handler.doHelo(session, INVALID_HOST);
        assertNotNull("Invalid HELO",session.getState().get(ResolvableEhloHeloHandler.BAD_EHLO_HELO));
       
        int result = handler.doRcpt(session,null, mailAddress).getResult();
        assertEquals("Reject", result,HookReturnCode.DENY);
    }
View Full Code Here

Examples of org.apache.james.protocols.smtp.SMTPSession

    }
   
   
    public void testNotRejectValidHelo() throws MailAddressException {
        MailAddress mailAddress = new MailAddress("test@localhost");
        SMTPSession session = setupMockSession(VALID_HOST,false,false,null,mailAddress);
        ResolvableEhloHeloHandler handler = new ResolvableEhloHeloHandler();
               
        handler.setDNSService(setupMockDNSServer());
 
        handler.doHelo(session, VALID_HOST);
        assertNull("Valid HELO",session.getState().get(ResolvableEhloHeloHandler.BAD_EHLO_HELO));

        int result = handler.doRcpt(session,null, mailAddress).getResult();
        assertEquals("Not reject", result,HookReturnCode.DECLINED);
    }
View Full Code Here

Examples of org.apache.james.protocols.smtp.SMTPSession

    }
  
   
    public void testRejectInvalidHeloAuthUser() throws MailAddressException {
        MailAddress mailAddress = new MailAddress("test@localhost");
        SMTPSession session = setupMockSession(INVALID_HOST,false,true,"valid@user",mailAddress);
        ResolvableEhloHeloHandler handler = new ResolvableEhloHeloHandler();
               
        handler.setDNSService(setupMockDNSServer());

        handler.doHelo(session, INVALID_HOST);
        assertNotNull("Value stored",session.getState().get(ResolvableEhloHeloHandler.BAD_EHLO_HELO));
       
       
        int result = handler.doRcpt(session,null, mailAddress).getResult();
        assertEquals("Reject", result,HookReturnCode.DENY);
    }
View Full Code Here

Examples of org.apache.james.protocols.smtp.SMTPSession

   
  
   
    public void testRejectRelay() throws MailAddressException {
        MailAddress mailAddress = new MailAddress("test@localhost");
        SMTPSession session = setupMockSession(INVALID_HOST,true,false,null,mailAddress);
        ResolvableEhloHeloHandler handler = new ResolvableEhloHeloHandler();
       
       
        handler.setDNSService(setupMockDNSServer());

        handler.doHelo(session, INVALID_HOST);
        assertNotNull("Value stored",session.getState().get(ResolvableEhloHeloHandler.BAD_EHLO_HELO));
       
       
        int result = handler.doRcpt(session,null, mailAddress).getResult();
        assertEquals("Reject", result,HookReturnCode.DENY);
    }
View Full Code Here

Examples of org.apache.james.protocols.smtp.SMTPSession

public class MaxUnknownCmdHandlerTest extends TestCase{

   
    public void testRejectAndClose() throws MailAddressException {
        SMTPSession session = new BaseFakeSMTPSession() {
            private final HashMap<String,Object> state = new HashMap<String,Object>();

            public Map<String,Object> getState() {
                return state;
            }
View Full Code Here

Examples of org.apache.james.protocols.smtp.SMTPSession

        };
        return dns;
    }
   
    private SMTPSession setupMockedSession(final MailAddress sender) {
        SMTPSession session = new BaseFakeSMTPSession() {
            HashMap<String,Object> state = new HashMap<String,Object>();

            public Map<String,Object> getState() {

                state.put(SMTPSession.SENDER, sender);
View Full Code Here

Examples of org.apache.james.protocols.smtp.SMTPSession

        assertEquals("Not blocked cause its a nullsender",response,HookReturnCode.DECLINED);
    }

    public void testInvalidSenderDomainReject() throws MailAddressException {
        ValidSenderDomainHandler handler = new ValidSenderDomainHandler();
        SMTPSession session = setupMockedSession(new MailAddress("invalid@invalid"));
        handler.setDNSService(setupDNSServer());
        int response = handler.doMail(session,(MailAddress) session.getState().get(SMTPSession.SENDER)).getResult();
       
        assertEquals("Blocked cause we use reject action", response,HookReturnCode.DENY);
    }
View Full Code Here

Examples of org.apache.james.protocols.smtp.SMTPSession


public class MaxRcptHandlerTest extends TestCase{
   
    private SMTPSession setupMockedSession(final int rcptCount) {
        SMTPSession session = new BaseFakeSMTPSession() {
            HashMap<String,Object> state = new HashMap<String,Object>();

            public Map<String,Object> getState() {
                return state;
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.