soaspec 0.0.1
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 +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +86 -0
- data/LICENSE.txt +21 -0
- data/README.md +42 -0
- data/Rakefile +17 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/soaspec +3 -0
- data/lib/soaspec.rb +27 -0
- data/lib/soaspec/basic_soap_handler.rb +86 -0
- data/lib/soaspec/common.rb +24 -0
- data/lib/soaspec/exchange.rb +34 -0
- data/lib/soaspec/matchers.rb +5 -0
- data/lib/soaspec/shared_examples.rb +7 -0
- data/lib/soaspec/tester.rb +40 -0
- data/lib/soaspec/version.rb +3 -0
- data/soaspec.gemspec +40 -0
- data/template/soap_template.xml +10 -0
- metadata +139 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: f6c7d3e73ca6b3f4f5ba1d6d6583ffbb5eade12b
|
|
4
|
+
data.tar.gz: 0652f9b7c77f7670ac37c8cf90e04cecf9ef34b8
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 6268399eb9a4419ca684513e69ba76fd874ea05292607827c5460667d71a4e9c3361a97ca676c0bf11d6c69ab67b773a1a4e07505eacd8ff18eca0a9f98189f5
|
|
7
|
+
data.tar.gz: f95fbda46d2131aafa18701296b8be9c01892366e651fe6fe3f3b9015be6dc2be5fccb2ff42c5cb4b5e966a95b84720c389d32d126a8b0ca3190dbfbacbce895
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at samuel.garratt@integrationqa.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
source "https://rubygems.org"
|
|
2
|
+
|
|
3
|
+
git_source(:github) { |repo_name| "https://gitlab.com/samuel-garratt/soaspec" }
|
|
4
|
+
|
|
5
|
+
# Specify your gem's dependencies in soaspec.gemspec
|
|
6
|
+
gemspec
|
|
7
|
+
gem 'rspec'
|
|
8
|
+
gem 'rest-client'
|
|
9
|
+
gem 'savon'
|
|
10
|
+
gem 'require_all'
|
|
11
|
+
gem 'nokogiri'
|
|
12
|
+
gem 'rake', '12.2.1'
|
|
13
|
+
gem 'rspec_junit_formatter'
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
soaspec (0.0.1)
|
|
5
|
+
rest-client
|
|
6
|
+
savon
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
akami (1.3.1)
|
|
12
|
+
gyoku (>= 0.4.0)
|
|
13
|
+
nokogiri
|
|
14
|
+
builder (3.2.3)
|
|
15
|
+
diff-lcs (1.3)
|
|
16
|
+
domain_name (0.5.20170404)
|
|
17
|
+
unf (>= 0.0.5, < 1.0.0)
|
|
18
|
+
gyoku (1.3.1)
|
|
19
|
+
builder (>= 2.1.2)
|
|
20
|
+
http-cookie (1.0.3)
|
|
21
|
+
domain_name (~> 0.5)
|
|
22
|
+
httpi (2.4.2)
|
|
23
|
+
rack
|
|
24
|
+
socksify
|
|
25
|
+
mime-types (3.1)
|
|
26
|
+
mime-types-data (~> 3.2015)
|
|
27
|
+
mime-types-data (3.2016.0521)
|
|
28
|
+
mini_portile2 (2.3.0)
|
|
29
|
+
netrc (0.11.0)
|
|
30
|
+
nokogiri (1.8.1)
|
|
31
|
+
mini_portile2 (~> 2.3.0)
|
|
32
|
+
nori (2.6.0)
|
|
33
|
+
rack (2.0.3)
|
|
34
|
+
rake (12.2.1)
|
|
35
|
+
require_all (1.5.0)
|
|
36
|
+
rest-client (2.0.2)
|
|
37
|
+
http-cookie (>= 1.0.2, < 2.0)
|
|
38
|
+
mime-types (>= 1.16, < 4.0)
|
|
39
|
+
netrc (~> 0.8)
|
|
40
|
+
rspec (3.7.0)
|
|
41
|
+
rspec-core (~> 3.7.0)
|
|
42
|
+
rspec-expectations (~> 3.7.0)
|
|
43
|
+
rspec-mocks (~> 3.7.0)
|
|
44
|
+
rspec-core (3.7.0)
|
|
45
|
+
rspec-support (~> 3.7.0)
|
|
46
|
+
rspec-expectations (3.7.0)
|
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
48
|
+
rspec-support (~> 3.7.0)
|
|
49
|
+
rspec-mocks (3.7.0)
|
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
51
|
+
rspec-support (~> 3.7.0)
|
|
52
|
+
rspec-support (3.7.0)
|
|
53
|
+
rspec_junit_formatter (0.3.0)
|
|
54
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
|
55
|
+
savon (2.11.2)
|
|
56
|
+
akami (~> 1.2)
|
|
57
|
+
builder (>= 2.1.2)
|
|
58
|
+
gyoku (~> 1.2)
|
|
59
|
+
httpi (~> 2.3)
|
|
60
|
+
nokogiri (>= 1.4.0)
|
|
61
|
+
nori (~> 2.4)
|
|
62
|
+
wasabi (~> 3.4)
|
|
63
|
+
socksify (1.7.1)
|
|
64
|
+
unf (0.1.4)
|
|
65
|
+
unf_ext
|
|
66
|
+
unf_ext (0.0.7.4)
|
|
67
|
+
wasabi (3.5.0)
|
|
68
|
+
httpi (~> 2.0)
|
|
69
|
+
nokogiri (>= 1.4.2)
|
|
70
|
+
|
|
71
|
+
PLATFORMS
|
|
72
|
+
ruby
|
|
73
|
+
|
|
74
|
+
DEPENDENCIES
|
|
75
|
+
bundler (~> 1.16)
|
|
76
|
+
nokogiri
|
|
77
|
+
rake (= 12.2.1)
|
|
78
|
+
require_all
|
|
79
|
+
rest-client
|
|
80
|
+
rspec
|
|
81
|
+
rspec_junit_formatter
|
|
82
|
+
savon
|
|
83
|
+
soaspec!
|
|
84
|
+
|
|
85
|
+
BUNDLED WITH
|
|
86
|
+
1.16.0
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Samuel Garratt
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Soaspec
|
|
2
|
+
|
|
3
|
+
This gem helps to represent multiple API tests against a backend briefly, concisely and clearly. It is essentially a wrapper around the Savon and RestClient gems.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
Add this line to your application's Gemfile:
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
gem 'soaspec'
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
And then execute:
|
|
15
|
+
|
|
16
|
+
$ bundle
|
|
17
|
+
|
|
18
|
+
Or install it yourself as:
|
|
19
|
+
|
|
20
|
+
$ gem install soaspec
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
See specs for example of usage. This will be added to later.
|
|
25
|
+
|
|
26
|
+
## Development
|
|
27
|
+
|
|
28
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
29
|
+
|
|
30
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
31
|
+
|
|
32
|
+
## Contributing
|
|
33
|
+
|
|
34
|
+
Bug reports and pull requests are welcome on GitLab at https://gitlab.com/samuel-garratt/soaspec. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
39
|
+
|
|
40
|
+
## Code of Conduct
|
|
41
|
+
|
|
42
|
+
Everyone interacting in the Soaspec project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://gitlab.com/samuel-garratt/soaspec/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
|
2
|
+
require "rspec/core/rake_task"
|
|
3
|
+
|
|
4
|
+
RSpec::Core::RakeTask.new(:run_spec) do |t|
|
|
5
|
+
t.pattern = "spec/*/#{ENV['test_name']}*_spec.rb"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
desc 'Prepare log files'
|
|
9
|
+
task :logs do
|
|
10
|
+
mkdir_p 'logs'
|
|
11
|
+
touch 'logs/traffic.log'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
desc 'Run tests'
|
|
15
|
+
task :spec => %w[logs run_spec]
|
|
16
|
+
|
|
17
|
+
task :default => :spec
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "soaspec"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/soaspec
ADDED
data/lib/soaspec.rb
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'soaspec/version'
|
|
2
|
+
require 'soaspec/common'
|
|
3
|
+
require 'soaspec/basic_soap_handler'
|
|
4
|
+
require 'soaspec/tester'
|
|
5
|
+
require 'soaspec/exchange'
|
|
6
|
+
require 'soaspec/matchers'
|
|
7
|
+
require 'soaspec/shared_examples'
|
|
8
|
+
|
|
9
|
+
# Gem for handling SOAP and REST api tests
|
|
10
|
+
module Soaspec
|
|
11
|
+
|
|
12
|
+
def self.hi
|
|
13
|
+
puts 'Hello world!'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Represents Environment parameters used in Soaspec tests
|
|
17
|
+
module Environment
|
|
18
|
+
|
|
19
|
+
def self.api_handler=(handler)
|
|
20
|
+
@api_handler = handler
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.api_handler
|
|
24
|
+
@api_handler
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
require 'yaml'
|
|
2
|
+
require_relative 'common'
|
|
3
|
+
require_relative 'tester'
|
|
4
|
+
|
|
5
|
+
module Soaspec
|
|
6
|
+
# Wraps around Savon client defining default values dependent on the soap request
|
|
7
|
+
class BasicSoapHandler < Tester
|
|
8
|
+
# Savon client used to make SOAP calls
|
|
9
|
+
attr_accessor :client
|
|
10
|
+
# Namespaces used in XML body
|
|
11
|
+
attr_accessor :namespaces
|
|
12
|
+
# SOAP Operation to use by default
|
|
13
|
+
attr_accessor :default_operation
|
|
14
|
+
|
|
15
|
+
# Setup object to handle communicating with a particular SOAP WSDL
|
|
16
|
+
# @param [Hash] specific_options Options defining SOAP request. WSDL, authentication, see http://savonrb.com/version2/globals.html for list of options
|
|
17
|
+
def initialize(name, specific_options)
|
|
18
|
+
super
|
|
19
|
+
options = {
|
|
20
|
+
ssl_verify_mode: :none,
|
|
21
|
+
follow_redirects: true, # Necessary
|
|
22
|
+
log: true, # See request and response. (Put this in traffic file)
|
|
23
|
+
log_level: :debug,
|
|
24
|
+
logger: file_logger,
|
|
25
|
+
soap_version: 2, # use SOAP 1.2. You will get 415 error if this set to default
|
|
26
|
+
pretty_print_xml: true, # Prints XML pretty
|
|
27
|
+
raise_errors: false
|
|
28
|
+
}
|
|
29
|
+
options.merge!(specific_options)
|
|
30
|
+
@client = Savon.client(options)
|
|
31
|
+
self.namespaces = {}
|
|
32
|
+
@name = name
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Sends a call to the API (is being made obsolete)
|
|
36
|
+
# @param [Hash] options Dictionary of key value pairs specifying what API call to make
|
|
37
|
+
# @return [SavonResponse] Savon response from which areas (header, body, etc) of the SOAP response can be accessed
|
|
38
|
+
def call(options)
|
|
39
|
+
test_values = options[:overide_values]['request'] || {} # Empty hash if no specific request values are set
|
|
40
|
+
options[:operation] ||= self.default_operation
|
|
41
|
+
# Erb parses template file, executing Ruby code in `<% %>` blocks to work out final request
|
|
42
|
+
render_body = ERB.new(options[:template]).result(binding)
|
|
43
|
+
@client.call(options[:operation], xml: render_body ) # Call the SOAP operation with the request XML provided
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def name(name)
|
|
47
|
+
@test_values = {}
|
|
48
|
+
@test_name = name
|
|
49
|
+
self
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def override(request_parameters)
|
|
53
|
+
@test_values = request_parameters
|
|
54
|
+
self
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# TODO: Use this together with Exchange request
|
|
58
|
+
def make_request(override_parameters)
|
|
59
|
+
test_values = override_parameters # Used in Erb
|
|
60
|
+
# Erb parses template file, executing Ruby code in `<% %>` blocks to work out final request
|
|
61
|
+
puts 'O' + override_parameters.to_s
|
|
62
|
+
if @request_option == :template
|
|
63
|
+
request_body = File.read('template/' + template_name + '.xml')
|
|
64
|
+
render_body = ERB.new(request_body).result(binding)
|
|
65
|
+
@client.call(default_operation, xml: render_body ) # Call the SOAP operation with the request XML provided
|
|
66
|
+
elsif @request_option == :hash
|
|
67
|
+
@client.call(default_operation, message: @default_hash)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def to_s
|
|
72
|
+
Soaspec::Environment.api_handler = self
|
|
73
|
+
@name
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def include?(value)
|
|
77
|
+
@xml_response.include? value
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def default_hash=(hash)
|
|
81
|
+
@request_option = :hash
|
|
82
|
+
@default_hash = hash
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
class Hash
|
|
2
|
+
|
|
3
|
+
# Loop through each item within a key within a Hash if the key exists
|
|
4
|
+
# @param [Key] Key within hash to iterate through
|
|
5
|
+
def each_if_not_null(key)
|
|
6
|
+
case key.class.to_s
|
|
7
|
+
when 'String'
|
|
8
|
+
if self[key]
|
|
9
|
+
self[key].each do |list_item|
|
|
10
|
+
yield(list_item)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
when 'Array'
|
|
14
|
+
if self[key[0]]
|
|
15
|
+
if self[key[0]][key[1]]
|
|
16
|
+
self[key[0]][key[1]].each do |list_item|
|
|
17
|
+
yield(list_item)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require_relative '../soaspec'
|
|
2
|
+
# This represents a request / response pair
|
|
3
|
+
class Exchange
|
|
4
|
+
|
|
5
|
+
attr_reader :xml_response
|
|
6
|
+
|
|
7
|
+
def initialize(name, override_parameters = {})
|
|
8
|
+
@test_name = name.to_s
|
|
9
|
+
@api_class = Soaspec::Environment.api_handler
|
|
10
|
+
@override_parameters = override_parameters
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Make request to handler with parameters defined
|
|
14
|
+
def make_request
|
|
15
|
+
@api_class.make_request(@override_parameters)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Name describing this class when used with `RSpec.describe`
|
|
19
|
+
# @return [String] Name given when initializing
|
|
20
|
+
def to_s
|
|
21
|
+
@response = self.make_request
|
|
22
|
+
@xml_response = @response.to_xml
|
|
23
|
+
@test_name
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def contain(value)
|
|
27
|
+
@xml_response.include? value
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def status_code
|
|
31
|
+
@response.http.code
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
require 'yaml'
|
|
3
|
+
require_relative 'common'
|
|
4
|
+
|
|
5
|
+
module Soaspec
|
|
6
|
+
# Has basic methods common for methods defining RSpec tests in YAML
|
|
7
|
+
class Tester
|
|
8
|
+
|
|
9
|
+
attr_reader :template_name
|
|
10
|
+
|
|
11
|
+
# Load default groups. Set name
|
|
12
|
+
def initialize(name, options)
|
|
13
|
+
@name = name
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Name describing this class when used with `RSpec.describe`
|
|
17
|
+
# @return [String] Name given when initializing
|
|
18
|
+
def to_s
|
|
19
|
+
@response = make_request
|
|
20
|
+
@xml_response = @response.to_xml
|
|
21
|
+
@test_name
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def template_name=(name)
|
|
25
|
+
@request_option = :template
|
|
26
|
+
@template_name = name
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
protected
|
|
30
|
+
|
|
31
|
+
# Log API request and response traffic in 'logs/traffic.log'
|
|
32
|
+
# @return [Logger] Ruby logger that will log to 'logs/traffic.log'
|
|
33
|
+
def file_logger
|
|
34
|
+
logger = Logger.new('logs/traffic.log') # Where request and responses of APIs are stored
|
|
35
|
+
logger.level = Logger::DEBUG
|
|
36
|
+
logger
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
end
|
data/soaspec.gemspec
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'soaspec/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = 'soaspec'
|
|
8
|
+
spec.version = Soaspec::VERSION
|
|
9
|
+
spec.authors = ["SamuelGarrattIQA"]
|
|
10
|
+
spec.email = ["samuel.garratt@integrationqa.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Helps to create RSoec soecs for SOAP or REST apis }
|
|
13
|
+
spec.description = %q{Helps to create RSoec soecs for SOAP or REST apis. Create classes with your configuration
|
|
14
|
+
and use }
|
|
15
|
+
spec.homepage = "https://about.gitlab.com/"
|
|
16
|
+
spec.license = "MIT"
|
|
17
|
+
|
|
18
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
19
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
20
|
+
if spec.respond_to?(:metadata)
|
|
21
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
22
|
+
else
|
|
23
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
|
24
|
+
"public gem pushes."
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
28
|
+
f.match(%r{^(test|spec|features)/})
|
|
29
|
+
end
|
|
30
|
+
spec.bindir = "exe"
|
|
31
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
32
|
+
spec.require_paths = ["lib"]
|
|
33
|
+
|
|
34
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
|
35
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
36
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
37
|
+
spec.add_dependency 'rest-client', '>= 2.0'
|
|
38
|
+
spec.add_dependency 'savon', '>= 2'
|
|
39
|
+
|
|
40
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<s12:Envelope xmlns:s12='http://www.w3.org/2003/05/soap-envelope'>
|
|
2
|
+
<s12:Body>
|
|
3
|
+
<ns1:GetWeather xmlns:ns1='http://www.webserviceX.NET'>
|
|
4
|
+
<!-- optional -->
|
|
5
|
+
<ns1:CityName><%= test_values[:city_name] || 'Wellington' %></ns1:CityName>
|
|
6
|
+
<!-- optional -->
|
|
7
|
+
<ns1:CountryName><%= test_values[:country] || 'New Zealand' %></ns1:CountryName>
|
|
8
|
+
</ns1:GetWeather>
|
|
9
|
+
</s12:Body>
|
|
10
|
+
</s12:Envelope>
|
metadata
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: soaspec
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- SamuelGarrattIQA
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-01-17 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.16'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.16'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rest-client
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '2.0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '2.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: savon
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '2'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '2'
|
|
83
|
+
description: "Helps to create RSoec soecs for SOAP or REST apis. Create classes with
|
|
84
|
+
your configuration\nand use "
|
|
85
|
+
email:
|
|
86
|
+
- samuel.garratt@integrationqa.com
|
|
87
|
+
executables:
|
|
88
|
+
- soaspec
|
|
89
|
+
extensions: []
|
|
90
|
+
extra_rdoc_files: []
|
|
91
|
+
files:
|
|
92
|
+
- ".gitignore"
|
|
93
|
+
- ".rspec"
|
|
94
|
+
- ".travis.yml"
|
|
95
|
+
- CODE_OF_CONDUCT.md
|
|
96
|
+
- Gemfile
|
|
97
|
+
- Gemfile.lock
|
|
98
|
+
- LICENSE.txt
|
|
99
|
+
- README.md
|
|
100
|
+
- Rakefile
|
|
101
|
+
- bin/console
|
|
102
|
+
- bin/setup
|
|
103
|
+
- exe/soaspec
|
|
104
|
+
- lib/soaspec.rb
|
|
105
|
+
- lib/soaspec/basic_soap_handler.rb
|
|
106
|
+
- lib/soaspec/common.rb
|
|
107
|
+
- lib/soaspec/exchange.rb
|
|
108
|
+
- lib/soaspec/matchers.rb
|
|
109
|
+
- lib/soaspec/shared_examples.rb
|
|
110
|
+
- lib/soaspec/tester.rb
|
|
111
|
+
- lib/soaspec/version.rb
|
|
112
|
+
- soaspec.gemspec
|
|
113
|
+
- template/soap_template.xml
|
|
114
|
+
homepage: https://about.gitlab.com/
|
|
115
|
+
licenses:
|
|
116
|
+
- MIT
|
|
117
|
+
metadata:
|
|
118
|
+
allowed_push_host: https://rubygems.org
|
|
119
|
+
post_install_message:
|
|
120
|
+
rdoc_options: []
|
|
121
|
+
require_paths:
|
|
122
|
+
- lib
|
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
|
+
requirements:
|
|
125
|
+
- - ">="
|
|
126
|
+
- !ruby/object:Gem::Version
|
|
127
|
+
version: '0'
|
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
|
+
requirements:
|
|
130
|
+
- - ">="
|
|
131
|
+
- !ruby/object:Gem::Version
|
|
132
|
+
version: '0'
|
|
133
|
+
requirements: []
|
|
134
|
+
rubyforge_project:
|
|
135
|
+
rubygems_version: 2.6.14
|
|
136
|
+
signing_key:
|
|
137
|
+
specification_version: 4
|
|
138
|
+
summary: Helps to create RSoec soecs for SOAP or REST apis
|
|
139
|
+
test_files: []
|