Example #1
0
def test_rfc822_format(stub_message_from_raw, api_client, mime_message):
    """ Test the API response to retreive raw message contents """
    full_path = '/messages/{}'.format(stub_message_from_raw.public_id)

    results = api_client.get_raw(full_path,
                                 headers={'Accept': 'message/rfc822'})
    assert results.data == mime_message.to_string()
Example #2
0
def test_rfc822_format(stub_message_from_raw, api_client, mime_message):
    """ Test the API response to retreive raw message contents """
    full_path = '/messages/{}'.format(stub_message_from_raw.public_id)

    results = api_client.get_raw(full_path,
                                    headers={'Accept': 'message/rfc822'})
    assert results.data == mime_message.to_string()
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'
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'
def test_handle_bad_content_disposition(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(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
def test_handle_bad_content_disposition(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(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
def test_save_inline_attachments(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(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'
def test_save_inline_attachments(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(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'
Example #9
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)
Example #10
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)
def test_handle_long_subjects(default_account, mime_message):
    mime_message.headers['Subject'] = 4096 * 'A'
    m = create_from_synced(default_account, mime_message.to_string())
    assert len(m.subject) < 256
Example #12
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