action_mailbox_amazon_ingress 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f08bddaffb7a4483d75df3c8bf6daebdd58cbb6673f9d8edb02b0fa3f881edc1
4
- data.tar.gz: a32fc9ffaa109603235667fa7169625d149db1aafbc6b8179625edca204f69e2
3
+ metadata.gz: 7a83ae0efbb2c0f3027ef29b0aa7586d46993c25a4f2c12c06fb7174fb3d1271
4
+ data.tar.gz: f90c9da49e0b53f4c8b6687adb6d76c08cef34f9e0f7f4f1896f37e33d718825
5
5
  SHA512:
6
- metadata.gz: 24e5461c1e6c24b192f312d1384a4d5f863da866a769575361c380150129c05a0d28d7b7d6c7624fa7f01a2fa4ee8db70cbe080e26e13b3cb6469fb6aeb47777
7
- data.tar.gz: 22d1eff8e7cc534adbf9b2333189797546cde4f177dc172cb66a45f6cf37da01751deb082e1e21f2dfebbbc3a352f2c8c1fbdaaccfe46273104dbe82fd653311
6
+ metadata.gz: e4d6813c196bdc0ce6da6a639cf8c7ccbcda8131587eb1ad49540a76141bc8993c596949b865084b956d38b6c8637e6ae4e7a52ee421f98d429dc2e21e90b924
7
+ data.tar.gz: 35dfa9d498ad50f2b4f102d370d5305b506c0971d48ee56c07f7ef1e07b494d31c009c65522e59bd555104849c3aa77a74d6ecc4b1efce61e44bdf539f81f734
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ spec/support/dummy/db/*
17
17
  Gemfile.lock
18
18
 
19
19
  .byebug_history
20
+ *.gem
@@ -8,8 +8,10 @@ Metrics/AbcSize:
8
8
  Metrics/BlockLength:
9
9
  Exclude:
10
10
  - 'spec/**/*'
11
+ - 'action_mailbox_amazon_ingress.gemspec'
11
12
 
12
13
  AllCops:
14
+ NewCops: enable
13
15
  Exclude:
14
16
  - 'bin/**/*'
15
17
  - 'db/migrate/**/*.rb'
@@ -1 +1 @@
1
- 2.6.5
1
+ 2.5.3
data/Makefile CHANGED
@@ -1,4 +1,6 @@
1
- all:
1
+ test:
2
2
  bundle exec rspec
3
3
  bundle exec rubocop
4
4
  bundle exec strong_versions
