Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
111 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,3 @@ cover/ | |
requirements.txt.out | ||
|
||
serviceprincipal.json | ||
volumes/ | ||
downloaded.tar.gz | ||
register.json | ||
download.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
register.json | ||
download.json | ||
downloaded.tar.gz | ||
emails.jsonl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
data_dir="$(dirname "$0")/../files/end_to_end" | ||
|
||
# workflow 3: register a new client called "developer" | ||
# normally this endpoint would be called during a new lokole device setup | ||
curl -fs \ | ||
-H "Content-Type: application/json" \ | ||
-u "admin:password" \ | ||
-d '{"domain":"developer.lokole.ca"}' \ | ||
"http://localhost:8080/api/email/register/" \ | ||
| tee "${data_dir}/register.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
data_dir="$(dirname "$0")/../files/end_to_end" | ||
|
||
emails_to_send="${data_dir}/client-emails.tar.gz" | ||
client_id="$(jq -r '.client_id' < "${data_dir}/register.json")" | ||
resource_container="$(jq -r '.resource_container' < "${data_dir}/register.json")" | ||
resource_id="$(python3 -c 'import uuid;print(str(uuid.uuid4()))').tar.gz" | ||
|
||
# workflow 1: send emails written on the client to the world | ||
# first we simulate the client uploading its emails to the shared blob storage | ||
curl -fs \ | ||
-X PUT -T "${emails_to_send}" \ | ||
-H "x-ms-blob-type: BlockBlob" \ | ||
-H "Content-Length: $(wc -c "${emails_to_send}" | cut -d' ' -f1)" \ | ||
"http://localhost:10000/devstoreaccount1/${resource_container}/${resource_id}" | ||
|
||
# the client then calls the server to trigger the delivery of the emails | ||
curl -fs \ | ||
-H "Content-Type: application/json" \ | ||
-d '{"resource_id":"'"${resource_id}"'"}' \ | ||
"http://localhost:8080/api/email/upload/${client_id}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
data_dir="$(dirname "$0")/../files/end_to_end" | ||
|
||
email_to_receive="${data_dir}/inbound-email.mime" | ||
|
||
client_id="$(jq -r '.client_id' < "${data_dir}/register.json")" | ||
|
||
# workflow 2a: receive an email directed at one of the clients | ||
# this simulates sendgrid delivering an email to the service | ||
curl -fs \ | ||
-H "Content-Type: multipart/form-data" \ | ||
-F "email=$(cat "${email_to_receive}")" \ | ||
"http://localhost:8080/api/email/sendgrid/${client_id}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
data_dir="$(dirname "$0")/../files/end_to_end" | ||
|
||
client_id="$(jq -r '.client_id' < "${data_dir}/register.json")" | ||
resource_container="$(jq -r '.resource_container' < "${data_dir}/register.json")" | ||
|
||
# workflow 2b: deliver emails written by the world to a lokole client | ||
# first the client makes a request to ask the server to package up all the | ||
# emails sent from the world to the client during the last period; the server | ||
# will package up the emails and store them on the shared blob storage | ||
curl -fs \ | ||
-H "Accept: application/json" \ | ||
"http://localhost:8080/api/email/download/${client_id}" \ | ||
| tee "${data_dir}/download.json" | ||
|
||
resource_id="$(jq -r '.resource_id' < "${data_dir}/download.json")" | ||
|
||
# now we simulate the client downloading the package from the shared blob storage | ||
curl -fs \ | ||
"http://localhost:10000/devstoreaccount1/${resource_container}/${resource_id}" \ | ||
> "${data_dir}/downloaded.tar.gz" | ||
|
||
tar xzf "${data_dir}/downloaded.tar.gz" -C "${data_dir}" | ||
|
||
num_emails_actual="$(wc -l "${data_dir}/emails.jsonl" | cut -d' ' -f1)" | ||
num_emails_expected=1 | ||
|
||
if [[ "${num_emails_actual}" -ne "${num_emails_expected}" ]]; then | ||
echo "Got ${num_emails_actual} but expected ${num_emails_expected}" >&2 | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters