wire4_auth 0.0.3.pre.SNAPSHOT → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91be7d2fbaeff4c75e2fca18f881cd3731a8b96f795d70dfffe5efced4f448b1
4
- data.tar.gz: 5f52234512e058313dbe80fd6b53d4af024ac33c4ae42075277638dd16320e26
3
+ metadata.gz: c09fada6f331355a7e383a58f25715e280caf45797f200e36ca2bcd42c881a89
4
+ data.tar.gz: a8d38663f14122d13ff6f485e6b407e4fe2dda0a75948459caaf9ccc140ad8ce
5
5
  SHA512:
6
- metadata.gz: c6d0aad8ab23c580f470dc39bac61c8bb940253d7eaa5a0a62a7ae1cc51faf0afecabeb9567f1277df51ae055dbbfe49d6c7c1a929ea21aace8ed5293d6c2a04
7
- data.tar.gz: fc8e30fba52cbcabdbe2edb24b27c90529d4c289bb972147ef83ccf68d45e4828fca4ea9013d4d30c2c2dae36c398a144fc521bc7d230b7e657267725125831b
6
+ metadata.gz: f400b6a6505fb87c28df741d4daa01208c0bea583dd4d1b7fc9316cdc2bdb268db5fa7a4030ed92055c2fa4235e00d3eb3ba4647116f95f600ee64e2c34f3195
7
+ data.tar.gz: 650ae52a164020c83aba6178aa53e4e8254b4e656f80839a8017b68e91f6188eba19f52ed5e6cb509a7805525b392a3da07034ea6bc8b620e79aa8c873694a0a
data/Gemfile CHANGED
@@ -3,6 +3,6 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :development, :test do
6
- gem 'oauth2', '~> 1.4.2'
7
- gem 'wire4_client', '~> 0.0.3.pre.SNAPSHOT'
6
+ gem 'oauth2', '~> 1.4.3'
7
+ gem 'wire4_client', '~> 1.1.0'
8
8
  end
@@ -47,48 +47,50 @@ module Wire4Auth
47
47
  @tokens_cached_app_user = {}
48
48
  end
49
49
 
50
- def is_expire(expires_at)
51
-
52
- time = Time.at(expires_at)
53
- # Get current time using the time zone
54
- now = Time.now - 5 * 60 # minus 5 minutes
55
-
56
- time > now
57
- end
58
-
50
+ #noinspection DuplicatedCode
59
51
  def obtain_access_token_app(scope = "general")
52
+ key_search = @client_id + scope
53
+ token_cached = @tokens_cached_app_user[key_search]
54
+ if !token_cached.nil? and !token_cached.access_token.nil? and !token_cached.access_token.params.nil? and
55
+ !token_cached.access_token.params['scope'].nil? and !token_cached.access_token.expires_at.nil? and
56
+ token_cached.access_token.expires_at.is_a? Integer and is_valid(token_cached.access_token.expires_at) and
57
+ !token_cached.access_token.token.nil?
60
58
 
61
- if !@token_cached_app.access_token.nil? and !@token_cached_app.access_token.params.nil? and
62
- !@token_cached_app.access_token.params['scope'].nil? and
63
- @token_cached_app.access_token.params['scope'].include? scope and
64
- !@token_cached_app.access_token.expires_at.nil? and @token_cached_app.access_token.expires_at.is_a? Integer and
65
- is_expire(@token_cached_app.access_token.expires_at) and !@token_cached_app.access_token.token.nil?
66
-
67
- return @token_cached_app.access_token.token
59
+ return format_to_header(token_cached.access_token.token)
68
60
  end
69
61
 
70
62
  begin
71
63
  client = OAuth2::Client.new(@client_id, @client_secret, :token_url => @environment.token_url)
72
- access_token = client.get_token({:grant_type => "client_credentials", :scope => scope})
73
- @token_cached_app.access_token = access_token
64
+ access_token = client.get_token({ :grant_type => "client_credentials", :scope => scope})
65
+
66
+ if @tokens_cached_app_user.length + 1 > MAX_APP_USER_SIZE_CACHED
67
+ @tokens_cached_app_user.each_key do |key|
68
+ @tokens_cached_app_user.delete(key)
69
+ break
70
+ end
71
+ end
74
72
 
75
- return access_token.token
73
+ @tokens_cached_app_user[key_search] = Wire4Auth::CachedToken.new(@client_id, @client_secret, access_token)
74
+
75
+ return format_to_header(access_token.token)
76
76
  rescue OAuth2::Error => e