5
+
6
+ all: test
data/README.md CHANGED
@@ -7,7 +7,7 @@ Provides _Amazon SES/SNS_ integration with [_Rails ActionMailbox_](https://guide
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'action_mailbox_amazon_ingress', '~> 0.1.0'
10
+ gem 'action_mailbox_amazon_ingress', '~> 0.1.1'
11
11
  ```
12
12
 
13
13
  ## Configuration
@@ -45,6 +45,58 @@ Note that even if you manually confirm subscriptions you will still need to prov
45
45
 
46
46
  See [ActionMailbox documentation](https://guides.rubyonrails.org/action_mailbox_basics.html) for full usage information.
47
47
 
48
+ ## Testing
49
+
50
+ ### RSpec
51
+
52
+ Two _RSpec_ _request spec_ helpers are provided to facilitate testing _Amazon SNS/SES_ notifications in your application:
53
+
54
+ * `amazon_ingress_deliver_subscription_confirmation`
55
+ * `amazon_ingress_deliver_email`
56
+
57
+ Include the `ActionMailboxAmazonIngress::RSpec` extension in your tests:
58
+
59
+ ```ruby
60
+ # spec/rails_helper.rb
61
+
62
+ require 'action_mailbox_amazon_ingress/rspec'
63
+
64
+ RSpec.configure do |config|
65
+ config.include ActionMailboxAmazonIngress::RSpec
66
+ end
67
+ ```
68
+
69
+ Configure your _test_ environment to accept the default topic used by the provided helpers:
70
+
71
+ ```ruby
72
+ # config/environments/test.rb
73
+
74
+ config.action_mailbox.amazon.subscribed_topics = ['topic:arn:default']
75
+ ```
76
+
77
+ #### Example Usage
78
+
79
+ ```ruby
80
+ # spec/requests/amazon_emails_spec.rb
81
+
82
+ RSpec.describe 'amazon emails', type: :request do
83
+ it 'delivers a subscription notification' do
84
+ amazon_ingress_deliver_subscription_confirmation
85
+ expect(response).to have_http_status :ok
86
+ end
87
+
88
+ it 'delivers an email notification' do
89
+ amazon_ingress_deliver_email(mail: Mail.new(to: 'user@example.com'))
90
+ expect(ActionMailbox::InboundEmail.last.mail.recipients).to eql ['user@example.com']
91
+ end
92
+ end
93
+ ```
94
+
95
+ You may also pass the following keyword arguments to both helpers:
96
+
97
+ * `topic`: The _SNS_ topic used for each notification (default: `topic:arn:default`).
98
+ * `authentic`: The `Aws::SNS::MessageVerifier` class is stubbed by these helpers; set `authentic` to `true` or `false` to define how it will verify incoming notifications (default: `true`).
99
+
48
100
  ## Development
49
101
 
50
102
  Ensure _Rubocop_, _RSpec_, and _StrongVersions_ compliance by running `make`:
@@ -9,6 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.version = ActionMailboxAmazonIngress::VERSION
10
10
  spec.authors = ['Bob Farrell']
11
11
  spec.email = ['git@bob.frl']
12
+ spec.required_ruby_version = '>= 2.5'
12
13
 
13
14
  spec.summary = 'Amazon SES ingress for Rails ActionMailbox'
14
15
  spec.description = 'Integrate Amazon SES with ActionMailbox'
@@ -28,10 +29,12 @@ Gem::Specification.new do |spec|
28
29
  spec.add_dependency 'rails', '~> 6.0'
29
30
 
30
31
  spec.add_development_dependency 'betterp', '~> 0.1.3'
32
+ spec.add_development_dependency 'devpack', '~> 0.2.1'
31
33
  spec.add_development_dependency 'rake', '~> 13.0'
34
+ spec.add_development_dependency 'rspec-its', '~> 1.3'
32
35
  spec.add_development_dependency 'rspec-rails', '~> 4.0'
33
- spec.add_development_dependency 'rubocop', '~> 0.82.0'
36
+ spec.add_development_dependency 'rubocop', '~> 0.90.0'
34
37
  spec.add_development_dependency 'sqlite3', '~> 1.4'
35
- spec.add_development_dependency 'strong_versions', '~> 0.4.3'
38
+ spec.add_development_dependency 'strong_versions', '~> 0.4.5'
36
39
  spec.add_development_dependency 'webmock', '~> 3.8'
37
40
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # rubocop:disable Layout/LineLength
4
3
  module ActionMailbox
5
4
  # Ingests inbound emails from Amazon SES/SNS and confirms subscriptions.
6
5
  #
@@ -50,7 +49,7 @@ module ActionMailbox
50
49
  # If your application is found at <tt>https://example.com</tt> you would
51
50
  # specify the fully-qualified URL <tt>https://example.com/rails/action_mailbox/amazon/inbound_emails</tt>.
52
51
  #
53
- # rubocop:enable Layout/LineLength
52
+
54
53
  module Ingresses
55
54
  module Amazon
56
55
  class InboundEmailsController < ActionMailbox::BaseController
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'action_mailbox_amazon_ingress/rspec/email'
4
+ require 'action_mailbox_amazon_ingress/rspec/subscription_confirmation'
5
+
6
+ module ActionMailboxAmazonIngress
7
+ module RSpec
8
+ def amazon_ingress_deliver_subscription_confirmation(options = {})
9
+ subscription_confirmation = SubscriptionConfirmation.new(**options)
10
+ stub_aws_sns_message_verifier(subscription_confirmation)
11
+ stub_aws_sns_subscription_request
12
+ post subscription_confirmation.url, params: subscription_confirmation.params.to_json,
13
+ headers: subscription_confirmation.headers
14
+ end
15
+
16
+ def amazon_ingress_deliver_email(options = {})
17
+ email = Email.new(**options)
18
+ stub_aws_sns_message_verifier(email)
19
+ post email.url, params: email.params.to_json,
20
+ headers: email.headers
21
+ end
22
+
23
+ private
24
+
25
+ def message_verifier(subscription_confirmation)
26
+ instance_double(Aws::SNS::MessageVerifier, authentic?: subscription_confirmation.authentic?)
27
+ end
28
+
29
+ def stub_aws_sns_message_verifier(notification)
30
+ allow(Aws::SNS::MessageVerifier).to receive(:new) { message_verifier(notification) }
31
+ end
32
+
33
+ def stub_aws_sns_subscription_request
34
+ allow(Net::HTTP).to receive(:get_response).and_call_original
35
+ allow(Net::HTTP)
36
+ .to receive(:get_response)
37
+ .with(URI('http://example.com/subscribe')) { double(code: '200') }
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionMailboxAmazonIngress
4
+ module RSpec
5
+ class Email
6
+ def initialize(authentic: true, topic: 'topic:arn:default', mail: default_mail)
7
+ @authentic = authentic
8
+ @topic = topic
9
+ @mail = mail
10
+ end
11
+
12
+ def headers
13
+ { 'content-type' => 'application/json' }
14
+ end
15
+
16
+ def url
17
+ '/rails/action_mailbox/amazon/inbound_emails'
18
+ end
19
+
20
+ def params
21
+ {
22
+ 'Type' => 'Notification',
23
+ 'TopicArn' => @topic,
24
+ 'Message' => {
25
+ 'notificationType' => 'Received',
26
+ 'content' => @mail.encoded
27
+ }.to_json
28
+ }
29
+ end
30
+
31
+ def authentic?
32
+ @authentic
33
+ end
34
+
35
+ def default_mail
36
+ Mail.new
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionMailboxAmazonIngress
4
+ module RSpec
5
+ class SubscriptionConfirmation
6
+ def initialize(authentic: true, topic: 'topic:arn:default')
7
+ @authentic = authentic
8
+ @topic = topic
9
+ end
10
+
11
+ def url
12
+ '/rails/action_mailbox/amazon/inbound_emails'
13
+ end
14
+
15
+ def headers
16
+ { 'content-type' => 'application/json' }
17
+ end
18
+
19
+ def params
20
+ {
21
+ 'Type' => 'SubscriptionConfirmation',
22
+ 'TopicArn' => @topic,
23
+ 'SubscribeURL' => 'http://example.com/subscribe'
24
+ }
25
+ end
26
+
27
+ def authentic?
28
+ @authentic
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActionMailboxAmazonIngress
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_mailbox_amazon_ingress
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Farrell
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-09 00:00:00.000000000 Z
11
+ date: 2020-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-sns
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.1.3
55
+ - !ruby/object:Gem::Dependency
56
+ name: devpack
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.2.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.2.1
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +80,20 @@ dependencies:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '13.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-its
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.3'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: rspec-rails
71
99
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +114,14 @@ dependencies:
86
114
  requirements:
87
115
  - - "~>"
88
116
  - !ruby/object:Gem::Version
89
- version: 0.82.0
117
+ version: 0.90.0
90
118
  type: :development
91
119
  prerelease: false
92
120
  version_requirements: !ruby/object:Gem::Requirement
93
121
  requirements:
94
122
  - - "~>"
95
123
  - !ruby/object:Gem::Version
96
- version: 0.82.0
124
+ version: 0.90.0
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: sqlite3
99
127
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +142,14 @@ dependencies:
114
142
  requirements:
115
143
  - - "~>"
116
144
  - !ruby/object:Gem::Version
117
- version: 0.4.3
145
+ version: 0.4.5
118
146
  type: :development
119
147
  prerelease: false
120
148
  version_requirements: !ruby/object:Gem::Requirement
121
149
  requirements:
122
150
  - - "~>"
123
151
  - !ruby/object:Gem::Version
124
- version: 0.4.3
152
+ version: 0.4.5
125
153
  - !ruby/object:Gem::Dependency
126
154
  name: webmock
127
155
  requirement: !ruby/object:Gem::Requirement
@@ -161,12 +189,15 @@ files:
161
189
  - db/migrate/20200508151056_create_action_mailbox_tables.action_mailbox.rb
162
190
  - lib/action_mailbox_amazon_ingress.rb
163
191
  - lib/action_mailbox_amazon_ingress/engine.rb
192
+ - lib/action_mailbox_amazon_ingress/rspec.rb
193
+ - lib/action_mailbox_amazon_ingress/rspec/email.rb
194
+ - lib/action_mailbox_amazon_ingress/rspec/subscription_confirmation.rb
164
195
  - lib/action_mailbox_amazon_ingress/version.rb
165
196
  homepage: https://github.com/bobf/action_mailbox_amazon_ingress
166
197
  licenses:
167
198
  - MIT
168
199
  metadata: {}
169
- post_install_message:
200
+ post_install_message:
170
201
  rdoc_options: []
171
202
  require_paths:
172
203
  - lib
@@ -174,15 +205,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
174
205
  requirements:
175
206
  - - ">="
176
207
  - !ruby/object:Gem::Version
177
- version: '0'
208
+ version: '2.5'
178
209
  required_rubygems_version: !ruby/object:Gem::Requirement
179
210
  requirements:
180
211
  - - ">="
181
212
  - !ruby/object:Gem::Version
182
213
  version: '0'
183
214
  requirements: []
184
- rubygems_version: 3.0.3
185
- signing_key:
215
+ rubyforge_project:
216
+ rubygems_version: 2.7.6
217
+ signing_key:
186
218
  specification_version: 4
187
219
  summary: Amazon SES ingress for Rails ActionMailbox
188
220
  test_files: []