fat_zebra 3.2.0 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +2 -2
- data/fat_zebra.gemspec +1 -1
- data/lib/fat_zebra.rb +1 -1
- data/lib/fat_zebra/authenticate.rb +64 -0
- data/lib/fat_zebra/version.rb +1 -1
- data/spec/cassettes/FatZebra_Authenticate/_authenticate/validations/1_3_4_1.yml +46 -0
- data/spec/cassettes/FatZebra_Authenticate/_authenticate/with_challenge_response/1_3_3_1.yml +91 -0
- data/spec/cassettes/FatZebra_Authenticate/_authenticate/with_challenge_response/1_3_3_2.yml +91 -0
- data/spec/cassettes/FatZebra_Authenticate/_authenticate/with_frictionless_response/1_3_2_1.yml +91 -0
- data/spec/cassettes/FatZebra_Authenticate/_authenticate/with_frictionless_response/1_3_2_2.yml +91 -0
- data/spec/cassettes/FatZebra_Authenticate/_authenticate/with_invalid_input/1_3_1_1.yml +91 -0
- data/spec/cassettes/FatZebra_Authenticate/_authenticate/with_invalid_input/1_3_1_2.yml +87 -0
- data/spec/cassettes/FatZebra_Authenticate/_authenticate/with_invalid_input/1_3_1_3.yml +92 -0
- data/spec/cassettes/FatZebra_Authenticate/_authenticate/with_invalid_input/1_3_1_4.yml +92 -0
- data/spec/cassettes/FatZebra_Authenticate/_decode_session/when_token_is_invalid/returns_error_when_invalid_token.yml +47 -0
- data/spec/cassettes/FatZebra_Authenticate/_decode_session/when_token_is_valid/decodes_JWT.yml +87 -0
- data/spec/cassettes/FatZebra_Authenticate/_session/returns_JWT_with_given_params.yml +44 -0
- data/spec/cassettes/{FatZebra_Authorise/_jwt_token → FatZebra_Authenticate/_session}/returns_JWT_with_no_params.yml +8 -10
- data/spec/cassettes/FatZebra_Authenticate/_session/returns_JWT_with_some_params.yml +44 -0
- data/spec/cassettes/FatZebra_Authenticate/_session/returns_error_when_amount_is_invalid.yml +44 -0
- data/spec/lib/fat_zebra/authenticate_spec.rb +144 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/support/payloads.rb +36 -31
- metadata +21 -15
- data/lib/fat_zebra/authorise.rb +0 -49
- data/spec/cassettes/FatZebra_Authorise/_authorise/with_challenge_response/1_2_3_1.yml +0 -48
- data/spec/cassettes/FatZebra_Authorise/_authorise/with_challenge_response/1_2_3_2.yml +0 -48
- data/spec/cassettes/FatZebra_Authorise/_authorise/with_frictionless_response/1_2_2_1.yml +0 -48
- data/spec/cassettes/FatZebra_Authorise/_authorise/with_frictionless_response/1_2_2_2.yml +0 -48
- data/spec/cassettes/FatZebra_Authorise/_authorise/with_invalid_input/1_2_1_1.yml +0 -50
- data/spec/cassettes/FatZebra_Authorise/_jwt_token/returns_JWT_with_given_params.yml +0 -46
- data/spec/cassettes/FatZebra_Authorise/_jwt_token/returns_JWT_with_some_params.yml +0 -46
- data/spec/lib/fat_zebra/authorise_spec.rb +0 -101
@@ -1,46 +0,0 @@
|
|
1
|
-
---
|
2
|
-
http_interactions:
|
3
|
-
- request:
|
4
|
-
method: get
|
5
|
-
uri: https://gateway.sandbox.fatzebra.com.au/v1.0/authorise/jwt_token?amount=100&confirm_url=https://example.com¤cy_code=036&order_number=xxxx-xxxx-xxxx&reference_id=xxxx-xxxx-xxxx&test=true
|
6
|
-
body:
|
7
|
-
encoding: US-ASCII
|
8
|
-
string: ''
|
9
|
-
headers:
|
10
|
-
Accept-Encoding:
|
11
|
-
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
-
Accept:
|
13
|
-
- application/json
|
14
|
-
User-Agent:
|
15
|
-
- Ruby
|
16
|
-
Host:
|
17
|
-
- gateway.sandbox.fatzebra.com.au
|
18
|
-
Authorization:
|
19
|
-
- Basic VEVTVDpURVNU
|
20
|
-
Content-Type:
|
21
|
-
- application/json
|
22
|
-
response:
|
23
|
-
status:
|
24
|
-
code: 200
|
25
|
-
message: OK
|
26
|
-
headers:
|
27
|
-
Cache-Control:
|
28
|
-
- no-store
|
29
|
-
Pragma:
|
30
|
-
- no-cache
|
31
|
-
Content-Type:
|
32
|
-
- application/json; charset=utf-8
|
33
|
-
X-Request-Version:
|
34
|
-
- 1.21.8
|
35
|
-
X-Request-Id:
|
36
|
-
- ca35fe7e5bb33bf91045771b066e3225
|
37
|
-
X-Runtime:
|
38
|
-
- '2.541608'
|
39
|
-
Transfer-Encoding:
|
40
|
-
- chunked
|
41
|
-
body:
|
42
|
-
encoding: UTF-8
|
43
|
-
string: '{"successful":true,"response":{"jwt":"eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NjczOTkyMDMsImlhdCI6MTU2NzM4NDgwMywiaXNzIjoiNTgyZTBhMjAzM2ZhZGQxMjYwZjk5MGY2IiwianRpIjoiNzJjYzkzZTktY2I0Ni00NjNiLTllZWMtNWFjYzViMzRlZDk2IiwiT3JnVW5pdElkIjoiNTgyYmU5ZGVkYTUyOTMyYTk0NmM0NWM0IiwiT2JqZWN0aWZ5UGF5bG9hZCI6dHJ1ZSwiUmVmZXJlbmNlSWQiOiJlMTdkMGIxNy1jYTViLTRhYzQtYWE3YS0xN2ZhYzQzMDNiM2IifQ.pslZfApXY1MtDA2OKks9OhkEY_KIFkc-XTrO4Xc7zIg","reference_id":"e17d0b17-ca5b-4ac4-aa7a-17fac4303b3b"},"errors":[],"test":true}'
|
44
|
-
http_version:
|
45
|
-
recorded_at: Mon, 02 Sep 2019 00:40:03 GMT
|
46
|
-
recorded_with: VCR 3.0.3
|
@@ -1,46 +0,0 @@
|
|
1
|
-
---
|
2
|
-
http_interactions:
|
3
|
-
- request:
|
4
|
-
method: get
|
5
|
-
uri: https://gateway.sandbox.fatzebra.com.au/v1.0/authorise/jwt_token?amount=100&confirm_url=https://example.com¤cy_code=036&order_number=xxxx-xxxx-xxxx&test=true
|
6
|
-
body:
|
7
|
-
encoding: US-ASCII
|
8
|
-
string: ''
|
9
|
-
headers:
|
10
|
-
Accept-Encoding:
|
11
|
-
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
-
Accept:
|
13
|
-
- application/json
|
14
|
-
User-Agent:
|
15
|
-
- Ruby
|
16
|
-
Host:
|
17
|
-
- gateway.sandbox.fatzebra.com.au
|
18
|
-
Authorization:
|
19
|
-
- Basic VEVTVDpURVNU
|
20
|
-
Content-Type:
|
21
|
-
- application/json
|
22
|
-
response:
|
23
|
-
status:
|
24
|
-
code: 200
|
25
|
-
message: OK
|
26
|
-
headers:
|
27
|
-
Cache-Control:
|
28
|
-
- no-store
|
29
|
-
Pragma:
|
30
|
-
- no-cache
|
31
|
-
Content-Type:
|
32
|
-
- application/json; charset=utf-8
|
33
|
-
X-Request-Version:
|
34
|
-
- 1.21.8
|
35
|
-
X-Request-Id:
|
36
|
-
- baa38892840aad6e85125b672b0f3264
|
37
|
-
X-Runtime:
|
38
|
-
- '0.265561'
|
39
|
-
Transfer-Encoding:
|
40
|
-
- chunked
|
41
|
-
body:
|
42
|
-
encoding: UTF-8
|
43
|
-
string: '{"successful":true,"response":{"jwt":"eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NjczOTkyMDMsImlhdCI6MTU2NzM4NDgwMywiaXNzIjoiNTgyZTBhMjAzM2ZhZGQxMjYwZjk5MGY2IiwianRpIjoiZDZkMTFjYzItYzJlNS00MDk1LWJhMjktMmY2NDhiNzJjNzU1IiwiT3JnVW5pdElkIjoiNTgyYmU5ZGVkYTUyOTMyYTk0NmM0NWM0IiwiT2JqZWN0aWZ5UGF5bG9hZCI6dHJ1ZSwiUmVmZXJlbmNlSWQiOiJiODg2MDAzZi1lYTJiLTQwMjAtOGVlNC01NjFlYTdjMTI3MzEifQ.w2EKM09LU0lF7iq5luyVbpwXx6p_np3DApXsP5XpTWw","reference_id":"b886003f-ea2b-4020-8ee4-561ea7c12731"},"errors":[],"test":true}'
|
44
|
-
http_version:
|
45
|
-
recorded_at: Mon, 02 Sep 2019 00:40:03 GMT
|
46
|
-
recorded_with: VCR 3.0.3
|
@@ -1,101 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe FatZebra::Authorise do
|
4
|
-
|
5
|
-
describe '.jwt_token', :vcr do
|
6
|
-
subject(:token) { FatZebra::Authorise.jwt_token(valid_3ds_token_payload) }
|
7
|
-
|
8
|
-
let(:valid_3ds_token_payload) {{
|
9
|
-
reference_id: 'xxxx-xxxx-xxxx',
|
10
|
-
confirm_url: 'https://example.com',
|
11
|
-
order_number: 'xxxx-xxxx-xxxx',
|
12
|
-
currency_code: '036',
|
13
|
-
amount: 100
|
14
|
-
}}
|
15
|
-
|
16
|
-
it 'returns JWT with given params' do
|
17
|
-
is_expected.to be_accepted
|
18
|
-
expect(token.jwt).to be_truthy
|
19
|
-
expect(token.reference_id).to be_truthy
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'returns JWT with some params' do
|
23
|
-
valid_3ds_token_payload.delete(:reference_id)
|
24
|
-
is_expected.to be_accepted
|
25
|
-
expect(token.jwt).to be_truthy
|
26
|
-
expect(token.reference_id).to be_truthy
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'returns JWT with no params' do
|
30
|
-
valid_3ds_token_payload.clear
|
31
|
-
is_expected.to be_accepted
|
32
|
-
expect(token.jwt).to be_truthy
|
33
|
-
expect(token.reference_id).to be_truthy
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '.authorise', :vcr do
|
38
|
-
subject(:authorise) { FatZebra::Authorise.authorise(valid_3ds_authorise_payload) }
|
39
|
-
|
40
|
-
context 'with invalid input' do
|
41
|
-
before do
|
42
|
-
valid_3ds_authorise_payload[:card_expiry] = DateTime.now.prev_month.strftime('%m/%Y')
|
43
|
-
end
|
44
|
-
|
45
|
-
it do
|
46
|
-
is_expected.not_to be_accepted
|
47
|
-
expect(authorise.errors).to match(/Error Validating Credit Card Expiration/)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'with frictionless response' do
|
52
|
-
before do
|
53
|
-
valid_3ds_authorise_payload[:card_number] = '4000000000001000'
|
54
|
-
end
|
55
|
-
|
56
|
-
it do
|
57
|
-
is_expected.to be_accepted
|
58
|
-
expect(authorise.keys).to include('Enrolled', 'ACSUrl', 'CardBin', 'TransactionId')
|
59
|
-
expect(authorise.errors).not_to be_truthy
|
60
|
-
end
|
61
|
-
|
62
|
-
it do
|
63
|
-
expect(authorise.Enrolled).to eq('Y')
|
64
|
-
expect(authorise.ACSUrl).not_to be_truthy
|
65
|
-
expect(authorise.CardBin).to be_truthy
|
66
|
-
expect(authorise.ErrorNo).to eq('0')
|
67
|
-
expect(authorise.ErrorDesc).not_to be_truthy
|
68
|
-
expect(authorise.CardBrand).to be_truthy
|
69
|
-
expect(authorise.TransactionId).to be_truthy
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context 'with challenge response' do
|
74
|
-
before do
|
75
|
-
valid_3ds_authorise_payload[:card_number] = '4111111111111111'
|
76
|
-
end
|
77
|
-
|
78
|
-
it do
|
79
|
-
is_expected.to be_accepted
|
80
|
-
expect(authorise.keys).to include('Enrolled', 'ACSUrl', 'CardBin', 'TransactionId')
|
81
|
-
expect(authorise.errors).not_to be_truthy
|
82
|
-
end
|
83
|
-
|
84
|
-
it do
|
85
|
-
expect(authorise.Enrolled).to eq('Y')
|
86
|
-
expect(authorise.ACSUrl).to be_truthy
|
87
|
-
expect(authorise.CardBin).to be_truthy
|
88
|
-
expect(authorise.ErrorNo).to eq('0')
|
89
|
-
expect(authorise.ErrorDesc).not_to be_truthy
|
90
|
-
expect(authorise.CardBrand).to be_truthy
|
91
|
-
expect(authorise.TransactionId).to be_truthy
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
context 'validations' do
|
96
|
-
let(:valid_3ds_authorise_payload) {{}}
|
97
|
-
|
98
|
-
it { expect{ authorise }.to raise_error(FatZebra::RequestValidationError) }
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|