/
stripe_test.rb
132 lines (111 loc) · 3.72 KB
/
stripe_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# frozen_string_literal: true
require ::File.expand_path("test_helper", __dir__)
class StripeTest < Test::Unit::TestCase
should "allow app_info to be configured" do
begin
old = Stripe.app_info
Stripe.set_app_info(
"MyAwesomePlugin",
partner_id: "partner_1234",
url: "https://myawesomeplugin.info",
version: "1.2.34"
)
assert_equal({
name: "MyAwesomePlugin",
partner_id: "partner_1234",
url: "https://myawesomeplugin.info",
version: "1.2.34",
}, Stripe.app_info)
ensure
Stripe.app_info = old
end
end
context "forwardable configurations" do
context "internal configurations" do
should "return the certificate store" do
assert Stripe.ca_store.is_a?(OpenSSL::X509::Store)
end
should "return the max_network_retry_delay" do
assert_equal 2, Stripe.max_network_retry_delay
end
should "return the initial_network_retry_delay" do
assert_equal 0.5, Stripe.initial_network_retry_delay
end
end
should "allow ca_bundle_path to be configured" do
Stripe::StripeClient.expects(:clear_all_connection_managers)
Stripe.ca_bundle_path = "/path/to/ca/bundle"
assert_equal "/path/to/ca/bundle", Stripe.ca_bundle_path
end
should "allow open timeout to be configured" do
Stripe.open_timeout = 10
assert_equal 10, Stripe.open_timeout
end
should "allow read timeout to be configured" do
Stripe.read_timeout = 10
assert_equal 10, Stripe.read_timeout
end
if WRITE_TIMEOUT_SUPPORTED
should "allow write timeout to be configured" do
Stripe.write_timeout = 10
assert_equal 10, Stripe.write_timeout
end
else
should "raise when write timeout to be configured is not supported" do
assert_raises NotImplementedError do
Stripe.write_timeout = 10
end
end
end
should "allow api_key to be configured" do
Stripe.api_key = "sk_local_test"
assert_equal "sk_local_test", Stripe.api_key
end
should "allow stripe_account to be configured" do
Stripe.stripe_account = "acct_1234"
assert_equal "acct_1234", Stripe.stripe_account
end
should "allow enable_telemetry to be configured" do
begin
old = Stripe.enable_telemetry?
Stripe.enable_telemetry = false
assert_equal false, Stripe.enable_telemetry?
ensure
Stripe.enable_telemetry = old
end
end
should "allow log_level to be configured" do
Stripe.log_level = "debug"
assert_equal ::Logger::DEBUG, Stripe.log_level
end
should "allow logger to be configured" do
logger = Object.new
Stripe.logger = logger
assert_equal logger, Stripe.logger
end
should "allow proxy to be configured" do
Stripe.proxy = "http://proxy"
assert_equal "http://proxy", Stripe.proxy
end
should "allow uploads_base to be configured" do
Stripe.uploads_base = "https://other.stripe.com"
assert_equal "https://other.stripe.com", Stripe.uploads_base
end
should "allow api_base to be configured" do
Stripe.api_base = "https://other.stripe.com"
assert_equal "https://other.stripe.com", Stripe.api_base
end
should "allow connect_base to be configured" do
Stripe.connect_base = "https://other.stripe.com"
assert_equal "https://other.stripe.com", Stripe.connect_base
end
should "allow verify_ssl_certs to be configured" do
Stripe.verify_ssl_certs = false
assert_equal false, Stripe.verify_ssl_certs
end
should "allow client_id to be configured" do
Stripe.client_id = "client"
assert_equal "client", Stripe.client_id
end
end
end