soaspec 0.2.18 → 0.2.19

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,36 @@
1
+ <html>
2
+ <head>
3
+ <title>REST Exchange generator</title>
4
+ <link rel="stylesheet" href="css/bootstrap.css" type="text/css" charset="utf-8" />
5
+ </head>
6
+ <body>
7
+ <main class="container-fluid">
8
+ <h1>REST Exchange generator</h1>
9
+ <h2>Handler creator <small><%= GenerateServer.create_params['feedback'] %></small></h2>
10
+ <form class="form-horizontal" method="POST" action="/generate">
11
+ <div class="form-group">
12
+ <label class="col-sm-2 control-label" for="className">Class Name</label>
13
+ <div class="col-sm-10">
14
+ <input id="className" class="form-control" type="text" name="className"
15
+ placeholder="ApiUnderTest" value="<%= GenerateServer.create_params['className'] %>">
16
+ <p class="help-block">This is what you will refer to the API in your test code. Use Pascal Case</p>
17
+ </div>
18
+ </div>
19
+ <div class="form-group">
20
+ <label class="col-sm-2 control-label" for="baseUrl">Base URL</label>
21
+ <div class="col-sm-10">
22
+ <input id="baseUrl" class="form-control" type="text" name="baseUrl"
23
+ placeholder="https://url/which/api/starts_with" value="<%= GenerateServer.create_params['baseUrl'] %>">
24
+ <p class="help-block">Url with which all REST requests using this class will start with.
25
+ Exchanges creating using this class can append to this with the 'suburl' parameter.</p>
26
+ </div>
27
+ </div>
28
+ <div class="form-group">
29
+ <div class="col-sm-offset-2 col-sm-10">
30
+ <input type="submit" value="Generate handler" class="btn btn-primary">
31
+ </div>
32
+ </div>
33
+ </form>
34
+ </main>
35
+ </body>
36
+ </html>
@@ -2,10 +2,12 @@
2
2
  class <%= @name %> < Soaspec::RestHandler
3
3
  ## Defining request
4
4
 
5
- # All requests to <%= @name %> will start with this url
5
+ # All requests to <%= @name %> will start with this url <% if @base_url %>
6
+ base_url '<%= @base_url %>'
7
+ <% else %>
6
8
  # TODO: Change this mandatory base_url to the url that all requests to this service start with
7
9
  # base_url "https://my_host/api/<%= ENV['environment'] %>/api_name" # ERB can be used to make this dynamic based on environment
8
-
10
+ <% end %>
9
11
  # Headers that will be sent by default using this Handler
10
12
  # If symbol is used, they'll be converted to standard HTTP headers
11
13
  # headers accept: 'application/json', content_type: 'application/json'
@@ -5,11 +5,13 @@ module Soaspec
5
5
  # Representing a GetBank SOAP service
6
6
  class GetBank
7
7
  class << self
8
+ # This is retrieved by Savon
8
9
  # @return [String] WSDL of mock web service
9
10
  def test_wsdl
10
11
  ERB.new(File.read(File.join(File.dirname(__FILE__), 'bank.wsdl'))).result(binding)
11
12
  end
12
13
 
14
+ # @return [String] XML of success SOAP Response
13
15
  def success_response_template
14
16
  <<-EOF
15
17
  <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
@@ -31,6 +33,7 @@ module Soaspec
31
33
  EOF
32
34
  end
33
35
 
36
+ # @return [String] XML of failure SOAP Response simulating bank not found
34
37
  def bank_not_found
35
38
  <<-EOF
36
39
  <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
@@ -1,3 +1,3 @@
1
1
  module Soaspec
2
- VERSION = '0.2.18'.freeze
2
+ VERSION = '0.2.19'.freeze
3
3
  end
@@ -1,6 +1,47 @@
1
1
  module Soaspec
2
2
  # Produce test content from a WSDL
3
3
  module WsdlGenerator
