stripe_event 1.8.0 → 1.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f9463bf4cf0ff40f3d50526e98d6167dc77dbbd1
4
- data.tar.gz: 5822f4e55cbc6ca4bc6f0870ac76055ff858cfbf
2
+ SHA256:
3
+ metadata.gz: 154ef1f07846c2b1a26499b02ed2119c3057636737d61ba6b9bcb234bc897782
4
+ data.tar.gz: ac4ea8924d5b8c037115131ae9d8e71f1f78a3dbd42da45b916e2584a76f4cdd
5
5
  SHA512:
6
- metadata.gz: 48ece33350c3b997dfc8008bb406e702f53e4c4f343d1789edc4e69b2d491b14652a6016604481a0682a1c639b71885de7128e9d8635481f9dde636359dc9711
7
- data.tar.gz: 4cc3051021fbfb1cc71c3feb0116a40d79739f5e2ddeb3646edbce592d343af60430d3bfe5deae60fcd026b298187a545618827dd9ec25c0bf18a4673ded85d4
6
+ metadata.gz: aaff93b989d0ecbf55748c01f029f824802b323966bf2ce78e1dc2b7b607a88585bf76ff45b36eb309a3d00f261cc8c7f36643633d4b58e81332ccb0db9de5b2
7
+ data.tar.gz: 2afffbfd031029657a1ba839d6dd56c4c809d2e7ba639db27ef5a9c320a533011c93d8163dbe6c353e57db6b3219dc78716c8fc892b89ec04ed1acb6f6ef997f
data/.gitignore CHANGED
@@ -8,3 +8,5 @@ spec/dummy/.sass-cache
8
8
  Gemfile.lock
