def test_dkim_sign_twice():

    # Test #44:
    # " if you put the open there and send more than one messages it fails
    #   (the first works but the next will not if you dont seek(0) the dkim file first)"
    # Actually not.

    priv_key, pub_key = _generate_key(length=1024)
    message = Message(**common_email_data())
    message.dkim(key=NativeStringIO(to_native(priv_key)), selector='_dkim', domain='somewhere.net')
    for n in range(2):
        message.subject = 'Test %s' % n
        assert _check_dkim(message, pub_key)
Example #2
0
def test_headers_not_double_encoded():

    TEXT = '웃'

    m = Message()
    m.mail_from = (TEXT, '[email protected]')
    m.mail_to = (TEXT, '[email protected]')
    m.subject = TEXT
    m.html = '...'
    msg = m.as_message()
    assert decode_header(parseaddr(msg['From'])[0]) == TEXT
    assert decode_header(parseaddr(msg['To'])[0]) == TEXT
    assert decode_header(msg['Subject']) == TEXT
Example #3
0
def test_headers_not_double_encoded():

    TEXT = '웃'

    m = Message()
    m.mail_from = (TEXT, '[email protected]')
    m.mail_to = (TEXT, '[email protected]')
    m.subject = TEXT
    m.html = '...'
    msg = m.as_message()
    assert decode_header(parseaddr(msg['From'])[0]) == TEXT
    assert decode_header(parseaddr(msg['To'])[0]) == TEXT
    assert decode_header(msg['Subject']) == TEXT
Example #4
0
def test_dkim_sign_twice():

    # Test #44:
    # " if you put the open there and send more than one messages it fails
    #   (the first works but the next will not if you dont seek(0) the dkim file first)"
    # Actually not.

    priv_key, pub_key = _generate_key(length=1024)
    message = Message(**common_email_data())
    message.dkim(key=NativeStringIO(to_native(priv_key)),
                 selector='_dkim',
                 domain='somewhere.net')
    for n in range(2):
        message.subject = 'Test %s' % n
        assert _check_dkim(message, pub_key)