gitlab-mail_room 0.0.3 → 0.0.9
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.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +14 -1
- data/.gitlab/issue_templates/Release.md +7 -0
- data/.ruby-version +1 -1
- data/README.md +30 -1
- data/lib/mail_room.rb +2 -0
- data/lib/mail_room/cli.rb +2 -2
- data/lib/mail_room/configuration.rb +11 -1
- data/lib/mail_room/connection.rb +7 -179
- data/lib/mail_room/coordinator.rb +8 -4
- data/lib/mail_room/crash_handler.rb +6 -10
- data/lib/mail_room/health_check.rb +60 -0
- data/lib/mail_room/imap.rb +8 -0
- data/lib/mail_room/imap/connection.rb +200 -0
- data/lib/mail_room/imap/message.rb +19 -0
- data/lib/mail_room/mailbox.rb +7 -4
- data/lib/mail_room/mailbox_watcher.rb +9 -2
- data/lib/mail_room/message.rb +16 -0
- data/lib/mail_room/version.rb +2 -2
- data/mail_room.gemspec +3 -3
- data/spec/fixtures/test_config.yml +3 -0
- data/spec/lib/arbitration/redis_spec.rb +3 -2
- data/spec/lib/cli_spec.rb +30 -15
- data/spec/lib/configuration_spec.rb +9 -2
- data/spec/lib/coordinator_spec.rb +27 -11
- data/spec/lib/crash_handler_spec.rb +10 -9
- data/spec/lib/delivery/letter_opener_spec.rb +9 -5
- data/spec/lib/delivery/logger_spec.rb +7 -9
- data/spec/lib/delivery/postback_spec.rb +11 -27
- data/spec/lib/delivery/que_spec.rb +5 -8
- data/spec/lib/health_check_spec.rb +57 -0
- data/spec/lib/{connection_spec.rb → imap/connection_spec.rb} +13 -17
- data/spec/lib/imap/message_spec.rb +36 -0
- data/spec/lib/mailbox_spec.rb +14 -17
- data/spec/lib/mailbox_watcher_spec.rb +9 -12
- data/spec/lib/message_spec.rb +35 -0
- data/spec/spec_helper.rb +0 -1
- metadata +31 -19
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal:true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'securerandom'
|
5
|
+
|
6
|
+
describe MailRoom::IMAP::Message do
|
7
|
+
let(:uid) { SecureRandom.hex }
|
8
|
+
let(:body) { 'hello world' }
|
9
|
+
let(:seqno) { 5 }
|
10
|
+
|
11
|
+
subject { described_class.new(uid: uid, body: body, seqno: seqno) }
|
12
|
+
|
13
|
+
describe '#initalize' do
|
14
|
+
it 'initializes with required parameters' do
|
15
|
+
subject
|
16
|
+
|
17
|
+
expect(subject.uid).to eq(uid)
|
18
|
+
expect(subject.body).to eq(body)
|
19
|
+
expect(subject.seqno).to eq(seqno)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#==' do
|
24
|
+
let(:dup) { described_class.new(uid: uid, body: body, seqno: seqno) }
|
25
|
+
let(:base_msg) { MailRoom::Message.new(uid: uid, body: body) }
|
26
|
+
|
27
|
+
it 'matches an equivalent message' do
|
28
|
+
expect(dup == subject).to be true
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'does not match a base message' do
|
32
|
+
expect(subject == base_msg).to be false
|
33
|
+
expect(base_msg == subject).to be false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/lib/mailbox_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe MailRoom::Mailbox do
|
4
|
-
let(:sample_message) {
|
4
|
+
let(:sample_message) { MailRoom::Message.new(uid: 123, body: 'a message') }
|
5
5
|
|
6
6
|
describe "#deliver" do
|
7
7
|
context "with arbitration_method of noop" do
|
@@ -12,9 +12,9 @@ describe MailRoom::Mailbox do
|
|
12
12
|
|
13
13
|
uid = 123
|
14
14
|
|
15
|
-
|
15
|
+
noop.expects(:deliver?).with(uid)
|
16
16
|
|
17
|
-
|
17
|
+
mailbox.deliver?(uid)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -23,12 +23,10 @@ describe MailRoom::Mailbox do
|
|
23
23
|
mailbox = build_mailbox({:arbitration_method => 'redis'})
|
24
24
|
redis = stub(:deliver?)
|
25
25
|
MailRoom::Arbitration['redis'].stubs(:new => redis)
|
26
|
-
|
27
26
|
uid = 123
|
27
|
+
redis.expects(:deliver?).with(uid)
|
28
28
|
|
29
29
|
mailbox.deliver?(uid)
|
30
|
-
|
31
|
-
expect(redis).to have_received(:deliver?).with(uid)
|
32
30
|
end
|
33
31
|
end
|
34
32
|
|
@@ -38,9 +36,9 @@ describe MailRoom::Mailbox do
|
|
38
36
|
noop = stub(:deliver)
|
39
37
|
MailRoom::Delivery['noop'].stubs(:new => noop)
|
40
38
|
|
41
|
-
|
39
|
+
noop.expects(:deliver).with(sample_message.body)
|
42
40
|
|
43
|
-
|
41
|
+
mailbox.deliver(sample_message)
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
@@ -50,9 +48,9 @@ describe MailRoom::Mailbox do
|
|
50
48
|
logger = stub(:deliver)
|
51
49
|
MailRoom::Delivery['logger'].stubs(:new => logger)
|
52
50
|
|
53
|
-
|
51
|
+
logger.expects(:deliver).with(sample_message.body)
|
54
52
|
|
55
|
-
|
53
|
+
mailbox.deliver(sample_message)
|
56
54
|
end
|
57
55
|
end
|
58
56
|
|
@@ -62,9 +60,9 @@ describe MailRoom::Mailbox do
|
|
62
60
|
postback = stub(:deliver)
|
63
61
|
MailRoom::Delivery['postback'].stubs(:new => postback)
|
64
62
|
|
65
|
-
|
63
|
+
postback.expects(:deliver).with(sample_message.body)
|
66
64
|
|
67
|
-
|
65
|
+
mailbox.deliver(sample_message)
|
68
66
|
end
|
69
67
|
end
|
70
68
|
|
@@ -74,9 +72,9 @@ describe MailRoom::Mailbox do
|
|
74
72
|
letter_opener = stub(:deliver)
|
75
73
|
MailRoom::Delivery['letter_opener'].stubs(:new => letter_opener)
|
76
74
|
|
77
|
-
|
75
|
+
letter_opener.expects(:deliver).with(sample_message.body)
|
78
76
|
|
79
|
-
|
77
|
+
mailbox.deliver(sample_message)
|
80
78
|
end
|
81
79
|
end
|
82
80
|
|
@@ -85,10 +83,9 @@ describe MailRoom::Mailbox do
|
|
85
83
|
mailbox = build_mailbox({ name: "magic mailbox", delivery_method: 'noop' })
|
86
84
|
noop = stub(:deliver)
|
87
85
|
MailRoom::Delivery['noop'].stubs(:new => noop)
|
86
|
+
noop.expects(:deliver).never
|
88
87
|
|
89
|
-
mailbox.deliver(
|
90
|
-
|
91
|
-
expect(noop).to have_received(:deliver).never
|
88
|
+
mailbox.deliver(MailRoom::Message.new(uid: 1234, body: nil))
|
92
89
|
end
|
93
90
|
end
|
94
91
|
|
@@ -19,20 +19,16 @@ describe MailRoom::MailboxWatcher do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'loops over wait while running' do
|
22
|
-
connection = MailRoom::Connection.new(mailbox)
|
23
|
-
connection.stubs(:on_new_message)
|
24
|
-
connection.stubs(:wait)
|
22
|
+
connection = MailRoom::IMAP::Connection.new(mailbox)
|
25
23
|
|
26
|
-
MailRoom::Connection.stubs(:new).returns(connection)
|
24
|
+
MailRoom::IMAP::Connection.stubs(:new).returns(connection)
|
27
25
|
|
28
|
-
watcher.
|
26
|
+
watcher.expects(:running?).twice.returns(true, false)
|
27
|
+
connection.expects(:wait).once
|
28
|
+
connection.expects(:on_new_message).once
|
29
29
|
|
30
30
|
watcher.run
|
31
31
|
watcher.watching_thread.join # wait for finishing run
|
32
|
-
|
33
|
-
expect(watcher).to have_received(:running?).times(2)
|
34
|
-
expect(connection).to have_received(:wait).once
|
35
|
-
expect(connection).to have_received(:on_new_message).once
|
36
32
|
end
|
37
33
|
end
|
38
34
|
|
@@ -45,19 +41,20 @@ describe MailRoom::MailboxWatcher do
|
|
45
41
|
end
|
46
42
|
|
47
43
|
it 'closes and waits for the connection' do
|
48
|
-
connection = MailRoom::Connection.new(mailbox)
|
44
|
+
connection = MailRoom::IMAP::Connection.new(mailbox)
|
49
45
|
connection.stubs(:wait)
|
50
46
|
connection.stubs(:quit)
|
51
47
|
|
52
|
-
MailRoom::Connection.stubs(:new).returns(connection)
|
48
|
+
MailRoom::IMAP::Connection.stubs(:new).returns(connection)
|
53
49
|
|
54
50
|
watcher.run
|
55
51
|
|
56
52
|
expect(watcher.running?).to eq(true)
|
57
53
|
|
54
|
+
connection.expects(:quit)
|
55
|
+
|
58
56
|
watcher.quit
|
59
57
|
|
60
|
-
expect(connection).to have_received(:quit)
|
61
58
|
expect(watcher.running?).to eq(false)
|
62
59
|
end
|
63
60
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal:true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'securerandom'
|
5
|
+
|
6
|
+
describe MailRoom::Message do
|
7
|
+
let(:uid) { SecureRandom.hex }
|
8
|
+
let(:body) { 'hello world' }
|
9
|
+
|
10
|
+
subject { described_class.new(uid: uid, body: body) }
|
11
|
+
|
12
|
+
describe '#initalize' do
|
13
|
+
it 'initializes with required parameters' do
|
14
|
+
subject
|
15
|
+
|
16
|
+
expect(subject.uid).to eq(uid)
|
17
|
+
expect(subject.body).to eq(body)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#==' do
|
22
|
+
let(:dup) { described_class.new(uid: uid, body: body) }
|
23
|
+
|
24
|
+
it 'matches an equivalent message' do
|
25
|
+
expect(dup == subject).to be true
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'does not match a message with a different UID' do
|
29
|
+
msg = described_class.new(uid: '12345', body: body)
|
30
|
+
|
31
|
+
expect(subject == msg).to be false
|
32
|
+
expect(msg == subject).to be false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-mail_room
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Pitale
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -28,32 +28,32 @@ dependencies:
|
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '3.9'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '3.9'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: mocha
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '1.11'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '1.11'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: simplecov
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,19 +67,19 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: webrick
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '1.6'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '1.6'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: faraday
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -188,6 +188,7 @@ extra_rdoc_files: []
|
|
188
188
|
files:
|
189
189
|
- ".gitignore"
|
190
190
|
- ".gitlab-ci.yml"
|
191
|
+
- ".gitlab/issue_templates/Release.md"
|
191
192
|
- ".ruby-version"
|
192
193
|
- ".travis.yml"
|
193
194
|
- CHANGELOG.md
|
@@ -213,9 +214,14 @@ files:
|
|
213
214
|
- lib/mail_room/delivery/postback.rb
|
214
215
|
- lib/mail_room/delivery/que.rb
|
215
216
|
- lib/mail_room/delivery/sidekiq.rb
|
217
|
+
- lib/mail_room/health_check.rb
|
218
|
+
- lib/mail_room/imap.rb
|
219
|
+
- lib/mail_room/imap/connection.rb
|
220
|
+
- lib/mail_room/imap/message.rb
|
216
221
|
- lib/mail_room/logger/structured.rb
|
217
222
|
- lib/mail_room/mailbox.rb
|
218
223
|
- lib/mail_room/mailbox_watcher.rb
|
224
|
+
- lib/mail_room/message.rb
|
219
225
|
- lib/mail_room/version.rb
|
220
226
|
- logfile.log
|
221
227
|
- mail_room.gemspec
|
@@ -223,7 +229,6 @@ files:
|
|
223
229
|
- spec/lib/arbitration/redis_spec.rb
|
224
230
|
- spec/lib/cli_spec.rb
|
225
231
|
- spec/lib/configuration_spec.rb
|
226
|
-
- spec/lib/connection_spec.rb
|
227
232
|
- spec/lib/coordinator_spec.rb
|
228
233
|
- spec/lib/crash_handler_spec.rb
|
229
234
|
- spec/lib/delivery/letter_opener_spec.rb
|
@@ -231,9 +236,13 @@ files:
|
|
231
236
|
- spec/lib/delivery/postback_spec.rb
|
232
237
|
- spec/lib/delivery/que_spec.rb
|
233
238
|
- spec/lib/delivery/sidekiq_spec.rb
|
239
|
+
- spec/lib/health_check_spec.rb
|
240
|
+
- spec/lib/imap/connection_spec.rb
|
241
|
+
- spec/lib/imap/message_spec.rb
|
234
242
|
- spec/lib/logger/structured_spec.rb
|
235
243
|
- spec/lib/mailbox_spec.rb
|
236
244
|
- spec/lib/mailbox_watcher_spec.rb
|
245
|
+
- spec/lib/message_spec.rb
|
237
246
|
- spec/spec_helper.rb
|
238
247
|
homepage: http://github.com/tpitale/mail_room
|
239
248
|
licenses: []
|
@@ -253,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
253
262
|
- !ruby/object:Gem::Version
|
254
263
|
version: '0'
|
255
264
|
requirements: []
|
256
|
-
rubygems_version: 3.1.
|
265
|
+
rubygems_version: 3.1.4
|
257
266
|
signing_key:
|
258
267
|
specification_version: 4
|
259
268
|
summary: mail_room will proxy email (gmail) from IMAP to a callback URL, logger, or
|
@@ -263,7 +272,6 @@ test_files:
|
|
263
272
|
- spec/lib/arbitration/redis_spec.rb
|
264
273
|
- spec/lib/cli_spec.rb
|
265
274
|
- spec/lib/configuration_spec.rb
|
266
|
-
- spec/lib/connection_spec.rb
|
267
275
|
- spec/lib/coordinator_spec.rb
|
268
276
|
- spec/lib/crash_handler_spec.rb
|
269
277
|
- spec/lib/delivery/letter_opener_spec.rb
|
@@ -271,7 +279,11 @@ test_files:
|
|
271
279
|
- spec/lib/delivery/postback_spec.rb
|
272
280
|
- spec/lib/delivery/que_spec.rb
|
273
281
|
- spec/lib/delivery/sidekiq_spec.rb
|
282
|
+
- spec/lib/health_check_spec.rb
|
283
|
+
- spec/lib/imap/connection_spec.rb
|
284
|
+
- spec/lib/imap/message_spec.rb
|
274
285
|
- spec/lib/logger/structured_spec.rb
|
275
286
|
- spec/lib/mailbox_spec.rb
|
276
287
|
- spec/lib/mailbox_watcher_spec.rb
|
288
|
+
- spec/lib/message_spec.rb
|
277
289
|
- spec/spec_helper.rb
|