9
9
  gemfiles/*.lock
10
10
  coverage/*
11
+ .ruby-version
12
+ .ruby-gemset
@@ -3,17 +3,21 @@ cache: bundler
3
3
  sudo: false
4
4
 
5
5
  rvm:
6
- - 2.2.7
7
- - 2.3.4
6
+ - 2.2.8
7
+ - 2.3.5
8
8
 
9
9
  gemfile:
10
10
  - gemfiles/rails4.1.gemfile
11
11
  - gemfiles/rails4.2.gemfile
12
+ - gemfiles/rails5.0.gemfile
13
+ - gemfiles/rails5.1.gemfile
12
14
 
13
15
  matrix:
14
16
  include:
15
- - rvm: 2.1.9
17
+ - rvm: 2.1.10
16
18
  gemfile: gemfiles/rails3.2.gemfile
19
+ - rvm: 2.4.2
20
+ gemfile: gemfiles/rails5.1.gemfile
17
21
  fast_finish: true
18
22
 
19
23
  notifications:
data/Appraisals CHANGED
@@ -1,5 +1,6 @@
1
1
  appraise "rails3.2" do
2
2
  gem "rails", "~> 3.2.0"
3
+ gem "test-unit", "~> 3.0"
3
4
  end
4
5
 
5
6
  appraise "rails4.1" do
@@ -9,3 +10,11 @@ end
9
10
  appraise "rails4.2" do
10
11
  gem "rails", "~> 4.2.0"
11
12
  end
13
+
14
+ appraise "rails5.0" do
15
+ gem "rails", "~> 5.0.0"
16
+ end
17
+
18
+ appraise "rails5.1" do
19
+ gem "rails", "~> 5.1.0"
20
+ end
@@ -1,3 +1,12 @@
1
+ ### 1.9.0 (November 30, 2017)
2
+
3
+ * Support for Rails 5.1 (#94, Thanks @krasnoukhov and @simplepractice!
4
+
5
+ ### 1.8.0 (August 29, 2017)
6
+
7
+ * Support for [Stripe's Webhook Signature Verification](https://stripe.com/docs/webhooks#signatures) (#83, #90, Thanks @mikeycgto!)
8
+ * Secure compare during basic authentication check (#91, Thanks @mikeycgto!)
9
+
1
10
  ### 1.7.0 (July 5, 2017)
2
11
 
3
12
  * Support stripe v3 gem as a dependency (#87)
@@ -3,5 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 3.2.0"
6
+ gem "test-unit", "~> 3.0"
6
7
 
7
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 4.1.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 4.2.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 5.0.0"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 5.1.0"
6
+
7
+ gemspec path: "../"
@@ -17,6 +17,10 @@ module StripeEvent
17
17
  event = event_retriever.call(params)
18
18
  rescue Stripe::AuthenticationError => e
19
19
  if params[:type] == "account.application.deauthorized"
20
+ if defined?(ActionController::Parameters) && params.is_a?(ActionController::Parameters)
21
+ params = params.permit!.to_h
22
+ end
23
+
20
24
  event = Stripe::Event.construct_from(params.deep_symbolize_keys)
21
25
  else
22
26
  raise UnauthorizedError.new(e)
@@ -1,3 +1,3 @@
1
1
  module StripeEvent
2
- VERSION = "1.8.0"
2
+ VERSION = "1.9.0"
3
3
  end
@@ -1,14 +1,20 @@
1
1
  require 'rails_helper'
2
2
  require 'spec_helper'
3
3
 
4
- describe StripeEvent::WebhookController do
4
+ describe StripeEvent::WebhookController, type: :controller do
5
5
  def stub_event(identifier, status = 200)
6
6
  stub_request(:get, "https://api.stripe.com/v1/events/#{identifier}").
7
7
  to_return(status: status, body: File.read("spec/support/fixtures/#{identifier}.json"))
8
8
  end
9
9
 
10
10
  def webhook(params)
11
- post :event, params
11
+ data = if Rails::VERSION::MAJOR > 4
12
+ { params: params }
13
+ else
14
+ params
15
+ end
16
+
17
+ post :event, data
12
18
  end
13
19
 
14
20
  routes { StripeEvent::Engine.routes }
@@ -53,33 +59,33 @@ describe StripeEvent::WebhookController do
53
59
 
54
60
  expect { webhook id: 'evt_charge_succeeded' }.to raise_error(Stripe::StripeError, /testing/)
55
61
  end
56
-
62
+
57
63
  context "with an authentication secret" do
58
64
  def webhook_with_secret(secret, params)
59
65
  request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials('user', secret)
60
66
  webhook params
61
67
  end
62
-
68
+
63
69
  before(:each) { StripeEvent.authentication_secret = "secret" }
64
70
  after(:each) { StripeEvent.authentication_secret = nil }
65
-
71
+
66
72
  it "rejects requests with no secret" do
67
73
  stub_event('evt_charge_succeeded')
68
-
74
+
69
75
  webhook id: 'evt_charge_succeeded'
70
76
  expect(response.code).to eq '401'
71
77
  end
72
-
78
+
73
79
  it "rejects requests with incorrect secret" do
74
80
  stub_event('evt_charge_succeeded')
75
-
81
+
76
82
  webhook_with_secret 'incorrect', id: 'evt_charge_succeeded'
77
83
  expect(response.code).to eq '401'
78
84
  end
79
-
85
+
80
86
  it "accepts requests with correct secret" do
81
87
  stub_event('evt_charge_succeeded')
82
-
88
+
83
89
  webhook_with_secret 'secret', id: 'evt_charge_succeeded'
84
90
  expect(response.code).to eq '200'
85
91
  end
@@ -54,11 +54,12 @@ module Dummy
54
54
  # parameters by using an attr_accessible or attr_protected declaration.
55
55
  # config.active_record.whitelist_attributes = true
56
56
 
57
- # Enable the asset pipeline
58
- config.assets.enabled = true
57
+ if config.respond_to?(:assets)
58
+ # Enable the asset pipeline
59
+ config.assets.enabled = true
59
60
 
60
- # Version of your assets, change this if you want to expire all your assets
61
- config.assets.version = '1.0'
61
+ # Version of your assets, change this if you want to expire all your assets
62
+ config.assets.version = '1.0'
63
+ end
62
64
  end
63
65
  end
64
-
@@ -83,6 +83,24 @@ describe StripeEvent do
83
83
  expect(events.first[:type]).to eq 'account.application.deauthorized'
84
84
  end
85
85
  end
86
+
87
+ # Rails 5.1 uses ActionController::Parameters which is not inherited from
88
+ # ActiveSupport::HashWithIndifferentAccess anymore
89
+ if Rails::VERSION::MAJOR > 3
90
+ context "with a subscriber params with indifferent access (controller params)" do
91
+ it "calls the subscriber with the retrieved event" do
92
+ StripeEvent.subscribe('account.application.deauthorized', subscriber)
93
+
94
+ StripeEvent.instrument(ActionController::Parameters.new(
95
+ id: 'evt_account_application_deauthorized',
96
+ type: 'account.application.deauthorized'
97
+ ))
98
+
99
+ expect(events.first.type).to eq 'account.application.deauthorized'
100
+ expect(events.first[:type]).to eq 'account.application.deauthorized'
101
+ end
102
+ end
103
+ end
86
104
  end
87
105
 
88
106
  describe "subscribing to a namespace of event types" do
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.add_development_dependency "rails", [">= 3.1"]
24
24
  s.add_development_dependency "rake", "< 11.0"
25
- s.add_development_dependency "rspec-rails", "~> 2.12"
25
+ s.add_development_dependency "rspec-rails", "~> 3.7"
26
26
  s.add_development_dependency "webmock", "~> 1.9"
27
27
  s.add_development_dependency "appraisal"
28
28
  s.add_development_dependency "coveralls"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe_event
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Whalen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-29 00:00:00.000000000 Z
11
+ date: 2017-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -78,14 +78,14 @@ dependencies:
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '2.12'
81
+ version: '3.7'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '2.12'
88
+ version: '3.7'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: webmock
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -149,6 +149,8 @@ files:
149
149
  - gemfiles/rails3.2.gemfile
150
150
  - gemfiles/rails4.1.gemfile
151
151
  - gemfiles/rails4.2.gemfile
152
+ - gemfiles/rails5.0.gemfile
153
+ - gemfiles/rails5.1.gemfile
152
154
  - lib/stripe_event.rb
153
155
  - lib/stripe_event/engine.rb
154
156
  - lib/stripe_event/version.rb
@@ -210,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
212
  version: '0'
211
213
  requirements: []
212
214
  rubyforge_project:
213
- rubygems_version: 2.6.11
215
+ rubygems_version: 2.7.0
214
216
  signing_key:
215
217
  specification_version: 4
216
218
  summary: Stripe webhook integration for Rails applications.
@@ -219,6 +221,8 @@ test_files:
219
221
  - gemfiles/rails3.2.gemfile
220
222
  - gemfiles/rails4.1.gemfile
221
223
  - gemfiles/rails4.2.gemfile
224
+ - gemfiles/rails5.0.gemfile
225
+ - gemfiles/rails5.1.gemfile
222
226
  - spec/controllers/webhook_controller_spec.rb
223
227
  - spec/dummy/README.rdoc
224
228
  - spec/dummy/Rakefile