From b114e82a2ec0b5c9df1b17a646e4e40a637df160 Mon Sep 17 00:00:00 2001 From: Clemens Wolff Date: Sun, 3 May 2020 10:17:02 -0400 Subject: [PATCH] Make webmail user management case insensitive (#423) * Make webmail user management case insensitive * Enable versioning of client emails test package * Increase integration test delay for live tests * Visualize test delays --- .env | 1 + .travis.yml | 1 + docker/docker-compose.test.yml | 1 + docker/integtest/2-client-uploads-emails.sh | 2 + .../integtest/3-receive-email-for-client.sh | 7 +++ docker/integtest/4-client-downloads-emails.sh | 6 ++- docker/integtest/files/.gitignore | 1 + docker/integtest/files/client-emails.tar.gz | Bin 533 -> 0 bytes docker/integtest/files/emails.jsonl | 3 ++ docker/integtest/files/inbound-email-2.mime | 27 ++++++++++ docker/integtest/files/zzusers.jsonl | 1 + docker/integtest/tests.sh | 6 ++- docker/integtest/utils.sh | 12 +++++ .../webapp/templates/macros/email.html | 2 +- opwen_email_server/integration/azure.py | 2 + opwen_email_server/services/storage.py | 46 ++++++++++++++++-- .../services/test_storage.py | 38 ++++++++++++++- 17 files changed, 147 insertions(+), 9 deletions(-) delete mode 100644 docker/integtest/files/client-emails.tar.gz create mode 100644 docker/integtest/files/emails.jsonl create mode 100644 docker/integtest/files/inbound-email-2.mime create mode 100644 docker/integtest/files/zzusers.jsonl diff --git a/.env b/.env index c5805aa9..330514b6 100644 --- a/.env +++ b/.env @@ -15,6 +15,7 @@ LOKOLE_EMAIL_SERVER_QUEUES_NAMESPACE= LOKOLE_SENDGRID_KEY= LOKOLE_RESOURCE_SUFFIX= REGISTRATION_CREDENTIALS=admin:password +TEST_STEP_DELAY=10 CLOUDBROWSER_PORT=10001 AZURITE_PORT=10000 diff --git a/.travis.yml b/.travis.yml index 98b52da2..64c0182d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,7 @@ before_script: | export AZURITE_KEY="$TEST_AZURE_STORAGE_KEY" export AZURITE_HOST="" export AZURITE_SECURE="True" + export TEST_STEP_DELAY=90 else export REGISTRATION_CREDENTIALS="admin:password" export LOKOLE_QUEUE_BROKER_SCHEME="amqp" diff --git a/docker/docker-compose.test.yml b/docker/docker-compose.test.yml index 4ccd81c1..458fd144 100644 --- a/docker/docker-compose.test.yml +++ b/docker/docker-compose.test.yml @@ -13,5 +13,6 @@ services: AZURITE_ACCOUNT: ${AZURITE_ACCOUNT} AZURITE_KEY: ${AZURITE_KEY} AZURITE_HOST: ${AZURITE_HOST} + TEST_STEP_DELAY: ${TEST_STEP_DELAY} volumes: - /var/run/docker.sock:/var/run/docker.sock diff --git a/docker/integtest/2-client-uploads-emails.sh b/docker/integtest/2-client-uploads-emails.sh index e4796abd..c4595e4a 100755 --- a/docker/integtest/2-client-uploads-emails.sh +++ b/docker/integtest/2-client-uploads-emails.sh @@ -9,6 +9,8 @@ mkdir -p "${out_dir}" . "${scriptdir}/utils.sh" emails_to_send="${in_dir}/client-emails.tar.gz" +tar -czf "${emails_to_send}" -C "${in_dir}" emails.jsonl zzusers.jsonl + client_id="$(jq -r '.client_id' < "${out_dir}/register1.json")" resource_container="$(jq -r '.resource_container' < "${out_dir}/register1.json")" resource_id="$(uuidgen).tar.gz" diff --git a/docker/integtest/3-receive-email-for-client.sh b/docker/integtest/3-receive-email-for-client.sh index b3d995ca..a0be2bee 100755 --- a/docker/integtest/3-receive-email-for-client.sh +++ b/docker/integtest/3-receive-email-for-client.sh @@ -26,3 +26,10 @@ http --check-status -f POST \ "dkim={@sendgrid.com : pass}" \ "SPF=pass" \ "email=@${email_to_receive}" + +# simulate delivery of another email +http --check-status -f POST \ + "http://nginx:8888/api/email/sendgrid/${client_id}" \ + "dkim={@sendgrid.com : pass}" \ + "SPF=pass" \ + "email=@${in_dir}/inbound-email-2.mime" diff --git a/docker/integtest/4-client-downloads-emails.sh b/docker/integtest/4-client-downloads-emails.sh index 9cfca1a4..d655e206 100755 --- a/docker/integtest/4-client-downloads-emails.sh +++ b/docker/integtest/4-client-downloads-emails.sh @@ -7,6 +7,10 @@ mkdir -p "${out_dir}" # shellcheck disable=SC1090 . "${scriptdir}/utils.sh" +declare -A num_emails_expected_for_client +num_emails_expected_for_client[1]=2 +num_emails_expected_for_client[2]=1 + for i in 1 2; do client_id="$(jq -r '.client_id' < "${out_dir}/register${i}.json")" @@ -29,7 +33,7 @@ az_storage download "${resource_container}" "${resource_id}" "${out_dir}/downloa tar xzf "${out_dir}/downloaded${i}.tar.gz" -C "${out_dir}" num_emails_actual="$(wc -l "${out_dir}/emails.jsonl" | cut -d' ' -f1)" -num_emails_expected=1 +num_emails_expected="${num_emails_expected_for_client[${i}]}" if [[ "${num_emails_actual}" -ne "${num_emails_expected}" ]]; then echo "Got ${num_emails_actual} emails but expected ${num_emails_expected}" >&2 diff --git a/docker/integtest/files/.gitignore b/docker/integtest/files/.gitignore index 071eb825..a151876c 100644 --- a/docker/integtest/files/.gitignore +++ b/docker/integtest/files/.gitignore @@ -1 +1,2 @@ test.out/ +client-emails.tar.gz diff --git a/docker/integtest/files/client-emails.tar.gz b/docker/integtest/files/client-emails.tar.gz deleted file mode 100644 index 89aee01fb8cac260f7e9b6db6f137995126e09e8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 533 zcmV+w0_y!AiwFpbBidaA0Ap-vWo~pWWo=<;Y;!JjVR8WNRohP7Fc8f%UlB$7NK)I0 zon)U-TlJ=`%B3wV6+({fumLAtVh2hP|6Y5yt6oHfio^;~&Vwz@jAzcVtYcBrO6urT zt44Yc1Yki3aXU;g__Z$qK|(wjV~i0XDNH;7V*-HZ18)uJw4trE8GI2Fv;A#bWy8{Y`KEFPY(MPq!&z@IFJ`Ak+eWE&QWU)d9Tsh!5cy#lg+S zO8Jud{dE5!ZckXA{QuR}s=Y-b2XR@J2!)to7$&79pFs#iT%d$xBqvGX_)%jho7MKH zwnVL_N{WWo!gg>(BJzQ$X}a?Jzjpvh?EIgQ1VNl2S5MGd{oey?ne_;99W1Qs?hjy2wZ2rX zv!)R$Mi7ni2|YMJ{J8z00^8N+X_RCBe&^E#%O+>joqkuIV4BZg?;j-T5)AOt5 X3mVL1z<>b*9tVB^b7Fx&01f~EZ9V +Date: Sun, 12 Feb 2017 22:25:01 -0800 +Message-ID: +Subject: Two recipients +To: Clemens@developer1.lokole.ca, LaUrA@developer1.lokole.ca +Content-Type: multipart/alternative; boundary=001a1146392641b94705486384bf + +--001a1146392641b94705486384bf +Content-Type: text/plain; charset=UTF-8 + +Body of the message. + +--001a1146392641b94705486384bf +Content-Type: text/html; charset=UTF-8 + +
Body of the message.
+ +--001a1146392641b94705486384bf-- diff --git a/docker/integtest/files/zzusers.jsonl b/docker/integtest/files/zzusers.jsonl new file mode 100644 index 00000000..bf63cd96 --- /dev/null +++ b/docker/integtest/files/zzusers.jsonl @@ -0,0 +1 @@ +{"email":"clemens@developer1.lokole.ca","password":"$2b$12$9LaXqZMPJi0PiTY.95dIQOvc8LkYQzRlg5a9pDWX47L/npaYqynU2"} diff --git a/docker/integtest/tests.sh b/docker/integtest/tests.sh index 648cc131..e01fc19d 100755 --- a/docker/integtest/tests.sh +++ b/docker/integtest/tests.sh @@ -2,11 +2,13 @@ set -eo pipefail scriptdir="$(dirname "$0")" +# shellcheck disable=SC1090 +. "${scriptdir}/utils.sh" "${scriptdir}/0-wait-for-services.sh" "${scriptdir}/1-register-client.sh" -"${scriptdir}/2-client-uploads-emails.sh" && sleep 10s -"${scriptdir}/3-receive-email-for-client.sh" && sleep 10s +"${scriptdir}/2-client-uploads-emails.sh" && wait_seconds "${TEST_STEP_DELAY}" +"${scriptdir}/3-receive-email-for-client.sh" && wait_seconds "${TEST_STEP_DELAY}" "${scriptdir}/4-client-downloads-emails.sh" "${scriptdir}/5-assert-on-results.sh" diff --git a/docker/integtest/utils.sh b/docker/integtest/utils.sh index a0708c9b..4787ae36 100755 --- a/docker/integtest/utils.sh +++ b/docker/integtest/utils.sh @@ -30,3 +30,15 @@ az_storage() { --connection-string "$(az_connection_string)" \ > /dev/null } + +wait_seconds() { + local seconds="$1" + + printf 'Waiting' >&2 + while [[ "${seconds}" -gt 0 ]]; do + printf '.' >&2 + sleep 1 + seconds="$((seconds - 1))" + done + echo >&2 +} diff --git a/opwen_email_client/webapp/templates/macros/email.html b/opwen_email_client/webapp/templates/macros/email.html index 1f7579a2..9c39b8d7 100644 --- a/opwen_email_client/webapp/templates/macros/email.html +++ b/opwen_email_client/webapp/templates/macros/email.html @@ -27,7 +27,7 @@

{% if show_sent_to %}