soaspec 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/lib/soaspec/exchange_handlers/rest_accessors.rb +7 -2
- data/lib/soaspec/o_auth2.rb +24 -3
- data/lib/soaspec/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c021efb99c24b3ab3c9e20d17d9a6162dbc2000
|
4
|
+
data.tar.gz: 8a565f97656d00caaa5f3d55f17d76ef3d2e0966
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29afe2d8539a57f203330bc5a869648dbfa018c27aba144af9d5343a592c74591c0d07cec5c22439d5286200a01d27ecd4fbee6b646aa8145a434950f8b7ff5b
|
7
|
+
data.tar.gz: eec926fd442193365280f711ed49d705dfa6b29de63cb18714af7101b5d9c1b469d73586d5c775dea9135eb02f077b7224d7a9dbedf5aedade90fb2549bdcc3f
|
data/ChangeLog
CHANGED
@@ -13,13 +13,18 @@ module Soaspec
|
|
13
13
|
# Will create access_token method based on passed parameters
|
14
14
|
# @param [Hash] params Params client_id: nil, client_secret: nil, token_url: nil, username: nil, password: nil, security_token: nil
|
15
15
|
def oauth2(params)
|
16
|
+
# Object to handle oauth2
|
17
|
+
define_method('oauth_obj') do
|
18
|
+
OAuth2.new(params, api_username)
|
19
|
+
end
|
20
|
+
|
16
21
|
# Method to send request to get oauth token based on parameters
|
17
22
|
define_method('oauth_response') do
|
18
|
-
|
23
|
+
oauth_obj.response
|
19
24
|
end
|
20
25
|
|
21
26
|
define_method('access_token') do
|
22
|
-
|
27
|
+
oauth_obj.access_token
|
23
28
|
end
|
24
29
|
|
25
30
|
define_method('instance_url') do
|
data/lib/soaspec/o_auth2.rb
CHANGED
@@ -3,14 +3,25 @@ require 'erb'
|
|
3
3
|
module Soaspec
|
4
4
|
# Handles working with OAuth2
|
5
5
|
class OAuth2
|
6
|
+
# How often to refresh access token
|
7
|
+
@refresh_token = :always
|
8
|
+
# List of access tokens. They are mapped according to the OAuth parameters used
|
9
|
+
@access_tokens = {}
|
6
10
|
class << self
|
7
11
|
# Default token url used across entire suite
|
8
12
|
attr_accessor :token_url
|
13
|
+
# @attr [Symbol] refresh_token How often to refresh access token
|
14
|
+
# Values are:
|
15
|
+
# * :always - (Default) Request token from token url every time it is needed
|
16
|
+
# * :once - Request token once for the entire execution of the suite
|
17
|
+
attr_accessor :refresh_token
|
18
|
+
# @attr [Hash] access_tokens List of access tokens. They are mapped according to the OAuth parameters used
|
19
|
+
attr_accessor :access_tokens
|
9
20
|
end
|
10
21
|
|
11
|
-
# [Hash] OAuth parameters
|
22
|
+
# @attr [Hash] OAuth parameters
|
12
23
|
attr_accessor :params
|
13
|
-
# Count of tries to obtain access token
|
24
|
+
# @attr [Integer] Count of tries to obtain access token
|
14
25
|
attr_accessor :retry_count
|
15
26
|
|
16
27
|
# @param [Hash] params_sent Parameters to make OAuth request
|
@@ -28,12 +39,22 @@ module Soaspec
|
|
28
39
|
Soaspec::SpecLogger.info request_message
|
29
40
|
end
|
30
41
|
|
42
|
+
# @return [String] Existing or new access token, dependent on refresh_token attribute
|
43
|
+
def access_token
|
44
|
+
case Soaspec::OAuth2.refresh_token
|
45
|
+
when :once
|
46
|
+
Soaspec::OAuth2.access_tokens[params] ||= response['access_token']
|
47
|
+
else # Default is :always
|
48
|
+
response['access_token']
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
31
52
|
# @return [Hash] Hash containing access token parameters
|
32
53
|
def response
|
54
|
+
Soaspec::SpecLogger.info "using oauth_params: #{params}" if Soaspec.debug_oauth?
|
33
55
|
response = RestClient.post(params[:token_url], payload, cache_control: 'no_cache', verify_ssl: false)
|
34
56
|
rescue RestClient::Exception => error
|
35
57
|
Soaspec::SpecLogger.info(["oauth_error: #{error.message}", "oauth_response: #{error.response}"])
|
36
|
-
Soaspec::SpecLogger.info "oauth_params_used: #{params}" if Soaspec.debug_oauth?
|
37
58
|
self.retry_count += 1
|
38
59
|
sleep 0.1 # Wait if a bit before retying obtaining access token
|
39
60
|
retry if retry_count < 3
|
data/lib/soaspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soaspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SamuelGarrattIQA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|