Ticket #7773: mail-regression-test.diff

File mail-regression-test.diff, 1.3 KB (added by serialx, 7 years ago)

A yet simple mail regression test to confirm correct EmailMessage operation plus a test for header injection.

  • new file django_trunk/tests/regressiontests/mail/tests.py

    - +  
     1# coding: utf-8
     2r"""
     3# Tests for the django.core.mail.
     4
     5>>> from django.core.mail import EmailMessage
     6
     7# Test normal ascii character case:
     8
     9>>> email = EmailMessage('Subject', 'Content', 'from@example.com', ['to@example.com'])
     10>>> message = email.message()
     11>>> str(message['Subject'])
     12'Subject'
     13>>> str(message.get_payload())
     14'Content'
     15>>> str(message['From'])
     16'from@example.com'
     17>>> str(message['To'])
     18'to@example.com'
     19
     20# Test for header injection
     21
     22>>> email = EmailMessage('Subject\nInjection Test', 'Content', 'from@example.com', ['to@example.com'])
     23>>> message = email.message()
     24Traceback (most recent call last):
     25    ...
     26BadHeaderError: Header values can't contain newlines (got 'Subject\nInjection Test' for header 'Subject')
     27
     28"""
  • new file django_trunk/tests/regressiontests/mail/__init__.py

    - +  
     1
     2
Back to Top