acquiring-sdk-ruby 1.2.0 → 1.3.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/acquiring-sdk-ruby.gemspec +1 -1
- data/lib/worldline/acquiring/sdk/authentication/oauth2_authenticator.rb +16 -11
- data/lib/worldline/acquiring/sdk/authentication/oauth2_scopes.rb +73 -0
- data/lib/worldline/acquiring/sdk/communication/metadata_provider.rb +1 -1
- data/lib/worldline/acquiring/sdk/communicator_configuration.rb +8 -1
- data/spec/integration/custom_oauth2_scopes_spec.rb +52 -0
- data/spec/lib/authentication/oauth2_scopes_spec.rb +66 -0
- data/spec/lib/communicator_configuration_spec.rb +23 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65d7222393ac5f2bc3d6fa6738fef483ffd4f9b0dcb77ed5ad390961553accb5
|
4
|
+
data.tar.gz: 97b45c00cea7585aed7b908cd9b1dd91c22a1060e3519a576217df7fd04e53ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b50b4baee7d42009803815a3d589fb7603933b7b8d6b3f85cfb5dbcdce0db817437cdea48a494126bd9192107e6889639a181e0a44d078ee035c194b727e54a
|
7
|
+
data.tar.gz: 6afbcb7fbbab00f166160127c25777539f6a44a34bb47e4ee3dbadff1058e2a3699d0cecf079a24462904207d5ed16a63a95254c4d105a0f8bcd83f1978622ff
|
data/acquiring-sdk-ruby.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'acquiring-sdk-ruby'
|
3
|
-
spec.version = '1.
|
3
|
+
spec.version = '1.3.0'
|
4
4
|
spec.authors = ['Worldline Acquiring']
|
5
5
|
spec.email = ['github.acquiring@worldline.com']
|
6
6
|
spec.summary = %q{SDK to communicate with the Worldline Acquiring platform using the Worldline Acquiring API}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'concurrent'
|
2
2
|
require 'worldline/acquiring/sdk/authentication/authenticator'
|
3
3
|
require 'worldline/acquiring/sdk/authentication/oauth2_exception'
|
4
|
+
require 'worldline/acquiring/sdk/authentication/oauth2_scopes'
|
4
5
|
require 'worldline/acquiring/sdk/communication/default_connection'
|
5
6
|
require 'worldline/acquiring/sdk/communication/request_header'
|
6
7
|
|
@@ -17,7 +18,7 @@ module Worldline
|
|
17
18
|
|
18
19
|
def initialize(path, scopes)
|
19
20
|
@path = path
|
20
|
-
@scopes = scopes
|
21
|
+
@scopes = scopes
|
21
22
|
end
|
22
23
|
|
23
24
|
attr_reader :path
|
@@ -39,10 +40,7 @@ module Worldline
|
|
39
40
|
# While at the moment all scopes fit in one request, keep this code so we can easily add more token types if necessary.
|
40
41
|
# The empty path will ensure that all paths will match, as each full path ends with an empty string.
|
41
42
|
TOKEN_TYPES = [
|
42
|
-
TokenType.new('',
|
43
|
-
'processing_payment', 'processing_refund', 'processing_credittransfer', 'processing_accountverification',
|
44
|
-
'processing_balanceinquiry', 'processing_operation_reverse', 'processing_dcc_rate', 'services_ping'
|
45
|
-
]),
|
43
|
+
TokenType.new('', OAuth2Scopes.all.join(' ')),
|
46
44
|
]
|
47
45
|
|
48
46
|
public
|
@@ -67,14 +65,21 @@ module Worldline
|
|
67
65
|
@connect_timeout = communicator_configuration.connect_timeout
|
68
66
|
@socket_timeout = communicator_configuration.socket_timeout
|
69
67
|
@proxy_configuration = communicator_configuration.proxy_configuration
|
68
|
+
|
69
|
+
oauth2_scopes = communicator_configuration.oauth2_scopes
|
70
|
+
if oauth2_scopes.nil? || oauth2_scopes.empty?
|
71
|
+
@path_to_scopes_mapper = lambda { |path| get_token_type(path).scopes }
|
72
|
+
else
|
73
|
+
@path_to_scopes_mapper = lambda { |_| oauth2_scopes }
|
74
|
+
end
|
70
75
|
end
|
71
76
|
|
72
77
|
# @param http_method [String, nil] 'GET', 'PUT', 'POST' or 'DELETE' indicating which HTTP method will be used with the request
|
73
78
|
# @param resource_uri [URI::HTTP, nil] URI object that includes #path and #query of the URL that will be used, #query may be *nil*
|
74
79
|
# @param request_headers [Array<Worldline::Acquiring::SDK::Communication::RequestHeader>, nil] all headers used by the request
|
75
80
|
def get_authorization(http_method, resource_uri, request_headers)
|
76
|
-
|
77
|
-
access_token = @access_tokens.compute(
|
81
|
+
scopes = @path_to_scopes_mapper.call(resource_uri&.path)
|
82
|
+
access_token = @access_tokens.compute(scopes) { |existing_token| get_valid_access_token(existing_token, scopes) }
|
78
83
|
"Bearer #{access_token.token}"
|
79
84
|
end
|
80
85
|
|
@@ -89,9 +94,9 @@ module Worldline
|
|
89
94
|
raise ArgumentError.new("scope could not be found for path '#{full_path}'")
|
90
95
|
end
|
91
96
|
|
92
|
-
def get_valid_access_token(existing_token,
|
97
|
+
def get_valid_access_token(existing_token, scopes)
|
93
98
|
if is_token_invalid(existing_token)
|
94
|
-
return get_access_token(
|
99
|
+
return get_access_token(scopes)
|
95
100
|
end
|
96
101
|
existing_token
|
97
102
|
end
|
@@ -100,9 +105,9 @@ module Worldline
|
|
100
105
|
not access_token or access_token.expiration < Time.now
|
101
106
|
end
|
102
107
|
|
103
|
-
def get_access_token(
|
108
|
+
def get_access_token(scopes)
|
104
109
|
request_headers = [RequestHeader.new('Content-Type', 'application/x-www-form-urlencoded')]
|
105
|
-
request_body = "grant_type=client_credentials&client_id=#{@client_id}&client_secret=#{@client_secret}&scope=#{
|
110
|
+
request_body = "grant_type=client_credentials&client_id=#{@client_id}&client_secret=#{@client_secret}&scope=#{scopes}"
|
106
111
|
|
107
112
|
start_time = Time.now
|
108
113
|
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#
|
2
|
+
# This file was automatically generated.
|
3
|
+
#
|
4
|
+
module Worldline
|
5
|
+
module Acquiring
|
6
|
+
module SDK
|
7
|
+
module Authentication
|
8
|
+
module OAuth2Scopes
|
9
|
+
private
|
10
|
+
|
11
|
+
SCOPES_BY_OPERATION = {
|
12
|
+
"v1" => {
|
13
|
+
"processPayment" => ["processing_payment"],
|
14
|
+
"getPaymentStatus" => ["processing_payment"],
|
15
|
+
"simpleCaptureOfPayment" => ["processing_payment"],
|
16
|
+
"reverseAuthorization" => ["processing_payment"],
|
17
|
+
"incrementPayment" => ["processing_payment"],
|
18
|
+
"createRefund" => ["processing_refund"],
|
19
|
+
"processStandaloneRefund" => ["processing_refund"],
|
20
|
+
"getRefund" => ["processing_refund"],
|
21
|
+
"captureRefund" => ["processing_refund"],
|
22
|
+
"reverseRefundAuthorization" => ["processing_refund"],
|
23
|
+
"processAccountVerification" => ["processing_accountverification"],
|
24
|
+
"processBalanceInquiry" => ["processing_balanceinquiry"],
|
25
|
+
"technicalReversal" => ["processing_operation_reverse"],
|
26
|
+
"requestDccRate" => ["processing_dcc_rate"],
|
27
|
+
"ping" => ["services_ping"]
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
ALL_SCOPES = SCOPES_BY_OPERATION.values.map { |m| m.values }.flatten.uniq.freeze
|
32
|
+
|
33
|
+
public
|
34
|
+
|
35
|
+
# Returns all available scopes.
|
36
|
+
def self.all
|
37
|
+
ALL_SCOPES
|
38
|
+
end
|
39
|
+
|
40
|
+
# Returns all scopes needed for all operations of the given API version.
|
41
|
+
def self.for_api_version(api_version)
|
42
|
+
operations = SCOPES_BY_OPERATION[api_version] || {}
|
43
|
+
operations.values.flatten.uniq.freeze
|
44
|
+
end
|
45
|
+
|
46
|
+
# Returns all scopes needed for the given operation of the given API version.
|
47
|
+
def self.for_operation(api_version, operation_id)
|
48
|
+
operations = SCOPES_BY_OPERATION[api_version] || {}
|
49
|
+
scopes = operations[operation_id] || []
|
50
|
+
scopes.uniq.freeze
|
51
|
+
end
|
52
|
+
|
53
|
+
# Returns all scopes needed for the given operations of the given API version.
|
54
|
+
def self.for_operations(api_version, *operation_ids)
|
55
|
+
operations = SCOPES_BY_OPERATION[api_version] || {}
|
56
|
+
operation_ids.map { |operation_id| operations[operation_id] || [] }.flatten.uniq.freeze
|
57
|
+
end
|
58
|
+
|
59
|
+
# Returns all scopes needed for the operations that pass the given filter.
|
60
|
+
# The first argument to the filter is the API version, the second is the operation id.
|
61
|
+
def self.for_filtered_operations(filter)
|
62
|
+
SCOPES_BY_OPERATION.keys.map { |api_version|
|
63
|
+
operations = SCOPES_BY_OPERATION[api_version]
|
64
|
+
operations.keys
|
65
|
+
.filter { |operation_id| filter.call(api_version, operation_id) }
|
66
|
+
.map { |operation_id| operations[operation_id] }
|
67
|
+
}.flatten.uniq.freeze
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -14,7 +14,7 @@ module Worldline
|
|
14
14
|
class MetadataProvider
|
15
15
|
private
|
16
16
|
|
17
|
-
SDK_VERSION = '1.
|
17
|
+
SDK_VERSION = '1.3.0'.freeze
|
18
18
|
SERVER_META_INFO_HEADER = 'X-WL-ServerMetaInfo'.freeze
|
19
19
|
PROHIBITED_HEADERS = [SERVER_META_INFO_HEADER, 'Date', 'Content-Type', 'Authorization'].sort!.freeze
|
20
20
|
CHARSET = 'utf-8'.freeze
|
@@ -11,6 +11,7 @@ module Worldline
|
|
11
11
|
# @attr [String] authorization_secret A secret used for authorization. The meaning of this secret is different for each authorization type.
|
12
12
|
# For instance, for OAuth2 this is the client secret
|
13
13
|
# @attr [String] oauth2_token_uri The OAuth2 token URI
|
14
|
+
# @attr [String] oauth2_scopes The OAuth2 scopes; leave empty to let the SDK provide a set of defaults
|
14
15
|
# @attr [String] authorization_type String representing the authentication algorithm used
|
15
16
|
# @attr [Integer] connect_timeout The number of seconds before a connection attempt with the Worldline Acquiring platform times out.
|
16
17
|
# @attr [Integer] socket_timeout The number of seconds before a timeout occurs when transmitting data to or from the Worldline Acquiring platform.
|
@@ -50,6 +51,7 @@ module Worldline
|
|
50
51
|
# @param oauth2_client_secret [String, nil] The OAuth2 client secret.
|
51
52
|
# This is an alias for _authorization_secret_.
|
52
53
|
# @param oauth2_token_uri [String, nil] The OAuth2 token URI.
|
54
|
+
# @param oauth2_scopes [String, nil] The OAuth2 scopes; leave empty to let the SDK provide a set of defaults
|
53
55
|
# @param authorization_type [String, nil] string describing the authorization protocol to follow.
|
54
56
|
# @param connect_timeout [Integer, nil] the number of seconds before a connection attempt with the Worldline Acquiring platform times out.
|
55
57
|
# @param socket_timeout [Integer, nil] the number of seconds before a timeout occurs when transmitting data to or from the Worldline Acquiring platform.
|
@@ -61,7 +63,7 @@ module Worldline
|
|
61
63
|
# @param shopping_cart_extension [Worldline::Acquiring::SDK::Domain::ShoppingCartExtension, nil] stores shopping cart-related metadata.
|
62
64
|
def initialize(properties: nil, api_endpoint: nil,
|
63
65
|
authorization_id: nil, authorization_secret: nil,
|
64
|
-
oauth2_client_id: nil, oauth2_client_secret: nil, oauth2_token_uri: nil,
|
66
|
+
oauth2_client_id: nil, oauth2_client_secret: nil, oauth2_token_uri: nil, oauth2_scopes: nil,
|
65
67
|
authorization_type: nil,
|
66
68
|
connect_timeout: nil, socket_timeout: nil,
|
67
69
|
max_connections: nil, proxy_configuration: nil,
|
@@ -70,6 +72,7 @@ module Worldline
|
|
70
72
|
@api_endpoint = get_endpoint(properties)
|
71
73
|
@authorization_type = Authentication::AuthorizationType.get_authorization(properties['acquiring.api.authorizationType'])
|
72
74
|
@oauth2_token_uri = properties['acquiring.api.oauth2.tokenUri']
|
75
|
+
@oauth2_scopes = properties['acquiring.api.oauth2.scopes']
|
73
76
|
@connect_timeout = properties['acquiring.api.connectTimeout']
|
74
77
|
@socket_timeout = properties['acquiring.api.socketTimeout']
|
75
78
|
@max_connections = get_property(properties, 'acquiring.api.maxConnections', DEFAULT_MAX_CONNECTIONS)
|
@@ -104,6 +107,9 @@ module Worldline
|
|
104
107
|
if oauth2_token_uri
|
105
108
|
@oauth2_token_uri = oauth2_token_uri
|
106
109
|
end
|
110
|
+
if oauth2_scopes
|
111
|
+
@oauth2_scopes = oauth2_scopes
|
112
|
+
end
|
107
113
|
if authorization_type
|
108
114
|
@authorization_type = authorization_type
|
109
115
|
end
|
@@ -132,6 +138,7 @@ module Worldline
|
|
132
138
|
attr_accessor :authorization_id
|
133
139
|
attr_accessor :authorization_secret
|
134
140
|
attr_accessor :oauth2_token_uri
|
141
|
+
attr_accessor :oauth2_scopes
|
135
142
|
attr_accessor :authorization_type
|
136
143
|
|
137
144
|
attr_accessor :connect_timeout
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'yaml'
|
3
|
+
require 'integration_setup'
|
4
|
+
require 'webmock/rspec'
|
5
|
+
|
6
|
+
describe 'custom OAuth2 scopes' do
|
7
|
+
|
8
|
+
before(:context){WebMock.allow_net_connect!}
|
9
|
+
after(:context){WebMock.disable_net_connect!}
|
10
|
+
|
11
|
+
['processing_dcc_rate', 'processing_dcc_rate services_ping', '', nil].each do |oauth2_scopes|
|
12
|
+
it "'#{oauth2_scopes || 'nil'}' are valid" do
|
13
|
+
configuration = Integration.init_communicator_configuration
|
14
|
+
configuration.oauth2_scopes = oauth2_scopes
|
15
|
+
|
16
|
+
Factory.create_client_from_configuration(configuration) do |client|
|
17
|
+
request = Integration.get_dcc_rate_request
|
18
|
+
response = client.v1.acquirer(Integration::ACQUIRER_ID).merchant(Integration::MERCHANT_ID).dynamic_currency_conversion.request_dcc_rate(request)
|
19
|
+
|
20
|
+
expect(response.proposal).to_not be_nil
|
21
|
+
expect(response.proposal.original_amount).to_not be_nil
|
22
|
+
expect(response.proposal.original_amount.amount).to eq(request.transaction.amount.amount)
|
23
|
+
expect(response.proposal.original_amount.currency_code).to eq(request.transaction.amount.currency_code)
|
24
|
+
expect(response.proposal.original_amount.number_of_decimals).to eq(request.transaction.amount.number_of_decimals)
|
25
|
+
expect(response.proposal.resulting_amount.currency_code).to eq(request.target_currency)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'misses required scope' do
|
31
|
+
configuration = Integration.init_communicator_configuration
|
32
|
+
configuration.oauth2_scopes = 'services_ping'
|
33
|
+
|
34
|
+
Factory.create_client_from_configuration(configuration) do |client|
|
35
|
+
request = Integration.get_dcc_rate_request
|
36
|
+
expect{client.v1.acquirer(Integration::ACQUIRER_ID).merchant(Integration::MERCHANT_ID).dynamic_currency_conversion.request_dcc_rate(request)}
|
37
|
+
.to raise_error(Worldline::Acquiring::SDK::V1::AuthorizationException)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'has an invalid scope' do
|
42
|
+
configuration = Integration.init_communicator_configuration
|
43
|
+
configuration.oauth2_scopes = 'processing_dcc_rate invalid_scope'
|
44
|
+
|
45
|
+
Factory.create_client_from_configuration(configuration) do |client|
|
46
|
+
request = Integration.get_dcc_rate_request
|
47
|
+
expect {client.v1.acquirer(Integration::ACQUIRER_ID).merchant(Integration::MERCHANT_ID).dynamic_currency_conversion.request_dcc_rate(request)}
|
48
|
+
.to raise_error(Worldline::Acquiring::SDK::Authentication::OAuth2Exception)
|
49
|
+
.with_message(/There was an error while retrieving the OAuth2 access token: invalid_scope - .*/)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'OAuth2Scopes' do
|
4
|
+
|
5
|
+
it 'all should contain the correct scopes' do
|
6
|
+
all_scopes = Worldline::Acquiring::SDK::Authentication::OAuth2Scopes.all
|
7
|
+
expect(all_scopes).to include('processing_payment')
|
8
|
+
expect(all_scopes).to include('processing_dcc_rate')
|
9
|
+
expect(all_scopes).to include('services_ping')
|
10
|
+
|
11
|
+
all_scopes_string = all_scopes.join(' ')
|
12
|
+
expect(all_scopes_string.length).to be <= 260
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'for v1 should contain the correct scopes' do
|
16
|
+
scopes = Worldline::Acquiring::SDK::Authentication::OAuth2Scopes.for_api_version('v1')
|
17
|
+
expect(scopes).to include('processing_payment')
|
18
|
+
expect(scopes).to include('processing_dcc_rate')
|
19
|
+
expect(scopes).to include('services_ping')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'for an unknown API version should contain no scopes' do
|
23
|
+
scopes = Worldline::Acquiring::SDK::Authentication::OAuth2Scopes.for_api_version('v-1')
|
24
|
+
expect(scopes).to eq([])
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'for v1 processPayment should contain the correct scopes' do
|
28
|
+
scopes = Worldline::Acquiring::SDK::Authentication::OAuth2Scopes.for_operation('v1', 'processPayment')
|
29
|
+
expect(scopes).to include('processing_payment')
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'for v1 requestDccRate should contain the correct scopes' do
|
33
|
+
scopes = Worldline::Acquiring::SDK::Authentication::OAuth2Scopes.for_operation('v1', 'requestDccRate')
|
34
|
+
expect(scopes).to include('processing_dcc_rate')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'for an unknown operation should contain no scopes' do
|
38
|
+
scopes = Worldline::Acquiring::SDK::Authentication::OAuth2Scopes.for_operation('v1', 'unknown')
|
39
|
+
expect(scopes).to eq([])
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'for an unknown API version should contain no scopes' do
|
43
|
+
scopes = Worldline::Acquiring::SDK::Authentication::OAuth2Scopes.for_operation('v-1', 'processPayment')
|
44
|
+
expect(scopes).to eq([])
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'for multiple v1 operations should contain the correct scopes' do
|
48
|
+
scopes = Worldline::Acquiring::SDK::Authentication::OAuth2Scopes.for_operations('v1', 'processPayment', 'requestDccRate', 'unknown')
|
49
|
+
expect(scopes).to include('processing_payment')
|
50
|
+
expect(scopes).to include('processing_dcc_rate')
|
51
|
+
expect(scopes).not_to include('services_ping')
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'for multiple operations of an unknown API version should contain no scopes' do
|
55
|
+
scopes = Worldline::Acquiring::SDK::Authentication::OAuth2Scopes.for_operations('v-1', 'processPayment', 'requestDccRate')
|
56
|
+
expect(scopes).to eq([])
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'for filtered operations should contain the correct scopes' do
|
60
|
+
operation_ids = [ 'processPayment', 'requestDccRate', 'unknown' ]
|
61
|
+
scopes = Worldline::Acquiring::SDK::Authentication::OAuth2Scopes.for_filtered_operations(lambda { |api_version, operation_id| api_version == 'v1' && operation_ids.include?(operation_id) })
|
62
|
+
expect(scopes).to include('processing_payment')
|
63
|
+
expect(scopes).to include('processing_dcc_rate')
|
64
|
+
expect(scopes).not_to include('services_ping')
|
65
|
+
end
|
66
|
+
end
|
@@ -22,6 +22,7 @@ describe 'CommunicatorConfiguration' do
|
|
22
22
|
|
23
23
|
expect(communicator_config.authorization_id).to be_nil
|
24
24
|
expect(communicator_config.authorization_secret).to be_nil
|
25
|
+
expect(communicator_config.oauth2_scopes).to be_nil
|
25
26
|
expect(communicator_config.proxy_configuration).to be_nil
|
26
27
|
expect(communicator_config.integrator).to be_nil
|
27
28
|
expect(communicator_config.shopping_cart_extension).to be_nil
|
@@ -46,6 +47,7 @@ describe 'CommunicatorConfiguration' do
|
|
46
47
|
|
47
48
|
expect(communicator_config.authorization_id).to be_nil
|
48
49
|
expect(communicator_config.authorization_secret).to be_nil
|
50
|
+
expect(communicator_config.oauth2_scopes).to be_nil
|
49
51
|
expect(proxy_config).to be_truthy
|
50
52
|
expect(proxy_config.scheme).to eq('http')
|
51
53
|
expect(proxy_config.host).to eq('proxy.example.org')
|
@@ -75,6 +77,7 @@ describe 'CommunicatorConfiguration' do
|
|
75
77
|
|
76
78
|
expect(communicator_config.authorization_id).to be_nil
|
77
79
|
expect(communicator_config.authorization_secret).to be_nil
|
80
|
+
expect(communicator_config.oauth2_scopes).to be_nil
|
78
81
|
expect(proxy_config).to be_truthy
|
79
82
|
expect(proxy_config.scheme).to eq('http')
|
80
83
|
expect(proxy_config.host).to eq('proxy.example.org')
|
@@ -102,6 +105,7 @@ describe 'CommunicatorConfiguration' do
|
|
102
105
|
|
103
106
|
expect(communicator_config.authorization_id).to be_nil
|
104
107
|
expect(communicator_config.authorization_secret).to be_nil
|
108
|
+
expect(communicator_config.oauth2_scopes).to be_nil
|
105
109
|
expect(communicator_config.proxy_configuration).to be_nil
|
106
110
|
end
|
107
111
|
|
@@ -170,6 +174,7 @@ describe 'CommunicatorConfiguration' do
|
|
170
174
|
|
171
175
|
expect(communicator_config.authorization_id).to be_nil
|
172
176
|
expect(communicator_config.authorization_secret).to be_nil
|
177
|
+
expect(communicator_config.oauth2_scopes).to be_nil
|
173
178
|
expect(communicator_config.proxy_configuration).to be_nil
|
174
179
|
expect(communicator_config.integrator).to eq('Worldline.Integrator')
|
175
180
|
expect(communicator_config.shopping_cart_extension).to be_truthy
|
@@ -178,4 +183,22 @@ describe 'CommunicatorConfiguration' do
|
|
178
183
|
expect(communicator_config.shopping_cart_extension.version).to eq('1.0')
|
179
184
|
expect(communicator_config.shopping_cart_extension.extension_id).to eq('ExtensionId')
|
180
185
|
end
|
186
|
+
|
187
|
+
it 'stores custom OAuth2 scopes' do
|
188
|
+
yaml = '---
|
189
|
+
acquiring.api.endpoint.host: api.preprod.acquiring.worldline-solutions.com
|
190
|
+
acquiring.api.authorizationType: OAuth2
|
191
|
+
acquiring.api.oauth2.scopes: processing_dcc_rate invalid_scope
|
192
|
+
acquiring.api.connectTimeout: 20
|
193
|
+
acquiring.api.socketTimeout: 10'
|
194
|
+
config = YAML.load(yaml)
|
195
|
+
|
196
|
+
communicator_config = CommunicatorConfiguration.new(properties: config)
|
197
|
+
|
198
|
+
expect(communicator_config.api_endpoint).to eq('https://api.preprod.acquiring.worldline-solutions.com')
|
199
|
+
expect(communicator_config.authorization_type).to eq('OAuth2')
|
200
|
+
expect(communicator_config.connect_timeout).to eq(20)
|
201
|
+
expect(communicator_config.socket_timeout).to eq(10)
|
202
|
+
expect(communicator_config.oauth2_scopes).to eq('processing_dcc_rate invalid_scope')
|
203
|
+
end
|
181
204
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acquiring-sdk-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Worldline Acquiring
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- lib/worldline/acquiring/sdk/authentication/authorization_type.rb
|
149
149
|
- lib/worldline/acquiring/sdk/authentication/oauth2_authenticator.rb
|
150
150
|
- lib/worldline/acquiring/sdk/authentication/oauth2_exception.rb
|
151
|
+
- lib/worldline/acquiring/sdk/authentication/oauth2_scopes.rb
|
151
152
|
- lib/worldline/acquiring/sdk/call_context.rb
|
152
153
|
- lib/worldline/acquiring/sdk/client.rb
|
153
154
|
- lib/worldline/acquiring/sdk/communication.rb
|
@@ -302,12 +303,14 @@ files:
|
|
302
303
|
- spec/fixtures/resources/properties.oauth2.yml
|
303
304
|
- spec/fixtures/resources/properties.proxy.yml
|
304
305
|
- spec/integration/connection_pooling_spec.rb
|
306
|
+
- spec/integration/custom_oauth2_scopes_spec.rb
|
305
307
|
- spec/integration/multipart_form_data_spec.rb
|
306
308
|
- spec/integration/process_payment_spec.rb
|
307
309
|
- spec/integration/request_dcc_rate_spec.rb
|
308
310
|
- spec/integration/sdk_proxy_spec.rb
|
309
311
|
- spec/integration_setup.rb
|
310
312
|
- spec/lib/authentication/oauth2_authenticator_spec.rb
|
313
|
+
- spec/lib/authentication/oauth2_scopes_spec.rb
|
311
314
|
- spec/lib/client_spec.rb
|
312
315
|
- spec/lib/communication/default_connection_logger_spec.rb
|
313
316
|
- spec/lib/communication/default_connection_spec.rb
|
@@ -367,12 +370,14 @@ test_files:
|
|
367
370
|
- spec/fixtures/resources/properties.oauth2.yml
|
368
371
|
- spec/fixtures/resources/properties.proxy.yml
|
369
372
|
- spec/integration/connection_pooling_spec.rb
|
373
|
+
- spec/integration/custom_oauth2_scopes_spec.rb
|
370
374
|
- spec/integration/multipart_form_data_spec.rb
|
371
375
|
- spec/integration/process_payment_spec.rb
|
372
376
|
- spec/integration/request_dcc_rate_spec.rb
|
373
377
|
- spec/integration/sdk_proxy_spec.rb
|
374
378
|
- spec/integration_setup.rb
|
375
379
|
- spec/lib/authentication/oauth2_authenticator_spec.rb
|
380
|
+
- spec/lib/authentication/oauth2_scopes_spec.rb
|
376
381
|
- spec/lib/client_spec.rb
|
377
382
|
- spec/lib/communication/default_connection_logger_spec.rb
|
378
383
|
- spec/lib/communication/default_connection_spec.rb
|