77
77
  raise Wire4Client::ApiError.new(:code => e.code,
78
78
  :message => e.description)
79
79
  end
80
+
80
81
  end
81
82
 
83
+ #noinspection DuplicatedCode
82
84
  def obtain_access_token_app_user(user_key, secret_key, scope = "spei_admin")
83
85
 
84
86
  key_search = user_key + scope
85
87
  token_cached = @tokens_cached_app_user[key_search]
86
88
  if !token_cached.nil? and !token_cached.access_token.nil? and !token_cached.access_token.params.nil? and
87
- !token_cached.access_token.params['scope'].nil? and token_cached.access_token.params['scope'].include? scope and
88
- !token_cached.access_token.expires_at.nil? and token_cached.access_token.expires_at.is_a? Integer and
89
- is_expire(token_cached.access_token.expires_at) and !token_cached.access_token.token.nil?
89
+ !token_cached.access_token.params['scope'].nil? and !token_cached.access_token.expires_at.nil? and
90
+ token_cached.access_token.expires_at.is_a? Integer and is_valid(token_cached.access_token.expires_at) and
91
+ !token_cached.access_token.token.nil?
90
92
 
91
- return token_cached.access_token.token
93
+ return format_to_header(token_cached.access_token.token)
92
94
  end
93
95
 
94
96
  begin
@@ -105,20 +107,87 @@ module Wire4Auth
105
107
 
106
108
  @tokens_cached_app_user[key_search] = Wire4Auth::CachedToken.new(user_key, secret_key, access_token)
107
109
 
108
- return access_token.token
110
+ return format_to_header(access_token.token)
109
111
  rescue OAuth2::Error => e
110
112
  raise Wire4Client::ApiError.new(:code => e.code,
111
113
  :message => e.description)
112
114
  end
113
115
  end
114
116
 
115
- def config_default_api_client(token)
117
+ def regenerate_access_token_app(scope = "general")
118
+
119
+ begin
120
+ client = OAuth2::Client.new(@client_id, @client_secret, :token_url => @environment.token_url)
121
+ access_token = client.get_token({ :grant_type => "client_credentials", :scope => scope})
122
+
123
+ key_search = @client_id + scope
124
+ token_cached = @tokens_cached_app_user[key_search]
125
+ if token_cached.nil? and @tokens_cached_app_user.length + 1 > MAX_APP_USER_SIZE_CACHED
126
+ @tokens_cached_app_user.each_key do |key|
127
+ @tokens_cached_app_user.delete(key)
128
+ break
129
+ end
130
+ end
131
+
132
+ @tokens_cached_app_user[key_search] = Wire4Auth::CachedToken.new(@client_id, @client_secret, access_token)
133
+
134
+ return format_to_header(access_token.token)
135
+ rescue OAuth2::Error => e
136
+ raise Wire4Client::ApiError.new(:code => e.code,
137
+ :message => e.description)
138
+ end
139
+
140
+ end
141
+
142
+ #noinspection RubyInstanceMethodNamingConvention
143
+ def regenerate_access_token_app_user(user_key, secret_key, scope = "spei_admin")
144
+
145
+ begin
146
+ client = OAuth2::Client.new(@client_id, @client_secret, :token_url => @environment.token_url)
147
+ access_token = client.get_token({ :grant_type => "password", :scope => scope,
148
+ :username => user_key, :password => secret_key })
149
+
150
+ key_search = user_key + scope
151
+ token_cached = @tokens_cached_app_user[key_search]
152
+ if token_cached.nil? and @tokens_cached_app_user.length + 1 > MAX_APP_USER_SIZE_CACHED
153
+ @tokens_cached_app_user.each_key do |key|
154
+ @tokens_cached_app_user.delete(key)
155
+ break
156
+ end
157
+ end
158
+
159
+ @tokens_cached_app_user[key_search] = Wire4Auth::CachedToken.new(user_key, secret_key, access_token)
160
+
161
+ return format_to_header(access_token.token)
162
+ rescue OAuth2::Error => e
163
+ raise Wire4Client::ApiError.new(:code => e.code,
164
+ :message => e.description)
165
+ end
166
+ end
167
+
168
+ def config_default_api_client
116
169
  # Setup authorization
117
170
  Wire4Client.configure do |config|
118
171
  # Configure OAuth2 access token for authorization
119
- config.access_token = token
120
172
  config.host = @environment.service_url
