soaspec 0.0.33 → 0.0.34

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 387fc51c51aab5fb2d1e63f026e750833b5e327c
4
- data.tar.gz: b2c5da0da53297f1c4aec4eaefd2c6735616807f
3
+ metadata.gz: 2772080392ed404ebee4d3a0824f37e9571bfa3e
4
+ data.tar.gz: a60560d10c60d210f73d9d5a8c41cac99c3537c4
5
5
  SHA512:
6
- metadata.gz: 8dac65516d2c883b1fd110face90cc57231c588fcf2e9cebb30b6ffa09f4596dbccff8314d7f0413951330b6ba77c9d3d9cf189a2c668be44ac5aab6a78cf852
7
- data.tar.gz: 96b1e4e8e099dd4ccff26243c95f77143a33d636ea827ea165817895640535bea4dd1e4b9ae69a29b1ea5e90b997530fb4ee34378694fd15ca88f271d7b4557c
6
+ metadata.gz: 8b1de42e0a49fae8cecf9062bd82fe9c9a4c097e6cc8b38e12055cf5dc8e45c2234eca0fd26c4275f27551708f717412b771d1e4558314f828f32e5753046042
7
+ data.tar.gz: '080b93456d42b877b5f2d86d5a18e323310eedd11cd3cbbd159518aafbccbb3e8882c9a2afebff0d22fabcc7309dfd9b96532ad2fb6d47fa25183e8f5607b34d'
data/.gitignore CHANGED
@@ -8,6 +8,7 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  /.idea/
11
+ /credentials/
11
12
 
12
13
  # rspec failure tracking
13
14
  .rspec_status
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
@@ -14,3 +14,4 @@ gem 'rspec'
14
14
  gem 'rspec-its'
15
15
  gem 'rspec_junit_formatter'
16
16
  gem 'xml-simple'
17
+ gem 'jsonpath'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- soaspec (0.0.33)
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
@@ -17,7 +17,14 @@ class Hash
17
17
  result = []
18
18
  result << self[key]
19
19
  self.values.each do |hash_value|
20
- next if hash_value.is_a? Array
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
@@ -1,3 +1,3 @@
1
1
  module Soaspec
2
- VERSION = '0.0.33'
2
+ VERSION = '0.0.34'
3
3
  end
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.33
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-09 00:00:00.000000000 Z
11
+ date: 2018-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler