def __init__(self):
     """Start the local SMTP test server"""
     unittest.TestSuite.__init__(self)
     self.smtpd = SMTPThreadedServer(SMTP_TEST_PORT)
     self.smtpd.start()
     self.addTest(unittest.makeSuite(NotificationTestCase, 'test'))
     self.remaining = self.countTestCases()
Пример #2
0
 def __init__(self):
     """Start the local SMTP test server"""
     unittest.TestSuite.__init__(self)
     self.smtpd = SMTPThreadedServer(SMTP_TEST_PORT)
     self.smtpd.start()
     self.addTest(unittest.makeSuite(NotificationTestCase, 'test'))
     self.remaining = self.countTestCases()
 def setUp(self):
     self.env = EnvironmentStub(default_data=True)
     self.env.config.set('project', 'name', 'TracTest')
     self.env.config.set('notification', 'smtp_enabled', 'true')
     self.env.config.set('notification', 'always_notify_owner', 'true')
     self.env.config.set('notification', 'always_notify_reporter', 'true')
     self.env.config.set('notification', 'smtp_always_cc',
                                             '*****@*****.**')
     # BBB: [email protected] chi è in always_cc viene notificato
     # sempre anche se non ha il permesso SENSITIVE_VIEW
     # è corretto?
     self.env.config.set('notification', 'use_public_cc', 'true')
     self.env.config.set('notification', 'smtp_port', str(SMTP_TEST_PORT))
     self.env.config.set('notification', 'smtp_server','localhost')
     self.req = Mock(href=self.env.href, abs_href=self.env.abs_href, tz=utc,
                     perm=MockPerm())
     self.smtpd = SMTPThreadedServer(SMTP_TEST_PORT)
     self.smtpd.start()
class NotificationTestSuite(unittest.TestSuite):
    """Thin test suite wrapper to start and stop the SMTP test server"""
    def __init__(self):
        """Start the local SMTP test server"""
        unittest.TestSuite.__init__(self)
        self.smtpd = SMTPThreadedServer(SMTP_TEST_PORT)
        self.smtpd.start()
        self.addTest(unittest.makeSuite(NotificationTestCase, 'test'))
        self.remaining = self.countTestCases()

    def tear_down(self):
        """Reset the local SMTP test server"""
        self.smtpd.cleanup()
        self.remaining = self.remaining - 1
        if self.remaining > 0:
            return
        # stop the SMTP test server when all tests have been completed
        self.smtpd.stop()
Пример #5
0
class NotificationTestSuite(unittest.TestSuite):
    """Thin test suite wrapper to start and stop the SMTP test server"""

    def __init__(self):
        """Start the local SMTP test server"""
        unittest.TestSuite.__init__(self)
        self.smtpd = SMTPThreadedServer(SMTP_TEST_PORT)
        self.smtpd.start()
        self.addTest(unittest.makeSuite(NotificationTestCase, 'test'))
        self.remaining = self.countTestCases()

    def tear_down(self):
        """Reset the local SMTP test server"""
        self.smtpd.cleanup()
        self.remaining = self.remaining-1
        if self.remaining > 0:
            return
        # stop the SMTP test server when all tests have been completed
        self.smtpd.stop()
Пример #6
0
 def __init__(self, port):
     SMTPThreadedServer.__init__(self, port)
     # Override the store with out own
     self.store  = NonForgetingSMTPServerStore()
Пример #7
0
 def __init__(self, port):
     SMTPThreadedServer.__init__(self, port)
     # Override the store with out own
     self.store = NonForgetingSMTPServerStore()
class NotificationTestCase(unittest.TestCase):
    """Notification test cases that send email over SMTP"""

    def setUp(self):
        self.env = EnvironmentStub(default_data=True)
        self.env.config.set('project', 'name', 'TracTest')
        self.env.config.set('notification', 'smtp_enabled', 'true')
        self.env.config.set('notification', 'always_notify_owner', 'true')
        self.env.config.set('notification', 'always_notify_reporter', 'true')
        self.env.config.set('notification', 'smtp_always_cc',
                                                '*****@*****.**')
        # BBB: [email protected] chi è in always_cc viene notificato
        # sempre anche se non ha il permesso SENSITIVE_VIEW
        # è corretto?
        self.env.config.set('notification', 'use_public_cc', 'true')
        self.env.config.set('notification', 'smtp_port', str(SMTP_TEST_PORT))
        self.env.config.set('notification', 'smtp_server','localhost')
        self.req = Mock(href=self.env.href, abs_href=self.env.abs_href, tz=utc,
                        perm=MockPerm())
        self.smtpd = SMTPThreadedServer(SMTP_TEST_PORT)
        self.smtpd.start()

    def tearDown(self):
        """Signal the notification test suite that a test is over"""
        self.smtpd.cleanup()
        self.smtpd.stop()
        self.env.reset_db()

    def test_recipients(self):
        """To/Cc recipients"""
        db = self.env.get_db_cnx()
        cursor = db.cursor()
        cursor.executemany("INSERT INTO permission VALUES (%s,%s)", [
                           ('*****@*****.**', 'SENSITIVE_VIEW'), 
                           ('*****@*****.**', 'SENSITIVE_VIEW'), 
                           ('*****@*****.**', 'SENSITIVE_VIEW'), 
                           ])
        ticket = Ticket(self.env)
        ticket['reporter'] = '*****@*****.**'
        ticket['owner']    = '*****@*****.**'
        ticket['cc']       = '[email protected], [email protected], ' \
                             '*****@*****.**'
        ticket['summary'] = 'Foo'
        ticket['sensitive'] = '1'
        ticket.insert()
        tn = TicketNotifyEmail(self.env)
        tn.notify(ticket, newticket=True)
        recipients = self.smtpd.get_recipients()
        # checks there is no duplicate in the recipient list
        rcpts = []
        for r in recipients:
            self.failIf(r in rcpts)
            rcpts.append(r)
        # checks that all cc recipients have been notified
        cc_list = self.env.config.get('notification', 'smtp_always_cc')
        cc_list = "%s, %s" % (cc_list, ticket['cc'])
        for r in cc_list.replace(',', ' ').split():
            if 'customer' in r:
                self.failIf(r in recipients)
            else:
                self.failIf(r not in recipients)
        # checks that owner has not been notified
        self.failIf(smtp_address(ticket['owner']) not in recipients)
        # checks that reporter has not been notified (is a customer)
        self.failIf(smtp_address(ticket['reporter']) in recipients)
Пример #9
0
 def cleanup(self):
     SMTPThreadedServer.cleanup(self)
     self.store.messages = 0
Пример #10
0
 def __init__(self, port):
     SMTPThreadedServer.__init__(self, port)
     self.store = CustomSMTPServerStore()
Пример #11
0
 def cleanup(self):
     SMTPThreadedServer.cleanup(self)
     self.store.messages = 0
Пример #12
0
 def __init__(self, port):
     SMTPThreadedServer.__init__(self, port)
     self.store = CustomSMTPServerStore()