def test_original_to_in_body(self): header_to = "*****@*****.**" original_to = "*****@*****.**" alias = "librarian-somewhere" body = "%s: %s\n\nsome body stuff" % (ORIGINAL_TO_HEADER, original_to) log = BufferLogger() mail = self.factory.makeSignedMessage(body=body, to_address=header_to) addresses = extract_addresses(mail, alias, log) self.assertThat(addresses, Equals([header_to])) self.assertThat(log.getLogBuffer(), Equals("INFO Suspected spam: librarian-somewhere\n"))
def test_original_to_missing(self): header_to = '*****@*****.**' alias = 'librarian-somewhere' log = BufferLogger() mail = self.factory.makeSignedMessage(to_address=header_to) addresses = extract_addresses(mail, alias, log) self.assertThat(addresses, Equals([header_to])) self.assertThat( log.getLogBuffer(), Equals('WARNING No X-Launchpad-Original-To header was present ' 'in email: librarian-somewhere\n'))
def test_original_to_in_body(self): header_to = '*****@*****.**' original_to = '*****@*****.**' alias = 'librarian-somewhere' body = '%s: %s\n\nsome body stuff' % (ORIGINAL_TO_HEADER, original_to) log = BufferLogger() mail = self.factory.makeSignedMessage(body=body, to_address=header_to) addresses = extract_addresses(mail, alias, log) self.assertThat(addresses, Equals([header_to])) self.assertThat(log.getLogBuffer(), Equals('INFO Suspected spam: librarian-somewhere\n'))
def test_original_to_missing(self): header_to = "*****@*****.**" alias = "librarian-somewhere" log = BufferLogger() mail = self.factory.makeSignedMessage(to_address=header_to) addresses = extract_addresses(mail, alias, log) self.assertThat(addresses, Equals([header_to])) self.assertThat( log.getLogBuffer(), Equals("WARNING No X-Launchpad-Original-To header was present " "in email: librarian-somewhere\n"), )
def test_original_to(self): mail = self.factory.makeSignedMessage() original_to = '*****@*****.**' mail[ORIGINAL_TO_HEADER] = original_to self.assertThat(extract_addresses(mail, None, None), Equals([original_to]))
def test_original_to(self): mail = self.factory.makeSignedMessage() original_to = "*****@*****.**" mail[ORIGINAL_TO_HEADER] = original_to self.assertThat(extract_addresses(mail, None, None), Equals([original_to]))