savon 2.11.0 → 2.11.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +12 -3
- data/CHANGELOG.md +13 -0
- data/Gemfile +1 -7
- data/README.md +5 -5
- data/lib/savon/builder.rb +32 -6
- data/lib/savon/client.rb +1 -2
- data/lib/savon/header.rb +2 -2
- data/lib/savon/log_message.rb +1 -1
- data/lib/savon/mock/expectation.rb +11 -2
- data/lib/savon/operation.rb +9 -2
- data/lib/savon/options.rb +33 -17
- data/lib/savon/qualified_message.rb +29 -28
- data/lib/savon/request.rb +4 -3
- data/lib/savon/response.rb +6 -5
- data/lib/savon/soap_fault.rb +1 -1
- data/lib/savon/version.rb +1 -1
- data/savon.gemspec +0 -1
- data/spec/fixtures/wsdl/brand.xml +624 -0
- data/spec/integration/random_quote_spec.rb +1 -1
- data/spec/integration/stockquote_example_spec.rb +6 -0
- data/spec/savon/builder_spec.rb +13 -4
- data/spec/savon/log_message_spec.rb +7 -1
- data/spec/savon/mock_spec.rb +11 -0
- data/spec/savon/options_spec.rb +21 -1
- data/spec/savon/qualified_message_spec.rb +53 -5
- data/spec/savon/soap_fault_spec.rb +5 -0
- data/spec/savon/softlayer_spec.rb +27 -0
- metadata +5 -17
@@ -16,7 +16,7 @@ describe 'rpc/encoded binding test' do
|
|
16
16
|
$stderr.puts e.to_hash.inspect
|
17
17
|
f_c = e.to_hash[:fault][:faultstring]
|
18
18
|
expect(f_c).not_to eq('No such operation \'getQuoteRequest\'')
|
19
|
-
expect(f_c).to eq('
|
19
|
+
expect(f_c).to eq('lucee.runtime.exp.DatabaseException: ')
|
20
20
|
pending e
|
21
21
|
end
|
22
22
|
end
|
@@ -19,6 +19,12 @@ describe "Stockquote example" do
|
|
19
19
|
|
20
20
|
cdata = response.body[:get_quote_response][:get_quote_result]
|
21
21
|
|
22
|
+
if cdata == "exception"
|
23
|
+
# Fallback to not fail the specs when the service's API limit is reached,
|
24
|
+
# but to mark the spec as pending instead.
|
25
|
+
pending "Exception on API"
|
26
|
+
end
|
27
|
+
|
22
28
|
nori_options = { :convert_tags_to => lambda { |tag| tag.snakecase.to_sym } }
|
23
29
|
result = Nori.new(nori_options).parse(cdata)
|
24
30
|
|
data/spec/savon/builder_spec.rb
CHANGED
@@ -83,10 +83,19 @@ describe Savon::Builder do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
describe "#wsse_signature" do
|
86
|
-
|
87
|
-
|
88
|
-
let(:
|
89
|
-
let(:
|
86
|
+
fixture_dir = File.join(File.dirname(__FILE__), '..', 'fixtures', 'ssl')
|
87
|
+
|
88
|
+
let(:cert) { File.join(fixture_dir, 'client_cert.pem') }
|
89
|
+
let(:private_key) { File.join(fixture_dir, 'client_key.pem') }
|
90
|
+
let(:signature) do
|
91
|
+
Akami::WSSE::Signature.new(
|
92
|
+
Akami::WSSE::Certs.new(
|
93
|
+
:cert_file => cert,
|
94
|
+
:private_key_file => private_key
|
95
|
+
)
|
96
|
+
)
|
97
|
+
end
|
98
|
+
let(:globals) { Savon::GlobalOptions.new(wsse_signature: signature) }
|
90
99
|
|
91
100
|
subject(:signed_message_nn) {Nokogiri::XML(builder.to_s).remove_namespaces!}
|
92
101
|
subject(:signed_message) {Nokogiri::XML(builder.to_s)}
|
@@ -21,9 +21,15 @@ describe Savon::LogMessage do
|
|
21
21
|
expect(message).to include("\n <body>")
|
22
22
|
end
|
23
23
|
|
24
|
-
it "filters tags in a given message" do
|
24
|
+
it "filters tags in a given message without pretty printing" do
|
25
25
|
message = log_message("<root><password>secret</password></root>", [:password], false).to_s
|
26
26
|
expect(message).to include("<password>***FILTERED***</password>")
|
27
|
+
expect(message).to_not include("\n <password>***FILTERED***</password>") # no pretty printing
|
28
|
+
end
|
29
|
+
|
30
|
+
it "filters tags in a given message with pretty printing" do
|
31
|
+
message = log_message("<root><password>secret</password></root>", [:password], true).to_s
|
32
|
+
expect(message).to include("\n <password>***FILTERED***</password>")
|
27
33
|
end
|
28
34
|
|
29
35
|
it "properly applies Proc filter" do
|
data/spec/savon/mock_spec.rb
CHANGED
@@ -23,6 +23,17 @@ describe "Savon's mock interface" do
|
|
23
23
|
expect(response.http.body).to eq("<fixture/>")
|
24
24
|
end
|
25
25
|
|
26
|
+
it "can verify a request with any parameters and return a fixture response" do
|
27
|
+
message = { :username => "luke", :password => :any }
|
28
|
+
savon.expects(:authenticate).with(:message => message).returns("<fixture/>")
|
29
|
+
|
30
|
+
response = new_client.call(:authenticate) do
|
31
|
+
message(:username => "luke", :password => "secret")
|
32
|
+
end
|
33
|
+
|
34
|
+
expect(response.http.body).to eq("<fixture/>")
|
35
|
+
end
|
36
|
+
|
26
37
|
it "accepts a Hash to specify the response code, headers and body" do
|
27
38
|
soap_fault = Fixture.response(:soap_fault)
|
28
39
|
response = { :code => 500, :headers => { "X-Result" => "invalid" }, :body => soap_fault }
|
data/spec/savon/options_spec.rb
CHANGED
@@ -114,6 +114,15 @@ describe "Options" do
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
+
context "global :host" do
|
118
|
+
it "overrides the WSDL endpoint host" do
|
119
|
+
client = new_client(:wsdl => Fixture.wsdl(:no_message_tag), host: "https://example.com:8080")
|
120
|
+
|
121
|
+
request = client.build_request(:update_orders)
|
122
|
+
expect(request.url.to_s).to eq "https://example.com:8080/webserviceexternal/contracts.asmx"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
117
126
|
context "global :headers" do
|
118
127
|
it "sets the HTTP headers for the next request" do
|
119
128
|
client = new_client(:endpoint => @server.url(:inspect_request), :headers => { "X-Token" => "secret" })
|
@@ -578,7 +587,7 @@ describe "Options" do
|
|
578
587
|
expect(request).to include("<wsse:Username>#{username}</wsse:Username>")
|
579
588
|
|
580
589
|
# the nonce node
|
581
|
-
expect(request).to match(/<wsse:Nonce.*>.+\n
|
590
|
+
expect(request).to match(/<wsse:Nonce.*>.+\n?<\/wsse:Nonce>/)
|
582
591
|
|
583
592
|
# the created node with a timestamp
|
584
593
|
expect(request).to match(/<wsu:Created>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.*<\/wsu:Created>/)
|
@@ -1037,6 +1046,17 @@ describe "Options" do
|
|
1037
1046
|
end
|
1038
1047
|
end
|
1039
1048
|
|
1049
|
+
context "request :headers" do
|
1050
|
+
it "sets headers" do
|
1051
|
+
client = new_client(:endpoint => @server.url(:inspect_request))
|
1052
|
+
|
1053
|
+
response = client.call(:authenticate, :headers => { "X-Token" => "secret" })
|
1054
|
+
x_token = inspect_request(response).x_token
|
1055
|
+
|
1056
|
+
expect(x_token).to eq("secret")
|
1057
|
+
end
|
1058
|
+
end
|
1059
|
+
|
1040
1060
|
def new_client(globals = {}, &block)
|
1041
1061
|
globals = { :wsdl => Fixture.wsdl(:authentication), :log => false }.merge(globals)
|
1042
1062
|
Savon.client(globals, &block)
|
@@ -4,15 +4,63 @@ module Savon
|
|
4
4
|
describe QualifiedMessage, "#to_hash" do
|
5
5
|
|
6
6
|
context "if a key ends with !" do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
types = {}
|
7
|
+
let(:used_namespaces) { {} }
|
8
|
+
let(:key_converter) { :camelcase }
|
9
|
+
let(:types) { {} }
|
11
10
|
|
11
|
+
it "restores the ! in a key" do
|
12
12
|
message = described_class.new(types, used_namespaces, key_converter)
|
13
13
|
resulting_hash = message.to_hash({:Metal! => "<Nice/>"}, ["Rock"])
|
14
14
|
|
15
|
-
expect(resulting_hash).to eq({
|
15
|
+
expect(resulting_hash).to eq({ :Metal! => "<Nice/>" })
|
16
|
+
end
|
17
|
+
|
18
|
+
it "properly handles special keys when namespaces are present" do
|
19
|
+
used_namespaces = {
|
20
|
+
%w(tns Foo) => 'ns',
|
21
|
+
%w(tns Foo Bar) => 'ns'
|
22
|
+
}
|
23
|
+
|
24
|
+
hash = {
|
25
|
+
:foo => {
|
26
|
+
:bar => {
|
27
|
+
:zing => 'pow'
|
28
|
+
},
|
29
|
+
:cash => {
|
30
|
+
:@attr1 => 'val1',
|
31
|
+
:content! => 'Chunky Bacon'
|
32
|
+
},
|
33
|
+
:attributes! => {
|
34
|
+
:bar => { :attr2 => 'val2' },
|
35
|
+
},
|
36
|
+
:"self_closing/" => '',
|
37
|
+
:order! => [:cash, :bar, :"self_closing/"]
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
good_result = {
|
42
|
+
"ns:Foo" => {
|
43
|
+
'ns:Bar' => { :zing => "pow" },
|
44
|
+
:cash => {
|
45
|
+
:@attr1 => "val1",
|
46
|
+
:content! => "Chunky Bacon"
|
47
|
+
},
|
48
|
+
:attributes! => {
|
49
|
+
'ns:Bar' => { :attr2 => 'val2' }
|
50
|
+
},
|
51
|
+
:"self_closing/" => '',
|
52
|
+
:order! => [:cash, 'ns:Bar', :"self_closing/"]
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
good_xml = %(<ns:Foo><Cash attr1="val1">Chunky Bacon</Cash><ns:Bar attr2="val2"><Zing>pow</Zing></ns:Bar><SelfClosing/></ns:Foo>)
|
57
|
+
|
58
|
+
message = described_class.new(types, used_namespaces, key_converter)
|
59
|
+
resulting_hash = message.to_hash(hash, ['tns'])
|
60
|
+
xml = Gyoku.xml(resulting_hash, key_converter: key_converter)
|
61
|
+
|
62
|
+
expect(resulting_hash).to eq good_result
|
63
|
+
expect(xml).to eq good_xml
|
16
64
|
end
|
17
65
|
end
|
18
66
|
|
@@ -7,6 +7,7 @@ describe Savon::SOAPFault do
|
|
7
7
|
let(:soap_fault_nc) { Savon::SOAPFault.new new_response(:body => Fixture.response(:soap_fault)), nori_no_convert }
|
8
8
|
let(:soap_fault_nc2) { Savon::SOAPFault.new new_response(:body => Fixture.response(:soap_fault12)), nori_no_convert }
|
9
9
|
let(:another_soap_fault) { Savon::SOAPFault.new new_response(:body => Fixture.response(:another_soap_fault)), nori }
|
10
|
+
let(:soap_fault_no_body) { Savon::SOAPFault.new new_response(:body => {}), nori }
|
10
11
|
let(:no_fault) { Savon::SOAPFault.new new_response, nori }
|
11
12
|
|
12
13
|
let(:nori) { Nori.new(:strip_namespaces => true, :convert_tags_to => lambda { |tag| tag.snakecase.to_sym }) }
|
@@ -119,6 +120,10 @@ describe Savon::SOAPFault do
|
|
119
120
|
|
120
121
|
expect(soap_fault_nc2.to_hash).to eq(expected)
|
121
122
|
end
|
123
|
+
|
124
|
+
it "returns empty hash" do
|
125
|
+
expect(soap_fault_no_body.to_hash).to eq({})
|
126
|
+
end
|
122
127
|
end
|
123
128
|
|
124
129
|
def new_response(options = {})
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Savon::Builder do
|
4
|
+
|
5
|
+
subject(:builder) { Savon::Builder.new(:create_object, wsdl, globals, locals) }
|
6
|
+
|
7
|
+
let(:globals) { Savon::GlobalOptions.new }
|
8
|
+
# let(:locals) { Savon::LocalOptions.new }
|
9
|
+
let(:wsdl) { Wasabi::Document.new Fixture.wsdl(:brand) }
|
10
|
+
let(:no_wsdl) { Wasabi::Document.new }
|
11
|
+
|
12
|
+
describe "#to_s" do
|
13
|
+
it "defaults to include the default envelope namespace of :env" do
|
14
|
+
message = {
|
15
|
+
:message=>{
|
16
|
+
:template_object=>{
|
17
|
+
:longName=>"Zertico LLC Reseller"
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
locals = Savon::LocalOptions.new(message)
|
23
|
+
builder = Savon::Builder.new(:create_object, wsdl, globals, locals)
|
24
|
+
expect(builder.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://api.service.softlayer.com/soap/v3/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><tns:createObject><templateObject><longName>Zertico LLC Reseller</longName></templateObject></tns:createObject></env:Body></env:Envelope>')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: savon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.11.
|
4
|
+
version: 2.11.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Harrington
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nori
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.2'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: uuid
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 2.3.7
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 2.3.7
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: builder
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -261,6 +247,7 @@ files:
|
|
261
247
|
- spec/fixtures/ssl/client_key.pem
|
262
248
|
- spec/fixtures/wsdl/authentication.xml
|
263
249
|
- spec/fixtures/wsdl/betfair.xml
|
250
|
+
- spec/fixtures/wsdl/brand.xml
|
264
251
|
- spec/fixtures/wsdl/edialog.xml
|
265
252
|
- spec/fixtures/wsdl/interhome.xml
|
266
253
|
- spec/fixtures/wsdl/lower_camel.xml
|
@@ -297,6 +284,7 @@ files:
|
|
297
284
|
- spec/savon/request_spec.rb
|
298
285
|
- spec/savon/response_spec.rb
|
299
286
|
- spec/savon/soap_fault_spec.rb
|
287
|
+
- spec/savon/softlayer_spec.rb
|
300
288
|
- spec/spec_helper.rb
|
301
289
|
- spec/support/adapters.rb
|
302
290
|
- spec/support/endpoint.rb
|
@@ -323,7 +311,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
323
311
|
version: '0'
|
324
312
|
requirements: []
|
325
313
|
rubyforge_project: savon
|
326
|
-
rubygems_version: 2.
|
314
|
+
rubygems_version: 2.6.12
|
327
315
|
signing_key:
|
328
316
|
specification_version: 4
|
329
317
|
summary: Heavy metal SOAP client
|