예제 #1
0
def test_sanitize_subject(default_account, mime_message):
    # Parse a raw message with encoded null bytes in subject header;
    # check that we strip the null bytes.
    mime_message.headers['Subject'] = \
        '=?UTF-8?B?WW91ciBVUFMgUGFja2FnZSB3YXMgZGVsaXZlcmVkAAAA?='
    m = Message.create_from_synced(
        default_account, 22, '[Gmail]/All Mail', datetime.datetime.utcnow(),
        mime_message.to_string())
    assert m.subject == u'Your UPS Package was delivered'
예제 #2
0
def test_sanitize_subject(default_account, mime_message):
    # Parse a raw message with encoded null bytes in subject header;
    # check that we strip the null bytes.
    mime_message.headers['Subject'] = \
        '=?UTF-8?B?WW91ciBVUFMgUGFja2FnZSB3YXMgZGVsaXZlcmVkAAAA?='
    m = Message.create_from_synced(default_account, 22, '[Gmail]/All Mail',
                                   datetime.datetime.utcnow(),
                                   mime_message.to_string())
    assert m.subject == u'Your UPS Package was delivered'
예제 #3
0
def test_handle_bad_content_disposition(db, default_account, default_namespace,
                                        mime_message):
    # Message with a MIME part that has an invalid content-disposition.
    mime_message.append(
        mime.create.attachment('image/png', 'filler', 'attached_image.png',
                               disposition='alternative')
    )
    m = create_from_synced(db, default_account, mime_message.to_string())
    assert m.namespace_id == default_namespace.id
    assert m.to_addr == [['Alice', '*****@*****.**']]
    assert m.cc_addr == [['Bob', '*****@*****.**']]
    assert m.body == '<html>Hello World!</html>'
    assert len(m.parts) == 0
    assert (db.session.query(Block).filter(
            Block.namespace_id == default_namespace.id).count() == 0)
예제 #4
0
def test_save_inline_attachments(db, default_account):
    mime_msg = mime.create.multipart('mixed')
    inline_attachment = mime.create.attachment('image/png', 'filler',
                                               'inline_image.png', 'inline')
    inline_attachment.headers['Content-Id'] = '<*****@*****.**>'
    mime_msg.append(inline_attachment)
    return mime_msg
    msg = create_from_synced(db, default_account, mime_message.to_string())
    assert len(msg.parts) == 1
    part = msg.parts[0]
    assert part.content_disposition == 'inline'
    assert part.content_id == '<*****@*****.**>'
    assert part.block.content_type == 'image/png'
    assert part.block.data == 'filler'
    assert (db.session.query(Block).filter(
            Block.namespace_id == default_account.namespace.id).count() == 1)
예제 #5
0
def test_handle_bad_content_disposition(db, default_account, default_namespace,
                                        mime_message):
    # Message with a MIME part that has an invalid content-disposition.
    mime_message.append(
        mime.create.attachment('image/png',
                               'filler',
                               'attached_image.png',
                               disposition='alternative'))
    m = create_from_synced(db, default_account, mime_message.to_string())
    assert m.namespace_id == default_namespace.id
    assert m.to_addr == [['Alice', '*****@*****.**']]
    assert m.cc_addr == [['Bob', '*****@*****.**']]
    assert m.body == '<html>Hello World!</html>'
    assert len(m.parts) == 0
    assert (db.session.query(Block).filter(
        Block.namespace_id == default_namespace.id).count() == 0)
예제 #6
0
def test_save_inline_attachments(db, default_account):
    mime_msg = mime.create.multipart('mixed')
    inline_attachment = mime.create.attachment('image/png', 'filler',
                                               'inline_image.png', 'inline')
    inline_attachment.headers['Content-Id'] = '<*****@*****.**>'
    mime_msg.append(inline_attachment)
    return mime_msg
    msg = create_from_synced(db, default_account, mime_message.to_string())
    assert len(msg.parts) == 1
    part = msg.parts[0]
    assert part.content_disposition == 'inline'
    assert part.content_id == '<*****@*****.**>'
    assert part.block.content_type == 'image/png'
    assert part.block.data == 'filler'
    assert (db.session.query(Block).filter(
        Block.namespace_id == default_account.namespace.id).count() == 1)
예제 #7
0
def test_handle_long_subjects(db, default_account, mime_message):
    mime_message.headers['Subject'] = 4096 * 'A'
    m = create_from_synced(db, default_account, mime_message.to_string())
    assert len(m.subject) < 256
예제 #8
0
def test_handle_long_subjects(db, default_account, mime_message):
    mime_message.headers['Subject'] = 4096 * 'A'
    m = create_from_synced(db, default_account, mime_message.to_string())
    assert len(m.subject) < 256