173
+ config.base_path = @environment.base_path
121
174
  end
122
175
  end
176
+
177
+ private
178
+
179
+ def is_valid(expires_at)
180
+
181
+ time = Time.at(expires_at)
182
+ # Get current time using the time zone
183
+ now = Time.now + 5 * 60 # plus 5 minutes
184
+
185
+ time > now
186
+ end
187
+
188
+ def format_to_header(token)
189
+
190
+ "Bearer " + token
191
+ end
123
192
  end
124
193
  end
@@ -23,16 +23,19 @@ module Wire4Auth
23
23
 
24
24
  attr_reader :service_url
25
25
 
26
- def initialize(token_url, service_url)
26
+ attr_reader :base_path
27
+
28
+ def initialize(token_url, service_url, base_path)
27
29
  @token_url = token_url
28
30
  @service_url = service_url
31
+ @base_path = base_path
29
32
  end
30
33
 
31
- SANDBOX = new("https://sandbox-api.wire4.mx/token", "sandbox-api.wire4.mx")
34
+ SANDBOX = new('https://sandbox-api.wire4.mx/token', 'sandbox-api.wire4.mx', '/wire4/1.0.0')
32
35
 
33
- DEVELOPMENT = new('https://development-api.wire4.mx/token', 'development-api.wire4.mx')
36
+ DEVELOPMENT = new('https://development-api.wire4.mx/token', 'development-api.wire4.mx', '/wire4/1.0.0')
34
37
 
35
- PRODUCTION = new("https://api.wire4.mx/token", "api.wire4.mx")
38
+ PRODUCTION = new('https://api.wire4.mx/token', 'api.wire4.mx', '/wire4/1.0.0')
36
39
 
37
40
  class << self
38
41
  private :new
