Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
SecureMailHost.tests.test_validateEmail.TestValidateEmail Class Reference

List of all members.

Public Member Functions

def afterSetUp
def testvalidateSingleEmailAddress
def testvalidateEmailAddresses

Public Attributes

 mailhost

Detailed Description

Definition at line 11 of file test_validateEmail.py.


Member Function Documentation

Definition at line 13 of file test_validateEmail.py.

00013 
00014     def afterSetUp(self):
00015         self.mailhost = SecureMailBase('securemailhost', '')

Definition at line 59 of file test_validateEmail.py.

00059 
00060     def testvalidateEmailAddresses(self):
00061         # Any RFC 822 email address allowed and address list allowed
00062         val = self.mailhost.validateEmailAddresses
00063 
00064         validInputs = (
00065             'user@example.org',
00066             'foo&.%#$&\'*+-/=?^_`{}|~bar@baz.org,\n foo&.%#$&\'*+-/=?^_`{}|~bar@baz.org',
00067             'user@example.org,\n user2@example.org',
00068             'user@example.org\n user2@example.org' # omitting comma is ok
00069         )
00070         invalidInputs = (
00071             'user@example.org\n\nfoo', # double new lines
00072             'user@example.org\n\rfoo',
00073             'user@example.org\r\nfoo',
00074             'user@example.org\r\rfoo',
00075             #py stdlib bug? 'user@example.org\nuser2@example.org', # continuation line doesn't begin with white space
00076         )
00077         for address in validInputs:
00078             self.failUnless(val(address), '%s should validate' % address)
00079         for address in invalidInputs:
00080             self.failIf(val(address), '%s should fail' % address)

Definition at line 16 of file test_validateEmail.py.

00016 
00017     def testvalidateSingleEmailAddress(self):
00018         # Any RFC 822 email address allowed, but address list must fail
00019         val = self.mailhost.validateSingleEmailAddress
00020         validInputs = (
00021             'user@example.org',
00022             'user@host.example.org',
00023             'm@t.nu',
00024             'm+m@example.biz',
00025             'm.+m@example.info',
00026             'foo&.%#$&\'*+-/=?^_`{}|~bar@baz.org'
00027 
00028             ## Some trickier ones, from RFC 822
00029             #'"A Name" user @ example',
00030             #'"A Name" user\n @ example',
00031             #'nn@[1.2.3.4]'
00032         )
00033         invalidInputs = (
00034             'user@foo', # rfc 822 requires the domain part
00035             'user@example.org, user2@example.org',   # only single address allowed
00036             'user@example.org,user2@example.org',
00037             #'user@example.org;user2@example.org',
00038             'user@example.org\n\nfoo', # double new lines
00039             'user@example.org\n\rfoo',
00040             'user@example.org\r\nfoo',
00041             'user@example.org\r\rfoo',
00042             'user@example.org\nfoo@example.org', # only single address allowed, even if given one per line
00043             'user@example.org\nBcc: user@example.org',
00044             'user@example.org\nCc: user@example.org',
00045             'user@example.org\nSubject: Spam',
00046             # and a full email (note the missing ,!)
00047             'From: foo@example.org\n'
00048             'To: bar@example.org, spam@example.org\n'
00049             'Cc: egg@example.org\n'
00050             'Subject: Spam me plenty\n'
00051             'Spam Spam Spam\n'
00052             'I hate spam',
00053             
00054         )
00055         for address in validInputs:
00056             self.failUnless(val(address), '%s should validate' % address)
00057         for address in invalidInputs:
00058             self.failIf(val(address), '%s should fail' % address)
    

Member Data Documentation

Definition at line 14 of file test_validateEmail.py.


The documentation for this class was generated from the following file: