def test_add_message_id_header_existing(self):
     env = Envelope()
     env.parse(b'Message-Id: testing\r\n')
     amih = AddMessageIdHeader()
     self.assertEqual('testing', env.headers['Message-Id'])
     amih.apply(env)
     self.assertEqual('testing', env.headers['Message-Id'])
 def test_add_message_id_header_existing(self):
     env = Envelope()
     env.parse('Message-Id: testing\r\n')
     amih = AddMessageIdHeader()
     self.assertEqual('testing', env.headers['Message-Id'])
     amih.apply(env)
     self.assertEqual('testing', env.headers['Message-Id'])
 def test_add_message_id_header(self):
     env = Envelope()
     env.parse(b'')
     env.timestamp = 1234567890
     amih = AddMessageIdHeader('example.com')
     self.assertEqual(None, env.headers['Message-Id'])
     amih.apply(env)
     pattern = r'^<[0-9a-fA-F]{32}\[email protected]>$'
     self.assertRegexpMatches(env.headers['Message-Id'], pattern)
 def test_add_message_id_header(self):
     env = Envelope()
     env.parse('')
     env.timestamp = 1234567890
     amih = AddMessageIdHeader('example.com')
     self.assertEqual(None, env.headers['Message-Id'])
     amih.apply(env)
     pattern = r'^<[0-9a-fA-F]{32}\[email protected]>$'
     self.assertRegexpMatches(env.headers['Message-Id'], pattern)
def _start_outbound_queue(args, relay, inbound_queue):
    from slimta.queue.dict import DictStorage
    from slimta.queue import Queue
    from slimta.policy.headers import AddDateHeader, \
        AddMessageIdHeader, AddReceivedHeader
    from slimta.policy.split import RecipientDomainSplit

    envelope_db = {}
    meta_db = {}

    storage = DictStorage(envelope_db, meta_db)
    queue = Queue(storage, relay, bounce_queue=inbound_queue)
    queue.start()

    queue.add_policy(AddDateHeader())
    queue.add_policy(AddMessageIdHeader())
    queue.add_policy(AddReceivedHeader())
    queue.add_policy(RecipientDomainSplit())

    return queue
def _start_inbound_queue(args, relay):
    from slimta.queue.dict import DictStorage
    from slimta.queue import Queue
    from slimta.policy.headers import AddDateHeader, \
        AddMessageIdHeader, AddReceivedHeader
    from slimta.policy.spamassassin import SpamAssassin

    envelope_db = {}
    meta_db = {}

    storage = DictStorage(envelope_db, meta_db)
    queue = Queue(storage, relay)
    queue.start()

    queue.add_policy(AddDateHeader())
    queue.add_policy(AddMessageIdHeader())
    queue.add_policy(AddReceivedHeader())
    if args.spamassassin:
        queue.add_policy(SpamAssassin())

    return queue