@@ -0,0 +1,222 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+
4
+ # COPYRIGHT © 2017. TCPIP.
5
+ # PATENT PENDING. ALL RIGHTS RESERVED.
6
+ # SPEI GATEWAY IS REGISTERED TRADEMARKS OF TCPIP.
7
+ #
8
+ # This software is confidential and proprietary information of TCPIP.
9
+ # You shall not disclose such Confidential Information and shall use it only
10
+ # in accordance with the company policy.
11
+
12
+ =begin
13
+ #Wire4Auth
14
+
15
+ Fecha de creación: 01 de september, 2020
16
+ author: Juan Mandujano
17
+ version: 1.0
18
+ =end
19
+
20
+ require 'test/unit'
21
+ require 'wire4_auth/auth/oauth_wire4'
22
+ require 'wire4_auth/webhook_verification_signature/utils_compute'
23
+ require 'wire4_client'
24
+
25
+ #noinspection RubyTooManyMethodsInspection
26
+ class Wire4ExamplesTest < Test::Unit::TestCase
27
+
28
+ CLIENT_ID = "6PqWzT6DgbEyLNu7d4YItJyuT2Ea"
29
+
30
+ CLIENT_SECRET = "00cRaDHZimyDENOJOQbA5psoVNoa"
31
+
32
+ USER_KEY = "9548042dccc4790a43c36d919fb677@develop.wire4.mx"
33
+
34
+ SECRET_KEY = "e9c24e4aa064a34bd6357400fab7c0"
35
+
36
+ SUBSCRIPTION = "73be6d4e-fa70-4732-8eab-a47b2b798a83"
37
+
38
+ def test_given_bad_credentials_should_raise_error
39
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID,'CLIENT_SECRET',Wire4Auth::EnvironmentEnum::DEVELOPMENT)
40
+ oauth_wire4.config_default_api_client
41
+ puts "Calling token creation..."
42
+ assert_raise( Wire4Client::ApiError){oauth_wire4.obtain_access_token_app('general')}
43
+ end
44
+
45
+ def test_given_valid_credentials_should_return_token
46
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID,CLIENT_SECRET,Wire4Auth::EnvironmentEnum::DEVELOPMENT)
47
+ oauth_wire4.config_default_api_client
48
+ puts "Calling token creation..."
49
+ token = oauth_wire4.obtain_access_token_app('general')
50
+ assert_not_nil(token, 'the token should not be nil')
51
+ end
52
+
53
+ def test_same_credentials_should_return_same_token
54
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID,CLIENT_SECRET,Wire4Auth::EnvironmentEnum::DEVELOPMENT)
55
+ oauth_wire4.config_default_api_client
56
+ puts "Calling token creation..."
57
+ token = oauth_wire4.obtain_access_token_app('general')
58
+ second_token = oauth_wire4.obtain_access_token_app('general')
59
+ assert_equal(token, second_token, 'the tokens should be equals')
60
+ end
61
+
62
+ def test_different_scopes_for_same_user_should_return_different_tokens
63
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID,CLIENT_SECRET,Wire4Auth::EnvironmentEnum::DEVELOPMENT)
64
+ oauth_wire4.config_default_api_client
65
+ puts "Calling token creation..."
66
+ general_token = oauth_wire4.obtain_access_token_app('general')
67
+ spei_admin_token = oauth_wire4.obtain_access_token_app('spei_admin')
68
+ spid_admin_token = oauth_wire4.obtain_access_token_app('spid_admin')
69
+ codi_general_token = oauth_wire4.obtain_access_token_app('codi_general')
70
+ codi_report_token = oauth_wire4.obtain_access_token_app('codi_report')
71
+ double_token = oauth_wire4.obtain_access_token_app('spei_admin codi_report')
72
+ assert_not_equal(general_token, spei_admin_token, 'the tokens should not be equals')
73
+ assert_not_equal(general_token, spid_admin_token, 'the tokens should not be equals')
74
+ assert_not_equal(general_token, codi_general_token, 'the tokens should not be equals')
75
+ assert_not_equal(general_token, codi_report_token, 'the tokens should not be equals')
76
+ assert_not_equal(general_token, double_token, 'the tokens should not be equals')
77
+ assert_not_equal(spei_admin_token, spid_admin_token, 'the tokens should not be equals')
78
+ assert_not_equal(codi_general_token, codi_report_token, 'the tokens should not be equals')
79
+ assert_not_equal(double_token, codi_report_token, 'the tokens should not be equals')
80
+ assert_not_equal(double_token, codi_general_token, 'the tokens should not be equals')
81
+ end
82
+
83
+ def test_given_many_tokens_for_same_user_should_keeps_in_cache
84
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID,CLIENT_SECRET,Wire4Auth::EnvironmentEnum::DEVELOPMENT)
85
+ oauth_wire4.config_default_api_client
86
+ puts "Calling token creation..."
87
+ general_token = oauth_wire4.obtain_access_token_app('general')
88
+ spei_admin_token = oauth_wire4.obtain_access_token_app('spei_admin')
89
+ spid_admin_token = oauth_wire4.obtain_access_token_app('spid_admin')
90
+ codi_general_token = oauth_wire4.obtain_access_token_app('codi_general')
91
+ codi_report_token = oauth_wire4.obtain_access_token_app('codi_report')
92
+ double_token = oauth_wire4.obtain_access_token_app('spei_admin codi_report')
93
+ general_token_second = oauth_wire4.obtain_access_token_app('general')
94
+ spei_admin_token_second = oauth_wire4.obtain_access_token_app('spei_admin')
95
+ spid_admin_token_second = oauth_wire4.obtain_access_token_app('spid_admin')
96
+ codi_general_token_second = oauth_wire4.obtain_access_token_app('codi_general')
97
+ codi_report_token_second = oauth_wire4.obtain_access_token_app('codi_report')
98
+ double_token_second = oauth_wire4.obtain_access_token_app('spei_admin codi_report')
99
+ assert_equal(general_token, general_token_second, 'the tokens should be equals')
100
+ assert_equal(spei_admin_token, spei_admin_token_second, 'the tokens should be equals')
101
+ assert_equal(spid_admin_token, spid_admin_token_second, 'the tokens should be equals')
102
+ assert_equal(codi_general_token, codi_general_token_second, 'the tokens should be equals')
103
+ assert_equal(codi_report_token, codi_report_token_second, 'the tokens should be equals')
104
+ assert_equal(double_token, double_token_second, 'the tokens should be equals')
105
+ end
106
+
107
+ def test_when_regenerate_token_should_replace_old_token
108
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID,CLIENT_SECRET,Wire4Auth::EnvironmentEnum::DEVELOPMENT)
109
+ oauth_wire4.config_default_api_client
110
+ puts "Calling token creation..."
111
+ general_token = oauth_wire4.obtain_access_token_app('general')
112
+ spei_admin_token = oauth_wire4.obtain_access_token_app('spei_admin')
113
+ spid_admin_token = oauth_wire4.obtain_access_token_app('spid_admin')
114
+ codi_general_token = oauth_wire4.obtain_access_token_app('codi_general')
115
+ codi_report_token = oauth_wire4.obtain_access_token_app('codi_report')
116
+ double_token = oauth_wire4.obtain_access_token_app('general codi_report')
117
+ puts "#{double_token}"
118
+ general_token_second = oauth_wire4.regenerate_access_token_app('general')
119
+ spei_admin_token_second = oauth_wire4.regenerate_access_token_app('spei_admin')
120
+ spid_admin_token_second = oauth_wire4.regenerate_access_token_app('spid_admin')
121
+ codi_general_token_second = oauth_wire4.regenerate_access_token_app('codi_general')
122
+ codi_report_token_second = oauth_wire4.regenerate_access_token_app('codi_report')
123
+ double_token_second = oauth_wire4.regenerate_access_token_app('general codi_report')
124
+ assert_not_equal(general_token, general_token_second, 'the tokens should not be equals')
125
+ assert_not_equal(spei_admin_token, spei_admin_token_second, 'the tokens should not be equals')
126
+ assert_not_equal(spid_admin_token, spid_admin_token_second, 'the tokens should not be equals')
127
+ assert_not_equal(codi_general_token, codi_general_token_second, 'the tokens should not be equals')
128
+ assert_not_equal(codi_report_token, codi_report_token_second, 'the tokens should not be equals')
129
+ assert_not_equal(double_token, double_token_second, 'the tokens should not be equals')
130
+ end
131
+
132
+ def test_given_bad_user_credentials_should_raise_error
133
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID,CLIENT_SECRET,Wire4Auth::EnvironmentEnum::DEVELOPMENT)
134
+ oauth_wire4.config_default_api_client
135
+ puts "Calling token creation..."
136
+ assert_raise( Wire4Client::ApiError){oauth_wire4.obtain_access_token_app_user(USER_KEY, 'SECRET_KEY','spei_admin')}
137
+ end
138
+
139
+ def test_given_valid_user_credentials_should_return_token
140
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID,CLIENT_SECRET,Wire4Auth::EnvironmentEnum::DEVELOPMENT)
141
+ oauth_wire4.config_default_api_client
142
+ puts "Calling token creation..."
143
+ token = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'spei_admin')
144
+ assert_not_nil(token, 'the token should not be nil')
145
+ end
146
+
147
+ def test_same_user_credentials_should_return_same_token
148
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID,CLIENT_SECRET,Wire4Auth::EnvironmentEnum::DEVELOPMENT)
149
+ oauth_wire4.config_default_api_client
150
+ puts "Calling token creation..."
151
+ token = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'spei_admin')
152
+ second_token = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'spei_admin')
153
+ assert_equal(token, second_token, 'the tokens should be equals')
154
+ end
155
+
156
+ def test_different_scopes_for_same_user_credentials_should_return_different_tokens
157
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID,CLIENT_SECRET,Wire4Auth::EnvironmentEnum::DEVELOPMENT)
158
+ oauth_wire4.config_default_api_client
159
+ puts "Calling token creation..."
160
+
161
+ spei_admin_token = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'spei_admin')
162
+ spid_admin_token = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'spid_admin')
163
+ codi_general_token = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'codi_general')
164
+ codi_report_token = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'codi_report')
165
+ double_token = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'spei_admin, codi_report')
166
+ assert_not_equal(spei_admin_token, spid_admin_token, 'the tokens should not be equals')
167
+ assert_not_equal(spei_admin_token, codi_general_token, 'the tokens should not be equals')
168
+ assert_not_equal(spei_admin_token, codi_report_token, 'the tokens should not be equals')
169
+ assert_not_equal(spei_admin_token, double_token, 'the tokens should not be equals')
170
+ assert_not_equal(spid_admin_token, double_token, 'the tokens should not be equals')
171
+ assert_not_equal(spid_admin_token, codi_report_token, 'the tokens should not be equals')
172
+ assert_not_equal(codi_general_token, codi_report_token, 'the tokens should not be equals')
173
+ assert_not_equal(double_token, codi_report_token, 'the tokens should not be equals')
174
+ assert_not_equal(double_token, codi_general_token, 'the tokens should not be equals')
175
+ end
176
+
177
+ def test_given_many_tokens_for_same_user_credentials_should_keeps_in_cache
178
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID,CLIENT_SECRET,Wire4Auth::EnvironmentEnum::DEVELOPMENT)
179
+ oauth_wire4.config_default_api_client
180
+ puts "Calling token creation..."
181
+
182
+ spei_admin_token = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'spei_admin')
183
+ spid_admin_token = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'spid_admin')
184
+ codi_general_token = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'codi_general')
185
+ codi_report_token = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'codi_report')
186
+ double_token = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'spei_admin, codi_report')
187
+ spei_admin_token_second = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'spei_admin')
188
+ spid_admin_token_second = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'spid_admin')
189
+ codi_general_token_second = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'codi_general')
190
+ codi_report_token_second = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'codi_report')
191
+ double_token_second = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'spei_admin, codi_report')
192
+ assert_equal(spei_admin_token, spei_admin_token_second, 'the tokens should be equals')
193
+ assert_equal(spid_admin_token, spid_admin_token_second, 'the tokens should be equals')
194
+ assert_equal(codi_general_token, codi_general_token_second, 'the tokens should be equals')
195
+ assert_equal(codi_report_token, codi_report_token_second, 'the tokens should be equals')
196
+ assert_equal(double_token, double_token_second, 'the tokens should be equals')
197
+
198
+ end
199
+
200
+ def test_when_regenerate_user_token_should_replace_old_token
201
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID,CLIENT_SECRET,Wire4Auth::EnvironmentEnum::DEVELOPMENT)
202
+ oauth_wire4.config_default_api_client
203
+ puts "Calling token creation..."
204
+
205
+ spei_admin_token = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'spei_admin')
206
+ spid_admin_token = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'spid_admin')
207
+ codi_general_token = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'codi_general')
208
+ codi_report_token = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'codi_report')
209
+ double_token = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY,'spei_admin, codi_report')
210
+ spei_admin_token_second = oauth_wire4.regenerate_access_token_app_user(USER_KEY, SECRET_KEY,'spei_admin')
211
+ spid_admin_token_second = oauth_wire4.regenerate_access_token_app_user(USER_KEY, SECRET_KEY,'spid_admin')
212
+ codi_general_token_second = oauth_wire4.regenerate_access_token_app_user(USER_KEY, SECRET_KEY,'codi_general')
213
+ codi_report_token_second = oauth_wire4.regenerate_access_token_app_user(USER_KEY, SECRET_KEY,'codi_report')
214
+ double_token_second = oauth_wire4.regenerate_access_token_app_user(USER_KEY, SECRET_KEY,'spei_admin, codi_report')
215
+ assert_not_equal(spei_admin_token, spei_admin_token_second, 'the tokens should not be equals')
216
+ assert_not_equal(spid_admin_token, spid_admin_token_second, 'the tokens should not be equals')
217
+ assert_not_equal(codi_general_token, codi_general_token_second, 'the tokens should not be equals')
218
+ assert_not_equal(codi_report_token, codi_report_token_second, 'the tokens should not be equals')
219
+ assert_not_equal(double_token, double_token_second, 'the tokens should not be equals')
220
+ end
221
+
222
+ end
@@ -15,5 +15,5 @@ version: 1.0
15
15
  =end
