gitlab-mail_room 0.0.24 → 1.1.0
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/.github/workflows/ci.yml +5 -4
- data/.gitlab-ci.yml +3 -4
- data/.rubocop_todo.yml +38 -37
- data/.ruby-version +1 -1
- data/.tool-versions +1 -0
- data/CHANGELOG.md +15 -0
- data/README.md +0 -10
- data/lib/mail_room/arbitration/redis.rb +12 -3
- data/lib/mail_room/configuration.rb +1 -1
- data/lib/mail_room/delivery/postback.rb +15 -6
- data/lib/mail_room/delivery/sidekiq.rb +10 -2
- data/lib/mail_room/version.rb +1 -1
- data/mail_room.gemspec +9 -7
- data/spec/lib/arbitration/redis_spec.rb +54 -20
- data/spec/lib/coordinator_spec.rb +1 -1
- data/spec/lib/delivery/postback_spec.rb +83 -109
- data/spec/lib/delivery/sidekiq_spec.rb +54 -26
- data/spec/lib/health_check_spec.rb +3 -1
- data/spec/lib/microsoft_graph/connection_spec.rb +3 -3
- metadata +32 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0e8a5af986fff787ca0cd1ba45293f44a2f5130ddc8f1a2e762258d397d3eb7d
|
|
4
|
+
data.tar.gz: 6056b4c396bb63fd769ddd26c0860f65095045f84c334e7531f40b465c7f2326
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c100b13d4179d816a39c308c36f0bb47e4c43bba80d549ef0a7f37cc70fb73d03dc3ecd554a50b4f350beb527bcff7cbeee999d737dcb7527d872d1606e204aa
|
|
7
|
+
data.tar.gz: d483eb80b21ee39e54b3a08ca18c3dad015027684dbb2d87b2b2d8b0c71a6bd72931932408034a6014b013ee653698703d9571a07385a162cfee0054fcd1fe8b
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -26,12 +26,13 @@ jobs:
|
|
|
26
26
|
matrix:
|
|
27
27
|
ruby-version:
|
|
28
28
|
- head
|
|
29
|
+
- '4.0'
|
|
30
|
+
- '3.4'
|
|
31
|
+
- '3.3'
|
|
29
32
|
- '3.2'
|
|
30
33
|
- '3.1'
|
|
31
|
-
- '3.0'
|
|
32
|
-
- '2.7'
|
|
33
34
|
steps:
|
|
34
|
-
- uses: actions/checkout@
|
|
35
|
+
- uses: actions/checkout@v4
|
|
35
36
|
- name: Set up Ruby ${{ matrix.ruby-version }}
|
|
36
37
|
uses: ruby/setup-ruby@v1
|
|
37
38
|
with:
|
|
@@ -43,7 +44,7 @@ jobs:
|
|
|
43
44
|
rubocop:
|
|
44
45
|
runs-on: ubuntu-latest
|
|
45
46
|
steps:
|
|
46
|
-
- uses: actions/checkout@
|
|
47
|
+
- uses: actions/checkout@v4
|
|
47
48
|
- name: Set up Ruby ${{ matrix.ruby-version }}
|
|
48
49
|
uses: ruby/setup-ruby@v1
|
|
49
50
|
with:
|
data/.gitlab-ci.yml
CHANGED
|
@@ -10,11 +10,10 @@ services:
|
|
|
10
10
|
paths:
|
|
11
11
|
- vendor/ruby
|
|
12
12
|
variables:
|
|
13
|
-
REDIS_URL: redis://redis:6379
|
|
13
|
+
REDIS_URL: redis://redis:6379
|
|
14
14
|
before_script:
|
|
15
15
|
- apt update && apt install -y libicu-dev
|
|
16
16
|
- ruby -v # Print out ruby version for debugging
|
|
17
|
-
- gem install bundler --no-document # Bundler is not installed with the image
|
|
18
17
|
- bundle config set --local path 'vendor'
|
|
19
18
|
- bundle install -j $(nproc)
|
|
20
19
|
script:
|
|
@@ -23,8 +22,8 @@ services:
|
|
|
23
22
|
rspec:
|
|
24
23
|
parallel:
|
|
25
24
|
matrix:
|
|
26
|
-
- RUBY_VERSION: [ "
|
|
25
|
+
- RUBY_VERSION: [ "3.1", "3.2", "3.3", "3.4", "4.0" ]
|
|
27
26
|
<<: *test
|
|
28
27
|
|
|
29
28
|
include:
|
|
30
|
-
- template: Security/Dependency-Scanning.gitlab-ci.yml
|
|
29
|
+
- template: Security/Dependency-Scanning.gitlab-ci.yml
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on
|
|
3
|
+
# on 2026-01-14 08:16:06 UTC using RuboCop version 1.82.1.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
@@ -8,24 +8,20 @@
|
|
|
8
8
|
|
|
9
9
|
# Offense count: 5
|
|
10
10
|
# This cop supports safe autocorrection (--autocorrect).
|
|
11
|
-
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation
|
|
12
|
-
# Include: **/*.gemspec
|
|
11
|
+
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation.
|
|
13
12
|
Gemspec/OrderedDependencies:
|
|
14
13
|
Exclude:
|
|
15
14
|
- 'mail_room.gemspec'
|
|
16
15
|
|
|
17
16
|
# Offense count: 1
|
|
18
|
-
# Configuration parameters: Severity, Include.
|
|
19
|
-
# Include: **/*.gemspec
|
|
20
17
|
Gemspec/RequiredRubyVersion:
|
|
21
18
|
Exclude:
|
|
22
19
|
- 'mail_room.gemspec'
|
|
23
20
|
|
|
24
|
-
# Offense count:
|
|
21
|
+
# Offense count: 1
|
|
25
22
|
# This cop supports safe autocorrection (--autocorrect).
|
|
26
23
|
Layout/BlockEndNewline:
|
|
27
24
|
Exclude:
|
|
28
|
-
- 'spec/lib/delivery/postback_spec.rb'
|
|
29
25
|
- 'spec/lib/delivery/que_spec.rb'
|
|
30
26
|
|
|
31
27
|
# Offense count: 5
|
|
@@ -51,14 +47,13 @@ Layout/EmptyLinesAroundAccessModifier:
|
|
|
51
47
|
- 'lib/mail_room/coordinator.rb'
|
|
52
48
|
- 'lib/mail_room/delivery/que.rb'
|
|
53
49
|
|
|
54
|
-
# Offense count:
|
|
50
|
+
# Offense count: 3
|
|
55
51
|
# This cop supports safe autocorrection (--autocorrect).
|
|
56
52
|
# Configuration parameters: EnforcedStyle.
|
|
57
53
|
# SupportedStyles: empty_lines, no_empty_lines
|
|
58
54
|
Layout/EmptyLinesAroundBlockBody:
|
|
59
55
|
Exclude:
|
|
60
56
|
- 'spec/lib/crash_handler_spec.rb'
|
|
61
|
-
- 'spec/lib/delivery/sidekiq_spec.rb'
|
|
62
57
|
- 'spec/lib/logger/structured_spec.rb'
|
|
63
58
|
|
|
64
59
|
# Offense count: 1
|
|
@@ -69,13 +64,12 @@ Layout/EmptyLinesAroundClassBody:
|
|
|
69
64
|
Exclude:
|
|
70
65
|
- 'lib/mail_room/logger/structured.rb'
|
|
71
66
|
|
|
72
|
-
# Offense count:
|
|
67
|
+
# Offense count: 7
|
|
73
68
|
# This cop supports safe autocorrection (--autocorrect).
|
|
74
69
|
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
|
75
70
|
# SupportedStyles: special_inside_parentheses, consistent, align_braces
|
|
76
71
|
Layout/FirstHashElementIndentation:
|
|
77
72
|
Exclude:
|
|
78
|
-
- 'spec/lib/delivery/postback_spec.rb'
|
|
79
73
|
- 'spec/lib/delivery/que_spec.rb'
|
|
80
74
|
- 'spec/lib/logger/structured_spec.rb'
|
|
81
75
|
|
|
@@ -91,19 +85,26 @@ Layout/HashAlignment:
|
|
|
91
85
|
|
|
92
86
|
# Offense count: 2
|
|
93
87
|
# This cop supports safe autocorrection (--autocorrect).
|
|
94
|
-
# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment.
|
|
88
|
+
# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment, AllowRBSInlineAnnotation, AllowSteepAnnotation.
|
|
95
89
|
Layout/LeadingCommentSpace:
|
|
96
90
|
Exclude:
|
|
97
91
|
- 'lib/mail_room/mailbox.rb'
|
|
98
92
|
- 'spec/lib/arbitration/redis_spec.rb'
|
|
99
93
|
|
|
100
|
-
# Offense count:
|
|
94
|
+
# Offense count: 1
|
|
101
95
|
# This cop supports safe autocorrection (--autocorrect).
|
|
102
96
|
Layout/MultilineBlockLayout:
|
|
103
97
|
Exclude:
|
|
104
|
-
- 'spec/lib/delivery/postback_spec.rb'
|
|
105
98
|
- 'spec/lib/delivery/que_spec.rb'
|
|
106
99
|
|
|
100
|
+
# Offense count: 1
|
|
101
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
102
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
|
103
|
+
# SupportedStyles: aligned, indented, indented_relative_to_receiver
|
|
104
|
+
Layout/MultilineMethodCallIndentation:
|
|
105
|
+
Exclude:
|
|
106
|
+
- 'lib/mail_room/imap/connection.rb'
|
|
107
|
+
|
|
107
108
|
# Offense count: 3
|
|
108
109
|
# This cop supports safe autocorrection (--autocorrect).
|
|
109
110
|
# Configuration parameters: EnforcedStyle.
|
|
@@ -123,8 +124,9 @@ Layout/SpaceAroundKeyword:
|
|
|
123
124
|
|
|
124
125
|
# Offense count: 2
|
|
125
126
|
# This cop supports safe autocorrection (--autocorrect).
|
|
126
|
-
# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
|
|
127
|
+
# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator, EnforcedStyleForRationalLiterals.
|
|
127
128
|
# SupportedStylesForExponentOperator: space, no_space
|
|
129
|
+
# SupportedStylesForRationalLiterals: space, no_space
|
|
128
130
|
Layout/SpaceAroundOperators:
|
|
129
131
|
Exclude:
|
|
130
132
|
- 'lib/mail_room/mailbox.rb'
|
|
@@ -141,7 +143,7 @@ Layout/SpaceBeforeBlockBraces:
|
|
|
141
143
|
- 'spec/lib/crash_handler_spec.rb'
|
|
142
144
|
- 'spec/lib/mailbox_spec.rb'
|
|
143
145
|
|
|
144
|
-
# Offense count:
|
|
146
|
+
# Offense count: 47
|
|
145
147
|
# This cop supports safe autocorrection (--autocorrect).
|
|
146
148
|
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
|
|
147
149
|
# SupportedStyles: space, no_space
|
|
@@ -153,7 +155,6 @@ Layout/SpaceInsideBlockBraces:
|
|
|
153
155
|
- 'spec/lib/configuration_spec.rb'
|
|
154
156
|
- 'spec/lib/delivery/letter_opener_spec.rb'
|
|
155
157
|
- 'spec/lib/delivery/logger_spec.rb'
|
|
156
|
-
- 'spec/lib/delivery/postback_spec.rb'
|
|
157
158
|
- 'spec/lib/delivery/que_spec.rb'
|
|
158
159
|
- 'spec/lib/imap/connection_spec.rb'
|
|
159
160
|
- 'spec/lib/mailbox_watcher_spec.rb'
|
|
@@ -208,17 +209,18 @@ Lint/RescueException:
|
|
|
208
209
|
|
|
209
210
|
# Offense count: 1
|
|
210
211
|
# This cop supports safe autocorrection (--autocorrect).
|
|
211
|
-
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
|
|
212
|
+
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
|
|
213
|
+
# NotImplementedExceptions: NotImplementedError
|
|
212
214
|
Lint/UnusedMethodArgument:
|
|
213
215
|
Exclude:
|
|
214
216
|
- 'lib/mail_room/logger/structured.rb'
|
|
215
217
|
|
|
216
|
-
# Offense count:
|
|
218
|
+
# Offense count: 7
|
|
217
219
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
|
218
220
|
Metrics/AbcSize:
|
|
219
|
-
Max:
|
|
221
|
+
Max: 34
|
|
220
222
|
|
|
221
|
-
# Offense count:
|
|
223
|
+
# Offense count: 34
|
|
222
224
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
223
225
|
# AllowedMethods: refine
|
|
224
226
|
Metrics/BlockLength:
|
|
@@ -229,12 +231,12 @@ Metrics/BlockLength:
|
|
|
229
231
|
Metrics/ClassLength:
|
|
230
232
|
Max: 169
|
|
231
233
|
|
|
232
|
-
# Offense count:
|
|
234
|
+
# Offense count: 3
|
|
233
235
|
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
234
236
|
Metrics/CyclomaticComplexity:
|
|
235
237
|
Max: 8
|
|
236
238
|
|
|
237
|
-
# Offense count:
|
|
239
|
+
# Offense count: 16
|
|
238
240
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
239
241
|
Metrics/MethodLength:
|
|
240
242
|
Max: 22
|
|
@@ -244,14 +246,13 @@ Metrics/MethodLength:
|
|
|
244
246
|
Metrics/ModuleLength:
|
|
245
247
|
Max: 172
|
|
246
248
|
|
|
247
|
-
# Offense count:
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
249
|
+
# Offense count: 2
|
|
250
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
251
|
+
Metrics/PerceivedComplexity:
|
|
252
|
+
Max: 9
|
|
251
253
|
|
|
252
254
|
# Offense count: 1
|
|
253
|
-
|
|
254
|
-
Security/YAMLLoad:
|
|
255
|
+
Naming/AccessorMethodName:
|
|
255
256
|
Exclude:
|
|
256
257
|
- 'lib/mail_room/configuration.rb'
|
|
257
258
|
|
|
@@ -263,7 +264,7 @@ Style/Alias:
|
|
|
263
264
|
Exclude:
|
|
264
265
|
- 'lib/mail_room/coordinator.rb'
|
|
265
266
|
|
|
266
|
-
# Offense count:
|
|
267
|
+
# Offense count: 12
|
|
267
268
|
# This cop supports safe autocorrection (--autocorrect).
|
|
268
269
|
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
|
|
269
270
|
# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
|
|
@@ -273,7 +274,6 @@ Style/Alias:
|
|
|
273
274
|
Style/BlockDelimiters:
|
|
274
275
|
Exclude:
|
|
275
276
|
- 'spec/lib/arbitration/redis_spec.rb'
|
|
276
|
-
- 'spec/lib/delivery/postback_spec.rb'
|
|
277
277
|
- 'spec/lib/delivery/que_spec.rb'
|
|
278
278
|
- 'spec/lib/delivery/sidekiq_spec.rb'
|
|
279
279
|
|
|
@@ -289,6 +289,7 @@ Style/Documentation:
|
|
|
289
289
|
- 'lib/mail_room/arbitration/redis.rb'
|
|
290
290
|
- 'lib/mail_room/connection.rb'
|
|
291
291
|
- 'lib/mail_room/crash_handler.rb'
|
|
292
|
+
- 'lib/mail_room/health_check.rb'
|
|
292
293
|
- 'lib/mail_room/delivery.rb'
|
|
293
294
|
- 'lib/mail_room/imap.rb'
|
|
294
295
|
- 'lib/mail_room/imap/connection.rb'
|
|
@@ -349,7 +350,7 @@ Style/GuardClause:
|
|
|
349
350
|
# This cop supports safe autocorrection (--autocorrect).
|
|
350
351
|
# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
|
351
352
|
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
|
352
|
-
# SupportedShorthandSyntax: always, never, either, consistent
|
|
353
|
+
# SupportedShorthandSyntax: always, never, either, consistent, either_consistent
|
|
353
354
|
Style/HashSyntax:
|
|
354
355
|
Exclude:
|
|
355
356
|
- 'spec/lib/microsoft_graph/connection_spec.rb'
|
|
@@ -390,7 +391,7 @@ Style/PreferredHashMethods:
|
|
|
390
391
|
- 'lib/mail_room/mailbox.rb'
|
|
391
392
|
|
|
392
393
|
# Offense count: 1
|
|
393
|
-
# This cop supports
|
|
394
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
394
395
|
# Configuration parameters: EnforcedStyle, AllowedCompactTypes.
|
|
395
396
|
# SupportedStyles: compact, exploded
|
|
396
397
|
Style/RaiseArgs:
|
|
@@ -443,7 +444,7 @@ Style/StringConcatenation:
|
|
|
443
444
|
Exclude:
|
|
444
445
|
- 'lib/mail_room/logger/structured.rb'
|
|
445
446
|
|
|
446
|
-
# Offense count:
|
|
447
|
+
# Offense count: 147
|
|
447
448
|
# This cop supports safe autocorrection (--autocorrect).
|
|
448
449
|
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
|
449
450
|
# SupportedStyles: single_quotes, double_quotes
|
|
@@ -462,7 +463,7 @@ Style/SymbolArray:
|
|
|
462
463
|
# Offense count: 2
|
|
463
464
|
# This cop supports safe autocorrection (--autocorrect).
|
|
464
465
|
# Configuration parameters: EnforcedStyleForMultiline.
|
|
465
|
-
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
|
|
466
|
+
# SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
|
|
466
467
|
Style/TrailingCommaInHashLiteral:
|
|
467
468
|
Exclude:
|
|
468
469
|
- 'spec/lib/mailbox_spec.rb'
|
|
@@ -489,9 +490,9 @@ Style/WordArray:
|
|
|
489
490
|
EnforcedStyle: percent
|
|
490
491
|
MinSize: 3
|
|
491
492
|
|
|
492
|
-
# Offense count:
|
|
493
|
+
# Offense count: 10
|
|
493
494
|
# This cop supports safe autocorrection (--autocorrect).
|
|
494
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes,
|
|
495
|
+
# Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
|
|
495
496
|
# URISchemes: http, https
|
|
496
497
|
Layout/LineLength:
|
|
497
498
|
Max: 177
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2
|
|
1
|
+
3.2
|
data/.tool-versions
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby 3.4.1
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## Unreleased ##
|
|
2
|
+
|
|
3
|
+
* Bump `net-imap` to `>= 0.5, < 0.7` (allows the 0.6.x line on Ruby 3.2+)
|
|
4
|
+
* Raise minimum Ruby to 3.1 (`required_ruby_version >= 3.1`), required by `net-imap` 0.5+
|
|
5
|
+
* Modernize runtime dependency bounds: `oauth2 >= 2.0.9, < 3`, `jwt >= 2.0, < 4`, `redis-namespace >= 1.8.2, < 2`
|
|
6
|
+
* Drop Ruby 3.0 from the CI matrix (GitLab CI and GitHub Actions now test 3.1–3.4 and 4.0)
|
|
7
|
+
|
|
8
|
+
## mail_room 0.11.1 ##
|
|
9
|
+
|
|
10
|
+
https://github.com/tpitale/mail_room/compare/v0.11.0...v0.11.1
|
|
11
|
+
|
|
12
|
+
## mail_room 0.11.0 ##
|
|
13
|
+
|
|
14
|
+
https://github.com/tpitale/mail_room/compare/v0.10.1...v0.11.0
|
|
15
|
+
|
|
1
16
|
## mail_room 0.10.1 ##
|
|
2
17
|
|
|
3
18
|
* Fix db attribute on redis URL PR#130 - @jarkaK
|
data/README.md
CHANGED
|
@@ -489,13 +489,3 @@ respectively and MailRoom will log there.
|
|
|
489
489
|
4. Push to the branch (`git push origin my-new-feature`)
|
|
490
490
|
5. Create new Pull Request
|
|
491
491
|
6. If accepted, ask for commit rights
|
|
492
|
-
|
|
493
|
-
## TODO ##
|
|
494
|
-
|
|
495
|
-
1. specs, this is just a (working) proof of concept √
|
|
496
|
-
2. finish code for POSTing to callback with auth √
|
|
497
|
-
3. accept mailbox configuration for one account directly on the commandline; or ask for it
|
|
498
|
-
4. add example rails endpoint, with auth examples
|
|
499
|
-
5. add example configs for upstart/init.d √
|
|
500
|
-
6. log to stdout √
|
|
501
|
-
7. add a development mode that opens in letter_opener by ryanb √
|
|
@@ -3,11 +3,15 @@ require "redis"
|
|
|
3
3
|
module MailRoom
|
|
4
4
|
module Arbitration
|
|
5
5
|
class Redis
|
|
6
|
-
Options = Struct.new(:redis_url, :namespace, :sentinels) do
|
|
6
|
+
Options = Struct.new(:redis_url, :redis_ssl_params, :namespace, :redis_db, :sentinels, :sentinel_username, :sentinel_password) do
|
|
7
7
|
def initialize(mailbox)
|
|
8
8
|
redis_url = mailbox.arbitration_options[:redis_url] || "redis://localhost:6379"
|
|
9
|
+
redis_ssl_params = mailbox.arbitration_options[:redis_ssl_params]
|
|
10
|
+
redis_db = mailbox.arbitration_options[:redis_db] || 0
|
|
9
11
|
namespace = mailbox.arbitration_options[:namespace]
|
|
10
12
|
sentinels = mailbox.arbitration_options[:sentinels]
|
|
13
|
+
sentinel_username = mailbox.arbitration_options[:sentinel_username]
|
|
14
|
+
sentinel_password = mailbox.arbitration_options[:sentinel_password]
|
|
11
15
|
|
|
12
16
|
if namespace
|
|
13
17
|
warn <<~MSG
|
|
@@ -16,7 +20,7 @@ module MailRoom
|
|
|
16
20
|
MSG
|
|
17
21
|
end
|
|
18
22
|
|
|
19
|
-
super(redis_url, namespace, sentinels)
|
|
23
|
+
super(redis_url, redis_ssl_params, namespace, redis_db, sentinels, sentinel_username, sentinel_password)
|
|
20
24
|
end
|
|
21
25
|
end
|
|
22
26
|
|
|
@@ -46,8 +50,13 @@ module MailRoom
|
|
|
46
50
|
def client
|
|
47
51
|
@client ||= begin
|
|
48
52
|
sentinels = options.sentinels
|
|
49
|
-
redis_options = { url: options.redis_url }
|
|
53
|
+
redis_options = { url: options.redis_url, db: options.redis_db }
|
|
54
|
+
# Needed for redis-client 0.26.2 and older: https://github.com/redis-rb/redis-client/pull/277
|
|
55
|
+
redis_options[:ssl] = true if options.redis_url.start_with?("rediss://")
|
|
56
|
+
redis_options[:ssl_params] = options.redis_ssl_params if options.redis_ssl_params
|
|
50
57
|
redis_options[:sentinels] = sentinels if sentinels
|
|
58
|
+
redis_options[:sentinel_username] = options.sentinel_username if options.sentinel_username
|
|
59
|
+
redis_options[:sentinel_password] = options.sentinel_password if options.sentinel_password
|
|
51
60
|
|
|
52
61
|
redis = ::Redis.new(redis_options)
|
|
53
62
|
|
|
@@ -15,7 +15,7 @@ module MailRoom
|
|
|
15
15
|
begin
|
|
16
16
|
erb = ERB.new(File.read(options[:config_path]))
|
|
17
17
|
erb.filename = options[:config_path]
|
|
18
|
-
config_file = YAML.load(erb.result)
|
|
18
|
+
config_file = YAML.load(erb.result, symbolize_names: true)
|
|
19
19
|
|
|
20
20
|
set_mailboxes(config_file[:mailboxes])
|
|
21
21
|
set_health_check(config_file[:health_check])
|
|
@@ -61,7 +61,6 @@ module MailRoom
|
|
|
61
61
|
# Build a new delivery, hold the delivery options
|
|
62
62
|
# @param [MailRoom::Delivery::Postback::Options]
|
|
63
63
|
def initialize(delivery_options)
|
|
64
|
-
puts delivery_options
|
|
65
64
|
@delivery_options = delivery_options
|
|
66
65
|
end
|
|
67
66
|
|
|
@@ -71,19 +70,17 @@ module MailRoom
|
|
|
71
70
|
connection = Faraday.new
|
|
72
71
|
|
|
73
72
|
if @delivery_options.token_auth?
|
|
74
|
-
connection
|
|
73
|
+
config_token_auth(connection)
|
|
75
74
|
elsif @delivery_options.basic_auth?
|
|
76
75
|
config_basic_auth(connection)
|
|
77
76
|
end
|
|
78
77
|
|
|
79
|
-
connection.post do |request|
|
|
80
|
-
request.url @delivery_options.url
|
|
81
|
-
request.body = message
|
|
78
|
+
result = connection.post(@delivery_options.url, message) do |request|
|
|
82
79
|
config_request_content_type(request)
|
|
83
80
|
config_request_jwt_auth(request)
|
|
84
81
|
end
|
|
85
82
|
|
|
86
|
-
@delivery_options.logger.info({ delivery_method: 'Postback', action: 'message pushed', url: @delivery_options.url })
|
|
83
|
+
@delivery_options.logger.info({ delivery_method: 'Postback', action: 'message pushed', url: @delivery_options.url, status_code: result.status })
|
|
87
84
|
true
|
|
88
85
|
end
|
|
89
86
|
|
|
@@ -101,6 +98,18 @@ module MailRoom
|
|
|
101
98
|
request.headers[@delivery_options.jwt.header] = @delivery_options.jwt.token
|
|
102
99
|
end
|
|
103
100
|
|
|
101
|
+
def config_token_auth(connection)
|
|
102
|
+
# connection.token_auth was removed in Faraday v2 in favor of connection.request(:authorization, 'Token', token)
|
|
103
|
+
if defined?(connection.token_auth)
|
|
104
|
+
connection.token_auth @delivery_options.token
|
|
105
|
+
else
|
|
106
|
+
connection.request(
|
|
107
|
+
:authorization, 'Token',
|
|
108
|
+
@delivery_options.token
|
|
109
|
+
)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
104
113
|
def config_basic_auth(connection)
|
|
105
114
|
if defined?(connection.basic_auth)
|
|
106
115
|
connection.basic_auth(
|
|
@@ -8,12 +8,15 @@ module MailRoom
|
|
|
8
8
|
# Sidekiq Delivery method
|
|
9
9
|
# @author Douwe Maan
|
|
10
10
|
class Sidekiq
|
|
11
|
-
Options = Struct.new(:redis_url, :namespace, :sentinels, :queue, :worker, :logger, :redis_db) do
|
|
11
|
+
Options = Struct.new(:redis_url, :redis_ssl_params, :namespace, :sentinels, :queue, :worker, :logger, :redis_db, :sentinel_username, :sentinel_password) do
|
|
12
12
|
def initialize(mailbox)
|
|
13
13
|
redis_url = mailbox.delivery_options[:redis_url] || "redis://localhost:6379"
|
|
14
|
+
redis_ssl_params = mailbox.delivery_options[:redis_ssl_params]
|
|
14
15
|
redis_db = mailbox.delivery_options[:redis_db] || 0
|
|
15
16
|
namespace = mailbox.delivery_options[:namespace]
|
|
16
17
|
sentinels = mailbox.delivery_options[:sentinels]
|
|
18
|
+
sentinel_username = mailbox.delivery_options[:sentinel_username]
|
|
19
|
+
sentinel_password = mailbox.delivery_options[:sentinel_password]
|
|
17
20
|
queue = mailbox.delivery_options[:queue] || "default"
|
|
18
21
|
worker = mailbox.delivery_options[:worker]
|
|
19
22
|
logger = mailbox.logger
|
|
@@ -25,7 +28,7 @@ module MailRoom
|
|
|
25
28
|
MSG
|
|
26
29
|
end
|
|
27
30
|
|
|
28
|
-
super(redis_url, namespace, sentinels, queue, worker, logger, redis_db)
|
|
31
|
+
super(redis_url, redis_ssl_params, namespace, sentinels, queue, worker, logger, redis_db, sentinel_username, sentinel_password)
|
|
29
32
|
end
|
|
30
33
|
end
|
|
31
34
|
|
|
@@ -54,7 +57,12 @@ module MailRoom
|
|
|
54
57
|
@client ||= begin
|
|
55
58
|
sentinels = options.sentinels
|
|
56
59
|
redis_options = { url: options.redis_url, db: options.redis_db }
|
|
60
|
+
# Needed for redis-client 0.26.2 and older: https://github.com/redis-rb/redis-client/pull/277
|
|
61
|
+
redis_options[:ssl] = true if options.redis_url.start_with?("rediss://")
|
|
62
|
+
redis_options[:ssl_params] = options.redis_ssl_params if options.redis_ssl_params
|
|
57
63
|
redis_options[:sentinels] = sentinels if sentinels
|
|
64
|
+
redis_options[:sentinel_username] = options.sentinel_username if options.sentinel_username
|
|
65
|
+
redis_options[:sentinel_password] = options.sentinel_password if options.sentinel_password
|
|
58
66
|
|
|
59
67
|
redis = ::Redis.new(redis_options)
|
|
60
68
|
|
data/lib/mail_room/version.rb
CHANGED
data/mail_room.gemspec
CHANGED
|
@@ -10,23 +10,25 @@ Gem::Specification.new do |gem|
|
|
|
10
10
|
gem.email = ["tpitale@gmail.com"]
|
|
11
11
|
gem.description = %q{mail_room will proxy email (gmail) from IMAP to a delivery method}
|
|
12
12
|
gem.summary = %q{mail_room will proxy email (gmail) from IMAP to a callback URL, logger, or letter_opener}
|
|
13
|
-
gem.homepage = "
|
|
13
|
+
gem.homepage = "https://gitlab.com/gitlab-org/ruby/gems/gitlab-mail_room"
|
|
14
14
|
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
18
18
|
gem.require_paths = ["lib"]
|
|
19
19
|
|
|
20
|
-
gem.
|
|
21
|
-
|
|
22
|
-
gem.add_dependency "
|
|
23
|
-
gem.add_dependency "
|
|
24
|
-
gem.add_dependency "
|
|
20
|
+
gem.required_ruby_version = ">= 3.1"
|
|
21
|
+
|
|
22
|
+
gem.add_dependency "net-imap", [">= 0.5", "< 0.7"]
|
|
23
|
+
gem.add_dependency "oauth2", [">= 2.0.9", "< 3"]
|
|
24
|
+
gem.add_dependency "jwt", [">= 2.0", "< 4"]
|
|
25
|
+
gem.add_dependency "redis", [">= 5", "< 6"]
|
|
26
|
+
gem.add_dependency "redis-namespace", [">= 1.8.2", "< 2"]
|
|
25
27
|
|
|
26
28
|
gem.add_development_dependency "rake"
|
|
27
29
|
gem.add_development_dependency "rspec", "~> 3.9"
|
|
28
30
|
gem.add_development_dependency "rubocop", "~> 1.11"
|
|
29
|
-
gem.add_development_dependency "mocha", "~>
|
|
31
|
+
gem.add_development_dependency "mocha", "~> 2.0"
|
|
30
32
|
gem.add_development_dependency "simplecov"
|
|
31
33
|
gem.add_development_dependency "webrick", "~> 1.6"
|
|
32
34
|
|
|
@@ -11,21 +11,12 @@ describe MailRoom::Arbitration::Redis do
|
|
|
11
11
|
)
|
|
12
12
|
}
|
|
13
13
|
let(:options) { described_class::Options.new(mailbox) }
|
|
14
|
-
let(:redis5) { Gem::Version.new(Redis::VERSION) >= Gem::Version.new('5.0') }
|
|
15
14
|
subject { described_class.new(options) }
|
|
16
15
|
|
|
17
16
|
# Private, but we don't care.
|
|
18
17
|
let(:redis) { subject.send(:client) }
|
|
19
18
|
let(:raw_client) { redis._client }
|
|
20
19
|
|
|
21
|
-
let(:server_url) do
|
|
22
|
-
if redis5
|
|
23
|
-
raw_client.config.server_url
|
|
24
|
-
else
|
|
25
|
-
raw_client.options[:url]
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
20
|
describe '#deliver?' do
|
|
30
21
|
context "when called the first time" do
|
|
31
22
|
after do
|
|
@@ -89,7 +80,7 @@ describe MailRoom::Arbitration::Redis do
|
|
|
89
80
|
|
|
90
81
|
context 'redis client connection params' do
|
|
91
82
|
context 'when only url is present' do
|
|
92
|
-
let(:redis_url) { ENV.fetch('REDIS_URL', 'redis://localhost:6379
|
|
83
|
+
let(:redis_url) { ENV.fetch('REDIS_URL', 'redis://localhost:6379') }
|
|
93
84
|
let(:mailbox) {
|
|
94
85
|
build_mailbox(
|
|
95
86
|
arbitration_options: {
|
|
@@ -105,7 +96,7 @@ describe MailRoom::Arbitration::Redis do
|
|
|
105
96
|
it 'client has same specified url' do
|
|
106
97
|
subject.deliver?(123)
|
|
107
98
|
|
|
108
|
-
expect(server_url).to eq redis_url
|
|
99
|
+
expect(raw_client.config.server_url).to eq redis_url
|
|
109
100
|
end
|
|
110
101
|
|
|
111
102
|
it 'client is a instance of Redis class' do
|
|
@@ -144,19 +135,62 @@ describe MailRoom::Arbitration::Redis do
|
|
|
144
135
|
)
|
|
145
136
|
}
|
|
146
137
|
|
|
138
|
+
before { ::RedisClient::SentinelConfig.any_instance.stubs(:resolve_master).returns(RedisClient::Config.new(**sentinels.first)) }
|
|
139
|
+
|
|
147
140
|
it 'client has same specified sentinel params' do
|
|
148
|
-
|
|
141
|
+
expect(raw_client.config).to be_a RedisClient::SentinelConfig
|
|
142
|
+
expect(raw_client.config.name).to eq('sentinel-master')
|
|
143
|
+
expect(raw_client.config.host).to eq('10.0.0.1')
|
|
144
|
+
expect(raw_client.config.password).to eq('mypassword')
|
|
145
|
+
expect(raw_client.config.sentinels.map(&:server_url)).to eq(["redis://10.0.0.1:26379"])
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
context 'with separate Sentinel username and password' do
|
|
149
|
+
let(:sentinel_username) { 'my-sentinel-user' }
|
|
150
|
+
let(:sentinel_password) { 'my-sentinel-pass' }
|
|
151
|
+
let(:mailbox) {
|
|
152
|
+
build_mailbox(
|
|
153
|
+
arbitration_options: {
|
|
154
|
+
redis_url: redis_url,
|
|
155
|
+
sentinels: sentinels,
|
|
156
|
+
sentinel_username: sentinel_username,
|
|
157
|
+
sentinel_password: sentinel_password
|
|
158
|
+
}
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
it 'client uses Sentinel username and password' do
|
|
163
|
+
expect(raw_client.config).to be_a RedisClient::SentinelConfig
|
|
149
164
|
expect(raw_client.config.password).to eq('mypassword')
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
expect(
|
|
153
|
-
expect(
|
|
154
|
-
else
|
|
155
|
-
expect(raw_client.options[:host]).to eq('sentinel-master')
|
|
156
|
-
expect(raw_client.options[:password]).to eq('mypassword')
|
|
157
|
-
expect(raw_client.options[:sentinels]).to eq(sentinels)
|
|
165
|
+
|
|
166
|
+
sentinels = raw_client.config.sentinels
|
|
167
|
+
expect(sentinels.map(&:username).uniq).to eq([sentinel_username])
|
|
168
|
+
expect(sentinels.map(&:password).uniq).to eq([sentinel_password])
|
|
158
169
|
end
|
|
159
170
|
end
|
|
160
171
|
end
|
|
172
|
+
|
|
173
|
+
context 'when redis_ssl_params is specified' do
|
|
174
|
+
let(:redis_url) { ENV['REDIS_URL'] }
|
|
175
|
+
let(:redis_ssl_params) { { verify_mode: OpenSSL::SSL::VERIFY_NONE } }
|
|
176
|
+
let(:mailbox) {
|
|
177
|
+
build_mailbox(
|
|
178
|
+
arbitration_options: {
|
|
179
|
+
redis_url: redis_url,
|
|
180
|
+
redis_ssl_params: redis_ssl_params
|
|
181
|
+
}
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
after do
|
|
186
|
+
redis.del("delivered:123")
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
it 'client has same specified ssl_params' do
|
|
190
|
+
subject.deliver?(123)
|
|
191
|
+
|
|
192
|
+
expect(raw_client.config.ssl_params).to eq(redis_ssl_params)
|
|
193
|
+
end
|
|
194
|
+
end
|
|
161
195
|
end
|
|
162
196
|
end
|
|
@@ -17,7 +17,7 @@ describe MailRoom::Coordinator do
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it 'sets the health check' do
|
|
20
|
-
health_check = MailRoom::HealthCheck.new({ address: '127.0.0.1', port: 8080})
|
|
20
|
+
health_check = MailRoom::HealthCheck.new({ address: '127.0.0.1', port: 8080 })
|
|
21
21
|
coordinator = MailRoom::Coordinator.new([], health_check)
|
|
22
22
|
|
|
23
23
|
expect(coordinator.health_check).to eq(health_check)
|
|
@@ -1,138 +1,112 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
require 'mail_room/delivery/postback'
|
|
3
|
+
require 'tempfile'
|
|
4
|
+
require 'base64'
|
|
5
|
+
require 'webmock/rspec'
|
|
3
6
|
|
|
4
7
|
describe MailRoom::Delivery::Postback do
|
|
5
8
|
describe '#deliver' do
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
delivery_token: 'abcdefg'
|
|
10
|
-
})}
|
|
9
|
+
let(:delivery_options) do
|
|
10
|
+
MailRoom::Delivery::Postback::Options.new(mailbox)
|
|
11
|
+
end
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
before do
|
|
14
|
+
stub_request(:post, 'http://localhost/inbox')
|
|
15
|
+
.with(body: 'a message', headers: headers)
|
|
16
|
+
.to_return(status: 201)
|
|
17
|
+
end
|
|
15
18
|
|
|
19
|
+
shared_examples 'message poster' do
|
|
16
20
|
it 'posts the message with faraday' do
|
|
17
|
-
connection = stub
|
|
18
|
-
request = stub
|
|
19
|
-
Faraday.stubs(:new).returns(connection)
|
|
20
|
-
|
|
21
|
-
connection.expects(:token_auth).with('abcdefg')
|
|
22
|
-
connection.expects(:post).yields(request)
|
|
23
|
-
|
|
24
|
-
request.expects(:url).with('http://localhost/inbox')
|
|
25
|
-
request.expects(:body=).with('a message')
|
|
26
|
-
|
|
27
21
|
MailRoom::Delivery::Postback.new(delivery_options).deliver('a message')
|
|
28
22
|
end
|
|
29
23
|
end
|
|
30
24
|
|
|
31
|
-
context 'with
|
|
32
|
-
let(:mailbox)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
})}
|
|
39
|
-
|
|
40
|
-
let(:delivery_options) {
|
|
41
|
-
MailRoom::Delivery::Postback::Options.new(mailbox)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
it 'posts the message with faraday' do
|
|
45
|
-
connection = stub
|
|
46
|
-
request = stub
|
|
47
|
-
Faraday.stubs(:new).returns(connection)
|
|
25
|
+
context 'with token auth delivery' do
|
|
26
|
+
let(:mailbox) do
|
|
27
|
+
build_mailbox({
|
|
28
|
+
delivery_url: 'http://localhost/inbox',
|
|
29
|
+
delivery_token: 'abcdefg'
|
|
30
|
+
})
|
|
31
|
+
end
|
|
48
32
|
|
|
49
|
-
|
|
50
|
-
connection.expects(:post).yields(request)
|
|
33
|
+
let(:headers) { { 'Authorization' => 'Token abcdefg' } }
|
|
51
34
|
|
|
52
|
-
|
|
53
|
-
|
|
35
|
+
it_behaves_like 'message poster'
|
|
36
|
+
end
|
|
54
37
|
|
|
55
|
-
|
|
38
|
+
context 'with basic auth delivery options' do
|
|
39
|
+
let(:mailbox) do
|
|
40
|
+
build_mailbox({
|
|
41
|
+
delivery_options: {
|
|
42
|
+
url: 'http://localhost/inbox',
|
|
43
|
+
username: 'user1',
|
|
44
|
+
password: 'password123abc'
|
|
45
|
+
}
|
|
46
|
+
})
|
|
56
47
|
end
|
|
57
48
|
|
|
58
|
-
|
|
59
|
-
let(:mailbox) {build_mailbox({
|
|
60
|
-
delivery_options: {
|
|
61
|
-
url: 'http://localhost/inbox',
|
|
62
|
-
username: 'user1',
|
|
63
|
-
password: 'password123abc',
|
|
64
|
-
content_type: 'text/plain'
|
|
65
|
-
}
|
|
66
|
-
})}
|
|
67
|
-
|
|
68
|
-
let(:delivery_options) {
|
|
69
|
-
MailRoom::Delivery::Postback::Options.new(mailbox)
|
|
70
|
-
}
|
|
49
|
+
let(:headers) { { 'Authorization' => 'Basic dXNlcjE6cGFzc3dvcmQxMjNhYmM=' } }
|
|
71
50
|
|
|
72
|
-
|
|
73
|
-
connection = stub
|
|
74
|
-
request = stub
|
|
75
|
-
Faraday.stubs(:new).returns(connection)
|
|
51
|
+
it_behaves_like 'message poster'
|
|
76
52
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
53
|
+
context 'with content type in the delivery options' do
|
|
54
|
+
let(:mailbox) do
|
|
55
|
+
build_mailbox({
|
|
56
|
+
delivery_options: {
|
|
57
|
+
url: 'http://localhost/inbox',
|
|
58
|
+
username: 'user1',
|
|
59
|
+
password: 'password123abc',
|
|
60
|
+
content_type: 'text/plain'
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
end
|
|
84
64
|
|
|
85
|
-
|
|
65
|
+
let(:headers) do
|
|
66
|
+
{
|
|
67
|
+
'Authorization' => 'Basic dXNlcjE6cGFzc3dvcmQxMjNhYmM=',
|
|
68
|
+
'Content-Type' => 'text/plain'
|
|
69
|
+
}
|
|
86
70
|
end
|
|
71
|
+
|
|
72
|
+
it_behaves_like 'message poster'
|
|
87
73
|
end
|
|
88
74
|
|
|
89
75
|
context 'with jwt token in the delivery options' do
|
|
90
|
-
let(:mailbox)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
76
|
+
let(:mailbox) do
|
|
77
|
+
build_mailbox({
|
|
78
|
+
delivery_options: {
|
|
79
|
+
url: 'http://localhost/inbox',
|
|
80
|
+
jwt_auth_header: "Mailroom-Api-Request",
|
|
81
|
+
jwt_issuer: "mailroom",
|
|
82
|
+
jwt_algorithm: "HS256",
|
|
83
|
+
jwt_secret_path: jwt_secret.path,
|
|
84
|
+
content_type: 'application/json'
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
let(:headers) do
|
|
90
|
+
{
|
|
91
|
+
'Content-Type' => 'application/json',
|
|
92
|
+
'Mailroom-Api-Request' => /.*/
|
|
97
93
|
}
|
|
98
|
-
})}
|
|
99
|
-
|
|
100
|
-
let(:delivery_options) {
|
|
101
|
-
MailRoom::Delivery::Postback::Options.new(mailbox)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
it 'posts the message with faraday' do
|
|
105
|
-
connection = stub
|
|
106
|
-
request = stub
|
|
107
|
-
Faraday.stubs(:new).returns(connection)
|
|
108
|
-
|
|
109
|
-
connection.expects(:post).yields(request).twice
|
|
110
|
-
request.stubs(:url)
|
|
111
|
-
request.stubs(:body=)
|
|
112
|
-
request.stubs(:headers).returns({})
|
|
113
|
-
|
|
114
|
-
jwt = stub
|
|
115
|
-
MailRoom::JWT.expects(:new).with(
|
|
116
|
-
header: 'Mailroom-Api-Request',
|
|
117
|
-
issuer: 'mailroom',
|
|
118
|
-
algorithm: 'HS256',
|
|
119
|
-
secret_path: 'secret_path'
|
|
120
|
-
).returns(jwt)
|
|
121
|
-
jwt.stubs(:valid?).returns(true)
|
|
122
|
-
jwt.stubs(:header).returns('Mailroom-Api-Request')
|
|
123
|
-
jwt.stubs(:token).returns('a_jwt_token')
|
|
124
|
-
|
|
125
|
-
delivery = MailRoom::Delivery::Postback.new(delivery_options)
|
|
126
|
-
|
|
127
|
-
delivery.deliver('a message')
|
|
128
|
-
expect(request.headers['Mailroom-Api-Request']).to eql('a_jwt_token')
|
|
129
|
-
|
|
130
|
-
# A different jwt token for the second time
|
|
131
|
-
jwt.stubs(:token).returns('another_jwt_token')
|
|
132
|
-
|
|
133
|
-
delivery.deliver('another message')
|
|
134
|
-
expect(request.headers['Mailroom-Api-Request']).to eql('another_jwt_token')
|
|
135
94
|
end
|
|
95
|
+
|
|
96
|
+
let(:jwt_secret) do
|
|
97
|
+
file = Tempfile.new('secret')
|
|
98
|
+
# The secret is read back and Base64-decoded by MailRoom::JWT, so it
|
|
99
|
+
# must be valid Base64 and flushed to disk before it is read.
|
|
100
|
+
file.write(Base64.strict_encode64("test secret"))
|
|
101
|
+
file.flush
|
|
102
|
+
file
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
after do
|
|
106
|
+
jwt_secret.unlink
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it_behaves_like 'message poster'
|
|
136
110
|
end
|
|
137
111
|
end
|
|
138
112
|
end
|
|
@@ -6,17 +6,9 @@ describe MailRoom::Delivery::Sidekiq do
|
|
|
6
6
|
let(:redis) { subject.send(:client) }
|
|
7
7
|
let(:raw_client) { redis._client }
|
|
8
8
|
let(:options) { MailRoom::Delivery::Sidekiq::Options.new(mailbox) }
|
|
9
|
-
let(:redis5) { Gem::Version.new(Redis::VERSION) >= Gem::Version.new('5.0') }
|
|
10
|
-
let(:server_url) do
|
|
11
|
-
if redis5
|
|
12
|
-
raw_client.config.server_url
|
|
13
|
-
else
|
|
14
|
-
raw_client.options[:url]
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
9
|
|
|
18
10
|
describe '#options' do
|
|
19
|
-
let(:redis_url) { 'redis://localhost' }
|
|
11
|
+
let(:redis_url) { 'redis://localhost:6379' }
|
|
20
12
|
let(:redis_options) { { redis_url: redis_url } }
|
|
21
13
|
|
|
22
14
|
context 'when only redis_url is specified' do
|
|
@@ -28,10 +20,8 @@ describe MailRoom::Delivery::Sidekiq do
|
|
|
28
20
|
}
|
|
29
21
|
|
|
30
22
|
context 'with simple redis url' do
|
|
31
|
-
let(:expected_url) { redis5 ? "#{redis_url}:6379/0" : redis_url }
|
|
32
|
-
|
|
33
23
|
it 'client has same specified redis_url' do
|
|
34
|
-
expect(raw_client.server_url).to eq(
|
|
24
|
+
expect(raw_client.config.server_url).to eq(redis_url)
|
|
35
25
|
end
|
|
36
26
|
|
|
37
27
|
it 'client is a instance of RedisNamespace class' do
|
|
@@ -45,19 +35,17 @@ describe MailRoom::Delivery::Sidekiq do
|
|
|
45
35
|
end
|
|
46
36
|
|
|
47
37
|
context 'with redis_db specified in options' do
|
|
48
|
-
let(:expected_url) { redis5 ? "#{redis_url}:6379/4" : redis_url }
|
|
49
|
-
|
|
50
38
|
before do
|
|
51
39
|
redis_options[:redis_db] = 4
|
|
52
40
|
end
|
|
53
41
|
|
|
54
42
|
it 'client has correct redis_url' do
|
|
55
|
-
expect(raw_client.server_url).to eq(
|
|
43
|
+
expect(raw_client.config.server_url).to eq("#{redis_url}/4")
|
|
56
44
|
end
|
|
57
45
|
|
|
58
46
|
it 'connection has correct values' do
|
|
59
|
-
expect(
|
|
60
|
-
expect(
|
|
47
|
+
expect(raw_client.config.host).to eq('localhost')
|
|
48
|
+
expect(raw_client.config.db).to eq(4)
|
|
61
49
|
end
|
|
62
50
|
end
|
|
63
51
|
end
|
|
@@ -96,19 +84,59 @@ describe MailRoom::Delivery::Sidekiq do
|
|
|
96
84
|
)
|
|
97
85
|
}
|
|
98
86
|
|
|
87
|
+
before { ::RedisClient::SentinelConfig.any_instance.stubs(:resolve_master).returns(RedisClient::Config.new(**sentinels.first)) }
|
|
88
|
+
|
|
99
89
|
it 'client has same specified sentinel params' do
|
|
100
|
-
|
|
90
|
+
expect(raw_client.config).to be_a RedisClient::SentinelConfig
|
|
91
|
+
expect(raw_client.config.host).to eq('10.0.0.1')
|
|
92
|
+
expect(raw_client.config.name).to eq('sentinel-master')
|
|
93
|
+
expect(raw_client.config.password).to eq('mypassword')
|
|
94
|
+
expect(raw_client.config.sentinels.map(&:server_url)).to eq(["redis://10.0.0.1:26379"])
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
context 'with separate Sentinel username and password' do
|
|
98
|
+
let(:sentinel_username) { 'my-sentinel-user' }
|
|
99
|
+
let(:sentinel_password) { 'my-sentinel-pass' }
|
|
100
|
+
let(:mailbox) {
|
|
101
|
+
build_mailbox(
|
|
102
|
+
delivery_method: :sidekiq,
|
|
103
|
+
delivery_options: {
|
|
104
|
+
redis_url: redis_url,
|
|
105
|
+
sentinels: sentinels,
|
|
106
|
+
sentinel_username: sentinel_username,
|
|
107
|
+
sentinel_password: sentinel_password
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
it 'client uses Sentinel username and password' do
|
|
113
|
+
expect(raw_client.config).to be_a RedisClient::SentinelConfig
|
|
101
114
|
expect(raw_client.config.password).to eq('mypassword')
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
expect(
|
|
106
|
-
|
|
107
|
-
expect(raw_client.options[:host]).to eq('sentinel-master')
|
|
108
|
-
expect(raw_client.options[:password]).to eq('mypassword')
|
|
109
|
-
expect(raw_client.options[:sentinels]).to eq(sentinels)
|
|
115
|
+
|
|
116
|
+
sentinels = raw_client.config.sentinels
|
|
117
|
+
|
|
118
|
+
expect(sentinels.map(&:username).uniq).to eq([sentinel_username])
|
|
119
|
+
expect(sentinels.map(&:password).uniq).to eq([sentinel_password])
|
|
110
120
|
end
|
|
111
121
|
end
|
|
112
122
|
end
|
|
123
|
+
|
|
124
|
+
context 'when redis_ssl_params is specified' do
|
|
125
|
+
let(:redis_url) { ENV['REDIS_URL'] }
|
|
126
|
+
let(:redis_ssl_params) { { verify_mode: OpenSSL::SSL::VERIFY_NONE } }
|
|
127
|
+
let(:mailbox) {
|
|
128
|
+
build_mailbox(
|
|
129
|
+
delivery_method: :sidekiq,
|
|
130
|
+
delivery_options: {
|
|
131
|
+
redis_url: redis_url,
|
|
132
|
+
redis_ssl_params: redis_ssl_params
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
it 'client has same specified ssl_params' do
|
|
138
|
+
expect(raw_client.config.ssl_params).to eq(redis_ssl_params)
|
|
139
|
+
end
|
|
140
|
+
end
|
|
113
141
|
end
|
|
114
142
|
end
|
|
@@ -34,12 +34,14 @@ describe MailRoom::HealthCheck do
|
|
|
34
34
|
|
|
35
35
|
describe '#run' do
|
|
36
36
|
it 'sets running to true' do
|
|
37
|
-
server = stub(start: true)
|
|
37
|
+
server = stub(start: true, shutdown: true)
|
|
38
38
|
subject.stubs(:create_server).returns(server)
|
|
39
39
|
|
|
40
40
|
subject.run
|
|
41
41
|
|
|
42
42
|
expect(subject.running).to be true
|
|
43
|
+
|
|
44
|
+
subject.quit
|
|
43
45
|
end
|
|
44
46
|
end
|
|
45
47
|
|
|
@@ -106,7 +106,7 @@ describe MailRoom::MicrosoftGraph::Connection do
|
|
|
106
106
|
|
|
107
107
|
shared_examples 'with a single message' do
|
|
108
108
|
let(:message_id) { SecureRandom.hex }
|
|
109
|
-
let(:unread_messages_body) { { value: ['id' => message_id] } }
|
|
109
|
+
let(:unread_messages_body) { { value: [{ 'id' => message_id }] } }
|
|
110
110
|
let(:message_url) { "#{message_base_url}/#{message_id}" }
|
|
111
111
|
let(:message_body) { 'hello world' }
|
|
112
112
|
|
|
@@ -168,13 +168,13 @@ describe MailRoom::MicrosoftGraph::Connection do
|
|
|
168
168
|
context 'with multiple pages of messages' do
|
|
169
169
|
let(:message_ids) { [SecureRandom.hex, SecureRandom.hex] }
|
|
170
170
|
let(:next_page_url) { "#{graph_endpoint}/v1.0/nextPage" }
|
|
171
|
-
let(:unread_messages_body) { { value: ['id' => message_ids.first], '@odata.nextLink' => next_page_url } }
|
|
171
|
+
let(:unread_messages_body) { { value: [{ 'id' => message_ids.first }], '@odata.nextLink' => next_page_url } }
|
|
172
172
|
let(:message_body) { 'hello world' }
|
|
173
173
|
|
|
174
174
|
it 'requests message ID' do
|
|
175
175
|
stub_request(:get, next_page_url).to_return(
|
|
176
176
|
status: 200,
|
|
177
|
-
body: { value: ['id' => message_ids[1]] }.to_json
|
|
177
|
+
body: { value: [{ 'id' => message_ids[1] }] }.to_json
|
|
178
178
|
)
|
|
179
179
|
|
|
180
180
|
stubs = []
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gitlab-mail_room
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tony Pitale
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 2026-06-18 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: net-imap
|
|
@@ -16,21 +15,27 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.
|
|
18
|
+
version: '0.5'
|
|
19
|
+
- - "<"
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0.7'
|
|
20
22
|
type: :runtime
|
|
21
23
|
prerelease: false
|
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
25
|
requirements:
|
|
24
26
|
- - ">="
|
|
25
27
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.
|
|
28
|
+
version: '0.5'
|
|
29
|
+
- - "<"
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: '0.7'
|
|
27
32
|
- !ruby/object:Gem::Dependency
|
|
28
33
|
name: oauth2
|
|
29
34
|
requirement: !ruby/object:Gem::Requirement
|
|
30
35
|
requirements:
|
|
31
36
|
- - ">="
|
|
32
37
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
38
|
+
version: 2.0.9
|
|
34
39
|
- - "<"
|
|
35
40
|
- !ruby/object:Gem::Version
|
|
36
41
|
version: '3'
|
|
@@ -40,7 +45,7 @@ dependencies:
|
|
|
40
45
|
requirements:
|
|
41
46
|
- - ">="
|
|
42
47
|
- !ruby/object:Gem::Version
|
|
43
|
-
version:
|
|
48
|
+
version: 2.0.9
|
|
44
49
|
- - "<"
|
|
45
50
|
- !ruby/object:Gem::Version
|
|
46
51
|
version: '3'
|
|
@@ -51,6 +56,9 @@ dependencies:
|
|
|
51
56
|
- - ">="
|
|
52
57
|
- !ruby/object:Gem::Version
|
|
53
58
|
version: '2.0'
|
|
59
|
+
- - "<"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '4'
|
|
54
62
|
type: :runtime
|
|
55
63
|
prerelease: false
|
|
56
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -58,13 +66,16 @@ dependencies:
|
|
|
58
66
|
- - ">="
|
|
59
67
|
- !ruby/object:Gem::Version
|
|
60
68
|
version: '2.0'
|
|
69
|
+
- - "<"
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: '4'
|
|
61
72
|
- !ruby/object:Gem::Dependency
|
|
62
73
|
name: redis
|
|
63
74
|
requirement: !ruby/object:Gem::Requirement
|
|
64
75
|
requirements:
|
|
65
76
|
- - ">="
|
|
66
77
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: '
|
|
78
|
+
version: '5'
|
|
68
79
|
- - "<"
|
|
69
80
|
- !ruby/object:Gem::Version
|
|
70
81
|
version: '6'
|
|
@@ -74,7 +85,7 @@ dependencies:
|
|
|
74
85
|
requirements:
|
|
75
86
|
- - ">="
|
|
76
87
|
- !ruby/object:Gem::Version
|
|
77
|
-
version: '
|
|
88
|
+
version: '5'
|
|
78
89
|
- - "<"
|
|
79
90
|
- !ruby/object:Gem::Version
|
|
80
91
|
version: '6'
|
|
@@ -85,6 +96,9 @@ dependencies:
|
|
|
85
96
|
- - ">="
|
|
86
97
|
- !ruby/object:Gem::Version
|
|
87
98
|
version: 1.8.2
|
|
99
|
+
- - "<"
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: '2'
|
|
88
102
|
type: :runtime
|
|
89
103
|
prerelease: false
|
|
90
104
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -92,6 +106,9 @@ dependencies:
|
|
|
92
106
|
- - ">="
|
|
93
107
|
- !ruby/object:Gem::Version
|
|
94
108
|
version: 1.8.2
|
|
109
|
+
- - "<"
|
|
110
|
+
- !ruby/object:Gem::Version
|
|
111
|
+
version: '2'
|
|
95
112
|
- !ruby/object:Gem::Dependency
|
|
96
113
|
name: rake
|
|
97
114
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -140,14 +157,14 @@ dependencies:
|
|
|
140
157
|
requirements:
|
|
141
158
|
- - "~>"
|
|
142
159
|
- !ruby/object:Gem::Version
|
|
143
|
-
version: '
|
|
160
|
+
version: '2.0'
|
|
144
161
|
type: :development
|
|
145
162
|
prerelease: false
|
|
146
163
|
version_requirements: !ruby/object:Gem::Requirement
|
|
147
164
|
requirements:
|
|
148
165
|
- - "~>"
|
|
149
166
|
- !ruby/object:Gem::Version
|
|
150
|
-
version: '
|
|
167
|
+
version: '2.0'
|
|
151
168
|
- !ruby/object:Gem::Dependency
|
|
152
169
|
name: simplecov
|
|
153
170
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -277,6 +294,7 @@ files:
|
|
|
277
294
|
- ".rubocop.yml"
|
|
278
295
|
- ".rubocop_todo.yml"
|
|
279
296
|
- ".ruby-version"
|
|
297
|
+
- ".tool-versions"
|
|
280
298
|
- CHANGELOG.md
|
|
281
299
|
- CODE_OF_CONDUCT.md
|
|
282
300
|
- CONTRIBUTING.md
|
|
@@ -337,10 +355,9 @@ files:
|
|
|
337
355
|
- spec/lib/message_spec.rb
|
|
338
356
|
- spec/lib/microsoft_graph/connection_spec.rb
|
|
339
357
|
- spec/spec_helper.rb
|
|
340
|
-
homepage:
|
|
358
|
+
homepage: https://gitlab.com/gitlab-org/ruby/gems/gitlab-mail_room
|
|
341
359
|
licenses: []
|
|
342
360
|
metadata: {}
|
|
343
|
-
post_install_message:
|
|
344
361
|
rdoc_options: []
|
|
345
362
|
require_paths:
|
|
346
363
|
- lib
|
|
@@ -348,15 +365,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
348
365
|
requirements:
|
|
349
366
|
- - ">="
|
|
350
367
|
- !ruby/object:Gem::Version
|
|
351
|
-
version: '
|
|
368
|
+
version: '3.1'
|
|
352
369
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
353
370
|
requirements:
|
|
354
371
|
- - ">="
|
|
355
372
|
- !ruby/object:Gem::Version
|
|
356
373
|
version: '0'
|
|
357
374
|
requirements: []
|
|
358
|
-
rubygems_version: 3.
|
|
359
|
-
signing_key:
|
|
375
|
+
rubygems_version: 3.6.2
|
|
360
376
|
specification_version: 4
|
|
361
377
|
summary: mail_room will proxy email (gmail) from IMAP to a callback URL, logger, or
|
|
362
378
|
letter_opener
|