Esempio n. 1
0
 def test_simple_message(self):
     output = create_message('hello world!', '*****@*****.**', '*****@*****.**', 'hi').as_string()
     assert 'From: [email protected]\n' in output
     assert 'To: [email protected]\n' in output
     assert 'Subject: hi\n' in output
     assert 'Date: ' in output
     assert 'hello world!' in output
Esempio n. 2
0
 def test_newline_in_subject(self):
     # prevent header injection
     subject = "Hello\nBcc: [email protected]"
     output = create_message('asdf', '*****@*****.**', '*****@*****.**',
                             subject).as_string()
     assert ('Subject: =?utf-8?q?Hello=0D=0A'
             'Bcc=3A_hacker=40domain=2Ecom?=\n' in output)
Esempio n. 3
0
 def test_multiple_recipients(self):
     recipients = ['*****@*****.**' % name for name in 'abcdefghijklm']
     output = create_message('hello world!', recipients, '*****@*****.**', 'hi').as_string()
     assert ('To: [email protected], [email protected], [email protected], [email protected], '
             '[email protected], [email protected], [email protected],\n'
             '\[email protected], [email protected], [email protected], '
             '[email protected], [email protected], [email protected]\n' in output)
Esempio n. 4
0
 def test_simple_message(self):
     output = create_message('hello world!', '*****@*****.**', '*****@*****.**',
                             'hi').as_string()
     assert 'From: [email protected]\n' in output
     assert 'To: [email protected]\n' in output
     assert 'Subject: hi\n' in output
     assert 'Date: ' in output
     assert 'hello world!' in output
Esempio n. 5
0
 def test_multiple_recipients(self):
     recipients = ['*****@*****.**' % name for name in 'abcdefghijklm']
     output = create_message('hello world!', recipients, '*****@*****.**',
                             'hi').as_string()
     assert ('To: [email protected], [email protected], [email protected], [email protected], '
             '[email protected], [email protected], [email protected],\n'
             '\[email protected], [email protected], [email protected], '
             '[email protected], [email protected], [email protected]\n' in output)
Esempio n. 6
0
 def test_unicode_recipient(self):
     recipient = u'H\u00E9ll\u00F8 Sayer <*****@*****.**>'
     output = create_message('hello world!', recipient, '*****@*****.**', 'hi').as_string()
     assert ('To: =?utf-8?b?SMOpbGzDuCBTYXllciA8aGV'
             'sbG8uc2F5ZXJAZWR3LnJvPg==?=' in output)
Esempio n. 7
0
 def test_newline_in_subject(self):
     # prevent header injection
     subject = "Hello\nBcc: [email protected]"
     output = create_message('asdf', '*****@*****.**', '*****@*****.**', subject).as_string()
     assert ('Subject: =?utf-8?q?Hello=0D=0A'
             'Bcc=3A_hacker=40domain=2Ecom?=\n' in output)
Esempio n. 8
0
 def test_unicode_subject(self):
     subject = u'h\u00E9ll\u00F8 w\u00F6rl\u1E0B\u203D'
     output = create_message('asdf', '*****@*****.**', '*****@*****.**', subject).as_string()
     assert 'Subject: =?utf-8?b?aMOpbGzDuCB3w7ZybOG4i+KAvQ==?=\n' in output
Esempio n. 9
0
 def test_unicode_body(self):
     body = u'h\u00E9ll\u00F8 w\u00F6rl\u1E0B\u203D'
     output = create_message(body, '*****@*****.**', '*****@*****.**', 'hi').as_string()
     assert 'Content-Type: text/plain; charset="utf-8"\n' in output
     assert 'Content-Transfer-Encoding: quoted-printable\n' in output
     assert 'h=C3=A9ll=C3=B8 w=C3=B6rl=E1=B8=8B=E2=80=BD' in output
Esempio n. 10
0
 def test_unicode_recipient(self):
     recipient = u'H\u00E9ll\u00F8 Sayer <*****@*****.**>'
     output = create_message('hello world!', recipient, '*****@*****.**',
                             'hi').as_string()
     assert ('To: =?utf-8?b?SMOpbGzDuCBTYXllciA8aGV'
             'sbG8uc2F5ZXJAZWR3LnJvPg==?=' in output)
Esempio n. 11
0
 def test_unicode_subject(self):
     subject = u'h\u00E9ll\u00F8 w\u00F6rl\u1E0B\u203D'
     output = create_message('asdf', '*****@*****.**', '*****@*****.**',
                             subject).as_string()
     assert 'Subject: =?utf-8?b?aMOpbGzDuCB3w7ZybOG4i+KAvQ==?=\n' in output
Esempio n. 12
0
 def test_unicode_body(self):
     body = u'h\u00E9ll\u00F8 w\u00F6rl\u1E0B\u203D'
     output = create_message(body, '*****@*****.**', '*****@*****.**', 'hi').as_string()
     assert 'Content-Type: text/plain; charset="utf-8"\n' in output
     assert 'Content-Transfer-Encoding: quoted-printable\n' in output
     assert 'h=C3=A9ll=C3=B8 w=C3=B6rl=E1=B8=8B=E2=80=BD' in output