soaspec 0.0.48 → 0.0.49
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Todo.md +5 -0
- data/lib/soaspec.rb +1 -1
- data/lib/soaspec/exchange.rb +6 -0
- data/lib/soaspec/exchange_handlers/exchange_handler.rb +10 -0
- data/lib/soaspec/{accessors.rb → exchange_handlers/handler_accessors.rb} +15 -1
- data/lib/soaspec/exchange_handlers/rest_handler.rb +21 -8
- data/lib/soaspec/exchange_handlers/soap_handler.rb +2 -4
- data/lib/soaspec/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3182f568caa56ca4f1f2982fd34cd03add94841
|
4
|
+
data.tar.gz: 0df96f12941e1b74393ebe45621d583f2e1ff956
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 932fe45f675620f1afa72ef36cb84fa8c54f6beebc7dd22686258fdf27c2f158a70b0a82bb7f280b111c81ae7657a01d7c5357af745247df58406efb764fd85d
|
7
|
+
data.tar.gz: f0e01064bacd3a5e10f59c24b4a74fdc7c471579012a61088b60d715912113696624b1893abbbbdb0de7b63e7a70dfe46c5f450041a591cc9a4f2e9f6b8daaab
|
data/Gemfile.lock
CHANGED
data/Todo.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
+
* ouath2 - handler
|
2
|
+
* Need to handle where username and password and no security token
|
3
|
+
* Perform ERB on values taken by file
|
4
|
+
|
1
5
|
* SoapHandler - define exhange method for each SOAP operation
|
6
|
+
* Accessors - similar to HappyMapper
|
2
7
|
* exchange add fields to overide parameters to support cucumber steps. exchange[from_temp] =
|
3
8
|
* Demonstrate using Cucumber
|
4
9
|
* Give examples and convenience methods for building classes for each SOAP or REST operation
|
data/lib/soaspec.rb
CHANGED
@@ -19,7 +19,7 @@ require 'soaspec/hash_methods'
|
|
19
19
|
require 'soaspec/spec_logger'
|
20
20
|
require 'soaspec/exe_helpers'
|
21
21
|
require 'soaspec/exchange_handlers/rest_handler'
|
22
|
-
require 'soaspec/
|
22
|
+
require 'soaspec/exchange_handlers/handler_accessors'
|
23
23
|
require 'soaspec/interpreter'
|
24
24
|
require 'soaspec/not_found_errors'
|
25
25
|
|
data/lib/soaspec/exchange.rb
CHANGED
@@ -28,6 +28,12 @@ class Exchange
|
|
28
28
|
@override_parameters = override_parameters
|
29
29
|
@retry_for_success = false
|
30
30
|
self.retry_count = 3
|
31
|
+
puts 'ELE ' + @api_class.elements.to_s
|
32
|
+
@api_class.elements.each do |element|
|
33
|
+
define_singleton_method(element) do
|
34
|
+
@api_class.__send__(element, response)
|
35
|
+
end
|
36
|
+
end
|
31
37
|
end
|
32
38
|
|
33
39
|
# Make request to handler with parameters defined
|
@@ -1,12 +1,21 @@
|
|
1
1
|
|
2
|
+
require_relative 'handler_accessors'
|
3
|
+
|
2
4
|
module Soaspec
|
5
|
+
|
3
6
|
# Inherit this for a class describing how to implement a particular exchange.
|
4
7
|
# Has basic methods common for methods defining RSpec tests in YAML
|
5
8
|
class ExchangeHandler
|
9
|
+
extend Soaspec::HandlerAccessors
|
6
10
|
|
7
11
|
# Retrieve the name of the template file to be used in the API request
|
8
12
|
attr_reader :template_name
|
9
13
|
|
14
|
+
# Explicitly defined elements for which a path has been predefined
|
15
|
+
def elements
|
16
|
+
@elements || []
|
17
|
+
end
|
18
|
+
|
10
19
|
# Set instance variable name
|
11
20
|
# @param [String, Symbol] name Name used when describing API test
|
12
21
|
# @param [Hash] options Parameters defining handler. Used in descendants
|
@@ -30,6 +39,7 @@ module Soaspec
|
|
30
39
|
end
|
31
40
|
|
32
41
|
# Set the request option type and the template name
|
42
|
+
# Erb is used to parse the template file, executing Ruby code in `<%= %>` blocks to work out the final request
|
33
43
|
# @param [String] name Name of file inside 'template' folder excluding extension
|
34
44
|
def template_name=(name)
|
35
45
|
@request_option = :template
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Soaspec
|
2
2
|
# Describes methods test handlers use to easily set attributes
|
3
3
|
# Some are included in 'success scenarios' and to configure the request sent
|
4
|
-
module
|
4
|
+
module HandlerAccessors
|
5
5
|
|
6
6
|
# Defines expected_mandatory_elements method used in 'success_scenario' shared examples
|
7
7
|
# to indicate certain elements must be present
|
@@ -60,5 +60,19 @@ module Soaspec
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
# Links a particular path to a meaningful name. This will use the 'value_from_path' method which
|
64
|
+
# should be implemented by each ExchangeHandler
|
65
|
+
# @param [String, Symbol] name Method name used to access element
|
66
|
+
# @param [String, Symbol] path Path to find object (e.g, XPath, JSONPath)
|
67
|
+
def element(name, path)
|
68
|
+
# puts 'Making with ' + name.to_s + path
|
69
|
+
@elements ||= []
|
70
|
+
@elements << name.to_s # Add record to list of elements used by exchange
|
71
|
+
# puts 'NOW ELE' + @elements.to_s
|
72
|
+
define_method(name.to_s) do |response|
|
73
|
+
value_from_path(response, path.to_s)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
63
77
|
end
|
64
78
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
require_relative 'exchange_handler'
|
3
3
|
require_relative '../hash_methods'
|
4
4
|
require_relative '../not_found_errors'
|
5
|
-
require_relative '
|
5
|
+
require_relative 'handler_accessors'
|
6
6
|
require_relative '../interpreter'
|
7
7
|
require 'json'
|
8
8
|
require 'jsonpath'
|
@@ -34,6 +34,20 @@ module Soaspec
|
|
34
34
|
username: username,
|
35
35
|
password: (password + security_token),
|
36
36
|
multipart: true
|
37
|
+
},
|
38
|
+
cache_control: 'no_cache',
|
39
|
+
verify_ssl: false
|
40
|
+
)
|
41
|
+
elsif password && username
|
42
|
+
RestClient.post(
|
43
|
+
token_url,
|
44
|
+
{
|
45
|
+
grant_type: 'password',
|
46
|
+
client_id: client_id,
|
47
|
+
client_secret: client_secret,
|
48
|
+
username: username,
|
49
|
+
password: password,
|
50
|
+
multipart: true
|
37
51
|
},
|
38
52
|
cache_control: 'no_cache',
|
39
53
|
verify_ssl: false
|
@@ -41,11 +55,11 @@ module Soaspec
|
|
41
55
|
else
|
42
56
|
RestClient.post(
|
43
57
|
token_url,
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
58
|
+
{
|
59
|
+
grant_type: 'client_credentials',
|
60
|
+
client_id: client_id,
|
61
|
+
client_secret: client_secret
|
62
|
+
},
|
49
63
|
cache_control: 'no_cache',
|
50
64
|
verify_ssl: false
|
51
65
|
)
|
@@ -58,7 +72,7 @@ module Soaspec
|
|
58
72
|
# @param [String] path_to_filename Will have Soaspec.credentials_folder appended to it if set
|
59
73
|
def oauth2_file(path_to_filename)
|
60
74
|
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)
|
75
|
+
file_hash = eval(ERB.new(YAML.load_file(full_path).to_s).result(binding))
|
62
76
|
raise 'File at ' + full_path + ' is not a hash ' unless file_hash.is_a? Hash
|
63
77
|
oauth_hash = file_hash.transform_keys_to_symbols
|
64
78
|
oauth2 **oauth_hash
|
@@ -69,7 +83,6 @@ module Soaspec
|
|
69
83
|
# Wraps around Savon client defining default values dependent on the soap request
|
70
84
|
class RestHandler < ExchangeHandler
|
71
85
|
extend Soaspec::RestAccessors
|
72
|
-
extend Soaspec::Accessors
|
73
86
|
|
74
87
|
# Savon client used to make SOAP calls
|
75
88
|
attr_accessor :client
|
@@ -2,7 +2,7 @@
|
|
2
2
|
require_relative 'exchange_handler'
|
3
3
|
require_relative '../hash_methods'
|
4
4
|
require_relative '../not_found_errors'
|
5
|
-
require_relative '
|
5
|
+
require_relative 'handler_accessors'
|
6
6
|
require_relative '../interpreter'
|
7
7
|
|
8
8
|
module Soaspec
|
@@ -20,7 +20,6 @@ module Soaspec
|
|
20
20
|
|
21
21
|
# Wraps around Savon client defining default values dependent on the soap request
|
22
22
|
class SoapHandler < ExchangeHandler
|
23
|
-
extend Soaspec::Accessors
|
24
23
|
extend Soaspec::SoapAccessors
|
25
24
|
|
26
25
|
# Savon client used to make SOAP calls
|
@@ -89,8 +88,7 @@ module Soaspec
|
|
89
88
|
|
90
89
|
# Used in together with Exchange request that passes such override parameters
|
91
90
|
def make_request(override_parameters)
|
92
|
-
test_values = override_parameters # Used in Erb
|
93
|
-
# Erb parses template file, executing Ruby code in `<% %>` blocks to work out final request
|
91
|
+
test_values = override_parameters # Used in making request via hash or in template via Erb
|
94
92
|
test_values = test_values.transform_keys_to_symbols if Soaspec.always_use_keys?
|
95
93
|
begin
|
96
94
|
if @request_option == :template
|
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.49
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SamuelGarrattIQA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -167,9 +167,9 @@ files:
|
|
167
167
|
- exe/soaspec-init
|
168
168
|
- exe/xml_to_yaml_file
|
169
169
|
- lib/soaspec.rb
|
170
|
-
- lib/soaspec/accessors.rb
|
171
170
|
- lib/soaspec/exchange.rb
|
172
171
|
- lib/soaspec/exchange_handlers/exchange_handler.rb
|
172
|
+
- lib/soaspec/exchange_handlers/handler_accessors.rb
|
173
173
|
- lib/soaspec/exchange_handlers/rest_handler.rb
|
174
174
|
- lib/soaspec/exchange_handlers/rest_methods.rb
|
175
175
|
- lib/soaspec/exchange_handlers/soap_handler.rb
|