From 8110ef8687b155df7b24a6c083404f9624e6a160 Mon Sep 17 00:00:00 2001 From: drebs Date: Sat, 16 Sep 2017 08:58:34 -0300 Subject: [test] add e2e test for incoming mail pipeline I had to include part of the bonafide source code because it was the easiest way to interact with the webapp. Closes: #8941 --- tests/e2e/test_incoming_mail_pipeline.py | 56 ++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tests/e2e/test_incoming_mail_pipeline.py (limited to 'tests/e2e/test_incoming_mail_pipeline.py') diff --git a/tests/e2e/test_incoming_mail_pipeline.py b/tests/e2e/test_incoming_mail_pipeline.py new file mode 100644 index 00000000..a5201a46 --- /dev/null +++ b/tests/e2e/test_incoming_mail_pipeline.py @@ -0,0 +1,56 @@ +# This script does the following: +# +# - create a user using bonafide and and invite code given as an environment +# variable. +# +# - create and upload an OpenPGP key manually, as that would be +# a responsibility of bitmask-dev. +# +# - send an email to the user using sendmail, with a secret in the body. +# +# - start a soledad client using the created user. +# +# - download pending blobs. There should be only one. +# +# - look inside the blob, parse the email message. +# +# - compare the token in the incoming message with the token in the sent +# message and succeed if the tokens are the same. +# +# - delete the user (even if the test failed). (TODO) + + +import pytest + +from utils import get_session +from utils import gen_key +from utils import put_key +from utils import send_email +from utils import get_incoming_fd +from utils import get_received_secret + + +@pytest.inlineCallbacks +def test_incoming_mail_pipeline(soledad_client, tmpdir): + + # create a user and login + session = yield get_session(tmpdir) + + # create a OpenPGP key and upload it + key = gen_key(session.username) + yield put_key(session.uuid, session.token, str(key.pubkey)) + + # get a soledad client for that user + client = soledad_client( + uuid=session.uuid, + passphrase='123', + token=session.token) + + # send the email + sent_secret = send_email(session.username) + + # check the incoming blob and compare sent and received secrets + fd = yield get_incoming_fd(client) + received_secret = get_received_secret(key, fd) + assert sent_secret == received_secret + # TODO: delete user in the end -- cgit v1.2.3