soaspec 0.0.33 → 0.0.34
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/.gitignore +1 -0
- data/ChangeLog +4 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -1
- data/lib/soaspec.rb +12 -0
- data/lib/soaspec/exchange_handlers/rest_handler.rb +44 -0
- data/lib/soaspec/hash_methods.rb +8 -1
- 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: 2772080392ed404ebee4d3a0824f37e9571bfa3e
|
4
|
+
data.tar.gz: a60560d10c60d210f73d9d5a8c41cac99c3537c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b1de42e0a49fae8cecf9062bd82fe9c9a4c097e6cc8b38e12055cf5dc8e45c2234eca0fd26c4275f27551708f717412b771d1e4558314f828f32e5753046042
|
7
|
+
data.tar.gz: '080b93456d42b877b5f2d86d5a18e323310eedd11cd3cbbd159518aafbccbb3e8882c9a2afebff0d22fabcc7309dfd9b96532ad2fb6d47fa25183e8f5607b34d'
|
data/.gitignore
CHANGED
data/ChangeLog
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
Version 0.0.34 / 2018-3-12
|
2
|
+
* Enhancements
|
3
|
+
* Add oauth2 and oauth2_file methods to make it easy to load oauth2 parameters. Still a work in progress to handle all oauth2 variations
|
4
|
+
|
1
5
|
Version 0.0.33 / 2018-3-9
|
2
6
|
* Enhancements
|
3
7
|
* Use 'jsonpath' instead of dig to check JSON responses. Much better for finding complex paths
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
soaspec (0.0.
|
4
|
+
soaspec (0.0.34)
|
5
5
|
jsonpath
|
6
6
|
rest-client (>= 2.0)
|
7
7
|
rspec (~> 3.0)
|
@@ -106,6 +106,7 @@ PLATFORMS
|
|
106
106
|
DEPENDENCIES
|
107
107
|
bundler (~> 1.16)
|
108
108
|
data_magic
|
109
|
+
jsonpath
|
109
110
|
nokogiri
|
110
111
|
rake (= 12.2.1)
|
111
112
|
require_all
|
data/lib/soaspec.rb
CHANGED
@@ -25,6 +25,18 @@ require 'soaspec/not_found_errors'
|
|
25
25
|
# Gem for handling SOAP and REST api tests
|
26
26
|
module Soaspec
|
27
27
|
|
28
|
+
# Folder used to store credentials
|
29
|
+
# Used in auth2_file command
|
30
|
+
# @param [String] folder
|
31
|
+
def self.credentials_folder=(folder)
|
32
|
+
@credentials_folder = folder
|
33
|
+
end
|
34
|
+
|
35
|
+
# Credentials folder used
|
36
|
+
def self.credentials_folder
|
37
|
+
@credentials_folder
|
38
|
+
end
|
39
|
+
|
28
40
|
# Represents Environment parameters used in Soaspec tests
|
29
41
|
module Environment
|
30
42
|
|
@@ -20,6 +20,50 @@ module Soaspec
|
|
20
20
|
url
|
21
21
|
end
|
22
22
|
end
|
23
|
+
|
24
|
+
# Will create access_token method based on passed parameters
|
25
|
+
def oauth2(client_id: nil, client_secret: nil, token_url: nil, username: nil, password: nil, security_token: nil)
|
26
|
+
define_method('access_token') do
|
27
|
+
response = if password && username && security_token
|
28
|
+
RestClient.post(
|
29
|
+
token_url,
|
30
|
+
{
|
31
|
+
grant_type: 'password',
|
32
|
+
client_id: client_id,
|
33
|
+
client_secret: client_secret,
|
34
|
+
username: username,
|
35
|
+
password: (password + security_token),
|
36
|
+
multipart: true
|
37
|
+
},
|
38
|
+
cache_control: 'no_cache',
|
39
|
+
verify_ssl: false
|
40
|
+
)
|
41
|
+
else
|
42
|
+
RestClient.post(
|
43
|
+
token_url,
|
44
|
+
{
|
45
|
+
grant_type: 'client_credentials',
|
46
|
+
client_id: client_id,
|
47
|
+
client_secret: client_secret
|
48
|
+
},
|
49
|
+
cache_control: 'no_cache',
|
50
|
+
verify_ssl: false
|
51
|
+
)
|
52
|
+
end
|
53
|
+
JSON.parse(response)['access_token']
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Pass path to YAML file containing OAuth2 parameters
|
58
|
+
# @param [String] path_to_filename Will have Soaspec.credentials_folder appended to it if set
|
59
|
+
def oauth2_file(path_to_filename)
|
60
|
+
full_path = Soaspec.credentials_folder ? File.join(Soaspec.credentials_folder, path_to_filename + '.yml') : path_to_filename + '.yml'
|
61
|
+
file_hash = YAML.load_file(full_path)
|
62
|
+
raise 'File at ' + full_path + ' is not a hash ' unless file_hash.is_a? Hash
|
63
|
+
oauth_hash = file_hash.transform_keys_to_symbols
|
64
|
+
oauth2 **oauth_hash
|
65
|
+
end
|
66
|
+
|
23
67
|
end
|
24
68
|
|
25
69
|
# Wraps around Savon client defining default values dependent on the soap request
|
data/lib/soaspec/hash_methods.rb
CHANGED
@@ -17,7 +17,14 @@ class Hash
|
|
17
17
|
result = []
|
18
18
|
result << self[key]
|
19
19
|
self.values.each do |hash_value|
|
20
|
-
|
20
|
+
# next if hash_value.is_a? Array
|
21
|
+
#
|
22
|
+
if hash_value.is_a?(Array)
|
23
|
+
hash_value.each do |array_element|
|
24
|
+
result += array_element.find_all_values_for(key) if array_element.is_a? Hash
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
21
28
|
values = [hash_value]
|
22
29
|
values.each do |value|
|
23
30
|
result += value.find_all_values_for(key) if value.is_a? Hash
|
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.0.
|
4
|
+
version: 0.0.34
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SamuelGarrattIQA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|