16
16
 
17
17
  module Wire4Auth
18
- VERSION = '0.0.3-SNAPSHOT'
18
+ VERSION = '1.1.0'
19
19
  end
data/wire4_auth.gemspec CHANGED
@@ -13,7 +13,7 @@
13
13
 
14
14
  Fecha de creación: 11 de diciembre, 2019
15
15
  author: Saintiago García
16
- version: 1.0
16
+ version: 1.1.0
17
17
  =end
18
18
 
19
19
  $:.push File.expand_path("../lib", __FILE__)
@@ -31,8 +31,10 @@ Gem::Specification.new do |s|
31
31
  s.license = "Unlicense"
32
32
  s.required_ruby_version = ">= 1.9"
33
33
 
34
- s.add_runtime_dependency 'oauth2', '~> 1.4', '>= 1.4.2'
35
- s.add_runtime_dependency 'wire4_client', '~> 0.0.1.pre.SNAPSHOT', '>= 0.0.1.pre.SNAPSHOT'
34
+ s.add_runtime_dependency 'oauth2', '~> 1.4', '>= 1.4.3'
35
+ s.add_runtime_dependency 'wire4_client', '~> 1.0', '>= 1.1.0'
36
+
37
+ s.add_development_dependency 'test-unit', '~> 3.3', '>= 3.3.5'
36
38
 
37
39
  s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }
38
40
  s.executables = []