Skip to content

Commit

Permalink
Fix TypeError in ReceiveInboundEmail (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsclafani authored May 11, 2020
1 parent 0f28fab commit 1dddd33
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
19 changes: 19 additions & 0 deletions docker/integtest/6-receive-service-email.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -eo pipefail

scriptdir="$(dirname "$0")"
in_dir="${scriptdir}/files"
out_dir="${scriptdir}/files/test.out"
mkdir -p "${out_dir}"
# shellcheck disable=SC1090
. "${scriptdir}/utils.sh"

email_to_receive="${in_dir}/service-email.mime"


#receive an email directed at the service endpoint
http --check-status -f POST \
"http://nginx:8888/api/email/sendgrid/service" \
"dkim={@sendgrid.com : pass}" \
"SPF=pass" \
"email=@${email_to_receive}"
27 changes: 27 additions & 0 deletions docker/integtest/files/service-email.mime
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Received: by mx0028p1mdw1.sendgrid.net with SMTP id Yt3NEnbnLU Mon, 13 Feb 2017 06:25:41 +0000 (UTC)
Received: from mail-yw0-f176.google.com (mail-yw0-f176.google.com [209.85.161.176]) by mx0028p1mdw1.sendgrid.net (Postfix) with ESMTPS id C726D640B63; Mon, 13 Feb 2017 06:25:41 +0000 (UTC)
Received: by mail-yw0-f176.google.com with SMTP id w75so45612320ywg.1; Sun, 12 Feb 2017 22:25:41 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=ViHLGS6kOdo9Q9CkDDSSSS3bgKuN0a+UXhwMw06ak4Q=; b=f3WGzjgLe0tPG2edhiHxiCEZatThUga/qJFnWZNyY4lEVjRM9l3qn1BZ4ITawT9tDK LS6qFx//6in7u0rV0YKoa8TfScUFOpPHGCmq1Wxdp7mrWP7GDuCOz3LzyXQsrBe/erGy YEjAVU876sWJ109mcMcmbgOL1SD3d4ak+8GVBSC8oMKPj5XWZsET7WmsonhKf5PHE9IW eJHKqdOkxiPbmDutVx7uS1Bi5u4d9UYPhgxFwAK9lWyJ/Esw6yffjlrUvmQCPibSCxRv o979yY6FyJXDJ82l4ErntcOloFNpzWZ89WkRhb1aBLUoZs3402s6D3wC0ljpmvneIAkw 3D6A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=ViHLGS6kOdo9Q9CkDDSSSS3bgKuN0a+UXhwMw06ak4Q=; b=sWY7uU6kK3dg62wVuxcLsRYLg3eGcoLuoLjL0Ju/sl9rGqSDxVc2saIS0ThfUaHlfZ g1zvF+rBoxa7v9jk7MhEw3izW01WXDMm0w2JGc1QLTo3ZM2xW9Clss63R3ZtNKabuyhd 77NHAgbarmQGW5XuqwS1Fy0NMWHkAlLsZd2AnkNb6gCI/VHCCv/oem19bWvNWwRTPBYE cQDPJfzRiUzRPNZPLtlL5ybd2yyb4lcuG+2QoQV8uxPsKS4eDOjNmM76UWZ9s/Ul/mR+ Qbyui7suOO0vPy8GFJHPV9X2ffLqesafTAetCj3LClCdLIdfQDaK86mmVHOT6zldeCTa HH6Q==
X-Gm-Message-State: AMke39n2h/OZU6fwgOdDltzsKqISVbe3ez6t19OeVrg2sT3pDRhSSQiIcwGzKjdWOD/oX96rQlTi0O9t9yhUfA==
X-Received: by 10.129.81.4 with SMTP id f4mr15409224ywb.239.1486967141412; Sun, 12 Feb 2017 22:25:41 -0800 (PST)
MIME-Version: 1.0
Received: by 10.129.156.139 with HTTP; Sun, 12 Feb 2017 22:25:01 -0800 (PST)
From: Clemens Wolff <clemens.wolff@gmail.com>
Date: Sun, 12 Feb 2017 22:25:01 -0800
Message-ID: <CAL79TcnjhV5PinZVY8Y3QEoNNcSa9uuNU5N3EP-gqcYPFfuHLA@mail.gmail.com>
Subject: Service Email
To: echo@bot.lokole.ca,
Content-Type: multipart/alternative; boundary=001a1146392641b94705486384bf

--001a1146392641b94705486384bf
Content-Type: text/plain; charset=UTF-8

This is an email that should be echoed.

--001a1146392641b94705486384bf
Content-Type: text/html; charset=UTF-8

<div dir="ltr">Body of the message.</div>

--001a1146392641b94705486384bf--
1 change: 1 addition & 0 deletions docker/integtest/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ scriptdir="$(dirname "$0")"
"${scriptdir}/3-receive-email-for-client.sh" && wait_seconds "${TEST_STEP_DELAY}"
"${scriptdir}/4-client-downloads-emails.sh"
"${scriptdir}/5-assert-on-results.sh"
"${scriptdir}/6-receive-service-email.sh"

rm -rf "${scriptdir}/files/test.out"
5 changes: 4 additions & 1 deletion opwen_email_server/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ def __init__(self, auth: Union[AzureAuth, NoAuth], raw_email_storage: AzureTextS
self._raw_email_storage = raw_email_storage
self._next_task = next_task

def _action(self, client_id, email, **sendgrid_args): # type: ignore
def _action(self, client_id=None, email=None, **sendgrid_args): # type: ignore
if email is None:
return 'email cannot be None', 400

domain = self._auth.domain_for(client_id)
if not domain:
self.log_event(events.UNREGISTERED_CLIENT, {'client_id': client_id}) # noqa: E501 # yapf: disable
Expand Down
2 changes: 2 additions & 0 deletions opwen_email_server/swagger/email-receive.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ paths:
responses:
200:
description: The email was succesfully received. No need to retry it.
400:
description: Malformed email.
403:
description: Error in receiving email.

Expand Down

0 comments on commit 1dddd33

Please sign in to comment.