示例#1
0
 def test_messageDeliveryAgentDeliveryFactory(self):
     """
     Similar to L{test_messageTransferAgentDeliveryFactory}, but test
     L{mail.MailDeliveryAgent} instead.
     """
     account = self.login.accountByAddress(u'testuser', u'example.com')
     factory = smtp.IMessageDeliveryFactory(account)
     delivery = factory.getMessageDelivery()
     self.failUnless(smtp.IMessageDelivery.providedBy(delivery))
示例#2
0
    def test_validateFromAuthenticatedNonLocal(self):
        """
        Test that using a non-local address as the sender address after
        authenticating as a user is rejected.
        """
        avatar = self.login.accountByAddress(u'testuser', u'localhost')
        delivery = smtp.IMessageDeliveryFactory(avatar).getMessageDelivery()

        addr = smtp.Address('*****@*****.**')
        d = delivery.validateFrom(('home.example.net', '192.168.1.1'), addr)
        return self.assertFailure(d, smtp.SMTPBadSender)
示例#3
0
    def test_validateFromAuthenticatedDisallowedLocal(self):
        """
        Test that using a local address as the sender address after
        authenticating as a user who does /not/ own that address is rejected.
        """
        avatar = self.login.accountByAddress(u'testuser', u'localhost')
        delivery = smtp.IMessageDeliveryFactory(avatar).getMessageDelivery()

        addr = smtp.Address('admistrator@localhost')
        d = delivery.validateFrom(('home.example.net', '192.168.1.1'), addr)
        return self.assertFailure(d, smtp.SMTPBadSender)
示例#4
0
    def test_validateFromAuthenticatedLocal(self):
        """
        Test that using a local address as the sender address after
        authenticating as the user who owns that address is accepted.
        """
        avatar = self.login.accountByAddress(u'testuser', u'localhost')
        delivery = smtp.IMessageDeliveryFactory(avatar).getMessageDelivery()

        addr = smtp.Address('testuser@localhost')
        d = delivery.validateFrom(('home.example.net', '192.168.1.1'), addr)
        return d.addCallback(self.assertEquals, addr)
示例#5
0
 def test_messageTransferAgentDeliveryFactory(self):
     """
     Test that L{mail.MailTransferAgent} properly powers up the Item it is
     installed on for L{smtp.IMessageDeliveryFactory} and that the
     L{smtp.IMessageDelivery} provider it makes available is at least
     minimally functional.
     """
     mta = mail.MailTransferAgent(store=self.store)
     installOn(mta, self.store)
     factory = smtp.IMessageDeliveryFactory(self.store)
     delivery = factory.getMessageDelivery()
     self.failUnless(smtp.IMessageDelivery.providedBy(delivery))
示例#6
0
    def test_validateToAuthenticatedNonExistentLocal(self):
        """
        Test that using as the recipient address a non-existent address which
        would exist locally if it existed at all is rejected.
        """
        avatar = self.login.accountByAddress(u'testuser', u'localhost')
        delivery = smtp.IMessageDeliveryFactory(avatar).getMessageDelivery()

        addr = smtp.Address('testuser@localhost')
        d = delivery.validateFrom(('home.example.net', '192.168.1.1'), addr)
        def validatedFrom(ign):
            d = delivery.validateTo(
                smtp.User(
                    smtp.Address('nonexistent', 'localhost'),
                    None, None, None))
            return self.assertFailure(d, smtp.SMTPBadRcpt)
        d.addCallback(validatedFrom)
        return d
示例#7
0
    def test_validateToAuthenticatedNonLocal(self):
        """
        Test that using a non-local address as the recipient address after
        authenticating as anyone is accepted.
        """
        avatar = self.login.accountByAddress(u'testuser', u'localhost')
        delivery = smtp.IMessageDeliveryFactory(avatar).getMessageDelivery()

        addr = smtp.Address('testuser@localhost')
        d = delivery.validateFrom(('home.example.net', '192.168.1.1'), addr)
        def validatedFrom(ign):
            d = delivery.validateTo(
                smtp.User(
                    smtp.Address('administrator', 'example.com'),
                    None, None, None))
            return d
        d.addCallback(validatedFrom)
        return d
示例#8
0
    def test_authenticatedMultipleRecipientsOneRecord(self):
        """
        Test that only one sent message object is created even if a messages is
        destined for multiple recipients.
        """
        self.installStubSender(u'testuser', u'localhost')
        account = self.login.accountByAddress(u'testuser', u'localhost')
        factory = smtp.IMessageDeliveryFactory(account)
        delivery = factory.getMessageDelivery()

        d = delivery.validateFrom(
            ('home.example.net', '192.168.1.1'),
            smtp.Address('testuser@localhost'))
        def validatedFrom(ign):
            return gatherResults([
                    delivery.validateTo(
                        smtp.User(
                            smtp.Address(addr), None, None, None))
                    for addr in self.MULTI_RECIPIENT_ADDRESSES])
        d.addCallback(validatedFrom)
        d.addCallback(self.deliverMessageAndVerify, u'testuser', u'localhost')
        return d