wash_out 0.9.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +23 -4
- data/Appraisals +2 -4
- data/Gemfile +1 -1
- data/README.md +38 -0
- data/Rakefile +6 -7
- data/app/helpers/wash_out_helper.rb +49 -18
- data/app/views/{wash_with_soap → wash_out}/document/error.builder +0 -0
- data/app/views/{wash_with_soap → wash_out}/document/response.builder +0 -0
- data/app/views/{wash_with_soap → wash_out}/document/wsdl.builder +13 -13
- data/app/views/{wash_with_soap → wash_out}/rpc/error.builder +0 -0
- data/app/views/{wash_with_soap → wash_out}/rpc/response.builder +0 -0
- data/app/views/{wash_with_soap → wash_out}/rpc/wsdl.builder +14 -14
- data/gemfiles/rails_3.1.3.gemfile +20 -0
- data/gemfiles/rails_3.2.12.gemfile +20 -0
- data/gemfiles/rails_4.0.0.gemfile +19 -0
- data/gemfiles/rails_4.1.0.gemfile +19 -0
- data/gemfiles/rails_4.2.0.gemfile +19 -0
- data/lib/wash_out/dispatcher.rb +28 -18
- data/lib/wash_out/param.rb +14 -2
- data/lib/wash_out/router.rb +5 -5
- data/lib/wash_out/soap.rb +1 -0
- data/lib/wash_out/version.rb +1 -1
- data/lib/wash_out/wsse.rb +3 -3
- data/lib/wash_out.rb +6 -0
- data/spec/dummy/config/environments/test.rb +1 -0
- data/spec/lib/wash_out/dispatcher_spec.rb +15 -15
- data/spec/lib/wash_out/middleware_spec.rb +8 -8
- data/spec/lib/wash_out/param_spec.rb +43 -11
- data/spec/lib/wash_out/type_spec.rb +9 -9
- data/spec/lib/wash_out_spec.rb +111 -96
- data/spec/spec_helper.rb +2 -0
- metadata +14 -9
@@ -13,19 +13,19 @@ describe WashOut::Dispatcher do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "finds nested hashes" do
|
16
|
-
WashOut::Dispatcher.deep_select(:foo => 1){|k,v| k == :foo}.
|
17
|
-
WashOut::Dispatcher.deep_select({:foo => {:foo => 1}}){|k,v| k == :foo}.
|
16
|
+
expect(WashOut::Dispatcher.deep_select(:foo => 1){|k,v| k == :foo}).to eq [1]
|
17
|
+
expect(WashOut::Dispatcher.deep_select({:foo => {:foo => 1}}){|k,v| k == :foo}).to eq([{:foo => 1}, 1])
|
18
18
|
end
|
19
19
|
|
20
20
|
it "replaces nested hashed" do
|
21
|
-
WashOut::Dispatcher.deep_replace_href({:foo => {:@href => 1}}, {1 => 2}).
|
22
|
-
WashOut::Dispatcher.deep_replace_href({:bar => {:foo => {:@href => 1}}}, {1 => 2}).
|
21
|
+
expect(WashOut::Dispatcher.deep_replace_href({:foo => {:@href => 1}}, {1 => 2})).to eq({:foo => 2})
|
22
|
+
expect(WashOut::Dispatcher.deep_replace_href({:bar => {:foo => {:@href => 1}}}, {1 => 2})).to eq({:bar => {:foo => 2}})
|
23
23
|
end
|
24
24
|
|
25
25
|
xit "parses typical request" do
|
26
26
|
dispatcher = Dispatcher.mock("<foo>1</foo>")
|
27
27
|
dispatcher._parse_soap_parameters
|
28
|
-
dispatcher.params.
|
28
|
+
expect(dispatcher.params).to eq({:foo => "1"})
|
29
29
|
end
|
30
30
|
|
31
31
|
xit "parses href request" do
|
@@ -45,11 +45,11 @@ describe WashOut::Dispatcher do
|
|
45
45
|
</root>
|
46
46
|
XML
|
47
47
|
dispatcher._parse_soap_parameters
|
48
|
-
dispatcher.params[:root][:request][:entities].
|
48
|
+
expect(dispatcher.params[:root][:request][:entities]).to eq({
|
49
49
|
:foo => {:bar=>"1"},
|
50
50
|
:sub => {:foo=>"1", :@id=>"id2"},
|
51
51
|
:@id => "id1"
|
52
|
-
}
|
52
|
+
})
|
53
53
|
end
|
54
54
|
|
55
55
|
describe "#_map_soap_parameters" do
|
@@ -57,13 +57,13 @@ describe WashOut::Dispatcher do
|
|
57
57
|
let(:soap_config) { WashOut::SoapConfig.new(camelize_wsdl: false) }
|
58
58
|
|
59
59
|
before do
|
60
|
-
allow(dispatcher).to receive(:action_spec).and_return(in: WashOut::Param.parse_def(soap_config, {:
|
61
|
-
allow(dispatcher).to receive(:xml_data).and_return(:
|
60
|
+
allow(dispatcher).to receive(:action_spec).and_return(in: WashOut::Param.parse_def(soap_config, { foo: { "@bar" => :string, empty: :string } } ))
|
61
|
+
allow(dispatcher).to receive(:xml_data).and_return(foo: { "@bar" => "buzz", empty: { :"@xsi:type" => "xsd:string" } })
|
62
62
|
end
|
63
63
|
|
64
|
-
it "should handle empty strings that have been parsed wrong by nori" do
|
64
|
+
it "should handle empty strings that have been parsed wrong by nori, but preserve attrs" do
|
65
65
|
dispatcher._map_soap_parameters
|
66
|
-
expect(dispatcher.params).to eq(
|
66
|
+
expect(dispatcher.params).to eq("foo" => { "bar" => "buzz", "empty" => nil })
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -73,25 +73,25 @@ describe WashOut::Dispatcher do
|
|
73
73
|
it "should load params for an array" do
|
74
74
|
spec = WashOut::Param.parse_def(soap_config, {:my_array => [:integer] } )
|
75
75
|
xml_data = {:my_array => [1, 2, 3]}
|
76
|
-
dispatcher._load_params(spec, xml_data).
|
76
|
+
expect(dispatcher._load_params(spec, xml_data)).to eq({"my_array" => [1, 2, 3]})
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should load params for an empty array" do
|
80
80
|
spec = WashOut::Param.parse_def(soap_config, {:my_array => [:integer] } )
|
81
81
|
xml_data = {}
|
82
|
-
dispatcher._load_params(spec, xml_data).
|
82
|
+
expect(dispatcher._load_params(spec, xml_data)).to eq({})
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should load params for a nested array" do
|
86
86
|
spec = WashOut::Param.parse_def(soap_config, {:nested => {:my_array => [:integer]}} )
|
87
87
|
xml_data = {:nested => {:my_array => [1, 2, 3]}}
|
88
|
-
dispatcher._load_params(spec, xml_data).
|
88
|
+
expect(dispatcher._load_params(spec, xml_data)).to eq({"nested" => {"my_array" => [1, 2, 3]}})
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should load params for an empty nested array" do
|
92
92
|
spec = WashOut::Param.parse_def(soap_config, {:nested => {:empty => [:integer] }} )
|
93
93
|
xml_data = {:nested => nil}
|
94
|
-
dispatcher._load_params(spec, xml_data).
|
94
|
+
expect(dispatcher._load_params(spec, xml_data)).to eq({"nested" => {}})
|
95
95
|
end
|
96
96
|
|
97
97
|
end
|
@@ -11,23 +11,23 @@ describe WashOut::Middleware do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
env = {}
|
14
|
-
|
14
|
+
expect {
|
15
15
|
WashOut::Middleware.raise_or_render_rexml_parse_error err, env
|
16
|
-
}.
|
16
|
+
}.to raise_exception(REXML::ParseException)
|
17
17
|
|
18
18
|
env['HTTP_SOAPACTION'] = 'pretend_action'
|
19
19
|
env['rack.errors'] = double 'logger', {:puts => true}
|
20
20
|
env['rack.input'] = double 'basic-rack-input', {:string => '<hi>'}
|
21
21
|
result = WashOut::Middleware.raise_or_render_rexml_parse_error err, env
|
22
|
-
result[0].
|
23
|
-
result[1]['Content-Type'].
|
22
|
+
expect(result[0]).to eq 400
|
23
|
+
expect(result[1]['Content-Type']).to eq 'text/xml'
|
24
24
|
msg = result[2][0]
|
25
|
-
msg.
|
26
|
-
msg.
|
27
|
-
msg.
|
25
|
+
expect(msg).to include 'Error parsing SOAP Request XML'
|
26
|
+
expect(msg).to include 'soap:Fault'
|
27
|
+
expect(msg).not_to include __FILE__
|
28
28
|
|
29
29
|
env['rack.input'] = double 'passenger-input', {:read => '<hi>'}
|
30
30
|
result = WashOut::Middleware.raise_or_render_rexml_parse_error err, env
|
31
|
-
result[0].
|
31
|
+
expect(result[0]).to eq 400
|
32
32
|
end
|
33
33
|
end
|
@@ -21,9 +21,9 @@ describe WashOut::Param do
|
|
21
21
|
soap_config = WashOut::SoapConfig.new({ camelize_wsdl: false })
|
22
22
|
map = WashOut::Param.parse_def soap_config, Abraka2
|
23
23
|
|
24
|
-
map.
|
25
|
-
map[0].name.
|
26
|
-
map[0].map[0].name.
|
24
|
+
expect(map).to be_a_kind_of(Array)
|
25
|
+
expect(map[0].name).to eq 'foo'
|
26
|
+
expect(map[0].map[0].name).to eq 'test'
|
27
27
|
end
|
28
28
|
|
29
29
|
it "respects camelization setting" do
|
@@ -31,16 +31,16 @@ describe WashOut::Param do
|
|
31
31
|
|
32
32
|
map = WashOut::Param.parse_def soap_config, Abraka2
|
33
33
|
|
34
|
-
map.
|
35
|
-
map[0].name.
|
36
|
-
map[0].map[0].name.
|
34
|
+
expect(map).to be_a_kind_of(Array)
|
35
|
+
expect(map[0].name).to eq 'Foo'
|
36
|
+
expect(map[0].map[0].name).to eq 'Test'
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should accept nested empty arrays" do
|
41
41
|
soap_config = WashOut::SoapConfig.new({ camelize_wsdl: false })
|
42
42
|
map = WashOut::Param.parse_def(soap_config, {:nested => {:some_attr => :string, :empty => [:integer] }} )
|
43
|
-
map[0].load( {:nested => nil}, :nested).
|
43
|
+
expect(map[0].load( {:nested => nil}, :nested)).to eq({})
|
44
44
|
end
|
45
45
|
|
46
46
|
describe "booleans" do
|
@@ -50,13 +50,45 @@ describe WashOut::Param do
|
|
50
50
|
let(:map) { WashOut::Param.parse_def(soap_config, :value => :boolean) }
|
51
51
|
|
52
52
|
it "should accept 'true' and '1'" do
|
53
|
-
map[0].load({:value => true}, :value).
|
54
|
-
map[0].load({:value => "1"}, :value).
|
53
|
+
expect(map[0].load({:value => true}, :value)).to be true
|
54
|
+
expect(map[0].load({:value => "1"}, :value)).to be true
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should accept 'false' and '0'" do
|
58
|
-
map[0].load({:value => false}, :value).
|
59
|
-
map[0].load({:value => "0"}, :value).
|
58
|
+
expect(map[0].load({:value => false}, :value)).to be false
|
59
|
+
expect(map[0].load({:value => "0"}, :value)).to be false
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe 'longs' do
|
64
|
+
let(:soap_config) { WashOut::SoapConfig.new({ camelize_wsdl: false }) }
|
65
|
+
let(:map) { WashOut::Param.parse_def(soap_config, :value => :long) }
|
66
|
+
|
67
|
+
it "should accept positive long" do
|
68
|
+
expect(map[0].load({:value => 9223372036854775807}, :value)).to eq 9223372036854775807
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should accept negative long" do
|
72
|
+
expect(map[0].load({:value => -9223372036854775807}, :value)).to eq -9223372036854775807
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#flat_copy' do
|
77
|
+
it 'should copy everything' do
|
78
|
+
soap_config = WashOut::SoapConfig.new({})
|
79
|
+
type = :foo
|
80
|
+
multiplied = "of course"
|
81
|
+
|
82
|
+
param = WashOut::Param.new(soap_config, 'name', type, multiplied)
|
83
|
+
param.source_class = "middle class"
|
84
|
+
evil_clone = param.flat_copy
|
85
|
+
|
86
|
+
expect(evil_clone.source_class).to eq "middle class"
|
87
|
+
expect(evil_clone.name).to eq 'name'
|
88
|
+
expect(evil_clone.raw_name).to eq 'name'
|
89
|
+
expect(evil_clone.type).to eq "foo"
|
90
|
+
expect(evil_clone.multiplied).to eq "of course"
|
91
|
+
expect(evil_clone.soap_config).to eq soap_config
|
60
92
|
end
|
61
93
|
end
|
62
94
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#encoding:utf-8
|
1
|
+
#encoding:utf-8
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
@@ -15,11 +15,11 @@ describe WashOut::Type do
|
|
15
15
|
map :foo => Abraka1
|
16
16
|
end
|
17
17
|
|
18
|
-
Abraka1.wash_out_param_name.
|
19
|
-
Abraka1.wash_out_param_map.
|
18
|
+
expect(Abraka1.wash_out_param_name).to eq 'abraka1'
|
19
|
+
expect(Abraka1.wash_out_param_map).to eq({:test => :string})
|
20
20
|
|
21
|
-
Abraka2.wash_out_param_name.
|
22
|
-
Abraka2.wash_out_param_map.
|
21
|
+
expect(Abraka2.wash_out_param_name).to eq 'test'
|
22
|
+
expect(Abraka2.wash_out_param_map).to eq({:foo => Abraka1})
|
23
23
|
end
|
24
24
|
|
25
25
|
it "allows arrays inside custom types" do
|
@@ -31,11 +31,11 @@ describe WashOut::Type do
|
|
31
31
|
map :foo => [:bar => Abraka1]
|
32
32
|
end
|
33
33
|
|
34
|
-
Abraka1.wash_out_param_name.
|
35
|
-
Abraka1.wash_out_param_map.
|
34
|
+
expect(Abraka1.wash_out_param_name).to eq 'abraka1'
|
35
|
+
expect(Abraka1.wash_out_param_map).to eq({:test => :string})
|
36
36
|
|
37
|
-
Abraka2.wash_out_param_name.
|
38
|
-
Abraka2.wash_out_param_map.
|
37
|
+
expect(Abraka2.wash_out_param_name).to eq 'test'
|
38
|
+
expect(Abraka2.wash_out_param_map).to eq({:foo => [:bar => Abraka1]})
|
39
39
|
end
|
40
40
|
|
41
41
|
end
|