Exemple #1
0
    def test_specific_template(self):

        providers = {
            'spamhaus': '*****@*****.**',
            'bitninja': '*****@*****.**',
            'nfoservers': '*****@*****.**',
            'lexsicom': '*****@*****.**',
        }

        for file_name, email in providers.iteritems():
            sample = self.samples[file_name]
            content = sample.read()
            headers = self.email_parser.get_headers(content)
            sender = parser.get_sender_from_headers(headers)
            template = self.email_parser.get_template(sender)
            self.assertEqual(self.email_parser._templates[email], template)

            subject = parser.get_subject_from_headers(headers)
            body, attachments = self.email_parser.get_body_and_attachments(content)
            content = subject + '\n' + body

            parsed_email = parser.ParsedEmail()
            self.email_parser.update_parsed_email(parsed_email, content, template=template)
            self.assertIn('1.2.3.4', parsed_email.ips)
Exemple #2
0
    def test_get_subject_sample2(self):

        sample = self.samples['sample2']
        headers = self.email_parser.get_headers(sample.read())
        subject = parser.get_subject_from_headers(headers)
        self.assertIn('[SpamCop (213.251.151.160) id:6301094139]{SPAM 07.7} =?UTF-8?Q?Impor', subject)
Exemple #3
0
    def test_get_subject_sample1(self):

        sample = self.samples['sample1']
        headers = self.email_parser.get_headers(sample.read())
        subject = parser.get_subject_from_headers(headers)
        self.assertEqual('Encoding test', subject)