braintree 4.39.0 → 4.41.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/lib/braintree/address_gateway.rb +13 -3
- data/lib/braintree/client_token_gateway.rb +10 -1
- data/lib/braintree/credit_card_gateway.rb +9 -2
- data/lib/braintree/credit_card_verification_gateway.rb +3 -0
- data/lib/braintree/customer_gateway.rb +11 -3
- data/lib/braintree/dispute_gateway.rb +7 -7
- data/lib/braintree/error_codes.rb +11 -0
- data/lib/braintree/http.rb +4 -2
- data/lib/braintree/merchant_account_gateway.rb +2 -0
- data/lib/braintree/payment_method_gateway.rb +7 -1
- data/lib/braintree/payment_method_nonce_gateway.rb +4 -0
- data/lib/braintree/paypal_account_gateway.rb +6 -1
- data/lib/braintree/plan_gateway.rb +4 -0
- data/lib/braintree/sepa_direct_debit_account_gateway.rb +4 -0
- data/lib/braintree/subscription_gateway.rb +6 -0
- data/lib/braintree/testing_gateway.rb +4 -0
- data/lib/braintree/three_d_secure_pass_thru.rb +11 -0
- data/lib/braintree/transaction.rb +6 -0
- data/lib/braintree/transaction_gateway.rb +17 -7
- data/lib/braintree/transaction_line_item_gateway.rb +3 -1
- data/lib/braintree/transaction_search.rb +1 -0
- data/lib/braintree/us_bank_account_gateway.rb +2 -0
- data/lib/braintree/us_bank_account_verification_gateway.rb +4 -0
- data/lib/braintree/util.rb +5 -0
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree.rb +1 -0
- data/spec/integration/braintree/advanced_search_spec.rb +4 -7
- data/spec/integration/braintree/braintree_gateway_spec.rb +1 -2
- data/spec/integration/braintree/client_api/client_token_spec.rb +14 -0
- data/spec/integration/braintree/credit_card_spec.rb +94 -2
- data/spec/integration/braintree/credit_card_verification_spec.rb +33 -0
- data/spec/integration/braintree/customer_spec.rb +196 -5
- data/spec/integration/braintree/http_spec.rb +1 -1
- data/spec/integration/braintree/payment_method_spec.rb +77 -7
- data/spec/integration/braintree/samsung_pay_card_spec.rb +1 -1
- data/spec/integration/braintree/transaction_search_spec.rb +113 -13
- data/spec/integration/braintree/transaction_spec.rb +197 -17
- data/spec/unit/braintree/address_spec.rb +32 -0
- data/spec/unit/braintree/client_token_spec.rb +72 -0
- data/spec/unit/braintree/credit_card_spec.rb +28 -0
- data/spec/unit/braintree/credit_card_verification_spec.rb +8 -0
- data/spec/unit/braintree/customer_spec.rb +28 -0
- data/spec/unit/braintree/dispute_spec.rb +38 -0
- data/spec/unit/braintree/http_spec.rb +44 -0
- data/spec/unit/braintree/merchant_account_spec.rb +11 -0
- data/spec/unit/braintree/package_tracking_spec.rb +2 -2
- data/spec/unit/braintree/payment_method_nonce_spec.rb +14 -0
- data/spec/unit/braintree/payment_method_spec.rb +20 -0
- data/spec/unit/braintree/paypal_account_spec.rb +20 -0
- data/spec/unit/braintree/plan_gateway_spec.rb +30 -0
- data/spec/unit/braintree/sepa_debit_account_spec.rb +14 -0
- data/spec/unit/braintree/subscription_spec.rb +20 -0
- data/spec/unit/braintree/test_transaction_spec.rb +18 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +11 -0
- data/spec/unit/braintree/transaction_line_item_spec.rb +11 -0
- data/spec/unit/braintree/transaction_search_spec.rb +25 -0
- data/spec/unit/braintree/transaction_spec.rb +68 -6
- data/spec/unit/braintree/us_bank_account_spec.rb +8 -0
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +14 -0
- data/spec/unit/braintree/util_spec.rb +37 -0
- metadata +8 -3
|
@@ -20,6 +20,78 @@ module Braintree
|
|
|
20
20
|
)
|
|
21
21
|
}.to raise_error(ArgumentError, /created_at, public_key/)
|
|
22
22
|
end
|
|
23
|
+
|
|
24
|
+
context "with preferred_payment_method_token" do
|
|
25
|
+
let(:config) { SpecHelper::TestMerchantConfig }
|
|
26
|
+
let(:gateway) { Gateway.new(config) }
|
|
27
|
+
let(:http) { double(:http) }
|
|
28
|
+
|
|
29
|
+
before do
|
|
30
|
+
allow(config).to receive(:http).and_return(http)
|
|
31
|
+
allow(Configuration).to receive(:gateway).and_return(gateway)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def expect_client_token_post(options)
|
|
35
|
+
expect(http).to receive(:post).with(
|
|
36
|
+
"#{config.base_merchant_path}/client_token",
|
|
37
|
+
:client_token => options,
|
|
38
|
+
).and_return(:client_token => {:value => "client-token"})
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "renames preferred_payment_method_token to payment_method_id" do
|
|
42
|
+
expect_client_token_post(
|
|
43
|
+
:payment_method_id => "a-pmt",
|
|
44
|
+
:version => ClientToken::DEFAULT_VERSION,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
client_token = Braintree::ClientToken.generate(
|
|
48
|
+
:preferred_payment_method_token => "a-pmt",
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
expect(client_token).to eq("client-token")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "renames string preferred_payment_method_token to payment_method_id" do
|
|
55
|
+
expect_client_token_post(
|
|
56
|
+
:payment_method_id => "a-pmt",
|
|
57
|
+
:version => ClientToken::DEFAULT_VERSION,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
client_token = Braintree::ClientToken.generate(
|
|
61
|
+
"preferred_payment_method_token" => "a-pmt",
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
expect(client_token).to eq("client-token")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "renames preferred_payment_method_token when the value is nil" do
|
|
68
|
+
expect_client_token_post(
|
|
69
|
+
:payment_method_id => nil,
|
|
70
|
+
:version => ClientToken::DEFAULT_VERSION,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
client_token = Braintree::ClientToken.generate(
|
|
74
|
+
:preferred_payment_method_token => nil,
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
expect(client_token).to eq("client-token")
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "does not mutate the caller's options hash" do
|
|
81
|
+
options = {:preferred_payment_method_token => "a-pmt"}
|
|
82
|
+
expect(http).to receive(:post).twice.with(
|
|
83
|
+
"#{config.base_merchant_path}/client_token",
|
|
84
|
+
:client_token => {
|
|
85
|
+
:payment_method_id => "a-pmt",
|
|
86
|
+
:version => ClientToken::DEFAULT_VERSION,
|
|
87
|
+
},
|
|
88
|
+
).and_return(:client_token => {:value => "client-token"})
|
|
89
|
+
|
|
90
|
+
expect(Braintree::ClientToken.generate(options)).to eq("client-token")
|
|
91
|
+
expect(Braintree::ClientToken.generate(options)).to eq("client-token")
|
|
92
|
+
expect(options).to eq(:preferred_payment_method_token => "a-pmt")
|
|
93
|
+
end
|
|
94
|
+
end
|
|
23
95
|
end
|
|
24
96
|
|
|
25
97
|
context "adding credit_card options with no customer ID" do
|
|
@@ -51,6 +51,7 @@ describe Braintree::CreditCard do
|
|
|
51
51
|
:directory_response,
|
|
52
52
|
:cavv_algorithm,
|
|
53
53
|
:ds_transaction_id,
|
|
54
|
+
:network,
|
|
54
55
|
]},
|
|
55
56
|
:customer_id,
|
|
56
57
|
])
|
|
@@ -100,6 +101,7 @@ describe Braintree::CreditCard do
|
|
|
100
101
|
:directory_response,
|
|
101
102
|
:cavv_algorithm,
|
|
102
103
|
:ds_transaction_id,
|
|
104
|
+
:network,
|
|
103
105
|
]},
|
|
104
106
|
])
|
|
105
107
|
end
|
|
@@ -291,4 +293,30 @@ describe Braintree::CreditCard do
|
|
|
291
293
|
card = Braintree::CreditCard._new(:gateway, {:purchase => "No"})
|
|
292
294
|
expect(card.purchase).to eq("No")
|
|
293
295
|
end
|
|
296
|
+
|
|
297
|
+
describe "path traversal" do
|
|
298
|
+
it "self.delete raises an exception if the token is a traversal segment" do
|
|
299
|
+
expect do
|
|
300
|
+
Braintree::CreditCard.delete("../payment_methods/paypal_account/victim_token")
|
|
301
|
+
end.to raise_error(ArgumentError, "token contains invalid characters")
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
it "self.find raises an exception if the token is a traversal segment" do
|
|
305
|
+
expect do
|
|
306
|
+
Braintree::CreditCard.find("../payment_methods/paypal_account/victim_token")
|
|
307
|
+
end.to raise_error(ArgumentError, "token contains invalid characters")
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
it "self.from_nonce raises an exception if the nonce is a traversal segment" do
|
|
311
|
+
expect do
|
|
312
|
+
Braintree::CreditCard.from_nonce("../payment_methods/paypal_account/victim_token")
|
|
313
|
+
end.to raise_error(ArgumentError, "nonce contains invalid characters")
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
it "self.update raises an exception if the token is a traversal segment" do
|
|
317
|
+
expect do
|
|
318
|
+
Braintree::CreditCard.update("../payment_methods/paypal_account/victim_token", :cvv => "123")
|
|
319
|
+
end.to raise_error(ArgumentError, "token contains invalid characters")
|
|
320
|
+
end
|
|
321
|
+
end
|
|
294
322
|
end
|
|
@@ -183,4 +183,12 @@ describe Braintree::CreditCardVerification do
|
|
|
183
183
|
expect(verification.credit_card[:payment_account_reference]).to eq("V0010013019339005665779448477")
|
|
184
184
|
end
|
|
185
185
|
end
|
|
186
|
+
|
|
187
|
+
describe "path traversal" do
|
|
188
|
+
it "self.find raises an exception if the id is a traversal segment" do
|
|
189
|
+
expect do
|
|
190
|
+
Braintree::CreditCardVerification.find("../verifications/victim_id")
|
|
191
|
+
end.to raise_error(ArgumentError, "id contains invalid characters")
|
|
192
|
+
end
|
|
193
|
+
end
|
|
186
194
|
end
|
|
@@ -164,6 +164,7 @@ describe Braintree::Customer do
|
|
|
164
164
|
:directory_response,
|
|
165
165
|
:cavv_algorithm,
|
|
166
166
|
:ds_transaction_id,
|
|
167
|
+
:network,
|
|
167
168
|
]},
|
|
168
169
|
]},
|
|
169
170
|
{:paypal_account => [
|
|
@@ -307,6 +308,7 @@ describe Braintree::Customer do
|
|
|
307
308
|
:directory_response,
|
|
308
309
|
:cavv_algorithm,
|
|
309
310
|
:ds_transaction_id,
|
|
311
|
+
:network,
|
|
310
312
|
]},
|
|
311
313
|
]},
|
|
312
314
|
{:tax_identifiers => [
|
|
@@ -413,4 +415,30 @@ describe Braintree::Customer do
|
|
|
413
415
|
end.to raise_error(NoMethodError, /protected method .new/)
|
|
414
416
|
end
|
|
415
417
|
end
|
|
418
|
+
|
|
419
|
+
describe "path traversal" do
|
|
420
|
+
it "self.delete raises an exception if the customer_id is a traversal segment" do
|
|
421
|
+
expect do
|
|
422
|
+
Braintree::Customer.delete("../transactions/some_id/void")
|
|
423
|
+
end.to raise_error(ArgumentError, "customer_id contains invalid characters")
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
it "self.find raises an exception if the customer_id is a traversal segment" do
|
|
427
|
+
expect do
|
|
428
|
+
Braintree::Customer.find("../transactions/some_id/void")
|
|
429
|
+
end.to raise_error(ArgumentError, "customer_id contains invalid characters")
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
it "self.update raises an exception if the customer_id is a traversal segment" do
|
|
433
|
+
expect do
|
|
434
|
+
Braintree::Customer.update("../transactions/some_id/void", :first_name => "HackerOne")
|
|
435
|
+
end.to raise_error(ArgumentError, "customer_id contains invalid characters")
|
|
436
|
+
end
|
|
437
|
+
|
|
438
|
+
it "self.transactions raises an exception if the customer_id is a traversal segment" do
|
|
439
|
+
expect do
|
|
440
|
+
Braintree::Customer.transactions("../transactions/some_id/void")
|
|
441
|
+
end.to raise_error(ArgumentError, "customer_id contains invalid characters")
|
|
442
|
+
end
|
|
443
|
+
end
|
|
416
444
|
end
|
|
@@ -278,6 +278,44 @@ describe Braintree::Dispute do
|
|
|
278
278
|
end
|
|
279
279
|
end
|
|
280
280
|
|
|
281
|
+
describe "path traversal" do
|
|
282
|
+
[
|
|
283
|
+
:accept,
|
|
284
|
+
:finalize,
|
|
285
|
+
:find,
|
|
286
|
+
].each do |method_name|
|
|
287
|
+
it "self.#{method_name} raises an exception if the dispute_id is a traversal segment" do
|
|
288
|
+
expect do
|
|
289
|
+
Braintree::Dispute.public_send(method_name, "../../foo")
|
|
290
|
+
end.to raise_error(ArgumentError, "dispute_id contains invalid characters")
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
it "self.add_file_evidence raises an exception if the dispute_id is a traversal segment" do
|
|
295
|
+
expect do
|
|
296
|
+
Braintree::Dispute.add_file_evidence("../../foo", "document_id")
|
|
297
|
+
end.to raise_error(ArgumentError, "dispute_id contains invalid characters")
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
it "self.add_text_evidence raises an exception if the dispute_id is a traversal segment" do
|
|
301
|
+
expect do
|
|
302
|
+
Braintree::Dispute.add_text_evidence("../../foo", "text evidence")
|
|
303
|
+
end.to raise_error(ArgumentError, "dispute_id contains invalid characters")
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
it "self.remove_evidence raises an exception if the dispute_id is a traversal segment" do
|
|
307
|
+
expect do
|
|
308
|
+
Braintree::Dispute.remove_evidence("../../foo", "evidence_id")
|
|
309
|
+
end.to raise_error(ArgumentError, "dispute_id contains invalid characters")
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
it "self.remove_evidence raises an exception if the evidence_id is a traversal segment" do
|
|
313
|
+
expect do
|
|
314
|
+
Braintree::Dispute.remove_evidence("dispute_id", "../../foo")
|
|
315
|
+
end.to raise_error(ArgumentError, "evidence_id contains invalid characters")
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
|
|
281
319
|
describe "initialize" do
|
|
282
320
|
it "converts string amount_dispute and amount_won" do
|
|
283
321
|
dispute = Braintree::Dispute._new(attributes)
|
|
@@ -183,6 +183,50 @@ END
|
|
|
183
183
|
end
|
|
184
184
|
end
|
|
185
185
|
|
|
186
|
+
describe "#delete" do
|
|
187
|
+
it "appends the query string to the path when query_params are present" do
|
|
188
|
+
http = Braintree::Http.new(Braintree::Configuration.new)
|
|
189
|
+
response = double("response", :code => "200")
|
|
190
|
+
|
|
191
|
+
expect(http).to receive(:_http_do).with(Net::HTTP::Delete, "/customers?id=123").and_return(response)
|
|
192
|
+
|
|
193
|
+
http.delete("/customers", :id => 123)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
it "does not append a query string when query_params are empty" do
|
|
197
|
+
http = Braintree::Http.new(Braintree::Configuration.new)
|
|
198
|
+
response = double("response", :code => "200")
|
|
199
|
+
|
|
200
|
+
expect(http).to receive(:_http_do).with(Net::HTTP::Delete, "/customers").and_return(response)
|
|
201
|
+
|
|
202
|
+
http.delete("/customers")
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
describe "#get" do
|
|
207
|
+
it "appends the query string to the path when query_params are present" do
|
|
208
|
+
http = Braintree::Http.new(Braintree::Configuration.new)
|
|
209
|
+
response = double("response", :code => "200")
|
|
210
|
+
allow(http).to receive(:_body).with(response).and_return("")
|
|
211
|
+
allow(Braintree::Xml).to receive(:hash_from_xml).with("").and_return({})
|
|
212
|
+
|
|
213
|
+
expect(http).to receive(:_http_do).with(Net::HTTP::Get, "/customers?id=123").and_return(response)
|
|
214
|
+
|
|
215
|
+
http.get("/customers", :id => 123)
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
it "does not append a query string when query_params are empty" do
|
|
219
|
+
http = Braintree::Http.new(Braintree::Configuration.new)
|
|
220
|
+
response = double("response", :code => "200")
|
|
221
|
+
allow(http).to receive(:_body).with(response).and_return("")
|
|
222
|
+
allow(Braintree::Xml).to receive(:hash_from_xml).with("").and_return({})
|
|
223
|
+
|
|
224
|
+
expect(http).to receive(:_http_do).with(Net::HTTP::Get, "/customers").and_return(response)
|
|
225
|
+
|
|
226
|
+
http.get("/customers")
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
|
|
186
230
|
describe "_build_query_string" do
|
|
187
231
|
it "returns an empty string for empty query params" do
|
|
188
232
|
expect(Braintree::Http.new(:config)._build_query_string({})).to eq("")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::MerchantAccount do
|
|
4
|
+
describe "path traversal" do
|
|
5
|
+
it "self.find raises an exception if the merchant_account_id is a traversal segment" do
|
|
6
|
+
expect do
|
|
7
|
+
Braintree::MerchantAccount.find("../transactions/some_id/void")
|
|
8
|
+
end.to raise_error(ArgumentError, "merchant_account_id contains invalid characters")
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -24,8 +24,8 @@ describe "Package Tracking Unit Tests" do
|
|
|
24
24
|
|
|
25
25
|
it "raises an ArgumentError if transaction_id is an invalid format" do
|
|
26
26
|
expect do
|
|
27
|
-
Braintree::Transaction.package_tracking("invalid
|
|
28
|
-
end.to raise_error(ArgumentError, "transaction_id
|
|
27
|
+
Braintree::Transaction.package_tracking("invalid/transaction/id", {})
|
|
28
|
+
end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it "raises an exception if attributes contain an invalid key" do
|
|
@@ -47,4 +47,18 @@ describe Braintree::PaymentMethodNonce do
|
|
|
47
47
|
expect(payment_method_nonce.default?).to be true
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
|
+
|
|
51
|
+
describe "path traversal" do
|
|
52
|
+
it "self.create raises an exception if the payment_method_token is a traversal segment" do
|
|
53
|
+
expect do
|
|
54
|
+
Braintree::PaymentMethodNonce.create("../payment_method_nonces/victim_nonce")
|
|
55
|
+
end.to raise_error(ArgumentError, "payment_method_token contains invalid characters")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "self.find raises an exception if the payment_method_nonce is a traversal segment" do
|
|
59
|
+
expect do
|
|
60
|
+
Braintree::PaymentMethodNonce.find("../payment_method_nonces/victim_nonce")
|
|
61
|
+
end.to raise_error(ArgumentError, "payment_method_nonce contains invalid characters")
|
|
62
|
+
end
|
|
63
|
+
end
|
|
50
64
|
end
|
|
@@ -144,4 +144,24 @@ describe Braintree::PaymentMethod do
|
|
|
144
144
|
end.to_not raise_error
|
|
145
145
|
end
|
|
146
146
|
end
|
|
147
|
+
|
|
148
|
+
describe "path traversal" do
|
|
149
|
+
it "self.find raises an exception if the token is a traversal segment" do
|
|
150
|
+
expect do
|
|
151
|
+
Braintree::PaymentMethod.find("../customers/some_id/transaction_ids")
|
|
152
|
+
end.to raise_error(ArgumentError, "token contains invalid characters")
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it "self.update raises an exception if the token is a traversal segment" do
|
|
156
|
+
expect do
|
|
157
|
+
Braintree::PaymentMethod.update("../customers/some_id/transaction_ids", {})
|
|
158
|
+
end.to raise_error(ArgumentError, "token contains invalid characters")
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
it "self.delete raises an exception if the token is a traversal segment" do
|
|
162
|
+
expect do
|
|
163
|
+
Braintree::PaymentMethod.delete("../customers/some_id/transaction_ids")
|
|
164
|
+
end.to raise_error(ArgumentError, "token contains invalid characters")
|
|
165
|
+
end
|
|
166
|
+
end
|
|
147
167
|
end
|
|
@@ -50,4 +50,24 @@ describe Braintree::PayPalAccount do
|
|
|
50
50
|
expect(paypal_account.edit_paypal_vault_id).to eq(mock_edit_paypal_vault_id)
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
|
+
|
|
54
|
+
describe "path traversal" do
|
|
55
|
+
it "self.find raises an exception if the token is a traversal segment" do
|
|
56
|
+
expect do
|
|
57
|
+
Braintree::PayPalAccount.find("../payment_methods/credit_card/victim_token")
|
|
58
|
+
end.to raise_error(ArgumentError, "token contains invalid characters")
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "self.update raises an exception if the token is a traversal segment" do
|
|
62
|
+
expect do
|
|
63
|
+
Braintree::PayPalAccount.update("../payment_methods/credit_card/victim_token", {})
|
|
64
|
+
end.to raise_error(ArgumentError, "token contains invalid characters")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "self.delete raises an exception if the token is a traversal segment" do
|
|
68
|
+
expect do
|
|
69
|
+
Braintree::PayPalAccount.delete("../payment_methods/credit_card/victim_token")
|
|
70
|
+
end.to raise_error(ArgumentError, "token contains invalid characters")
|
|
71
|
+
end
|
|
72
|
+
end
|
|
53
73
|
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::PlanGateway do
|
|
4
|
+
let(:gateway) do
|
|
5
|
+
config = Braintree::Configuration.new(
|
|
6
|
+
:merchant_id => "merchant_id",
|
|
7
|
+
:public_key => "public_key",
|
|
8
|
+
:private_key => "private_key",
|
|
9
|
+
)
|
|
10
|
+
Braintree::Gateway.new(config)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe "path traversal" do
|
|
14
|
+
it "find raises an exception if the id is a traversal segment" do
|
|
15
|
+
plan_gateway = Braintree::PlanGateway.new(gateway)
|
|
16
|
+
|
|
17
|
+
expect do
|
|
18
|
+
plan_gateway.find("../plans/victim_id")
|
|
19
|
+
end.to raise_error(ArgumentError, "id contains invalid characters")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "update raises an exception if the plan_id is a traversal segment" do
|
|
23
|
+
plan_gateway = Braintree::PlanGateway.new(gateway)
|
|
24
|
+
|
|
25
|
+
expect do
|
|
26
|
+
plan_gateway.update("../plans/victim_id", {})
|
|
27
|
+
end.to raise_error(ArgumentError, "plan_id contains invalid characters")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -83,4 +83,18 @@ describe Braintree::SepaDirectDebitAccount do
|
|
|
83
83
|
it { is_expected.to be false }
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
|
+
|
|
87
|
+
describe "path traversal" do
|
|
88
|
+
it "self.find raises an exception if the token is a traversal segment" do
|
|
89
|
+
expect do
|
|
90
|
+
Braintree::SepaDirectDebitAccount.find("../payment_methods/credit_card/victim_token")
|
|
91
|
+
end.to raise_error(ArgumentError, "token contains invalid characters")
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it "self.delete raises an exception if the token is a traversal segment" do
|
|
95
|
+
expect do
|
|
96
|
+
Braintree::SepaDirectDebitAccount.delete("../payment_methods/credit_card/victim_token")
|
|
97
|
+
end.to raise_error(ArgumentError, "token contains invalid characters")
|
|
98
|
+
end
|
|
99
|
+
end
|
|
86
100
|
end
|
|
@@ -77,4 +77,24 @@ describe Braintree::Subscription do
|
|
|
77
77
|
expect(subscription).not_to eq("not a subscription")
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
|
+
|
|
81
|
+
describe "path traversal" do
|
|
82
|
+
it "self.cancel raises an exception if the subscription_id is a traversal segment" do
|
|
83
|
+
expect do
|
|
84
|
+
Braintree::Subscription.cancel("../transactions/some_id/void")
|
|
85
|
+
end.to raise_error(ArgumentError, "subscription_id contains invalid characters")
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "self.find raises an exception if the id is a traversal segment" do
|
|
89
|
+
expect do
|
|
90
|
+
Braintree::Subscription.find("../transactions/some_id/void")
|
|
91
|
+
end.to raise_error(ArgumentError, "id contains invalid characters")
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it "self.update raises an exception if the subscription_id is a traversal segment" do
|
|
95
|
+
expect do
|
|
96
|
+
Braintree::Subscription.update("../transactions/some_id/void", {})
|
|
97
|
+
end.to raise_error(ArgumentError, "subscription_id contains invalid characters")
|
|
98
|
+
end
|
|
99
|
+
end
|
|
80
100
|
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::TestTransaction do
|
|
4
|
+
describe "path traversal" do
|
|
5
|
+
[
|
|
6
|
+
:settle,
|
|
7
|
+
:settlement_confirm,
|
|
8
|
+
:settlement_decline,
|
|
9
|
+
:settlement_pending,
|
|
10
|
+
].each do |method_name|
|
|
11
|
+
it "self.#{method_name} raises an exception if the transaction_id is a traversal segment" do
|
|
12
|
+
expect do
|
|
13
|
+
Braintree::TestTransaction.public_send(method_name, "../transactions/victim_id/void")
|
|
14
|
+
end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -128,6 +128,7 @@ describe Braintree::TransactionGateway do
|
|
|
128
128
|
:directory_response,
|
|
129
129
|
:cavv_algorithm,
|
|
130
130
|
:ds_transaction_id,
|
|
131
|
+
:network,
|
|
131
132
|
]
|
|
132
133
|
},
|
|
133
134
|
{
|
|
@@ -199,5 +200,15 @@ describe Braintree::TransactionGateway do
|
|
|
199
200
|
it "creates transaction gateway submit for partial settlement signature" do
|
|
200
201
|
expect(Braintree::TransactionGateway._submit_for_partial_settlement_signature).to include(:final_capture)
|
|
201
202
|
end
|
|
203
|
+
|
|
204
|
+
it "creates a transaction gateway refund signature" do
|
|
205
|
+
expect(Braintree::TransactionGateway._refund_signature).to match([
|
|
206
|
+
:amount,
|
|
207
|
+
:api_request_key,
|
|
208
|
+
:merchant_account_id,
|
|
209
|
+
:order_id,
|
|
210
|
+
:surcharge_amount,
|
|
211
|
+
])
|
|
212
|
+
end
|
|
202
213
|
end
|
|
203
214
|
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::TransactionLineItem do
|
|
4
|
+
describe "path traversal" do
|
|
5
|
+
it "self.find_all raises an exception if the transaction_id is a traversal segment" do
|
|
6
|
+
expect do
|
|
7
|
+
Braintree::TransactionLineItem.find_all("../transactions/victim_id/void")
|
|
8
|
+
end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -21,4 +21,29 @@ describe Braintree::TransactionSearch do
|
|
|
21
21
|
search.billing_company "one"
|
|
22
22
|
end.to raise_error(RuntimeError, "An operator is required")
|
|
23
23
|
end
|
|
24
|
+
|
|
25
|
+
it "builds a hash for ach_type with a single value (same_day)" do
|
|
26
|
+
search = Braintree::TransactionSearch.new
|
|
27
|
+
search.ach_type.is Braintree::Transaction::AchType::SameDay
|
|
28
|
+
expect(search.to_hash).to eq({:ach_type => [Braintree::Transaction::AchType::SameDay]})
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "builds a hash for ach_type with a single value (standard)" do
|
|
32
|
+
search = Braintree::TransactionSearch.new
|
|
33
|
+
search.ach_type.is Braintree::Transaction::AchType::Standard
|
|
34
|
+
expect(search.to_hash).to eq({:ach_type => [Braintree::Transaction::AchType::Standard]})
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "builds a hash for ach_type with both values" do
|
|
38
|
+
search = Braintree::TransactionSearch.new
|
|
39
|
+
search.ach_type.in Braintree::Transaction::AchType::SameDay, Braintree::Transaction::AchType::Standard
|
|
40
|
+
expect(search.to_hash).to eq({:ach_type => [Braintree::Transaction::AchType::SameDay, Braintree::Transaction::AchType::Standard]})
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "raises if ach_type is given a value outside the allow-list" do
|
|
44
|
+
search = Braintree::TransactionSearch.new
|
|
45
|
+
expect do
|
|
46
|
+
search.ach_type.is "invalid_ach_type"
|
|
47
|
+
end.to raise_error(ArgumentError, /Invalid argument\(s\) for ach_type: invalid_ach_type/)
|
|
48
|
+
end
|
|
24
49
|
end
|
|
@@ -40,8 +40,8 @@ describe Braintree::Transaction do
|
|
|
40
40
|
describe "self.submit_for_settlement" do
|
|
41
41
|
it "raises an ArgumentError if transaction_id is an invalid format" do
|
|
42
42
|
expect do
|
|
43
|
-
Braintree::Transaction.submit_for_settlement("invalid
|
|
44
|
-
end.to raise_error(ArgumentError, "transaction_id
|
|
43
|
+
Braintree::Transaction.submit_for_settlement("invalid/transaction/id")
|
|
44
|
+
end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
it "raises an ArgumentError if options hash includes an invalid key" do
|
|
@@ -54,16 +54,16 @@ describe Braintree::Transaction do
|
|
|
54
54
|
describe "self.adjust_authorization" do
|
|
55
55
|
it "raises an ArgumentError if transaction_id is an invalid format" do
|
|
56
56
|
expect do
|
|
57
|
-
Braintree::Transaction.adjust_authorization("invalid
|
|
58
|
-
end.to raise_error(ArgumentError, "transaction_id
|
|
57
|
+
Braintree::Transaction.adjust_authorization("invalid/transaction/id", "10.00")
|
|
58
|
+
end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
describe "self.update_details" do
|
|
63
63
|
it "raises an ArgumentError if transaction_id is an invalid format" do
|
|
64
64
|
expect do
|
|
65
|
-
Braintree::Transaction.update_details("invalid
|
|
66
|
-
end.to raise_error(ArgumentError, "transaction_id
|
|
65
|
+
Braintree::Transaction.update_details("invalid/transaction/id")
|
|
66
|
+
end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
69
|
|
|
@@ -604,4 +604,66 @@ describe Braintree::Transaction do
|
|
|
604
604
|
expect(transaction.surcharge_amount).to be_nil
|
|
605
605
|
end
|
|
606
606
|
end
|
|
607
|
+
|
|
608
|
+
describe "path traversal" do
|
|
609
|
+
it "self.clone_transaction raises an exception if the transaction_id is a traversal segment" do
|
|
610
|
+
expect do
|
|
611
|
+
Braintree::Transaction.clone_transaction("../customers/some_id", :amount => "10.00")
|
|
612
|
+
end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
|
|
613
|
+
end
|
|
614
|
+
|
|
615
|
+
it "self.find raises an exception if the id is a traversal segment" do
|
|
616
|
+
expect do
|
|
617
|
+
Braintree::Transaction.find("../customers/some_id")
|
|
618
|
+
end.to raise_error(ArgumentError, "id contains invalid characters")
|
|
619
|
+
end
|
|
620
|
+
|
|
621
|
+
it "self.refund raises an exception if the transaction_id is a traversal segment" do
|
|
622
|
+
expect do
|
|
623
|
+
Braintree::Transaction.refund("../customers/some_id")
|
|
624
|
+
end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
|
|
625
|
+
end
|
|
626
|
+
|
|
627
|
+
it "self.void raises an exception if the transaction_id is a traversal segment" do
|
|
628
|
+
expect do
|
|
629
|
+
Braintree::Transaction.void("../transactions/victim_id")
|
|
630
|
+
end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
|
|
631
|
+
end
|
|
632
|
+
|
|
633
|
+
it "self.cancel_release raises an exception if the transaction_id is a traversal segment" do
|
|
634
|
+
expect do
|
|
635
|
+
Braintree::Transaction.cancel_release("../transactions/victim_id/void")
|
|
636
|
+
end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
|
|
637
|
+
end
|
|
638
|
+
|
|
639
|
+
it "self.package_tracking raises an exception if the transaction_id is a traversal segment" do
|
|
640
|
+
expect do
|
|
641
|
+
Braintree::Transaction.package_tracking("../transactions/victim_id/void", {})
|
|
642
|
+
end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
|
|
643
|
+
end
|
|
644
|
+
|
|
645
|
+
it "self.submit_for_settlement raises an exception if the transaction_id is a traversal segment" do
|
|
646
|
+
expect do
|
|
647
|
+
Braintree::Transaction.submit_for_settlement("../transactions/victim_id/void")
|
|
648
|
+
end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
|
|
649
|
+
end
|
|
650
|
+
|
|
651
|
+
it "self.adjust_authorization raises an exception if the transaction_id is a traversal segment" do
|
|
652
|
+
expect do
|
|
653
|
+
Braintree::Transaction.adjust_authorization("../transactions/victim_id/void", "10.00")
|
|
654
|
+
end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
|
|
655
|
+
end
|
|
656
|
+
|
|
657
|
+
it "self.update_details raises an exception if the transaction_id is a traversal segment" do
|
|
658
|
+
expect do
|
|
659
|
+
Braintree::Transaction.update_details("../transactions/victim_id/void")
|
|
660
|
+
end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
|
|
661
|
+
end
|
|
662
|
+
|
|
663
|
+
it "self.submit_for_partial_settlement raises an exception if the authorized_transaction_id is a traversal segment" do
|
|
664
|
+
expect do
|
|
665
|
+
Braintree::Transaction.submit_for_partial_settlement("../transactions/victim_id/void")
|
|
666
|
+
end.to raise_error(ArgumentError, "authorized_transaction_id contains invalid characters")
|
|
667
|
+
end
|
|
668
|
+
end
|
|
607
669
|
end
|
|
@@ -10,4 +10,12 @@ describe Braintree::UsBankAccount do
|
|
|
10
10
|
expect(Braintree::UsBankAccount._new(:gateway, :default => false).default?).to eq(false)
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
|
+
|
|
14
|
+
describe "path traversal" do
|
|
15
|
+
it "self.find raises an exception if the token is a traversal segment" do
|
|
16
|
+
expect do
|
|
17
|
+
Braintree::UsBankAccount.find("../payment_methods/credit_card/victim_token")
|
|
18
|
+
end.to raise_error(ArgumentError, "token contains invalid characters")
|
|
19
|
+
end
|
|
20
|
+
end
|
|
13
21
|
end
|