wash_out 0.11.0.beta.2 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -6
- data/Appraisals +4 -9
- data/README.md +45 -1
- data/Rakefile +13 -2
- data/app/views/wash_out/document/response.builder +7 -0
- data/app/views/wash_out/rpc/response.builder +8 -1
- data/gemfiles/rails_5.0.0.gemfile +19 -0
- data/lib/wash_out/dispatcher.rb +33 -6
- data/lib/wash_out/router.rb +15 -20
- data/lib/wash_out/soap.rb +10 -0
- data/lib/wash_out/version.rb +1 -1
- data/lib/wash_out.rb +15 -1
- data/spec/lib/wash_out_spec.rb +205 -5
- data/spec/spec_helper.rb +3 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82173ea05524c819f835867ecc6c49b2e5264be4
|
4
|
+
data.tar.gz: c539a9c5a8793bb884c575f03624aec4f78dad09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f95800e511ef556fcd9be44eb3f15ce7c8a95ed9f90cf9bc35d2870f89c4cd7357059d914bc2f0c81eef0119adf092c6fad0cb803e4bc097c03cdcc25a01d8ab
|
7
|
+
data.tar.gz: e0aee07a1f29c56a175b4bbb764fffb086e515084783a305db61697efe287080aee785ed6cf165b58f285a615df3c93cd13dfafedc865c724fc82a14e4e3d13c
|
data/.travis.yml
CHANGED
@@ -4,7 +4,7 @@ gemfile:
|
|
4
4
|
- gemfiles/rails_4.0.0.gemfile
|
5
5
|
- gemfiles/rails_4.1.0.gemfile
|
6
6
|
- gemfiles/rails_4.2.0.gemfile
|
7
|
-
- gemfiles/rails_5.0.0.
|
7
|
+
- gemfiles/rails_5.0.0.gemfile
|
8
8
|
rvm:
|
9
9
|
- 1.9.3
|
10
10
|
- 2.0.0
|
@@ -18,17 +18,21 @@ matrix:
|
|
18
18
|
gemfile: gemfiles/rails_3.2.13.gemfile
|
19
19
|
- rvm: 2.3.0
|
20
20
|
gemfile: gemfiles/rails_3.2.13.gemfile
|
21
|
+
- rvm: 1.9.3
|
22
|
+
gemfile: gemfiles/rails_4.0.0.gemfile
|
21
23
|
- rvm: 1.9.3
|
22
24
|
gemfile: gemfiles/rails_4.2.0.gemfile
|
23
25
|
- rvm: jruby
|
24
26
|
gemfile: gemfiles/rails_4.2.0.gemfile
|
25
27
|
- rvm: 1.9.3
|
26
|
-
gemfile: gemfiles/rails_5.0.0.
|
28
|
+
gemfile: gemfiles/rails_5.0.0.gemfile
|
27
29
|
- rvm: 2.0.0
|
28
|
-
gemfile: gemfiles/rails_5.0.0.
|
30
|
+
gemfile: gemfiles/rails_5.0.0.gemfile
|
29
31
|
- rvm: 2.1.8
|
30
|
-
gemfile: gemfiles/rails_5.0.0.
|
32
|
+
gemfile: gemfiles/rails_5.0.0.gemfile
|
33
|
+
- rvm: 2.2.4
|
34
|
+
gemfile: gemfiles/rails_5.0.0.gemfile
|
31
35
|
- rvm: jruby
|
32
|
-
gemfile: gemfiles/rails_5.0.0.
|
36
|
+
gemfile: gemfiles/rails_5.0.0.gemfile
|
33
37
|
before_install:
|
34
|
-
- gem update bundler
|
38
|
+
- gem update bundler
|
data/Appraisals
CHANGED
@@ -1,9 +1,3 @@
|
|
1
|
-
appraise "rails-3.2.13" do
|
2
|
-
gem "rails", "3.2.13"
|
3
|
-
gem "test-unit"
|
4
|
-
gem "listen", "< 3.1.0"
|
5
|
-
end
|
6
|
-
|
7
1
|
appraise "rails-4.0.0" do
|
8
2
|
gem "rails", "4.0.0"
|
9
3
|
gem "listen", "< 3.1.0"
|
@@ -19,6 +13,7 @@ appraise "rails-4.2.0" do
|
|
19
13
|
gem "listen", "< 3.1.0"
|
20
14
|
end
|
21
15
|
|
22
|
-
|
23
|
-
|
24
|
-
|
16
|
+
|
17
|
+
appraise "rails-5.0.0" do
|
18
|
+
gem "rails", "5.0.0"
|
19
|
+
end
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ But if you have a chance, please [http://stopsoap.com/](http://stopsoap.com/).
|
|
10
10
|
|
11
11
|
## Compatibility
|
12
12
|
|
13
|
-
Rails
|
13
|
+
Rails 4.0 and higher is tested. Code is known to work with earlier versions but we don't bother testing outdated versions anymore - give it a try if you are THAT unlucky.
|
14
14
|
|
15
15
|
## Installation
|
16
16
|
|
@@ -118,6 +118,50 @@ class RumbasController < ApplicationController
|
|
118
118
|
def dump_parameters
|
119
119
|
Rails.logger.debug params.inspect
|
120
120
|
end
|
121
|
+
|
122
|
+
|
123
|
+
# Rendering SOAP headers
|
124
|
+
soap_action "integer_to_header_string",
|
125
|
+
:args => :integer,
|
126
|
+
:return => :string,
|
127
|
+
:header_return => :string
|
128
|
+
def integer_to_header_string
|
129
|
+
render :soap => params[:value].to_s, :header => (params[:value]+1).to_s
|
130
|
+
end
|
131
|
+
|
132
|
+
# Reading SOAP Headers
|
133
|
+
# This is different than normal SOAP params, because we don't specify the incoming format of the header,
|
134
|
+
# but we can still access it through `soap_request.headers`. Note that the values are all strings or hashes.
|
135
|
+
soap_action "AddCircleWithHeaderRadius",
|
136
|
+
:args => { :circle => { :center => { :x => :integer,
|
137
|
+
:y => :integer } } },
|
138
|
+
:return => nil, # [] for wash_out below 0.3.0
|
139
|
+
:to => :add_circle
|
140
|
+
# e.g. for a request to the 'AddCircleWithHeaderRadius' action:
|
141
|
+
# <soapenv:Envelope>
|
142
|
+
# <soap:Header>
|
143
|
+
# <radius>12345</radius>
|
144
|
+
# </soap:Header>
|
145
|
+
# <soapenv:Body>
|
146
|
+
# <AddCircle>
|
147
|
+
# <Circle radius="5.0">
|
148
|
+
# <Center x="10" y="12" />
|
149
|
+
# </Circle>
|
150
|
+
# </AddCircle>
|
151
|
+
# </soapenv:Body>
|
152
|
+
# </soapenv:Envelope>
|
153
|
+
def add_circle_with_header_radius
|
154
|
+
circle = params[:circle]
|
155
|
+
radius = soap_request.headers[:radius]
|
156
|
+
raise SOAPError, "radius must be specified in the SOAP header" if radius.blank?
|
157
|
+
radius = radius.to_f
|
158
|
+
raise SOAPError, "radius is too small" if radius < 3.0
|
159
|
+
|
160
|
+
Circle.new(circle[:center][:x], circle[:center][:y], radius)
|
161
|
+
|
162
|
+
render :soap => nil
|
163
|
+
end
|
164
|
+
|
121
165
|
end
|
122
166
|
```
|
123
167
|
|
data/Rakefile
CHANGED
@@ -3,11 +3,22 @@ require 'bundler/gem_tasks'
|
|
3
3
|
require 'appraisal'
|
4
4
|
require 'rspec/core/rake_task'
|
5
5
|
|
6
|
-
RSpec::Core::RakeTask.new
|
6
|
+
RSpec::Core::RakeTask.new
|
7
7
|
|
8
8
|
task :console do
|
9
9
|
require "action_controller/railtie"
|
10
10
|
require "rails/test_unit/railtie"
|
11
11
|
Bundler.require
|
12
12
|
binding.pry
|
13
|
-
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
desc 'Default: run the unit tests.'
|
17
|
+
task default: [:all]
|
18
|
+
|
19
|
+
desc 'Test the plugin under all supported Rails versions.'
|
20
|
+
task :all do |_t|
|
21
|
+
# this is needed for minitest because it does not support "--pattern" option as Rspec Does
|
22
|
+
ENV['SPEC'] = '--name=spec/**{,/*/**}/*_spec.rb'
|
23
|
+
exec('bundle exec appraisal install && bundle exec rake appraisal spec')
|
24
|
+
end
|
@@ -2,6 +2,13 @@ xml.instruct!
|
|
2
2
|
xml.tag! "soap:Envelope", "xmlns:soap" => 'http://schemas.xmlsoap.org/soap/envelope/',
|
3
3
|
"xmlns:xsd" => 'http://www.w3.org/2001/XMLSchema',
|
4
4
|
"xmlns:tns" => @namespace do
|
5
|
+
if !header.nil?
|
6
|
+
xml.tag! "soap:Header" do
|
7
|
+
xml.tag! "tns:#{@action_spec[:response_tag]}" do
|
8
|
+
wsdl_data xml, header
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
5
12
|
xml.tag! "soap:Body" do
|
6
13
|
xml.tag! "tns:#{@action_spec[:response_tag]}" do
|
7
14
|
wsdl_data xml, result
|
@@ -3,9 +3,16 @@ xml.tag! "soap:Envelope", "xmlns:soap" => 'http://schemas.xmlsoap.org/soap/envel
|
|
3
3
|
"xmlns:xsd" => 'http://www.w3.org/2001/XMLSchema',
|
4
4
|
"xmlns:xsi" => 'http://www.w3.org/2001/XMLSchema-instance',
|
5
5
|
"xmlns:tns" => @namespace do
|
6
|
+
if !header.nil?
|
7
|
+
xml.tag! "soap:Header" do
|
8
|
+
xml.tag! "tns:#{@action_spec[:response_tag]}" do
|
9
|
+
wsdl_data xml, header
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
6
13
|
xml.tag! "soap:Body" do
|
7
14
|
xml.tag! "tns:#{@action_spec[:response_tag]}" do
|
8
15
|
wsdl_data xml, result
|
9
16
|
end
|
10
17
|
end
|
11
|
-
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "http://rubygems.org"
|
4
|
+
|
5
|
+
gem "wasabi"
|
6
|
+
gem "savon", ">= 2.0.0"
|
7
|
+
gem "httpi"
|
8
|
+
gem "rspec-rails"
|
9
|
+
gem "guard"
|
10
|
+
gem "guard-rspec"
|
11
|
+
gem "rb-fsevent"
|
12
|
+
gem "appraisal"
|
13
|
+
gem "tzinfo"
|
14
|
+
gem "pry"
|
15
|
+
gem "simplecov"
|
16
|
+
gem "simplecov-summary"
|
17
|
+
gem "rails", "5.0.0"
|
18
|
+
|
19
|
+
gemspec :path => "../"
|
data/lib/wash_out/dispatcher.rb
CHANGED
@@ -31,10 +31,14 @@ module WashOut
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def _map_soap_parameters
|
34
|
-
|
34
|
+
self.params = _load_params action_spec[:in],
|
35
35
|
_strip_empty_nodes(action_spec[:in], xml_data)
|
36
36
|
end
|
37
37
|
|
38
|
+
def _map_soap_headers
|
39
|
+
@_soap_headers = xml_header_data
|
40
|
+
end
|
41
|
+
|
38
42
|
def _strip_empty_nodes(params, hash)
|
39
43
|
hash.keys.each do |key|
|
40
44
|
param = params.detect { |a| a.raw_name.to_s == key.to_s }
|
@@ -127,9 +131,19 @@ module WashOut
|
|
127
131
|
return result_spec
|
128
132
|
}
|
129
133
|
|
134
|
+
header = options[:header]
|
135
|
+
if header.present?
|
136
|
+
header = { 'value' => header } unless header.is_a? Hash
|
137
|
+
header = HashWithIndifferentAccess.new(header)
|
138
|
+
end
|
139
|
+
|
130
140
|
render :template => "wash_out/#{soap_config.wsdl_style}/response",
|
131
141
|
:layout => false,
|
132
|
-
:locals => {
|
142
|
+
:locals => {
|
143
|
+
:header => header.present? ? inject.call(header, @action_spec[:header_out])
|
144
|
+
: nil,
|
145
|
+
:result => inject.call(result, @action_spec[:out])
|
146
|
+
},
|
133
147
|
:content_type => 'text/xml'
|
134
148
|
end
|
135
149
|
|
@@ -159,18 +173,26 @@ module WashOut
|
|
159
173
|
:content_type => 'text/xml'
|
160
174
|
end
|
161
175
|
|
176
|
+
def soap_request
|
177
|
+
OpenStruct.new({
|
178
|
+
params: @_params,
|
179
|
+
headers: @_soap_headers
|
180
|
+
})
|
181
|
+
end
|
182
|
+
|
162
183
|
def self.included(controller)
|
163
184
|
entity = if defined?(Rails::VERSION::MAJOR) && (Rails::VERSION::MAJOR >= 4)
|
164
185
|
'action'
|
165
186
|
else
|
166
|
-
'filter'
|
187
|
+
'filter'
|
167
188
|
end
|
168
189
|
|
169
190
|
controller.send :"around_#{entity}", :_catch_soap_errors
|
170
191
|
controller.send :helper, :wash_out
|
171
192
|
controller.send :"before_#{entity}", :_authenticate_wsse, :if => :soap_action?
|
172
193
|
controller.send :"before_#{entity}", :_map_soap_parameters, :if => :soap_action?
|
173
|
-
controller.send :"
|
194
|
+
controller.send :"before_#{entity}", :_map_soap_headers, :if => :soap_action?
|
195
|
+
controller.send :"skip_before_#{entity}", :verify_authenticity_token, :raise => false
|
174
196
|
end
|
175
197
|
|
176
198
|
def self.deep_select(collection, result=[], &blk)
|
@@ -222,11 +244,16 @@ module WashOut
|
|
222
244
|
end
|
223
245
|
|
224
246
|
def xml_data
|
225
|
-
|
226
|
-
xml_data =
|
247
|
+
envelope = request.env['wash_out.soap_data'].values_at(:envelope, :Envelope).compact.first
|
248
|
+
xml_data = envelope.values_at(:body, :Body).compact.first || {}
|
227
249
|
return xml_data if soap_config.wsdl_style == "document"
|
228
250
|
xml_data = xml_data.values_at(soap_action.underscore.to_sym, soap_action.to_sym, request_input_tag.to_sym).compact.first || {}
|
229
251
|
end
|
230
252
|
|
253
|
+
def xml_header_data
|
254
|
+
envelope = request.env['wash_out.soap_data'].values_at(:envelope, :Envelope).compact.first
|
255
|
+
header_data = envelope.values_at(:header, :Header).compact.first || {}
|
256
|
+
end
|
257
|
+
|
231
258
|
end
|
232
259
|
end
|
data/lib/wash_out/router.rb
CHANGED
@@ -4,40 +4,35 @@ module WashOut
|
|
4
4
|
# This class is a Rack middleware used to route SOAP requests to a proper
|
5
5
|
# action of a given SOAP controller.
|
6
6
|
class Router
|
7
|
-
def self.lookup_soap_routes(controller_name, routes)
|
8
|
-
results = []
|
9
|
-
|
7
|
+
def self.lookup_soap_routes(controller_name, routes, path=[], &block)
|
10
8
|
routes.each do |x|
|
11
9
|
defaults = x.defaults
|
12
10
|
defaults = defaults[:defaults] if defaults.include?(:defaults) # Rails 5
|
13
11
|
if defaults[:controller] == controller_name && defaults[:action] == 'soap'
|
14
|
-
|
12
|
+
yield path+[x]
|
15
13
|
end
|
16
14
|
|
17
15
|
app = x.app
|
18
16
|
app = app.app if app.respond_to?(:app)
|
19
|
-
if app.
|
20
|
-
|
17
|
+
if app.respond_to?(:routes)
|
18
|
+
lookup_soap_routes(controller_name, app.routes.routes, path+[x], &block)
|
21
19
|
end
|
22
20
|
end
|
23
|
-
|
24
|
-
results
|
25
21
|
end
|
26
22
|
|
27
23
|
def self.url(request, controller_name)
|
28
|
-
|
29
|
-
|
30
|
-
path = if route.respond_to?(:optimized_path) # Rails 4
|
31
|
-
route.optimized_path
|
32
|
-
elsif route.path.respond_to?(:build_formatter) # Rails 5
|
33
|
-
route.path.build_formatter.evaluate(nil)
|
34
|
-
else
|
35
|
-
route.format({}) # Rails 3.2
|
36
|
-
end
|
24
|
+
lookup_soap_routes(controller_name, Rails.application.routes.routes) do |routes|
|
37
25
|
|
38
|
-
|
26
|
+
path = if routes.first.respond_to?(:optimized_path) # Rails 4
|
27
|
+
routes.map(&:optimized_path)
|
28
|
+
elsif routes.first.path.respond_to?(:build_formatter) # Rails 5
|
29
|
+
routes.map{|x| x.path.build_formatter.evaluate(nil)}
|
30
|
+
else
|
31
|
+
routes.map{|x| x.format({})} # Rails 3.2
|
32
|
+
end
|
39
33
|
|
40
|
-
|
34
|
+
return request.protocol + request.host_with_port + path.flatten.join('')
|
35
|
+
end
|
41
36
|
end
|
42
37
|
|
43
38
|
def initialize(controller_name)
|
@@ -123,7 +118,7 @@ module WashOut
|
|
123
118
|
'_invalid_action'
|
124
119
|
end
|
125
120
|
end
|
126
|
-
|
121
|
+
env["action_dispatch.request.content_type"] = Mime[:soap]
|
127
122
|
controller.action(action).call(env)
|
128
123
|
end
|
129
124
|
end
|
data/lib/wash_out/soap.rb
CHANGED
@@ -13,7 +13,15 @@ module WashOut
|
|
13
13
|
#
|
14
14
|
# An optional option :to can be passed to allow for names of SOAP actions
|
15
15
|
# which are not valid Ruby function names.
|
16
|
+
# There is also an optional :header_return option to specify the format of the
|
17
|
+
# SOAP response's header tag (<env:Header></env:Header>). If unspecified, there will
|
18
|
+
# be no header tag in the response.
|
16
19
|
def soap_action(action, options={})
|
20
|
+
if options[:as].present?
|
21
|
+
options[:to] ||= action
|
22
|
+
action = options[:as]
|
23
|
+
end
|
24
|
+
|
17
25
|
if action.is_a?(Symbol)
|
18
26
|
if soap_config.camelize_wsdl.to_s == 'lower'
|
19
27
|
options[:to] ||= action.to_s
|
@@ -28,10 +36,12 @@ module WashOut
|
|
28
36
|
default_response_tag = soap_config.camelize_wsdl ? 'Response' : '_response'
|
29
37
|
default_response_tag = action+default_response_tag
|
30
38
|
|
39
|
+
|
31
40
|
self.soap_actions[action] = options.merge(
|
32
41
|
:in => WashOut::Param.parse_def(soap_config, options[:args]),
|
33
42
|
:request_tag => options[:as] || action,
|
34
43
|
:out => WashOut::Param.parse_def(soap_config, options[:return]),
|
44
|
+
:header_out => options[:header_return].present? ? WashOut::Param.parse_def(soap_config, options[:header_return]) : nil,
|
35
45
|
:to => options[:to] || action,
|
36
46
|
:response_tag => options[:response_tag] || default_response_tag
|
37
47
|
)
|
data/lib/wash_out/version.rb
CHANGED
data/lib/wash_out.rb
CHANGED
@@ -44,7 +44,7 @@ ActionController::Renderers.add :soap do |what, options|
|
|
44
44
|
_render_soap(what, options)
|
45
45
|
end
|
46
46
|
|
47
|
-
ActionController::
|
47
|
+
ActionController::Metal.class_eval do
|
48
48
|
|
49
49
|
# Define a SOAP service. The function has no required +options+:
|
50
50
|
# but allow any of :parser, :namespace, :wsdl_style, :snakecase_input,
|
@@ -58,3 +58,17 @@ ActionController::Base.class_eval do
|
|
58
58
|
self.soap_config = options
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
62
|
+
if Rails::VERSION::MAJOR >= 5
|
63
|
+
module ActionController
|
64
|
+
module ApiRendering
|
65
|
+
include ActionView::Rendering
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
ActiveSupport.on_load :action_controller do
|
70
|
+
if self == ActionController::API
|
71
|
+
include ActionController::Helpers
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/spec/lib/wash_out_spec.rb
CHANGED
@@ -130,6 +130,37 @@ describe WashOut do
|
|
130
130
|
XML
|
131
131
|
end
|
132
132
|
|
133
|
+
it "accepts requests with no HTTP header with alias" do
|
134
|
+
mock_controller do
|
135
|
+
soap_action "answer", :as => 'whatever', :args => nil, :return => :int
|
136
|
+
def answer
|
137
|
+
render :soap => "42"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
request = <<-XML
|
142
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
143
|
+
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="false" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
|
144
|
+
<env:Body>
|
145
|
+
<tns:whatever>
|
146
|
+
<value>42</value>
|
147
|
+
</tns:whatever>
|
148
|
+
</env:Body>
|
149
|
+
</env:Envelope>
|
150
|
+
XML
|
151
|
+
|
152
|
+
expect(HTTPI.post("http://app/route/api/action", request).body).to eq <<-XML
|
153
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
154
|
+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="false">
|
155
|
+
<soap:Body>
|
156
|
+
<tns:whateverResponse>
|
157
|
+
<Value xsi:type="xsd:int">42</Value>
|
158
|
+
</tns:whateverResponse>
|
159
|
+
</soap:Body>
|
160
|
+
</soap:Envelope>
|
161
|
+
XML
|
162
|
+
end
|
163
|
+
|
133
164
|
it "accept no parameters" do
|
134
165
|
mock_controller do
|
135
166
|
soap_action "answer", :args => nil, :return => :int
|
@@ -313,10 +344,10 @@ describe WashOut do
|
|
313
344
|
|
314
345
|
expect(savon(:gogogo)[:gogogo_response]).
|
315
346
|
to eq({
|
316
|
-
:zoo=>"zoo",
|
347
|
+
:zoo=>"zoo",
|
317
348
|
:boo=>{
|
318
|
-
:moo=>"moo",
|
319
|
-
:doo=>"doo",
|
349
|
+
:moo=>"moo",
|
350
|
+
:doo=>"doo",
|
320
351
|
:"@xsi:type"=>"tns:Boo"
|
321
352
|
}
|
322
353
|
})
|
@@ -459,6 +490,175 @@ describe WashOut do
|
|
459
490
|
end
|
460
491
|
end
|
461
492
|
|
493
|
+
context "SOAP header" do
|
494
|
+
it "accepts requests with a simple header" do
|
495
|
+
mock_controller do
|
496
|
+
soap_action "answer", :args => nil, :return => :int, :header_args => :string
|
497
|
+
def answer
|
498
|
+
render :soap => "42"
|
499
|
+
end
|
500
|
+
end
|
501
|
+
|
502
|
+
request = <<-XML
|
503
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
504
|
+
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="false" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
|
505
|
+
<env:Header>
|
506
|
+
<tns:Auth>
|
507
|
+
<value>12345</value>
|
508
|
+
</tns:Auth>
|
509
|
+
</env:Header>
|
510
|
+
<env:Body>
|
511
|
+
<tns:answer>
|
512
|
+
<value>42</value>
|
513
|
+
</tns:answer>
|
514
|
+
</env:Body>
|
515
|
+
</env:Envelope>
|
516
|
+
XML
|
517
|
+
|
518
|
+
expect(HTTPI.post("http://app/route/api/action", request).body).to eq <<-XML
|
519
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
520
|
+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="false">
|
521
|
+
<soap:Body>
|
522
|
+
<tns:answerResponse>
|
523
|
+
<Value xsi:type="xsd:int">42</Value>
|
524
|
+
</tns:answerResponse>
|
525
|
+
</soap:Body>
|
526
|
+
</soap:Envelope>
|
527
|
+
XML
|
528
|
+
end
|
529
|
+
|
530
|
+
it "makes simple header values accessible" do
|
531
|
+
mock_controller do
|
532
|
+
soap_action "answer", :args => nil, :return => :int
|
533
|
+
def answer
|
534
|
+
expect(soap_request.headers).to eq({value: "12345"})
|
535
|
+
render :soap => "42"
|
536
|
+
end
|
537
|
+
end
|
538
|
+
|
539
|
+
request = <<-XML
|
540
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
541
|
+
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="false" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
|
542
|
+
<env:Header>
|
543
|
+
<value>12345</value>
|
544
|
+
</env:Header>
|
545
|
+
<env:Body>
|
546
|
+
<tns:answer>
|
547
|
+
<value>42</value>
|
548
|
+
</tns:answer>
|
549
|
+
</env:Body>
|
550
|
+
</env:Envelope>
|
551
|
+
XML
|
552
|
+
|
553
|
+
HTTPI.post("http://app/route/api/action", request)
|
554
|
+
|
555
|
+
end
|
556
|
+
|
557
|
+
it "makes complex header values accessible" do
|
558
|
+
mock_controller do
|
559
|
+
soap_action "answer", :args => nil, :return => :int
|
560
|
+
def answer
|
561
|
+
expect(soap_request.headers[:auth][:answer_response]).to eq "12345"
|
562
|
+
render :soap => "42"
|
563
|
+
end
|
564
|
+
end
|
565
|
+
|
566
|
+
request = <<-XML
|
567
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
568
|
+
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="false" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
|
569
|
+
<env:Header>
|
570
|
+
<Auth>
|
571
|
+
<AnswerResponse>12345</AnswerResponse>
|
572
|
+
</Auth>
|
573
|
+
</env:Header>
|
574
|
+
<env:Body>
|
575
|
+
<tns:answer>
|
576
|
+
<value>42</value>
|
577
|
+
</tns:answer>
|
578
|
+
</env:Body>
|
579
|
+
</env:Envelope>
|
580
|
+
XML
|
581
|
+
|
582
|
+
HTTPI.post("http://app/route/api/action", request)
|
583
|
+
|
584
|
+
end
|
585
|
+
|
586
|
+
it "renders a simple header if specified" do
|
587
|
+
mock_controller do
|
588
|
+
soap_action "answer", :args => nil, :return => :int, header_return: :string
|
589
|
+
def answer
|
590
|
+
render :soap => "42", :header => "12345"
|
591
|
+
end
|
592
|
+
end
|
593
|
+
|
594
|
+
|
595
|
+
request = <<-XML
|
596
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
597
|
+
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="false" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
|
598
|
+
<env:Body>
|
599
|
+
<tns:answer>
|
600
|
+
<value>42</value>
|
601
|
+
</tns:answer>
|
602
|
+
</env:Body>
|
603
|
+
</env:Envelope>
|
604
|
+
XML
|
605
|
+
|
606
|
+
expect(HTTPI.post("http://app/route/api/action", request).body).to eq <<-XML
|
607
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
608
|
+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="false">
|
609
|
+
<soap:Header>
|
610
|
+
<tns:answerResponse>
|
611
|
+
<Value xsi:type="xsd:string">12345</Value>
|
612
|
+
</tns:answerResponse>
|
613
|
+
</soap:Header>
|
614
|
+
<soap:Body>
|
615
|
+
<tns:answerResponse>
|
616
|
+
<Value xsi:type="xsd:int">42</Value>
|
617
|
+
</tns:answerResponse>
|
618
|
+
</soap:Body>
|
619
|
+
</soap:Envelope>
|
620
|
+
XML
|
621
|
+
end
|
622
|
+
end
|
623
|
+
|
624
|
+
it "renders a complex header if specified" do
|
625
|
+
mock_controller do
|
626
|
+
soap_action "answer", :args => nil, :return => :int, header_return: {:"Auth" => :string}
|
627
|
+
def answer
|
628
|
+
render :soap => "42", :header => {Auth: "12345"}
|
629
|
+
end
|
630
|
+
end
|
631
|
+
|
632
|
+
|
633
|
+
request = <<-XML
|
634
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
635
|
+
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="false" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
|
636
|
+
<env:Body>
|
637
|
+
<tns:answer>
|
638
|
+
<value>42</value>
|
639
|
+
</tns:answer>
|
640
|
+
</env:Body>
|
641
|
+
</env:Envelope>
|
642
|
+
XML
|
643
|
+
|
644
|
+
expect(HTTPI.post("http://app/route/api/action", request).body).to eq <<-XML
|
645
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
646
|
+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="false">
|
647
|
+
<soap:Header>
|
648
|
+
<tns:answerResponse>
|
649
|
+
<Auth xsi:type="xsd:string">12345</Auth>
|
650
|
+
</tns:answerResponse>
|
651
|
+
</soap:Header>
|
652
|
+
<soap:Body>
|
653
|
+
<tns:answerResponse>
|
654
|
+
<Value xsi:type="xsd:int">42</Value>
|
655
|
+
</tns:answerResponse>
|
656
|
+
</soap:Body>
|
657
|
+
</soap:Envelope>
|
658
|
+
XML
|
659
|
+
end
|
660
|
+
|
661
|
+
|
462
662
|
context "types" do
|
463
663
|
it "recognize boolean" do
|
464
664
|
mock_controller do
|
@@ -680,7 +880,7 @@ describe WashOut do
|
|
680
880
|
response_hash = Nori.new.parse(HTTPI.post("http://app/route/api/action", invalid_request).body)
|
681
881
|
expect(response_hash["soap:Envelope"]["soap:Body"]["soap:Fault"]['faultstring']).to eq "Invalid SOAP request"
|
682
882
|
end
|
683
|
-
|
883
|
+
|
684
884
|
it "raises when SOAP message without SOAP Body arrives" do
|
685
885
|
mock_controller do; end
|
686
886
|
invalid_request = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"></s:Envelope>'
|
@@ -762,7 +962,7 @@ describe WashOut do
|
|
762
962
|
it "handles auth callback" do
|
763
963
|
mock_controller(
|
764
964
|
wsse_auth_callback: lambda {|user, password|
|
765
|
-
return user == "gorilla" && password == "secret"
|
965
|
+
return user == "gorilla" && password == "secret"
|
766
966
|
}
|
767
967
|
) do
|
768
968
|
soap_action "checkAuth", :args => :integer, :return => :boolean, :to => 'check_auth'
|
data/spec/spec_helper.rb
CHANGED
@@ -24,6 +24,8 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
|
24
24
|
RSpec.configure do |config|
|
25
25
|
require 'rspec/expectations'
|
26
26
|
config.include RSpec::Matchers
|
27
|
+
config.filter_run focus: true
|
28
|
+
config.run_all_when_everything_filtered = true
|
27
29
|
|
28
30
|
config.mock_with :rspec
|
29
31
|
config.before(:all) do
|
@@ -63,7 +65,7 @@ def mock_controller(options = {}, &block)
|
|
63
65
|
Route::Space.send :remove_const, :ApiController if defined?(Route::Space::ApiController)
|
64
66
|
Route::Space.send :const_set, :ApiController, Class.new(ApplicationController) {
|
65
67
|
include RSpec::Matchers
|
66
|
-
|
68
|
+
|
67
69
|
soap_service options.reverse_merge({
|
68
70
|
snakecase_input: true,
|
69
71
|
camelize_wsdl: true,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wash_out
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.0
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boris Staal
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-12-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nori
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- gemfiles/rails_4.1.0.gemfile
|
54
54
|
- gemfiles/rails_4.2.0.gemfile
|
55
55
|
- gemfiles/rails_5.0.0.beta2.gemfile
|
56
|
+
- gemfiles/rails_5.0.0.gemfile
|
56
57
|
- init.rb
|
57
58
|
- lib/wash_out.rb
|
58
59
|
- lib/wash_out/configurable.rb
|
@@ -117,9 +118,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
117
118
|
version: '0'
|
118
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
120
|
requirements:
|
120
|
-
- - "
|
121
|
+
- - ">="
|
121
122
|
- !ruby/object:Gem::Version
|
122
|
-
version:
|
123
|
+
version: '0'
|
123
124
|
requirements: []
|
124
125
|
rubyforge_project:
|
125
126
|
rubygems_version: 2.5.1
|