Skip to content

Commit 1dddd33

Browse files
authored
Fix TypeError in ReceiveInboundEmail (#434)
1 parent 0f28fab commit 1dddd33

File tree

5 files changed

+53
-1
lines changed

5 files changed

+53
-1
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
set -eo pipefail
3+
4+
scriptdir="$(dirname "$0")"
5+
in_dir="${scriptdir}/files"
6+
out_dir="${scriptdir}/files/test.out"
7+
mkdir -p "${out_dir}"
8+
# shellcheck disable=SC1090
9+
. "${scriptdir}/utils.sh"
10+
11+
email_to_receive="${in_dir}/service-email.mime"
12+
13+
14+
#receive an email directed at the service endpoint
15+
http --check-status -f POST \
16+
"http://nginx:8888/api/email/sendgrid/service" \
17+
"dkim={@sendgrid.com : pass}" \
18+
"SPF=pass" \
19+
"email=@${email_to_receive}"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Received: by mx0028p1mdw1.sendgrid.net with SMTP id Yt3NEnbnLU Mon, 13 Feb 2017 06:25:41 +0000 (UTC)
2+
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)
3+
Received: by mail-yw0-f176.google.com with SMTP id w75so45612320ywg.1; Sun, 12 Feb 2017 22:25:41 -0800 (PST)
4+
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==
5+
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==
6+
X-Gm-Message-State: AMke39n2h/OZU6fwgOdDltzsKqISVbe3ez6t19OeVrg2sT3pDRhSSQiIcwGzKjdWOD/oX96rQlTi0O9t9yhUfA==
7+
X-Received: by 10.129.81.4 with SMTP id f4mr15409224ywb.239.1486967141412; Sun, 12 Feb 2017 22:25:41 -0800 (PST)
8+
MIME-Version: 1.0
9+
Received: by 10.129.156.139 with HTTP; Sun, 12 Feb 2017 22:25:01 -0800 (PST)
10+
From: Clemens Wolff <[email protected]>
11+
Date: Sun, 12 Feb 2017 22:25:01 -0800
12+
Message-ID: <CAL79TcnjhV5PinZVY8Y3QEoNNcSa9uuNU5N3EP-gqcYPFfuHLA@mail.gmail.com>
13+
Subject: Service Email
14+
15+
Content-Type: multipart/alternative; boundary=001a1146392641b94705486384bf
16+
17+
--001a1146392641b94705486384bf
18+
Content-Type: text/plain; charset=UTF-8
19+
20+
This is an email that should be echoed.
21+
22+
--001a1146392641b94705486384bf
23+
Content-Type: text/html; charset=UTF-8
24+
25+
<div dir="ltr">Body of the message.</div>
26+
27+
--001a1146392641b94705486384bf--

docker/integtest/tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ scriptdir="$(dirname "$0")"
1111
"${scriptdir}/3-receive-email-for-client.sh" && wait_seconds "${TEST_STEP_DELAY}"
1212
"${scriptdir}/4-client-downloads-emails.sh"
1313
"${scriptdir}/5-assert-on-results.sh"
14+
"${scriptdir}/6-receive-service-email.sh"
1415

1516
rm -rf "${scriptdir}/files/test.out"

opwen_email_server/actions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,10 @@ def __init__(self, auth: Union[AzureAuth, NoAuth], raw_email_storage: AzureTextS
221221
self._raw_email_storage = raw_email_storage
222222
self._next_task = next_task
223223

224-
def _action(self, client_id, email, **sendgrid_args): # type: ignore
224+
def _action(self, client_id=None, email=None, **sendgrid_args): # type: ignore
225+
if email is None:
226+
return 'email cannot be None', 400
227+
225228
domain = self._auth.domain_for(client_id)
226229
if not domain:
227230
self.log_event(events.UNREGISTERED_CLIENT, {'client_id': client_id}) # noqa: E501 # yapf: disable

opwen_email_server/swagger/email-receive.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ paths:
6060
responses:
6161
200:
6262
description: The email was succesfully received. No need to retry it.
63+
400:
64+
description: Malformed email.
6365
403:
6466
description: Error in receiving email.
6567

0 commit comments

Comments
 (0)