stripe_tester 0.3.3 → 0.4.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/README.md +8 -3
- data/lib/stripe_tester.rb +14 -4
- data/lib/stripe_tester/version.rb +1 -1
- data/spec/stripe_tester_spec.rb +30 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06f6394aa9d07f63c05ab4ec77775015f244f57e
|
4
|
+
data.tar.gz: 5f8becdc1a3db570a0113a31fea1d331ffce73a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a5fd56e31a7bdc6ab7cb1a13922636dbe994d6dffe0edff5e891920ea2cb3ff9dc464e8fd317cd5dfd9ff5fd44b1219e9df5edab0fedfa4340cce75b5f8f906
|
7
|
+
data.tar.gz: f83c7aa752beb8d06ebb2ad1b49696814807942cf38448a69d56405ef1dcd87139d447e9cc8917a33735670efa847afdd59a1e0871a93179be176fc1e014a096
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ StripeTester allows you to submit webhooks to your application without hitting S
|
|
10
10
|
|
11
11
|
Add this line to your application's Gemfile:
|
12
12
|
```ruby
|
13
|
-
gem 'stripe_tester', "~> 0.
|
13
|
+
gem 'stripe_tester', "~> 0.4.0"
|
14
14
|
```
|
15
15
|
And then execute:
|
16
16
|
```bash
|
@@ -40,12 +40,17 @@ In your test:
|
|
40
40
|
StripeTester.webhook_url = "https://www.secure-example.com/my_post_url"
|
41
41
|
```
|
42
42
|
|
43
|
-
2. If
|
43
|
+
2. If your URL is secured with a self-signed SSL certificate, disable SSL verification:
|
44
|
+
```ruby
|
45
|
+
StripeTester.verify_ssl = false
|
46
|
+
```
|
47
|
+
|
48
|
+
3. If you want to specify which Stripe webhook API version you would like to use (the default will be the latest [supported version](https://github.com/buttercloud/stripe_tester#supported-stripe-webhook-api-versions)):
|
44
49
|
```ruby
|
45
50
|
StripeTester.stripe_version = "2015-10-16"
|
46
51
|
```
|
47
52
|
|
48
|
-
|
53
|
+
4. Send the webhook. This will send a POST request to the URL with the event data as JSON:
|
49
54
|
```ruby
|
50
55
|
# as a symbol
|
51
56
|
StripeTester.create_event(:invoice_created)
|
data/lib/stripe_tester.rb
CHANGED
@@ -67,6 +67,7 @@ module StripeTester
|
|
67
67
|
|
68
68
|
http_object = Net::HTTP.new(post_url.hostname, post_url.port)
|
69
69
|
http_object.use_ssl = true if post_url.scheme == 'https'
|
70
|
+
http_object.verify_mode = OpenSSL::SSL::VERIFY_NONE if (!verify_ssl? && http_object.use_ssl?)
|
70
71
|
|
71
72
|
# send request
|
72
73
|
res = http_object.start do |http|
|
@@ -74,10 +75,10 @@ module StripeTester
|
|
74
75
|
end
|
75
76
|
|
76
77
|
case res
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
when Net::HTTPSuccess, Net::HTTPRedirection
|
79
|
+
true
|
80
|
+
else
|
81
|
+
res.value
|
81
82
|
end
|
82
83
|
else
|
83
84
|
raise "Could not post to URL. Please set URL."
|
@@ -131,4 +132,13 @@ module StripeTester
|
|
131
132
|
def self.stripe_version
|
132
133
|
@version ? @version : LATEST_STRIPE_VERSION
|
133
134
|
end
|
135
|
+
|
136
|
+
def self.verify_ssl=(verify)
|
137
|
+
@verify_ssl = verify
|
138
|
+
end
|
139
|
+
|
140
|
+
def self.verify_ssl?
|
141
|
+
!@verify_ssl.nil? ? @verify_ssl : true
|
142
|
+
end
|
143
|
+
|
134
144
|
end
|
data/spec/stripe_tester_spec.rb
CHANGED
@@ -12,6 +12,7 @@ describe StripeTester do
|
|
12
12
|
|
13
13
|
after(:each) do
|
14
14
|
StripeTester.stripe_version = nil
|
15
|
+
StripeTester.verify_ssl = nil
|
15
16
|
end
|
16
17
|
|
17
18
|
it "#load_template should return hash" do
|
@@ -56,6 +57,18 @@ describe StripeTester do
|
|
56
57
|
expect(result_url.to_s).to eq(url)
|
57
58
|
end
|
58
59
|
|
60
|
+
it "#verify_ssl should default to true" do
|
61
|
+
result_verify = StripeTester.verify_ssl?
|
62
|
+
expect(result_verify).to eq(true)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "#verify_ssl should set the verify_ssl flag" do
|
66
|
+
verify = false
|
67
|
+
StripeTester.verify_ssl = verify
|
68
|
+
|
69
|
+
expect(StripeTester.verify_ssl?).to eq(verify)
|
70
|
+
end
|
71
|
+
|
59
72
|
it "#webhook_url should store url as and URI object" do
|
60
73
|
url = 'http://www.hello.com'
|
61
74
|
StripeTester.webhook_url = url
|
@@ -117,6 +130,23 @@ describe StripeTester do
|
|
117
130
|
expect(response).to be_truthy
|
118
131
|
end
|
119
132
|
|
133
|
+
it "#post_to_url should support HTTPS without SSL verification" do
|
134
|
+
data = StripeTester.load_template(:invoice_created)
|
135
|
+
url = "https://localhost:3000/pathname"
|
136
|
+
verify = false
|
137
|
+
StripeTester.webhook_url = url
|
138
|
+
StripeTester.verify_ssl = verify
|
139
|
+
|
140
|
+
FakeWeb.register_uri(:post,
|
141
|
+
url,
|
142
|
+
body: data.to_json,
|
143
|
+
content_type: 'application/json')
|
144
|
+
|
145
|
+
response = StripeTester.post_to_url(data)
|
146
|
+
|
147
|
+
expect(response).to be_truthy
|
148
|
+
end
|
149
|
+
|
120
150
|
it "#overwrite_attributes should overwrite attributes in default data to custom data" do
|
121
151
|
original_data = {name: 'john smith', info: {age: 45, gender: 'male'}}
|
122
152
|
overwrite_data = {name: 'smith john', age: 99}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe_tester
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Buttercloud
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|