4
+ # Generate from WSDL
5
+ def generate_from_wsdl(options)
6
+ enter_auth_details if options[:auth] == 'basic'
7
+ @virtual = false
8
+ savon_options = { wsdl: options[:wsdl] }
9
+ savon_options[:basic_auth] = [@auth_name, @auth_password] if options[:auth] == 'basic'
10
+
11
+ @wsdl_doc = Savon.client(**savon_options).wsdl
12
+ @wsdl_schemas = @wsdl_doc.parser.schemas
13
+
14
+ create_files %w[Rakefile Gemfile README.md spec/spec_helper.rb], ignore_if_present: true
15
+ create_file(filename: '.rspec')
16
+ create_file(filename: '.travis.yml') if options[:ci] == 'travis'
17
+ create_folder 'logs'
18
+ create_file filename: "lib/#{options[:name].snakecase}.rb", content: class_content
19
+
20
+ # Files according to WSDL
21
+ @wsdl_doc.operations.each do |operation, op_details|
22
+ puts "Creating files for operation: #{operation}"
23
+ @content = "default:\n"
24
+ @use_camel_case = false
25
+ puts 'Message params: ' + op_details.to_s
26
+ # From namespace identifier, find namespace, and for that find schemaLocation xsd and use that to build request
27
+ if op_details[:parameters]
28
+ op_details[:parameters].each do |element, details|
29
+ @use_camel_case = true unless /[[:upper:]]/.match(element.to_s[0]).nil?
30
+ @content += " #{element.to_s.snakecase}: #{fill_in_field_from_type(details[:type])} # #{details[:type]} \n"
31
+ # TODO: If details is a Hash need to loop again
32
+ end
33
+ end
34
+ wsdl_to_yaml_for root_elements_for(op_details)
35
+ params = []
36
+ params << 'convert_request_keys_to: :camelcase' if @use_camel_case
37
+ params_string = params == [] ? '' : ', ' + params.join(', ')
38
+ @class_params = "'#{camel_case(operation)}'#{params_string}"
39
+
40
+ create_file(filename: "config/data/#{operation}.yml", content: @content)
41
+ create_file(filename: "spec/#{operation}_spec.rb", content: generated_soap_spec_for(operation))
42
+ end
43
+ end
44
+
4
45
  # Attempt to calculate values of enumeration by looking up type in Schema
5
46
  # @param [String] type Try out filling enumeration for type. Return Custom Type if can't be done
6
47
  def try_enum_for(type)
data/soaspec.gemspec CHANGED
@@ -25,6 +25,7 @@ the same configuration. Examples designed for RSpec and Cucumber."
25
25
  spec.add_development_dependency 'cucumber'
26
26
  spec.add_development_dependency 'data_magic'
27
27
  spec.add_development_dependency 'factory_bot'
28
+ spec.add_development_dependency 'parallel_tests'
28
29
  spec.add_development_dependency 'rack'
29
30
  spec.add_development_dependency 'rack-test'
30
31
  spec.add_development_dependency 'rake', '~> 12.0'
@@ -37,6 +38,7 @@ the same configuration. Examples designed for RSpec and Cucumber."
37
38
  spec.add_dependency 'faker'
38
39
  spec.add_dependency 'hashie'
39
40
  spec.add_dependency 'jsonpath'
41
+ spec.add_dependency 'launchy'
40
42
  spec.add_dependency 'nokogiri'
41
43
  spec.add_dependency 'rest-client', '>= 2.0' # REST
42
44
  spec.add_dependency 'rspec', '~> 3.0' # This framework is designed to work with RSpec
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.2.18
4
+ version: 0.2.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - SamuelGarrattIQA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-26 00:00:00.000000000 Z
11
+ date: 2019-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: parallel_tests
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rack
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -234,6 +248,20 @@ dependencies:
234
248
  - - ">="
235
249
  - !ruby/object:Gem::Version
236
250
  version: '0'
251
+ - !ruby/object:Gem::Dependency
252
+ name: launchy
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - ">="
256
+ - !ruby/object:Gem::Version
257
+ version: '0'
258
+ type: :runtime
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - ">="
263
+ - !ruby/object:Gem::Version
264
+ version: '0'
237
265
  - !ruby/object:Gem::Dependency
238
266
  name: nokogiri
239
267
  requirement: !ruby/object:Gem::Requirement
@@ -396,6 +424,8 @@ files:
396
424
  - README.md
397
425
  - Rakefile
398
426
  - Todo.md
427
+ - demo/css/bootstrap-theme.css
428
+ - demo/css/bootstrap.css
399
429
  - demo/index.html
400
430
  - demo/js/angular.min.js
401
431
  - demo/json_extract.html
@@ -425,12 +455,15 @@ files:
425
455
  - lib/soaspec/exchange_handlers/rest_parameters_defaults.rb
426
456
  - lib/soaspec/exchange_handlers/soap_handler.rb
427
457
  - lib/soaspec/exe_helpers.rb
458
+ - lib/soaspec/generate_server.rb
428
459
  - lib/soaspec/generator/.rspec.erb
429
460
  - lib/soaspec/generator/.travis.yml.erb
430
461
  - lib/soaspec/generator/Gemfile.erb
431
462
  - lib/soaspec/generator/README.md.erb
432
463
  - lib/soaspec/generator/Rakefile.erb
433
464
  - lib/soaspec/generator/config/data/default.yml.erb
465
+ - lib/soaspec/generator/css/bootstrap.css
466
+ - lib/soaspec/generator/generate_exchange.html.erb
434
467
  - lib/soaspec/generator/lib/blz_service.rb.erb
435
468
  - lib/soaspec/generator/lib/dynamic_class_content.rb.erb
436
469
  - lib/soaspec/generator/lib/new_rest_service.rb.erb