savon 2.12.0 → 2.15.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +115 -77
- data/README.md +23 -21
- data/lib/savon/block_interface.rb +1 -0
- data/lib/savon/builder.rb +100 -30
- data/lib/savon/client.rb +1 -0
- data/lib/savon/header.rb +2 -6
- data/lib/savon/http_error.rb +4 -4
- data/lib/savon/log_message.rb +1 -0
- data/lib/savon/message.rb +1 -0
- data/lib/savon/mock/expectation.rb +1 -0
- data/lib/savon/mock/spec_helper.rb +1 -0
- data/lib/savon/mock.rb +1 -0
- data/lib/savon/model.rb +4 -3
- data/lib/savon/operation.rb +20 -18
- data/lib/savon/options.rb +57 -1
- data/lib/savon/qualified_message.rb +4 -3
- data/lib/savon/request.rb +5 -0
- data/lib/savon/request_logger.rb +8 -2
- data/lib/savon/response.rb +51 -4
- data/lib/savon/soap_fault.rb +2 -1
- data/lib/savon/string_utils.rb +17 -0
- data/lib/savon/version.rb +2 -1
- data/lib/savon.rb +2 -0
- metadata +78 -101
- data/.gitignore +0 -14
- data/.travis.yml +0 -18
- data/.yardopts +0 -6
- data/CONTRIBUTING.md +0 -46
- data/Gemfile +0 -13
- data/donate.png +0 -0
- data/lib/savon/core_ext/string.rb +0 -29
- data/savon.gemspec +0 -46
- data/spec/fixtures/gzip/message.gz +0 -0
- data/spec/fixtures/response/another_soap_fault.xml +0 -14
- data/spec/fixtures/response/authentication.xml +0 -14
- data/spec/fixtures/response/f5.xml +0 -39
- data/spec/fixtures/response/header.xml +0 -13
- data/spec/fixtures/response/list.xml +0 -18
- data/spec/fixtures/response/multi_ref.xml +0 -39
- data/spec/fixtures/response/no_body.xml +0 -1
- data/spec/fixtures/response/soap_fault.xml +0 -8
- data/spec/fixtures/response/soap_fault12.xml +0 -18
- data/spec/fixtures/response/soap_fault_funky.xml +0 -8
- data/spec/fixtures/response/taxcloud.xml +0 -1
- data/spec/fixtures/ssl/client_cert.pem +0 -16
- data/spec/fixtures/ssl/client_encrypted_key.pem +0 -30
- data/spec/fixtures/ssl/client_encrypted_key_cert.pem +0 -24
- data/spec/fixtures/ssl/client_key.pem +0 -15
- data/spec/fixtures/wsdl/authentication.xml +0 -63
- data/spec/fixtures/wsdl/betfair.xml +0 -2981
- data/spec/fixtures/wsdl/brand.xml +0 -624
- data/spec/fixtures/wsdl/edialog.xml +0 -15416
- data/spec/fixtures/wsdl/interhome.xml +0 -2137
- data/spec/fixtures/wsdl/lower_camel.xml +0 -52
- data/spec/fixtures/wsdl/multiple_namespaces.xml +0 -92
- data/spec/fixtures/wsdl/multiple_types.xml +0 -60
- data/spec/fixtures/wsdl/no_message_tag.xml +0 -1267
- data/spec/fixtures/wsdl/taxcloud.xml +0 -934
- data/spec/fixtures/wsdl/team_software.xml +0 -1
- data/spec/fixtures/wsdl/vies.xml +0 -176
- data/spec/fixtures/wsdl/wasmuth.xml +0 -153
- data/spec/integration/centra_spec.rb +0 -67
- data/spec/integration/email_example_spec.rb +0 -32
- data/spec/integration/random_quote_spec.rb +0 -23
- data/spec/integration/ratp_example_spec.rb +0 -28
- data/spec/integration/stockquote_example_spec.rb +0 -34
- data/spec/integration/support/application.rb +0 -82
- data/spec/integration/support/server.rb +0 -84
- data/spec/integration/temperature_example_spec.rb +0 -46
- data/spec/integration/zipcode_example_spec.rb +0 -42
- data/spec/savon/builder_spec.rb +0 -137
- data/spec/savon/client_spec.rb +0 -271
- data/spec/savon/core_ext/string_spec.rb +0 -37
- data/spec/savon/features/message_tag_spec.rb +0 -61
- data/spec/savon/http_error_spec.rb +0 -49
- data/spec/savon/log_message_spec.rb +0 -50
- data/spec/savon/message_spec.rb +0 -70
- data/spec/savon/mock_spec.rb +0 -174
- data/spec/savon/model_spec.rb +0 -182
- data/spec/savon/observers_spec.rb +0 -92
- data/spec/savon/operation_spec.rb +0 -230
- data/spec/savon/options_spec.rb +0 -1104
- data/spec/savon/qualified_message_spec.rb +0 -101
- data/spec/savon/request_logger_spec.rb +0 -37
- data/spec/savon/request_spec.rb +0 -540
- data/spec/savon/response_spec.rb +0 -275
- data/spec/savon/soap_fault_spec.rb +0 -136
- data/spec/savon/softlayer_spec.rb +0 -27
- data/spec/spec_helper.rb +0 -30
- data/spec/support/adapters.rb +0 -48
- data/spec/support/endpoint.rb +0 -25
- data/spec/support/fixture.rb +0 -39
- data/spec/support/integration.rb +0 -9
- data/spec/support/stdout.rb +0 -25
data/spec/savon/response_spec.rb
DELETED
@@ -1,275 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Savon::Response do
|
4
|
-
|
5
|
-
let(:globals) { Savon::GlobalOptions.new }
|
6
|
-
let(:locals) { Savon::LocalOptions.new }
|
7
|
-
|
8
|
-
describe ".new" do
|
9
|
-
it "should raise a Savon::Fault in case of a SOAP fault" do
|
10
|
-
expect { soap_fault_response }.to raise_error(Savon::SOAPFault)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should not raise a Savon::Fault in case the default is turned off" do
|
14
|
-
globals[:raise_errors] = false
|
15
|
-
expect { soap_fault_response }.not_to raise_error
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should raise a Savon::HTTP::Error in case of an HTTP error" do
|
19
|
-
expect { soap_response :code => 500 }.to raise_error(Savon::HTTPError)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should not raise a Savon::HTTP::Error in case the default is turned off" do
|
23
|
-
globals[:raise_errors] = false
|
24
|
-
soap_response :code => 500
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "#success?" do
|
29
|
-
before { globals[:raise_errors] = false }
|
30
|
-
|
31
|
-
it "should return true if the request was successful" do
|
32
|
-
expect(soap_response).to be_a_success
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should return false if there was a SOAP fault" do
|
36
|
-
expect(soap_fault_response).not_to be_a_success
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should return false if there was an HTTP error" do
|
40
|
-
expect(http_error_response).not_to be_a_success
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "#soap_fault?" do
|
45
|
-
before { globals[:raise_errors] = false }
|
46
|
-
|
47
|
-
it "should not return true in case the response seems to be ok" do
|
48
|
-
expect(soap_response.soap_fault?).to be_falsey
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should return true in case of a SOAP fault" do
|
52
|
-
expect(soap_fault_response.soap_fault?).to be_truthy
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe "#soap_fault" do
|
57
|
-
before { globals[:raise_errors] = false }
|
58
|
-
|
59
|
-
it "should return nil in case the response seems to be ok" do
|
60
|
-
expect(soap_response.soap_fault).to be_nil
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should return a SOAPFault in case of a SOAP fault" do
|
64
|
-
expect(soap_fault_response.soap_fault).to be_a(Savon::SOAPFault)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe "#http_error?" do
|
69
|
-
before { globals[:raise_errors] = false }
|
70
|
-
|
71
|
-
it "should not return true in case the response seems to be ok" do
|
72
|
-
expect(soap_response.http_error?).not_to be_truthy
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should return true in case of an HTTP error" do
|
76
|
-
expect(soap_response(:code => 500).http_error?).to be_truthy
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe "#http_error" do
|
81
|
-
before { globals[:raise_errors] = false }
|
82
|
-
|
83
|
-
it "should return nil in case the response seems to be ok" do
|
84
|
-
expect(soap_response.http_error).to be_nil
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should return a HTTPError in case of an HTTP error" do
|
88
|
-
expect(soap_response(:code => 500).http_error).to be_a(Savon::HTTPError)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe "#header" do
|
93
|
-
it "should return the SOAP response header as a Hash" do
|
94
|
-
response = soap_response :body => Fixture.response(:header)
|
95
|
-
expect(response.header).to include(:session_number => "ABCD1234")
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'respects the global :strip_namespaces option' do
|
99
|
-
globals[:strip_namespaces] = false
|
100
|
-
|
101
|
-
response_with_header = soap_response(:body => Fixture.response(:header))
|
102
|
-
header = response_with_header.header
|
103
|
-
|
104
|
-
expect(header).to be_a(Hash)
|
105
|
-
|
106
|
-
# notice: :session_number is a snake_case Symbol without namespaces,
|
107
|
-
# but the Envelope and Header elements are qualified.
|
108
|
-
expect(header.keys).to include(:session_number)
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'respects the global :convert_response_tags_to option' do
|
112
|
-
globals[:convert_response_tags_to] = lambda { |key| key.upcase }
|
113
|
-
|
114
|
-
response_with_header = soap_response(:body => Fixture.response(:header))
|
115
|
-
header = response_with_header.header
|
116
|
-
|
117
|
-
expect(header).to be_a(Hash)
|
118
|
-
expect(header.keys).to include('SESSIONNUMBER')
|
119
|
-
end
|
120
|
-
|
121
|
-
it 'respects the global :convert_attributes_to option' do
|
122
|
-
globals[:convert_attributes_to] = lambda { |k,v| [] }
|
123
|
-
|
124
|
-
response_with_header = soap_response(:body => Fixture.response(:header))
|
125
|
-
header = response_with_header.header
|
126
|
-
|
127
|
-
expect(header).to be_a(Hash)
|
128
|
-
expect(header.keys).to include(:session_number)
|
129
|
-
end
|
130
|
-
|
131
|
-
it "should throw an exception when the response header isn't parsable" do
|
132
|
-
expect { invalid_soap_response.header }.to raise_error Savon::InvalidResponseError
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
%w(body to_hash).each do |method|
|
137
|
-
describe "##{method}" do
|
138
|
-
it "should return the SOAP response body as a Hash" do
|
139
|
-
expect(soap_response.send(method)[:authenticate_response][:return]).to eq(
|
140
|
-
Fixture.response_hash(:authentication)[:authenticate_response][:return]
|
141
|
-
)
|
142
|
-
end
|
143
|
-
|
144
|
-
it "should return a Hash for a SOAP multiRef response" do
|
145
|
-
hash = soap_response(:body => Fixture.response(:multi_ref)).send(method)
|
146
|
-
|
147
|
-
expect(hash[:list_response]).to be_a(Hash)
|
148
|
-
expect(hash[:multi_ref]).to be_an(Array)
|
149
|
-
end
|
150
|
-
|
151
|
-
it "should add existing namespaced elements as an array" do
|
152
|
-
hash = soap_response(:body => Fixture.response(:list)).send(method)
|
153
|
-
|
154
|
-
expect(hash[:multi_namespaced_entry_response][:history]).to be_a(Hash)
|
155
|
-
expect(hash[:multi_namespaced_entry_response][:history][:case]).to be_an(Array)
|
156
|
-
end
|
157
|
-
|
158
|
-
it 'respects the global :strip_namespaces option' do
|
159
|
-
globals[:strip_namespaces] = false
|
160
|
-
|
161
|
-
body = soap_response.body
|
162
|
-
|
163
|
-
expect(body).to be_a(Hash)
|
164
|
-
expect(body.keys).to include(:"ns2:authenticate_response")
|
165
|
-
end
|
166
|
-
|
167
|
-
it 'respects the global :convert_response_tags_to option' do
|
168
|
-
globals[:convert_response_tags_to] = lambda { |key| key.upcase }
|
169
|
-
|
170
|
-
body = soap_response.body
|
171
|
-
|
172
|
-
expect(body).to be_a(Hash)
|
173
|
-
expect(body.keys).to include('AUTHENTICATERESPONSE')
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
describe "#to_array" do
|
179
|
-
context "when the given path exists" do
|
180
|
-
it "should return an Array containing the path value" do
|
181
|
-
expect(soap_response.to_array(:authenticate_response, :return)).to eq(
|
182
|
-
[Fixture.response_hash(:authentication)[:authenticate_response][:return]]
|
183
|
-
)
|
184
|
-
end
|
185
|
-
|
186
|
-
it "should properly return FalseClass values [#327]" do
|
187
|
-
body = Gyoku.xml(:envelope => { :body => { :return => { :success => false } } })
|
188
|
-
expect(soap_response(:body => body).to_array(:return, :success)).to eq([false])
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
context "when the given path returns nil" do
|
193
|
-
it "should return an empty Array" do
|
194
|
-
expect(soap_response.to_array(:authenticate_response, :undefined)).to eq([])
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
context "when the given path does not exist at all" do
|
199
|
-
it "should return an empty Array" do
|
200
|
-
expect(soap_response.to_array(:authenticate_response, :some, :undefined, :path)).to eq([])
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
describe "#hash" do
|
206
|
-
it "should return the complete SOAP response XML as a Hash" do
|
207
|
-
response = soap_response :body => Fixture.response(:header)
|
208
|
-
expect(response.hash[:envelope][:header][:session_number]).to eq("ABCD1234")
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
describe "#to_xml" do
|
213
|
-
it "should return the raw SOAP response body" do
|
214
|
-
expect(soap_response.to_xml).to eq(Fixture.response(:authentication))
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
describe "#doc" do
|
219
|
-
it "returns a Nokogiri::XML::Document for the SOAP response XML" do
|
220
|
-
expect(soap_response.doc).to be_a(Nokogiri::XML::Document)
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
describe "#xpath" do
|
225
|
-
it "permits XPath access to elements in the request" do
|
226
|
-
expect(soap_response.xpath("//client").first.inner_text).to eq("radclient")
|
227
|
-
expect(soap_response.xpath("//ns2:authenticateResponse/return/success").first.inner_text).to eq("true")
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
describe '#find' do
|
232
|
-
it 'delegates to Nori#find to find child elements inside the Envelope' do
|
233
|
-
result = soap_response.find('Body', 'authenticateResponse', 'return')
|
234
|
-
|
235
|
-
expect(result).to be_a(Hash)
|
236
|
-
expect(result.keys).to include(:authentication_value)
|
237
|
-
end
|
238
|
-
|
239
|
-
it 'fails correctly when envelope contains only string' do
|
240
|
-
response = soap_response({ :body => Fixture.response(:no_body) })
|
241
|
-
expect { response.find('Body') }.to raise_error Savon::InvalidResponseError
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
describe "#http" do
|
246
|
-
it "should return the HTTPI::Response" do
|
247
|
-
expect(soap_response.http).to be_an(HTTPI::Response)
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
|
-
def soap_response(options = {})
|
252
|
-
defaults = { :code => 200, :headers => {}, :body => Fixture.response(:authentication) }
|
253
|
-
response = defaults.merge options
|
254
|
-
http_response = HTTPI::Response.new(response[:code], response[:headers], response[:body])
|
255
|
-
|
256
|
-
Savon::Response.new(http_response, globals, locals)
|
257
|
-
end
|
258
|
-
|
259
|
-
def soap_fault_response
|
260
|
-
soap_response :code => 500, :body => Fixture.response(:soap_fault)
|
261
|
-
end
|
262
|
-
|
263
|
-
def http_error_response
|
264
|
-
soap_response :code => 404, :body => "Not found"
|
265
|
-
end
|
266
|
-
|
267
|
-
def invalid_soap_response(options = {})
|
268
|
-
defaults = { :code => 200, :headers => {}, :body => "I'm not SOAP" }
|
269
|
-
response = defaults.merge options
|
270
|
-
http_response = HTTPI::Response.new(response[:code], response[:headers], response[:body])
|
271
|
-
|
272
|
-
Savon::Response.new(http_response, globals, locals)
|
273
|
-
end
|
274
|
-
|
275
|
-
end
|
@@ -1,136 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Savon::SOAPFault do
|
4
|
-
let(:soap_fault) { Savon::SOAPFault.new new_response(:body => Fixture.response(:soap_fault)), nori }
|
5
|
-
let(:soap_fault2) { Savon::SOAPFault.new new_response(:body => Fixture.response(:soap_fault12)), nori }
|
6
|
-
let(:soap_fault_funky) { Savon::SOAPFault.new new_response(:body => Fixture.response(:soap_fault_funky)), nori }
|
7
|
-
let(:soap_fault_nc) { Savon::SOAPFault.new new_response(:body => Fixture.response(:soap_fault)), nori_no_convert }
|
8
|
-
let(:soap_fault_nc2) { Savon::SOAPFault.new new_response(:body => Fixture.response(:soap_fault12)), nori_no_convert }
|
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 }
|
11
|
-
let(:no_fault) { Savon::SOAPFault.new new_response, nori }
|
12
|
-
|
13
|
-
let(:nori) { Nori.new(:strip_namespaces => true, :convert_tags_to => lambda { |tag| tag.snakecase.to_sym }) }
|
14
|
-
let(:nori_no_convert) { Nori.new(:strip_namespaces => true, :convert_tags_to => nil) }
|
15
|
-
|
16
|
-
it "inherits from Savon::Error" do
|
17
|
-
expect(Savon::SOAPFault.ancestors).to include(Savon::Error)
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "#http" do
|
21
|
-
it "returns the HTTPI::Response" do
|
22
|
-
expect(soap_fault.http).to be_an(HTTPI::Response)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe ".present?" do
|
27
|
-
it "returns true if the HTTP response contains a SOAP 1.1 fault" do
|
28
|
-
http = new_response(:body => Fixture.response(:soap_fault))
|
29
|
-
expect(Savon::SOAPFault.present? http).to be_truthy
|
30
|
-
end
|
31
|
-
|
32
|
-
it "returns true if the HTTP response contains a SOAP 1.2 fault" do
|
33
|
-
http = new_response(:body => Fixture.response(:soap_fault12))
|
34
|
-
expect(Savon::SOAPFault.present? http).to be_truthy
|
35
|
-
end
|
36
|
-
|
37
|
-
it "returns true if the HTTP response contains a SOAP fault with different namespaces" do
|
38
|
-
http = new_response(:body => Fixture.response(:another_soap_fault))
|
39
|
-
expect(Savon::SOAPFault.present? http).to be_truthy
|
40
|
-
end
|
41
|
-
|
42
|
-
it "returns false unless the HTTP response contains a SOAP fault" do
|
43
|
-
expect(Savon::SOAPFault.present? new_response).to be_falsey
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
[:message, :to_s].each do |method|
|
48
|
-
describe "##{method}" do
|
49
|
-
it "returns a SOAP 1.1 fault message" do
|
50
|
-
expect(soap_fault.send method).to eq("(soap:Server) Fault occurred while processing.")
|
51
|
-
end
|
52
|
-
|
53
|
-
it "returns a SOAP 1.2 fault message" do
|
54
|
-
expect(soap_fault2.send method).to eq("(soap:Sender) Sender Timeout")
|
55
|
-
end
|
56
|
-
|
57
|
-
it "returns a SOAP fault message (with different namespaces)" do
|
58
|
-
expect(another_soap_fault.send method).to eq("(ERR_NO_SESSION) Wrong session message")
|
59
|
-
end
|
60
|
-
|
61
|
-
it "works even if the keys are different in a SOAP 1.1 fault message" do
|
62
|
-
expect(soap_fault_nc.send method).to eq("(soap:Server) Fault occurred while processing.")
|
63
|
-
end
|
64
|
-
|
65
|
-
it "works even if the keys are different in a SOAP 1.2 fault message" do
|
66
|
-
expect(soap_fault_nc2.send method).to eq("(soap:Sender) Sender Timeout")
|
67
|
-
end
|
68
|
-
|
69
|
-
it "works even if the keys are different in a funky SOAP fault message" do
|
70
|
-
expect(soap_fault_funky.send method).to eq("(42) The Answer to Life The Universe And Everything")
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
describe "#to_hash" do
|
76
|
-
it "returns the SOAP response as a Hash unless a SOAP fault is present" do
|
77
|
-
expect(no_fault.to_hash[:authenticate_response][:return][:success]).to be_truthy
|
78
|
-
end
|
79
|
-
|
80
|
-
it "returns a SOAP 1.1 fault as a Hash" do
|
81
|
-
expected = {
|
82
|
-
:fault => {
|
83
|
-
:faultstring => "Fault occurred while processing.",
|
84
|
-
:faultcode => "soap:Server"
|
85
|
-
}
|
86
|
-
}
|
87
|
-
|
88
|
-
expect(soap_fault.to_hash).to eq(expected)
|
89
|
-
end
|
90
|
-
|
91
|
-
it "returns a SOAP 1.2 fault as a Hash" do
|
92
|
-
expected = {
|
93
|
-
:fault => {
|
94
|
-
:detail => { :max_time => "P5M" },
|
95
|
-
:reason => { :text => "Sender Timeout" },
|
96
|
-
:code => { :value => "soap:Sender", :subcode => { :value => "m:MessageTimeout" } }
|
97
|
-
}
|
98
|
-
}
|
99
|
-
|
100
|
-
expect(soap_fault2.to_hash).to eq(expected)
|
101
|
-
end
|
102
|
-
|
103
|
-
it "works even if the keys are different" do
|
104
|
-
expected = {
|
105
|
-
"Fault" => {
|
106
|
-
"Code" => {
|
107
|
-
"Value" => "soap:Sender",
|
108
|
-
"Subcode"=> {
|
109
|
-
"Value" => "m:MessageTimeout"
|
110
|
-
}
|
111
|
-
},
|
112
|
-
"Reason" => {
|
113
|
-
"Text" => "Sender Timeout"
|
114
|
-
},
|
115
|
-
"Detail" => {
|
116
|
-
"MaxTime" => "P5M"
|
117
|
-
}
|
118
|
-
}
|
119
|
-
}
|
120
|
-
|
121
|
-
expect(soap_fault_nc2.to_hash).to eq(expected)
|
122
|
-
end
|
123
|
-
|
124
|
-
it "returns empty hash" do
|
125
|
-
expect(soap_fault_no_body.to_hash).to eq({})
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def new_response(options = {})
|
130
|
-
defaults = { :code => 500, :headers => {}, :body => Fixture.response(:authentication) }
|
131
|
-
response = defaults.merge options
|
132
|
-
|
133
|
-
HTTPI::Response.new response[:code], response[:headers], response[:body]
|
134
|
-
end
|
135
|
-
|
136
|
-
end
|
@@ -1,27 +0,0 @@
|
|
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
|
data/spec/spec_helper.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require "bundler"
|
2
|
-
Bundler.setup(:default, :development)
|
3
|
-
|
4
|
-
unless RUBY_PLATFORM =~ /java/
|
5
|
-
require "simplecov"
|
6
|
-
require "coveralls"
|
7
|
-
|
8
|
-
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
9
|
-
SimpleCov.start do
|
10
|
-
add_filter "spec"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
require "savon"
|
15
|
-
require "rspec"
|
16
|
-
|
17
|
-
# don't have HTTPI lazy-load HTTPClient, because then
|
18
|
-
# it can't actually be refered to inside the specs.
|
19
|
-
require "httpclient"
|
20
|
-
|
21
|
-
support_files = File.expand_path("spec/support/**/*.rb")
|
22
|
-
Dir[support_files].each { |file| require file }
|
23
|
-
|
24
|
-
RSpec.configure do |config|
|
25
|
-
config.include SpecSupport
|
26
|
-
config.mock_with :mocha
|
27
|
-
config.order = "random"
|
28
|
-
end
|
29
|
-
|
30
|
-
HTTPI.log = false
|
data/spec/support/adapters.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'httpi/adapter/httpclient'
|
2
|
-
|
3
|
-
# Proxy adapter. Records all requests and passes them to HTTPClient
|
4
|
-
class AdapterForTest < HTTPI::Adapter::Base
|
5
|
-
|
6
|
-
register :adapter_for_test
|
7
|
-
|
8
|
-
def initialize(request)
|
9
|
-
@@requests ||= []
|
10
|
-
@@requests.push request
|
11
|
-
@request = request
|
12
|
-
@worker = HTTPI::Adapter::HTTPClient.new(request)
|
13
|
-
end
|
14
|
-
|
15
|
-
def client
|
16
|
-
@worker.client
|
17
|
-
end
|
18
|
-
|
19
|
-
def request(method)
|
20
|
-
@@methods ||= []
|
21
|
-
@@methods.push method
|
22
|
-
@worker.request(method)
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
# Fake adapter with request recording.
|
28
|
-
# Takes path from url and returns fixture WSDL with that name.
|
29
|
-
class FakeAdapterForTest < HTTPI::Adapter::Base
|
30
|
-
|
31
|
-
register :fake_adapter_for_test
|
32
|
-
|
33
|
-
def initialize(request)
|
34
|
-
@@requests ||= []
|
35
|
-
@@requests.push request
|
36
|
-
@request = request
|
37
|
-
end
|
38
|
-
|
39
|
-
attr_reader :client
|
40
|
-
|
41
|
-
def request(method)
|
42
|
-
@@methods ||= []
|
43
|
-
@@methods.push method
|
44
|
-
target = @request.url.path.to_sym
|
45
|
-
HTTPI::Response.new(200, {}, Fixture.wsdl(target))
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
data/spec/support/endpoint.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
class Endpoint
|
2
|
-
class << self
|
3
|
-
|
4
|
-
# Returns the WSDL endpoint for a given +type+ of request.
|
5
|
-
def wsdl(type = nil)
|
6
|
-
case type
|
7
|
-
when :no_namespace then "http://nons.example.com/Service?wsdl"
|
8
|
-
when :namespaced_actions then "http://nsactions.example.com/Service?wsdl"
|
9
|
-
when :geotrust then "https://test-api.geotrust.com/webtrust/query.jws?WSDL"
|
10
|
-
else soap(type)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
# Returns the SOAP endpoint for a given +type+ of request.
|
15
|
-
def soap(type = nil)
|
16
|
-
case type
|
17
|
-
when :soap_fault then "http://soapfault.example.com/Service?wsdl"
|
18
|
-
when :http_error then "http://httperror.example.com/Service?wsdl"
|
19
|
-
when :invalid then "http://invalid.example.com/Service?wsdl"
|
20
|
-
else "http://example.com/validation/1.0/AuthenticationService"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
data/spec/support/fixture.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
class Fixture
|
2
|
-
|
3
|
-
TYPES = { :gzip => "gz", :response => "xml", :wsdl => "xml" }
|
4
|
-
|
5
|
-
class << self
|
6
|
-
|
7
|
-
def [](type, fixture)
|
8
|
-
fixtures(type)[fixture] ||= read_file type, fixture
|
9
|
-
end
|
10
|
-
|
11
|
-
def response_hash(fixture)
|
12
|
-
@response_hash ||= {}
|
13
|
-
@response_hash[fixture] ||= nori.parse(response(fixture))[:envelope][:body]
|
14
|
-
end
|
15
|
-
|
16
|
-
TYPES.each do |type, ext|
|
17
|
-
define_method(type) { |fixture| self[type, fixture] }
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def nori
|
23
|
-
Nori.new(:strip_namespaces => true, :convert_tags_to => lambda { |tag| tag.snakecase.to_sym })
|
24
|
-
end
|
25
|
-
|
26
|
-
def fixtures(type)
|
27
|
-
@fixtures ||= {}
|
28
|
-
@fixtures[type] ||= {}
|
29
|
-
end
|
30
|
-
|
31
|
-
def read_file(type, fixture)
|
32
|
-
path = File.expand_path "../../fixtures/#{type}/#{fixture}.#{TYPES[type]}", __FILE__
|
33
|
-
raise ArgumentError, "Unable to load: #{path}" unless File.exist? path
|
34
|
-
|
35
|
-
File.read path
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
data/spec/support/integration.rb
DELETED
data/spec/support/stdout.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
module SpecSupport
|
2
|
-
|
3
|
-
def mock_stdout
|
4
|
-
original_stdout = $stdout
|
5
|
-
|
6
|
-
stdout = StringIO.new
|
7
|
-
$stdout = stdout
|
8
|
-
|
9
|
-
yield
|
10
|
-
|
11
|
-
$stdout = original_stdout
|
12
|
-
stdout
|
13
|
-
end
|
14
|
-
|
15
|
-
def silence_stdout
|
16
|
-
original_stdout = $stdout
|
17
|
-
$stdout = StringIO.new
|
18
|
-
|
19
|
-
result = yield
|
20
|
-
|
21
|
-
$stdout = original_stdout
|
22
|
-
result
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|