mail_to_hip_chat 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +7 -0
- data/.rbenv-version +1 -0
- data/.yardopts +5 -0
- data/Gemfile +4 -0
- data/LICENSE +24 -0
- data/README.md +90 -0
- data/Rakefile +17 -0
- data/lib/mail_to_hip_chat/chute_chain.rb +32 -0
- data/lib/mail_to_hip_chat/exceptions.rb +4 -0
- data/lib/mail_to_hip_chat/message_chute.rb +20 -0
- data/lib/mail_to_hip_chat/message_chutes/airbrake.rb +58 -0
- data/lib/mail_to_hip_chat/message_chutes/test_email.rb +18 -0
- data/lib/mail_to_hip_chat/rack_app/builder.rb +47 -0
- data/lib/mail_to_hip_chat/rack_app.rb +57 -0
- data/lib/mail_to_hip_chat/version.rb +3 -0
- data/lib/mail_to_hip_chat.rb +2 -0
- data/mail_to_hip_chat.gemspec +31 -0
- data/support/config.ru +18 -0
- data/test/fixtures/airbrake_exception_body.txt +27 -0
- data/test/fixtures/airbrake_request_dump.txt +325 -0
- data/test/fixtures/test_email_request_dump.txt +89 -0
- data/test/integration/airbrake_processing_test.rb +46 -0
- data/test/test_helper.rb +59 -0
- data/test/unit/chute_chain_test.rb +48 -0
- data/test/unit/message_chute_test.rb +33 -0
- data/test/unit/message_chutes/airbrake_test.rb +39 -0
- data/test/unit/message_chutes/test_email_test.rb +21 -0
- data/test/unit/rack_app_test.rb +54 -0
- data/test.rb +10 -0
- metadata +184 -0
@@ -0,0 +1,325 @@
|
|
1
|
+
POST /notifications/create HTTP/1.1
|
2
|
+
user-agent: CloudMailin Server
|
3
|
+
content-type: multipart/form-data; boundary=----cloudmailinboundry
|
4
|
+
connection: close
|
5
|
+
host: nvg7.showoff.io
|
6
|
+
content-length: 13721
|
7
|
+
x-forwarded-for: undefined
|
8
|
+
|
9
|
+
------cloudmailinboundry
|
10
|
+
Content-Disposition: form-data; name="to"
|
11
|
+
|
12
|
+
<60453ebc38386e438aae@cloudmailin.net>
|
13
|
+
------cloudmailinboundry
|
14
|
+
Content-Disposition: form-data; name="disposable"
|
15
|
+
|
16
|
+
|
17
|
+
------cloudmailinboundry
|
18
|
+
Content-Disposition: form-data; name="from"
|
19
|
+
|
20
|
+
bounces+5166-c14f-60453ebc38386e438aae=cloudmailin.net@mail.airbrakeapp.com
|
21
|
+
------cloudmailinboundry
|
22
|
+
Content-Disposition: form-data; name="subject"
|
23
|
+
|
24
|
+
[Mail Funnel] Unknown: RuntimeError: Test Exception
|
25
|
+
------cloudmailinboundry
|
26
|
+
Content-Disposition: form-data; name="message"
|
27
|
+
|
28
|
+
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=airbrake.io; h=date:from
|
29
|
+
:to:message-id:subject:mime-version:content-type
|
30
|
+
:content-transfer-encoding; s=smtpapi; bh=KKlxopAqERodeAyNLF18/K
|
31
|
+
MxQj0=; b=b47TkkTEkDIOxbpJ+XcYGDuM2vgffC40AL4MyhSTZ2y9mPb66cWCIR
|
32
|
+
WoV9x3g7hNK0Wn5LCRVNV9GmHmNUB2OSgVddE4/8H9YIe/iikNU0xWyRgqIoB07z
|
33
|
+
Cya5nE3FnDkrrvAj1HOK4j7Zh8GKzWWzc7DAcMjdxZoKfi64Th7Lw=
|
34
|
+
DomainKey-Signature: a=rsa-sha1; c=nofws; d=airbrake.io; h=date:from:to
|
35
|
+
:message-id:subject:mime-version:content-type
|
36
|
+
:content-transfer-encoding; q=dns; s=smtpapi; b=AXe+uQRX1MlGoqN6
|
37
|
+
4mQYhNdSpzF06o/LOZfPES1q/IrUd/Ri4xxB7T8vRJj2x+iRPHaqBjc54sLA05Y1
|
38
|
+
edPVLUba3fHn4/lVWJA8L5/xZNdFtSNQO2TaHY4EFVXo+nnAY9fDeRQnzNdmnfxd
|
39
|
+
uUTg6/dIgKxzscMjqd+7+0lbkxM=
|
40
|
+
Received: by 10.16.69.80 with SMTP id mf39.6551.4EC9B2C84
|
41
|
+
Sun, 20 Nov 2011 20:09:12 -0600 (CST)
|
42
|
+
Received: from mail-gw.airbrakeapp.com (unknown [10.9.180.5])
|
43
|
+
by mi12 (SG) with ESMTP id 4ec9b2c8.318c.10f7ae
|
44
|
+
for <60453ebc38386e438aae@cloudmailin.net>; Sun, 20 Nov 2011 20:09:12 -0600 (CST)
|
45
|
+
Received: from mail-gw.airbrakeapp.com (localhost.localdomain [127.0.0.1])
|
46
|
+
by mail-gw.airbrakeapp.com (Postfix) with ESMTP id 39B5460C005
|
47
|
+
for <60453ebc38386e438aae@cloudmailin.net>; Sun, 20 Nov 2011 18:09:12 -0800 (PST)
|
48
|
+
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=airbrakeapp.com; h=date
|
49
|
+
:from:to:message-id:subject:mime-version:content-type
|
50
|
+
:content-transfer-encoding; s=mailgw; bh=dSQtQ4kIv7VPSmdHkHwB2/5
|
51
|
+
9ITw=; b=pF/mMER+KTRXiuEC5VTNp82AnpOGheZWHlRSUE2cah8KUMgPBAHslOE
|
52
|
+
9ah3Y/4KhZsQb3qN/X3frclbJTvOpV5ZW5Iwdt/7Z8hxWXu7LrREuFmn9GkSICdF
|
53
|
+
odXLlhv+djVBAQ3NiboOBDE2AWt2gdumOYamPpvscBcS9I3gnCD0=
|
54
|
+
Received: from airbrake.io (app04.c45163.blueboxgrid.com [67.214.215.208])
|
55
|
+
by mail-gw.airbrakeapp.com (Postfix) with ESMTP id 3661A60C004
|
56
|
+
for <60453ebc38386e438aae@cloudmailin.net>; Sun, 20 Nov 2011 18:09:12 -0800 (PST)
|
57
|
+
Date: Sun, 20 Nov 2011 18:09:12 -0800
|
58
|
+
From: Airbrake <donotreply@airbrake.io>
|
59
|
+
To: 60453ebc38386e438aae@cloudmailin.net
|
60
|
+
Message-ID: <4ec9b2c832055_5d79107e0a6c102209@app04.c45163.blueboxgrid.com.mail>
|
61
|
+
Subject: [Mail Funnel] Unknown: RuntimeError: Test Exception
|
62
|
+
Mime-Version: 1.0
|
63
|
+
Content-Type: multipart/alternative;
|
64
|
+
boundary="--==_mimepart_4ec9b2c82d851_5d79107e0a6c10217ae";
|
65
|
+
charset=UTF-8
|
66
|
+
Content-Transfer-Encoding: 7bit
|
67
|
+
X-Sendgrid-EID: nmcxq1y3RJKAPQ7Sa91nulloMuqlCCsUjgwVCyO7bUPisBsGZlon70J9+djovKtmzRRVbZRyHuCVVM5ojJD9O0lyIkJT31YYJGiqJ6azBv0rJirHI2zEqJQzKjVTxeWI4PGnpucBIOio+5Uj0gwTgosIpF2aJjCuIJ3o4funNQ8=
|
68
|
+
|
69
|
+
|
70
|
+
----==_mimepart_4ec9b2c82d851_5d79107e0a6c10217ae
|
71
|
+
Date: Sun, 20 Nov 2011 18:09:12 -0800
|
72
|
+
Mime-Version: 1.0
|
73
|
+
Content-Type: text/plain;
|
74
|
+
charset=UTF-8
|
75
|
+
Content-Transfer-Encoding: 7bit
|
76
|
+
Content-ID: <4ec9b2c8307a9_5d79107e0a6c10218e7@app04.c45163.blueboxgrid.com.mail>
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
Project: Mail Funnel
|
81
|
+
Environment: Unknown
|
82
|
+
|
83
|
+
|
84
|
+
http://mailfunneltest.airbrake.io/errors/24746833
|
85
|
+
|
86
|
+
Error Message:
|
87
|
+
--------------
|
88
|
+
RuntimeError: Test Exception
|
89
|
+
|
90
|
+
Where:
|
91
|
+
------
|
92
|
+
/private/tmp/app.rb, line 10
|
93
|
+
|
94
|
+
URL:
|
95
|
+
----
|
96
|
+
http://localhost:7000/
|
97
|
+
|
98
|
+
Backtrace Summary:
|
99
|
+
------------------
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
----==_mimepart_4ec9b2c82d851_5d79107e0a6c10217ae
|
105
|
+
Date: Sun, 20 Nov 2011 18:09:12 -0800
|
106
|
+
Mime-Version: 1.0
|
107
|
+
Content-Type: text/html;
|
108
|
+
charset=UTF-8
|
109
|
+
Content-Transfer-Encoding: 7bit
|
110
|
+
Content-ID: <4ec9b2c831524_5d79107e0a6c10219fd@app04.c45163.blueboxgrid.com.mail>
|
111
|
+
|
112
|
+
<html>
|
113
|
+
<head></head>
|
114
|
+
|
115
|
+
<body bgcolor="#ffffff" link="#66bb0c" alink="#66bb0c" vlink="#66bb0c" style="background-color: #ffffff; text-align: left;">
|
116
|
+
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
117
|
+
|
118
|
+
|
119
|
+
<tr>
|
120
|
+
<td style="padding: 10px 20px 10px 20px; font-family: Helvetica, Arial, sans-serif; font-size: 14px; background-color: #ffffff; text-align: left; border-bottom: 1px solid #dddddd;" colspan="2">
|
121
|
+
<table cellpadding="0" cellspacing="0" border="0">
|
122
|
+
<tr>
|
123
|
+
<td style="padding: 0 0 5px 0; font-weight: normal; color: #999999;text-align: left; font-size: 14px; font-family: Helvetica, Arial, sans-serif;"
|
124
|
+
width="75"
|
125
|
+
valign="top">Project:</td>
|
126
|
+
<td style="padding: 0 0 5px 10px; font-size: 14px; font-weight: normal; text-align: left; font-family: Helvetica, Arial, sans-serif;"
|
127
|
+
valign="top">
|
128
|
+
<a href="http://mailfunneltest.airbrake.io/projects/54978" style="color: #000">
|
129
|
+
Mail Funnel
|
130
|
+
</a> </td>
|
131
|
+
</tr>
|
132
|
+
<tr>
|
133
|
+
<td style="padding: 0 0 5px 0; font-weight: normal; color: #999999; text-align: left; font-size: 14px; font-family: Helvetica, Arial, sans-serif;"
|
134
|
+
width="75"
|
135
|
+
valign="top">Environment:</td>
|
136
|
+
<td style="padding: 0 0 5px 10px; font-size: 14px; color: #000000; text-align: left; font-family: Helvetica, Arial, sans-serif;"
|
137
|
+
valign="top">
|
138
|
+
<a href="http://mailfunneltest.airbrake.io/projects/54978/environments/unknown/errors" style="color: #000">
|
139
|
+
Unknown
|
140
|
+
</a> </td>
|
141
|
+
</tr>
|
142
|
+
</table>
|
143
|
+
</td>
|
144
|
+
</tr>
|
145
|
+
|
146
|
+
<tr>
|
147
|
+
<td style="padding-top: 0; padding-bottom: 10px; text-align: left;">
|
148
|
+
<table cellpadding="0" cellspacing="0" border="0" align="left">
|
149
|
+
<tr>
|
150
|
+
<td valign="top" style="padding: 10px 20px 10px 20px; font-family: Helvetica, Arial, sans-serif; font-size: 14px; background-color: #ffffff; text-align: left;">
|
151
|
+
<div style="line-height: 1.3em;">
|
152
|
+
|
153
|
+
<p style="margin-bottom: 2px;">An error has just occurred. View full details at:</p>
|
154
|
+
<p style="padding: 0 0 12px 0; margin: 0;">
|
155
|
+
<a href="http://mailfunneltest.airbrake.io/errors/24746833" style="font-weight: bold;">
|
156
|
+
http://mailfunneltest.airbrake.io/errors/24746833
|
157
|
+
</a> </p>
|
158
|
+
|
159
|
+
<p style="color: #999999; margin-bottom: 2px;">Error Message:</p>
|
160
|
+
<p style="margin-top: 0;">RuntimeError: Test Exception</p>
|
161
|
+
|
162
|
+
<p style="color: #999999; padding: 10px 0 0 0; margin-bottom: 0px;">Where:</p>
|
163
|
+
<p style="margin-top: 0; font-family: monospace;">/private/tmp/app.rb, line 10</p>
|
164
|
+
<p style="color: #999999; padding: 10px 0 0 0; margin-bottom: 0px;">URL:</p>
|
165
|
+
<p style="margin-top: 0; margin-bottom: 0; font-family: monospace;">http://localhost:7000/</p>
|
166
|
+
<p style="color: #999999; padding: 10px 0 0 0; margin-bottom: 0px;">Backtrace Summary:</p>
|
167
|
+
|
168
|
+
</div>
|
169
|
+
|
170
|
+
</td>
|
171
|
+
</tr>
|
172
|
+
</table>
|
173
|
+
</td>
|
174
|
+
</tr>
|
175
|
+
<tr>
|
176
|
+
<table cellpadding="0" cellspacing="0" border="0" align="left" width="100%">
|
177
|
+
<tr>
|
178
|
+
<td style="padding: 10px 20px 20px 20px; font-size: 11px; font-family: Helvetica, Arial, sans-serif; font-weight: bold; color: #666666; text-align: left; border-top: 1px solid #dddddd;">
|
179
|
+
Delivered by <a href="http://airbrake.io/?source=email" style="">Airbrake</a>. <br/>
|
180
|
+
<a href="http://www.launchbit.com/az/46-59/"><img width="125" height="125" src="http://www.launchbit.com/az-images/46-59/"; /></a>
|
181
|
+
<br/>
|
182
|
+
These ads are powered by San Francisco based startup <a href="http://www.launchbit.com/">Launchbit</a>. You are seeing these ads because you are on our free plan tier. <a href="http://mailfunneltest.airbrake.io/account/plan/edit">Upgrade your plan now to start tracking your deploys, avail of SSL connections and receive ad-free emails</a>
|
183
|
+
<br/>
|
184
|
+
</td>
|
185
|
+
</tr>
|
186
|
+
</table>
|
187
|
+
</tr>
|
188
|
+
</table>
|
189
|
+
|
190
|
+
|
191
|
+
<img src="http://mail.airbrakeapp.com/wf/open?rp=lLqeeUOX8zyh0IqilG0ytE%2BBl4tQzaO0OL2oH4vTCgUjwLRyki9RYqhUszhboZzcyo4760NvkPyribnhqIEnhA9w0Pns4obBOqlPUTcnBMycr%2Buh6M1OxsgkKGqy0PfR&u=Oi1rUKmURXKW79QsyGsBwg%2Foo0.gif" alt="">
|
192
|
+
</body>
|
193
|
+
</html>
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
----==_mimepart_4ec9b2c82d851_5d79107e0a6c10217ae--
|
198
|
+
|
199
|
+
------cloudmailinboundry
|
200
|
+
Content-Disposition: form-data; name="plain"
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
Project: Mail Funnel
|
205
|
+
Environment: Unknown
|
206
|
+
|
207
|
+
|
208
|
+
http://mailfunneltest.airbrake.io/errors/24746833
|
209
|
+
|
210
|
+
Error Message:
|
211
|
+
--------------
|
212
|
+
RuntimeError: Test Exception
|
213
|
+
|
214
|
+
Where:
|
215
|
+
------
|
216
|
+
/private/tmp/app.rb, line 10
|
217
|
+
|
218
|
+
URL:
|
219
|
+
----
|
220
|
+
http://localhost:7000/
|
221
|
+
|
222
|
+
Backtrace Summary:
|
223
|
+
------------------
|
224
|
+
------cloudmailinboundry
|
225
|
+
Content-Disposition: form-data; name="html"
|
226
|
+
|
227
|
+
<html>
|
228
|
+
<head></head>
|
229
|
+
|
230
|
+
<body bgcolor="#ffffff" link="#66bb0c" alink="#66bb0c" vlink="#66bb0c" style="background-color: #ffffff; text-align: left;">
|
231
|
+
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
232
|
+
|
233
|
+
|
234
|
+
<tr>
|
235
|
+
<td style="padding: 10px 20px 10px 20px; font-family: Helvetica, Arial, sans-serif; font-size: 14px; background-color: #ffffff; text-align: left; border-bottom: 1px solid #dddddd;" colspan="2">
|
236
|
+
<table cellpadding="0" cellspacing="0" border="0">
|
237
|
+
<tr>
|
238
|
+
<td style="padding: 0 0 5px 0; font-weight: normal; color: #999999;text-align: left; font-size: 14px; font-family: Helvetica, Arial, sans-serif;"
|
239
|
+
width="75"
|
240
|
+
valign="top">Project:</td>
|
241
|
+
<td style="padding: 0 0 5px 10px; font-size: 14px; font-weight: normal; text-align: left; font-family: Helvetica, Arial, sans-serif;"
|
242
|
+
valign="top">
|
243
|
+
<a href="http://mailfunneltest.airbrake.io/projects/54978" style="color: #000">
|
244
|
+
Mail Funnel
|
245
|
+
</a> </td>
|
246
|
+
</tr>
|
247
|
+
<tr>
|
248
|
+
<td style="padding: 0 0 5px 0; font-weight: normal; color: #999999; text-align: left; font-size: 14px; font-family: Helvetica, Arial, sans-serif;"
|
249
|
+
width="75"
|
250
|
+
valign="top">Environment:</td>
|
251
|
+
<td style="padding: 0 0 5px 10px; font-size: 14px; color: #000000; text-align: left; font-family: Helvetica, Arial, sans-serif;"
|
252
|
+
valign="top">
|
253
|
+
<a href="http://mailfunneltest.airbrake.io/projects/54978/environments/unknown/errors" style="color: #000">
|
254
|
+
Unknown
|
255
|
+
</a> </td>
|
256
|
+
</tr>
|
257
|
+
</table>
|
258
|
+
</td>
|
259
|
+
</tr>
|
260
|
+
|
261
|
+
<tr>
|
262
|
+
<td style="padding-top: 0; padding-bottom: 10px; text-align: left;">
|
263
|
+
<table cellpadding="0" cellspacing="0" border="0" align="left">
|
264
|
+
<tr>
|
265
|
+
<td valign="top" style="padding: 10px 20px 10px 20px; font-family: Helvetica, Arial, sans-serif; font-size: 14px; background-color: #ffffff; text-align: left;">
|
266
|
+
<div style="line-height: 1.3em;">
|
267
|
+
|
268
|
+
<p style="margin-bottom: 2px;">An error has just occurred. View full details at:</p>
|
269
|
+
<p style="padding: 0 0 12px 0; margin: 0;">
|
270
|
+
<a href="http://mailfunneltest.airbrake.io/errors/24746833" style="font-weight: bold;">
|
271
|
+
http://mailfunneltest.airbrake.io/errors/24746833
|
272
|
+
</a> </p>
|
273
|
+
|
274
|
+
<p style="color: #999999; margin-bottom: 2px;">Error Message:</p>
|
275
|
+
<p style="margin-top: 0;">RuntimeError: Test Exception</p>
|
276
|
+
|
277
|
+
<p style="color: #999999; padding: 10px 0 0 0; margin-bottom: 0px;">Where:</p>
|
278
|
+
<p style="margin-top: 0; font-family: monospace;">/private/tmp/app.rb, line 10</p>
|
279
|
+
<p style="color: #999999; padding: 10px 0 0 0; margin-bottom: 0px;">URL:</p>
|
280
|
+
<p style="margin-top: 0; margin-bottom: 0; font-family: monospace;">http://localhost:7000/</p>
|
281
|
+
<p style="color: #999999; padding: 10px 0 0 0; margin-bottom: 0px;">Backtrace Summary:</p>
|
282
|
+
|
283
|
+
</div>
|
284
|
+
|
285
|
+
</td>
|
286
|
+
</tr>
|
287
|
+
</table>
|
288
|
+
</td>
|
289
|
+
</tr>
|
290
|
+
<tr>
|
291
|
+
<table cellpadding="0" cellspacing="0" border="0" align="left" width="100%">
|
292
|
+
<tr>
|
293
|
+
<td style="padding: 10px 20px 20px 20px; font-size: 11px; font-family: Helvetica, Arial, sans-serif; font-weight: bold; color: #666666; text-align: left; border-top: 1px solid #dddddd;">
|
294
|
+
Delivered by <a href="http://airbrake.io/?source=email" style="">Airbrake</a>. <br/>
|
295
|
+
<a href="http://www.launchbit.com/az/46-59/"><img width="125" height="125" src="http://www.launchbit.com/az-images/46-59/"; /></a>
|
296
|
+
<br/>
|
297
|
+
These ads are powered by San Francisco based startup <a href="http://www.launchbit.com/">Launchbit</a>. You are seeing these ads because you are on our free plan tier. <a href="http://mailfunneltest.airbrake.io/account/plan/edit">Upgrade your plan now to start tracking your deploys, avail of SSL connections and receive ad-free emails</a>
|
298
|
+
<br/>
|
299
|
+
</td>
|
300
|
+
</tr>
|
301
|
+
</table>
|
302
|
+
</tr>
|
303
|
+
</table>
|
304
|
+
|
305
|
+
|
306
|
+
<img src="http://mail.airbrakeapp.com/wf/open?rp=lLqeeUOX8zyh0IqilG0ytE%2BBl4tQzaO0OL2oH4vTCgUjwLRyki9RYqhUszhboZzcyo4760NvkPyribnhqIEnhA9w0Pns4obBOqlPUTcnBMycr%2Buh6M1OxsgkKGqy0PfR&u=Oi1rUKmURXKW79QsyGsBwg%2Foo0.gif" alt="">
|
307
|
+
</body>
|
308
|
+
</html>
|
309
|
+
------cloudmailinboundry
|
310
|
+
Content-Disposition: form-data; name="mid"
|
311
|
+
|
312
|
+
4ec9b2c832055_5d79107e0a6c102209@app04.c45163.blueboxgrid.com.mail
|
313
|
+
------cloudmailinboundry
|
314
|
+
Content-Disposition: form-data; name="x_to_header"
|
315
|
+
|
316
|
+
["60453ebc38386e438aae@cloudmailin.net"]
|
317
|
+
------cloudmailinboundry
|
318
|
+
Content-Disposition: form-data; name="x_cc_header"
|
319
|
+
|
320
|
+
|
321
|
+
------cloudmailinboundry
|
322
|
+
Content-Disposition: form-data; name="signature"
|
323
|
+
|
324
|
+
a7305c6fe551d80a7c56ab1746922619
|
325
|
+
------cloudmailinboundry--
|
@@ -0,0 +1,89 @@
|
|
1
|
+
POST / HTTP/1.1
|
2
|
+
user-agent: CloudMailin Server
|
3
|
+
content-type: multipart/form-data; boundary=----cloudmailinboundry
|
4
|
+
content-length: 2827
|
5
|
+
connection: close
|
6
|
+
host: vgwb.showoff.io
|
7
|
+
x-forwarded-for: undefined
|
8
|
+
|
9
|
+
------cloudmailinboundry
|
10
|
+
Content-Disposition: form-data; name="to"
|
11
|
+
|
12
|
+
<16fefd79fee99cc47215@cloudmailin.net>
|
13
|
+
------cloudmailinboundry
|
14
|
+
Content-Disposition: form-data; name="disposable"
|
15
|
+
|
16
|
+
|
17
|
+
------cloudmailinboundry
|
18
|
+
Content-Disposition: form-data; name="from"
|
19
|
+
|
20
|
+
gabrielg.test@example.com
|
21
|
+
------cloudmailinboundry
|
22
|
+
Content-Disposition: form-data; name="subject"
|
23
|
+
|
24
|
+
This is a test email to CloudMailIn
|
25
|
+
------cloudmailinboundry
|
26
|
+
Content-Disposition: form-data; name="message"
|
27
|
+
|
28
|
+
Received: by ggnr4 with SMTP id r4so955040ggn.3
|
29
|
+
for <16fefd79fee99cc47215@cloudmailin.net>; Wed, 09 Nov 2011 21:15:19 -0800 (PST)
|
30
|
+
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
|
31
|
+
d=gmail.com; s=gamma;
|
32
|
+
h=from:content-type:content-transfer-encoding:subject:date:message-id
|
33
|
+
:to:mime-version:x-mailer;
|
34
|
+
bh=A9jPqHVi05+rBptC4qDZ74YQYcYcOvVD/GoK4riS6zk=;
|
35
|
+
b=sNFTGMEfly/MtKvlbsc0RqIzfVmi7eGjwFfFxJV2NhTt05dQbUNEtiNqfi7ohezG1A
|
36
|
+
DCMVszc7qw0NtJv37Qgn5C8bjJIdR+fcR66lRVCDO/6uf4JymKupXPyw9B2bWjW7chgn
|
37
|
+
yHgcQtMtx4XUloNgxI9Q0U8Ent+JH1NkM34js=
|
38
|
+
Received: by 10.100.123.10 with SMTP id v10mr2641390anc.168.1320902119413;
|
39
|
+
Wed, 09 Nov 2011 21:15:19 -0800 (PST)
|
40
|
+
Return-Path: <gabrielg.test@example.com>
|
41
|
+
Received: from [10.0.1.54] (200-111-223-122.c3-0.mct-ubr1.chi-mct.il.cable.rcn.com. [200.111.223.122])
|
42
|
+
by mx.google.com with ESMTPS id l27sm20556805ani.21.2011.11.09.21.15.17
|
43
|
+
(version=SSLv3 cipher=OTHER);
|
44
|
+
Wed, 09 Nov 2011 21:15:18 -0800 (PST)
|
45
|
+
From: Gabriel Gironda <gabrielg.test@example.com>
|
46
|
+
Content-Type: text/plain; charset=us-ascii
|
47
|
+
Content-Transfer-Encoding: 7bit
|
48
|
+
Subject: This is a test email to CloudMailIn
|
49
|
+
Date: Wed, 9 Nov 2011 23:15:16 -0600
|
50
|
+
Message-Id: <61277AE7-938D-43CA-80CC-86AB47890FCE@gmail.com>
|
51
|
+
To: 16fefd79fee99cc47215@cloudmailin.net
|
52
|
+
Mime-Version: 1.0 (Apple Message framework v1251.1)
|
53
|
+
X-Mailer: Apple Mail (2.1251.1)
|
54
|
+
|
55
|
+
This is the body of the test email.
|
56
|
+
|
57
|
+
------cloudmailinboundry
|
58
|
+
Content-Disposition: form-data; name="plain"
|
59
|
+
|
60
|
+
This is the body of the test email.
|
61
|
+
------cloudmailinboundry
|
62
|
+
Content-Disposition: form-data; name="html"
|
63
|
+
|
64
|
+
|
65
|
+
------cloudmailinboundry
|
66
|
+
Content-Disposition: form-data; name="mid"
|
67
|
+
|
68
|
+
61277AE7-938D-43CA-80CC-86AB47890FCE@gmail.com
|
69
|
+
------cloudmailinboundry
|
70
|
+
Content-Disposition: form-data; name="x_to_header"
|
71
|
+
|
72
|
+
["16fefd79fee99cc47215@cloudmailin.net"]
|
73
|
+
------cloudmailinboundry
|
74
|
+
Content-Disposition: form-data; name="x_cc_header"
|
75
|
+
|
76
|
+
|
77
|
+
------cloudmailinboundry
|
78
|
+
Content-Disposition: form-data; name="helo_domain"
|
79
|
+
|
80
|
+
mail-gx0-f172.google.com
|
81
|
+
------cloudmailinboundry
|
82
|
+
Content-Disposition: form-data; name="return_path"
|
83
|
+
|
84
|
+
gabrielg.test@example.com
|
85
|
+
------cloudmailinboundry
|
86
|
+
Content-Disposition: form-data; name="signature"
|
87
|
+
|
88
|
+
a6fc5b4ab888ead36ea00aa430ad310a
|
89
|
+
------cloudmailinboundry--
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "rack/builder"
|
3
|
+
require "rack/utils"
|
4
|
+
|
5
|
+
class AirbrakeProcessingTest < Test::Unit::TestCase
|
6
|
+
include RackEnvHelper
|
7
|
+
|
8
|
+
def setup
|
9
|
+
WebMock.disable_net_connect!
|
10
|
+
ENV['CLOUDMAILIN_SECRET'] = "6e50b93207454d57d587"
|
11
|
+
ENV['HIPCHAT_ROOMS'] = "123"
|
12
|
+
ENV['HIPCHAT_API_TOKEN'] = "example_auth_token"
|
13
|
+
@app = app_from_config("support/config.ru")
|
14
|
+
@airbrake_rack_env = rack_env_from_fixture("airbrake_request_dump")
|
15
|
+
end
|
16
|
+
|
17
|
+
def teardown
|
18
|
+
WebMock.allow_net_connect!
|
19
|
+
end
|
20
|
+
|
21
|
+
test "an incoming request from airbrake via cloudmailin eventually posts to HipChat" do
|
22
|
+
exception_url = "http://mailfunneltest.airbrake.io/errors/24746833"
|
23
|
+
message = %Q[<b>Mail Funnel - Unknown</b><br /><a href="#{exception_url}">RuntimeError: Test Exception</a>]
|
24
|
+
|
25
|
+
stub_request(:post, "https://api.hipchat.com/v1/rooms/message").to_return(:status => 200)
|
26
|
+
|
27
|
+
@app.call(@airbrake_rack_env)
|
28
|
+
|
29
|
+
request_params = {"auth_token" => "example_auth_token", "from" => "Airbrake", "room_id" => "123", "message" => message}
|
30
|
+
|
31
|
+
assert_requested(:post, "https://api.hipchat.com/v1/rooms/message") do |req|
|
32
|
+
# Unfortunately, WebMock doesn't actually give me an easy way to check whether only certain
|
33
|
+
# values I care about are in the request body. Hence, this mess.
|
34
|
+
body_params = Rack::Utils.parse_query(req.body)
|
35
|
+
request_params.all? {|k,v| body_params[k] == v}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def app_from_config(config_file)
|
42
|
+
app, options = Rack::Builder.parse_file(config_file, nil)
|
43
|
+
app
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "mocha"
|
3
|
+
require "webmock/test_unit"
|
4
|
+
require "pathname"
|
5
|
+
require "http_parser.rb"
|
6
|
+
require "stringio"
|
7
|
+
|
8
|
+
class Test::Unit::TestCase
|
9
|
+
FIXTURES_DIR = Pathname.new(__FILE__).parent + "fixtures"
|
10
|
+
|
11
|
+
def self.test(test_description, &test_block)
|
12
|
+
define_method("test #{test_description}", &test_block)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def read_fixture(fixture_name)
|
18
|
+
(FIXTURES_DIR + "#{fixture_name}.txt").read
|
19
|
+
end
|
20
|
+
|
21
|
+
module RackEnvHelper
|
22
|
+
|
23
|
+
def rack_env_from_fixture(fixture_name)
|
24
|
+
parser, request_body = Http::Parser.new, StringIO.new
|
25
|
+
parser.on_body = proc {|chunk| request_body << chunk}
|
26
|
+
parser.on_message_complete = proc { request_body.rewind }
|
27
|
+
parser << read_fixture(fixture_name)
|
28
|
+
|
29
|
+
rack_env = rack_normalize_headers(parser.headers)
|
30
|
+
|
31
|
+
rack_env.merge!({"SCRIPT_NAME" => "",
|
32
|
+
"REQUEST_METHOD" => parser.http_method,
|
33
|
+
"PATH_INFO" => parser.request_path,
|
34
|
+
"QUERY_STRING" => parser.query_string,
|
35
|
+
"SERVER_NAME" => rack_env["HTTP_HOST"],
|
36
|
+
"SERVER_PORT" => "443"})
|
37
|
+
|
38
|
+
rack_env.merge!({"rack.version" => [1, 3],
|
39
|
+
"rack.url_scheme" => "https",
|
40
|
+
"rack.input" => request_body,
|
41
|
+
"rack.errors" => STDERR,
|
42
|
+
"rack.multithread" => false,
|
43
|
+
"rack.multiprocess" => false,
|
44
|
+
"rack.run_once" => false})
|
45
|
+
|
46
|
+
rack_env
|
47
|
+
end
|
48
|
+
|
49
|
+
def rack_normalize_headers(headers_hash)
|
50
|
+
headers_hash.inject({}) do |env,(header,value)|
|
51
|
+
header = "http_#{header}" unless header =~ /\A(content-type|content-length)\Z/i
|
52
|
+
env[header.upcase.tr('-', '_')] = value
|
53
|
+
env
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "mail_to_hip_chat/chute_chain"
|
3
|
+
|
4
|
+
class ChuteChainTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@chute_chain = MailToHipChat::ChuteChain.new
|
8
|
+
end
|
9
|
+
|
10
|
+
test "pushing a chute returns the chute chain" do
|
11
|
+
push_result = @chute_chain.push(lambda {})
|
12
|
+
assert_equal @chute_chain, push_result
|
13
|
+
end
|
14
|
+
|
15
|
+
test "chutes are traversed in the order they're pushed into the chain" do
|
16
|
+
chute_traversal = sequence('chute traversal')
|
17
|
+
|
18
|
+
chain_head_chute, chain_tail_chute = mock, mock
|
19
|
+
chain_head_chute.expects(:call).in_sequence(chute_traversal)
|
20
|
+
chain_tail_chute.expects(:call).in_sequence(chute_traversal)
|
21
|
+
|
22
|
+
@chute_chain.push(chain_head_chute).push(chain_tail_chute)
|
23
|
+
@chute_chain.accept({})
|
24
|
+
end
|
25
|
+
|
26
|
+
test "traversing the chain stops at the first chute that returns a response" do
|
27
|
+
chain_head_chute, chain_mid_chute, chain_tail_chute = mock, mock, mock
|
28
|
+
|
29
|
+
chain_head_chute.expects(:call).returns(false)
|
30
|
+
chain_mid_chute.expects(:call).returns(true)
|
31
|
+
chain_tail_chute.expects(:call).never
|
32
|
+
|
33
|
+
@chute_chain.push(chain_head_chute).push(chain_mid_chute).push(chain_tail_chute)
|
34
|
+
@chute_chain.accept({})
|
35
|
+
end
|
36
|
+
|
37
|
+
test "traversing the chain calls each chute with the given params" do
|
38
|
+
params = {:test => :params}
|
39
|
+
|
40
|
+
chain_head_chute, chain_tail_chute = mock, mock
|
41
|
+
chain_head_chute.expects(:call).with(params)
|
42
|
+
chain_tail_chute.expects(:call).with(params)
|
43
|
+
|
44
|
+
@chute_chain.push(chain_head_chute).push(chain_tail_chute)
|
45
|
+
@chute_chain.accept(params)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "mail_to_hip_chat/message_chute"
|
3
|
+
|
4
|
+
class MessageChuteTest < Test::Unit::TestCase
|
5
|
+
class TestMessageChute
|
6
|
+
include MailToHipChat::MessageChute
|
7
|
+
|
8
|
+
def call(params)
|
9
|
+
message_rooms(params[:sender], params[:message])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def setup
|
14
|
+
@hipchat_api = mock
|
15
|
+
end
|
16
|
+
|
17
|
+
test "message_rooms uses the hipchat api to message the given room" do
|
18
|
+
message_chute = TestMessageChute.new(:hipchat_api => @hipchat_api, :rooms => "123")
|
19
|
+
@hipchat_api.expects(:rooms_message).with('123', "TestMessageChute", "example")
|
20
|
+
message_chute.call(:sender => "TestMessageChute", :message => "example")
|
21
|
+
end
|
22
|
+
|
23
|
+
test "message_rooms uses the hipchat api to message all given rooms" do
|
24
|
+
message_chute = TestMessageChute.new(:hipchat_api => @hipchat_api, :rooms => ["123", "456"])
|
25
|
+
|
26
|
+
room_messages = sequence('room messages')
|
27
|
+
@hipchat_api.expects(:rooms_message).with('123', "TestMessageChute", "example").in_sequence(room_messages)
|
28
|
+
@hipchat_api.expects(:rooms_message).with('456', "TestMessageChute", "example").in_sequence(room_messages)
|
29
|
+
|
30
|
+
message_chute.call(:sender => "TestMessageChute", :message => "example")
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "mail_to_hip_chat/message_chutes/airbrake"
|
3
|
+
|
4
|
+
class AirbrakeMessageChuteTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@hipchat_api = mock
|
8
|
+
@airbrake_chute = MailToHipChat::MessageChutes::Airbrake.new(:rooms => "123", :hipchat_api => @hipchat_api)
|
9
|
+
end
|
10
|
+
|
11
|
+
test "a message with a parseable body is accepted" do
|
12
|
+
@hipchat_api.expects(:rooms_message).with(any_parameters)
|
13
|
+
message = read_fixture("airbrake_exception_body")
|
14
|
+
assert @airbrake_chute.call("plain" => message)
|
15
|
+
end
|
16
|
+
|
17
|
+
test "a message with an unparseable body is rejected" do
|
18
|
+
assert !@airbrake_chute.call("plain" => "zzzzzzz")
|
19
|
+
end
|
20
|
+
|
21
|
+
test "the message sent to HipChat contains exception information" do
|
22
|
+
project, environment = "Echelon", "Staging"
|
23
|
+
message = "AirbrakeTestingException: Testing airbrake via "rake airbrake:test". If you can see this, it works."
|
24
|
+
url = "http://the-nsa.airbrake.io/errors/11082122"
|
25
|
+
|
26
|
+
hipchat_message = %Q[<b>#{project} - #{environment}</b><br /><a href="#{url}">#{message}</a>]
|
27
|
+
|
28
|
+
@hipchat_api.expects(:rooms_message).with(anything, anything, hipchat_message)
|
29
|
+
|
30
|
+
@airbrake_chute.call("plain" => read_fixture("airbrake_exception_body"))
|
31
|
+
end
|
32
|
+
|
33
|
+
test "the message is sent to HipChat as coming from an Airbrake user" do
|
34
|
+
@hipchat_api.expects(:rooms_message).with(anything, "Airbrake", anything)
|
35
|
+
|
36
|
+
@airbrake_chute.call("plain" => read_fixture("airbrake_exception_body"))
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "mail_to_hip_chat/message_chutes/test_email"
|
3
|
+
|
4
|
+
class TestEmailMessageChuteTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@hipchat_api = mock
|
8
|
+
@airbrake_chute = MailToHipChat::MessageChutes::TestEmail.new(:rooms => "123", :hipchat_api => @hipchat_api)
|
9
|
+
end
|
10
|
+
|
11
|
+
test "a message with 'Testing Setup' in the subject in mixed case forwards to hipchat" do
|
12
|
+
@hipchat_api.expects(:rooms_message).with(anything, "Testing", "Message:<br />test <1,2,3>")
|
13
|
+
assert @airbrake_chute.call("subject" => "TeStInG SeTuP", "plain" => "test <1,2,3>")
|
14
|
+
end
|
15
|
+
|
16
|
+
test "a message with 'Testing Setup' anywhere in the subject forwards to hipchat" do
|
17
|
+
@hipchat_api.expects(:rooms_message).with(anything, "Testing", "Message:<br />test <1,2,3>")
|
18
|
+
assert @airbrake_chute.call("subject" => "i am testing setup", "plain" => "test <1,2,3>")
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|