savon_with_adapter 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.travis.yml +11 -0
  4. data/.yardopts +6 -0
  5. data/CHANGELOG.md +1042 -0
  6. data/CONTRIBUTING.md +46 -0
  7. data/Gemfile +18 -0
  8. data/LICENSE +20 -0
  9. data/README.md +81 -0
  10. data/Rakefile +14 -0
  11. data/donate.png +0 -0
  12. data/lib/savon.rb +27 -0
  13. data/lib/savon/block_interface.rb +26 -0
  14. data/lib/savon/builder.rb +166 -0
  15. data/lib/savon/client.rb +89 -0
  16. data/lib/savon/core_ext/string.rb +29 -0
  17. data/lib/savon/header.rb +70 -0
  18. data/lib/savon/http_error.rb +27 -0
  19. data/lib/savon/log_message.rb +48 -0
  20. data/lib/savon/message.rb +35 -0
  21. data/lib/savon/mock.rb +5 -0
  22. data/lib/savon/mock/expectation.rb +71 -0
  23. data/lib/savon/mock/spec_helper.rb +62 -0
  24. data/lib/savon/model.rb +80 -0
  25. data/lib/savon/operation.rb +127 -0
  26. data/lib/savon/options.rb +336 -0
  27. data/lib/savon/qualified_message.rb +49 -0
  28. data/lib/savon/request.rb +89 -0
  29. data/lib/savon/request_logger.rb +48 -0
  30. data/lib/savon/response.rb +112 -0
  31. data/lib/savon/soap_fault.rb +48 -0
  32. data/lib/savon/version.rb +3 -0
  33. data/savon.gemspec +52 -0
  34. data/spec/fixtures/gzip/message.gz +0 -0
  35. data/spec/fixtures/response/another_soap_fault.xml +14 -0
  36. data/spec/fixtures/response/authentication.xml +14 -0
  37. data/spec/fixtures/response/header.xml +13 -0
  38. data/spec/fixtures/response/list.xml +18 -0
  39. data/spec/fixtures/response/multi_ref.xml +39 -0
  40. data/spec/fixtures/response/soap_fault.xml +8 -0
  41. data/spec/fixtures/response/soap_fault12.xml +18 -0
  42. data/spec/fixtures/response/taxcloud.xml +1 -0
  43. data/spec/fixtures/ssl/client_cert.pem +16 -0
  44. data/spec/fixtures/ssl/client_encrypted_key.pem +30 -0
  45. data/spec/fixtures/ssl/client_encrypted_key_cert.pem +24 -0
  46. data/spec/fixtures/ssl/client_key.pem +15 -0
  47. data/spec/fixtures/wsdl/authentication.xml +63 -0
  48. data/spec/fixtures/wsdl/betfair.xml +2981 -0
  49. data/spec/fixtures/wsdl/edialog.xml +15416 -0
  50. data/spec/fixtures/wsdl/interhome.xml +2137 -0
  51. data/spec/fixtures/wsdl/lower_camel.xml +52 -0
  52. data/spec/fixtures/wsdl/multiple_namespaces.xml +92 -0
  53. data/spec/fixtures/wsdl/multiple_types.xml +60 -0
  54. data/spec/fixtures/wsdl/taxcloud.xml +934 -0
  55. data/spec/fixtures/wsdl/team_software.xml +1 -0
  56. data/spec/fixtures/wsdl/vies.xml +176 -0
  57. data/spec/fixtures/wsdl/wasmuth.xml +153 -0
  58. data/spec/integration/centra_spec.rb +72 -0
  59. data/spec/integration/email_example_spec.rb +32 -0
  60. data/spec/integration/random_quote_spec.rb +23 -0
  61. data/spec/integration/ratp_example_spec.rb +28 -0
  62. data/spec/integration/stockquote_example_spec.rb +28 -0
  63. data/spec/integration/support/application.rb +82 -0
  64. data/spec/integration/support/server.rb +84 -0
  65. data/spec/integration/temperature_example_spec.rb +46 -0
  66. data/spec/integration/zipcode_example_spec.rb +42 -0
  67. data/spec/savon/builder_spec.rb +86 -0
  68. data/spec/savon/client_spec.rb +198 -0
  69. data/spec/savon/core_ext/string_spec.rb +37 -0
  70. data/spec/savon/features/message_tag_spec.rb +61 -0
  71. data/spec/savon/http_error_spec.rb +49 -0
  72. data/spec/savon/log_message_spec.rb +33 -0
  73. data/spec/savon/message_spec.rb +40 -0
  74. data/spec/savon/mock_spec.rb +157 -0
  75. data/spec/savon/model_spec.rb +154 -0
  76. data/spec/savon/observers_spec.rb +92 -0
  77. data/spec/savon/operation_spec.rb +211 -0
  78. data/spec/savon/options_spec.rb +772 -0
  79. data/spec/savon/request_spec.rb +493 -0
  80. data/spec/savon/response_spec.rb +258 -0
  81. data/spec/savon/soap_fault_spec.rb +126 -0
  82. data/spec/spec_helper.rb +30 -0
  83. data/spec/support/endpoint.rb +25 -0
  84. data/spec/support/fixture.rb +39 -0
  85. data/spec/support/integration.rb +9 -0
  86. data/spec/support/stdout.rb +25 -0
  87. metadata +310 -0
@@ -0,0 +1,493 @@
1
+ require "spec_helper"
2
+ require "integration/support/server"
3
+
4
+ describe Savon::WSDLRequest do
5
+
6
+ let(:globals) { Savon::GlobalOptions.new }
7
+ let(:http_request) { HTTPI::Request.new }
8
+
9
+ def new_wsdl_request
10
+ Savon::WSDLRequest.new(globals, http_request)
11
+ end
12
+
13
+ describe "#build" do
14
+ it "returns an HTTPI::Request" do
15
+ wsdl_request = Savon::WSDLRequest.new(globals)
16
+ expect(wsdl_request.build).to be_an(HTTPI::Request)
17
+ end
18
+
19
+ describe "proxy" do
20
+ it "is set when specified" do
21
+ globals.proxy("http://proxy.example.com")
22
+ http_request.expects(:proxy=).with("http://proxy.example.com")
23
+
24
+ new_wsdl_request.build
25
+ end
26
+
27
+ it "is not set otherwise" do
28
+ http_request.expects(:proxy=).never
29
+ new_wsdl_request.build
30
+ end
31
+ end
32
+
33
+ describe "open timeout" do
34
+ it "is set when specified" do
35
+ globals.open_timeout(22)
36
+ http_request.expects(:open_timeout=).with(22)
37
+
38
+ new_wsdl_request.build
39
+ end
40
+
41
+ it "is not set otherwise" do
42
+ http_request.expects(:open_timeout=).never
43
+ new_wsdl_request.build
44
+ end
45
+ end
46
+
47
+ describe "read timeout" do
48
+ it "is set when specified" do
49
+ globals.read_timeout(33)
50
+ http_request.expects(:read_timeout=).with(33)
51
+
52
+ new_wsdl_request.build
53
+ end
54
+
55
+ it "is not set otherwise" do
56
+ http_request.expects(:read_timeout=).never
57
+ new_wsdl_request.build
58
+ end
59
+ end
60
+
61
+ describe "ssl version" do
62
+ it "is set when specified" do
63
+ globals.ssl_version(:SSLv3)
64
+ http_request.auth.ssl.expects(:ssl_version=).with(:SSLv3)
65
+
66
+ new_wsdl_request.build
67
+ end
68
+
69
+ it "is not set otherwise" do
70
+ http_request.auth.ssl.expects(:ssl_version=).never
71
+ new_wsdl_request.build
72
+ end
73
+ end
74
+
75
+ describe "ssl verify mode" do
76
+ it "is set when specified" do
77
+ globals.ssl_verify_mode(:none)
78
+ http_request.auth.ssl.expects(:verify_mode=).with(:none)
79
+
80
+ new_wsdl_request.build
81
+ end
82
+
83
+ it "is not set otherwise" do
84
+ http_request.auth.ssl.expects(:verify_mode=).never
85
+ new_wsdl_request.build
86
+ end
87
+ end
88
+
89
+ describe "ssl cert key file" do
90
+ it "is set when specified" do
91
+ cert_key = File.expand_path("../../fixtures/ssl/client_key.pem", __FILE__)
92
+ globals.ssl_cert_key_file(cert_key)
93
+ http_request.auth.ssl.expects(:cert_key_file=).with(cert_key)
94
+
95
+ new_wsdl_request.build
96
+ end
97
+
98
+ it "is not set otherwise" do
99
+ http_request.auth.ssl.expects(:cert_key_file=).never
100
+ new_wsdl_request.build
101
+ end
102
+ end
103
+
104
+ describe "ssl cert key password" do
105
+ it "is set when specified" do
106
+ the_pass = "secure-password!42"
107
+ globals.ssl_cert_key_password(the_pass)
108
+ http_request.auth.ssl.expects(:cert_key_password=).with(the_pass)
109
+
110
+ new_wsdl_request.build
111
+ end
112
+
113
+ it "is not set otherwise" do
114
+ http_request.auth.ssl.expects(:cert_key_password=).never
115
+ new_wsdl_request.build
116
+ end
117
+ end
118
+
119
+ describe "ssl encrypted cert key file" do
120
+ describe "set with an invalid decrypting password" do
121
+ it "fails when attempting to use the SSL private key" do
122
+ pass = "wrong-password"
123
+ key = File.expand_path("../../fixtures/ssl/client_encrypted_key.pem", __FILE__)
124
+ cert = File.expand_path("../../fixtures/ssl/client_encrypted_key_cert.pem", __FILE__)
125
+
126
+ globals.ssl_cert_file(cert)
127
+ globals.ssl_cert_key_password(pass)
128
+ globals.ssl_cert_key_file(key)
129
+
130
+ new_wsdl_request.build
131
+
132
+ expect { http_request.auth.ssl.cert_key }.to raise_error(OpenSSL::PKey::RSAError)
133
+ end
134
+ end
135
+
136
+ describe "set with a valid decrypting password" do
137
+ it "handles SSL private keys properly" do
138
+ pass = "secure-password!42"
139
+ key = File.expand_path("../../fixtures/ssl/client_encrypted_key.pem", __FILE__)
140
+ cert = File.expand_path("../../fixtures/ssl/client_encrypted_key_cert.pem", __FILE__)
141
+
142
+ globals.ssl_cert_file(cert)
143
+ globals.ssl_cert_key_password(pass)
144
+ globals.ssl_cert_key_file(key)
145
+
146
+ new_wsdl_request.build
147
+
148
+ http_request.auth.ssl.cert_key.to_s.should =~ /BEGIN RSA PRIVATE KEY/
149
+ end
150
+ end
151
+ end
152
+
153
+ describe "ssl cert file" do
154
+ it "is set when specified" do
155
+ cert = File.expand_path("../../fixtures/ssl/client_cert.pem", __FILE__)
156
+ globals.ssl_cert_file(cert)
157
+ http_request.auth.ssl.expects(:cert_file=).with(cert)
158
+
159
+ new_wsdl_request.build
160
+ end
161
+
162
+ it "is not set otherwise" do
163
+ http_request.auth.ssl.expects(:cert_file=).never
164
+ new_wsdl_request.build
165
+ end
166
+ end
167
+
168
+ describe "ssl ca cert file" do
169
+ it "is set when specified" do
170
+ ca_cert = File.expand_path("../../fixtures/ssl/client_cert.pem", __FILE__)
171
+ globals.ssl_ca_cert_file(ca_cert)
172
+ http_request.auth.ssl.expects(:ca_cert_file=).with(ca_cert)
173
+
174
+ new_wsdl_request.build
175
+ end
176
+
177
+ it "is not set otherwise" do
178
+ http_request.auth.ssl.expects(:ca_cert_file=).never
179
+ new_wsdl_request.build
180
+ end
181
+ end
182
+
183
+ describe "basic auth" do
184
+ it "is set when specified" do
185
+ globals.basic_auth("luke", "secret")
186
+ http_request.auth.expects(:basic).with("luke", "secret")
187
+
188
+ new_wsdl_request.build
189
+ end
190
+
191
+ it "is not set otherwise" do
192
+ http_request.auth.expects(:basic).never
193
+ new_wsdl_request.build
194
+ end
195
+ end
196
+
197
+ describe "digest auth" do
198
+ it "is set when specified" do
199
+ globals.digest_auth("lea", "top-secret")
200
+ http_request.auth.expects(:digest).with("lea", "top-secret")
201
+
202
+ new_wsdl_request.build
203
+ end
204
+
205
+ it "is not set otherwise" do
206
+ http_request.auth.expects(:digest).never
207
+ new_wsdl_request.build
208
+ end
209
+ end
210
+
211
+ describe "ntlm auth" do
212
+ it "is set when specified" do
213
+ globals.ntlm("han", "super-secret")
214
+ http_request.auth.expects(:ntlm).with("han", "super-secret")
215
+
216
+ new_wsdl_request.build
217
+ end
218
+
219
+ it "is not set otherwise" do
220
+ http_request.auth.expects(:ntlm).never
221
+ new_wsdl_request.build
222
+ end
223
+ end
224
+ end
225
+
226
+ end
227
+
228
+ describe Savon::SOAPRequest do
229
+
230
+ let(:globals) { Savon::GlobalOptions.new }
231
+ let(:http_request) { HTTPI::Request.new }
232
+
233
+ def new_soap_request
234
+ Savon::SOAPRequest.new(globals, http_request)
235
+ end
236
+
237
+ describe "#build" do
238
+ it "returns an HTTPI::Request" do
239
+ soap_request = Savon::SOAPRequest.new(globals)
240
+ expect(soap_request.build).to be_an(HTTPI::Request)
241
+ end
242
+
243
+ describe "proxy" do
244
+ it "is set when specified" do
245
+ globals.proxy("http://proxy.example.com")
246
+ http_request.expects(:proxy=).with("http://proxy.example.com")
247
+
248
+ new_soap_request.build
249
+ end
250
+
251
+ it "is not set otherwise" do
252
+ http_request.expects(:proxy=).never
253
+ new_soap_request.build
254
+ end
255
+ end
256
+
257
+ describe "cookies" do
258
+ it "sets the given cookies" do
259
+ cookies = [HTTPI::Cookie.new("some-cookie=choc-chip; Path=/; HttpOnly")]
260
+
261
+ http_request.expects(:set_cookies).with(cookies)
262
+ new_soap_request.build(:cookies => cookies)
263
+ end
264
+
265
+ it "does not set the cookies if there are none" do
266
+ http_request.expects(:set_cookies).never
267
+ new_soap_request.build
268
+ end
269
+ end
270
+
271
+ describe "open timeout" do
272
+ it "is set when specified" do
273
+ globals.open_timeout(22)
274
+ http_request.expects(:open_timeout=).with(22)
275
+
276
+ new_soap_request.build
277
+ end
278
+
279
+ it "is not set otherwise" do
280
+ http_request.expects(:open_timeout=).never
281
+ new_soap_request.build
282
+ end
283
+ end
284
+
285
+ describe "read timeout" do
286
+ it "is set when specified" do
287
+ globals.read_timeout(33)
288
+ http_request.expects(:read_timeout=).with(33)
289
+
290
+ new_soap_request.build
291
+ end
292
+
293
+ it "is not set otherwise" do
294
+ http_request.expects(:read_timeout=).never
295
+ new_soap_request.build
296
+ end
297
+ end
298
+
299
+ describe "headers" do
300
+ it "are set when specified" do
301
+ globals.headers("X-Token" => "secret")
302
+ configured_http_request = new_soap_request.build
303
+
304
+ expect(configured_http_request.headers["X-Token"]).to eq("secret")
305
+ end
306
+
307
+ it "are not set otherwise" do
308
+ configured_http_request = new_soap_request.build
309
+ expect(configured_http_request.headers).to_not include("X-Token")
310
+ end
311
+ end
312
+
313
+ describe "SOAPAction header" do
314
+ it "is set and wrapped in parenthesis" do
315
+ configured_http_request = new_soap_request.build(:soap_action => "findUser")
316
+ soap_action = configured_http_request.headers["SOAPAction"]
317
+
318
+ expect(soap_action).to eq(%("findUser"))
319
+ end
320
+
321
+ it "is not set when it's explicitely set to nil" do
322
+ configured_http_request = new_soap_request.build(:soap_action => nil)
323
+ expect(configured_http_request.headers).to_not include("SOAPAction")
324
+ end
325
+
326
+ it "is not set when there is already a SOAPAction value" do
327
+ globals.headers("SOAPAction" => %("authenticate"))
328
+ configured_http_request = new_soap_request.build(:soap_action => "findUser")
329
+ soap_action = configured_http_request.headers["SOAPAction"]
330
+
331
+ expect(soap_action).to eq(%("authenticate"))
332
+ end
333
+ end
334
+
335
+ describe "Content-Type header" do
336
+ it "defaults to SOAP 1.1 and UTF-8" do
337
+ configured_http_request = new_soap_request.build
338
+ content_type = configured_http_request.headers["Content-Type"]
339
+
340
+ expect(content_type).to eq("text/xml;charset=UTF-8")
341
+ end
342
+
343
+ it "can be changed to SOAP 1.2 and any other encoding" do
344
+ globals.soap_version(2)
345
+ globals.encoding("ISO-8859-1")
346
+
347
+ configured_http_request = new_soap_request.build
348
+ content_type = configured_http_request.headers["Content-Type"]
349
+
350
+ expect(content_type).to eq("application/soap+xml;charset=ISO-8859-1")
351
+ end
352
+
353
+ it "is not set when there is already a Content-Type value" do
354
+ globals.headers("Content-Type" => "application/awesomeness;charset=UTF-3000")
355
+ configured_http_request = new_soap_request.build(:soap_action => "findUser")
356
+ content_type = configured_http_request.headers["Content-Type"]
357
+
358
+ expect(content_type).to eq("application/awesomeness;charset=UTF-3000")
359
+ end
360
+ end
361
+
362
+ describe "ssl version" do
363
+ it "is set when specified" do
364
+ globals.ssl_version(:SSLv3)
365
+ http_request.auth.ssl.expects(:ssl_version=).with(:SSLv3)
366
+
367
+ new_soap_request.build
368
+ end
369
+
370
+ it "is not set otherwise" do
371
+ http_request.auth.ssl.expects(:ssl_version=).never
372
+ new_soap_request.build
373
+ end
374
+ end
375
+
376
+ describe "ssl verify mode" do
377
+ it "is set when specified" do
378
+ globals.ssl_verify_mode(:none)
379
+ http_request.auth.ssl.expects(:verify_mode=).with(:none)
380
+
381
+ new_soap_request.build
382
+ end
383
+
384
+ it "is not set otherwise" do
385
+ http_request.auth.ssl.expects(:verify_mode=).never
386
+ new_soap_request.build
387
+ end
388
+ end
389
+
390
+ describe "ssl cert key file" do
391
+ it "is set when specified" do
392
+ cert_key = File.expand_path("../../fixtures/ssl/client_key.pem", __FILE__)
393
+ globals.ssl_cert_key_file(cert_key)
394
+ http_request.auth.ssl.expects(:cert_key_file=).with(cert_key)
395
+
396
+ new_soap_request.build
397
+ end
398
+
399
+ it "is not set otherwise" do
400
+ http_request.auth.ssl.expects(:cert_key_file=).never
401
+ new_soap_request.build
402
+ end
403
+ end
404
+
405
+ describe "ssl cert key password" do
406
+ it "is set when specified" do
407
+ the_pass = "secure-password!42"
408
+ globals.ssl_cert_key_password(the_pass)
409
+ http_request.auth.ssl.expects(:cert_key_password=).with(the_pass)
410
+
411
+ new_soap_request.build
412
+ end
413
+
414
+ it "is not set otherwise" do
415
+ http_request.auth.ssl.expects(:cert_key_password=).never
416
+ new_soap_request.build
417
+ end
418
+ end
419
+
420
+ describe "ssl cert file" do
421
+ it "is set when specified" do
422
+ cert = File.expand_path("../../fixtures/ssl/client_cert.pem", __FILE__)
423
+ globals.ssl_cert_file(cert)
424
+ http_request.auth.ssl.expects(:cert_file=).with(cert)
425
+
426
+ new_soap_request.build
427
+ end
428
+
429
+ it "is not set otherwise" do
430
+ http_request.auth.ssl.expects(:cert_file=).never
431
+ new_soap_request.build
432
+ end
433
+ end
434
+
435
+ describe "ssl ca cert file" do
436
+ it "is set when specified" do
437
+ ca_cert = File.expand_path("../../fixtures/ssl/client_cert.pem", __FILE__)
438
+ globals.ssl_ca_cert_file(ca_cert)
439
+ http_request.auth.ssl.expects(:ca_cert_file=).with(ca_cert)
440
+
441
+ new_soap_request.build
442
+ end
443
+
444
+ it "is not set otherwise" do
445
+ http_request.auth.ssl.expects(:ca_cert_file=).never
446
+ new_soap_request.build
447
+ end
448
+ end
449
+
450
+ describe "basic auth" do
451
+ it "is set when specified" do
452
+ globals.basic_auth("luke", "secret")
453
+ http_request.auth.expects(:basic).with("luke", "secret")
454
+
455
+ new_soap_request.build
456
+ end
457
+
458
+ it "is not set otherwise" do
459
+ http_request.auth.expects(:basic).never
460
+ new_soap_request.build
461
+ end
462
+ end
463
+
464
+ describe "digest auth" do
465
+ it "is set when specified" do
466
+ globals.digest_auth("lea", "top-secret")
467
+ http_request.auth.expects(:digest).with("lea", "top-secret")
468
+
469
+ new_soap_request.build
470
+ end
471
+
472
+ it "is not set otherwise" do
473
+ http_request.auth.expects(:digest).never
474
+ new_soap_request.build
475
+ end
476
+ end
477
+
478
+ describe "ntlm auth" do
479
+ it "is set when specified" do
480
+ globals.ntlm("han", "super-secret")
481
+ http_request.auth.expects(:ntlm).with("han", "super-secret")
482
+
483
+ new_soap_request.build
484
+ end
485
+
486
+ it "is not set otherwise" do
487
+ http_request.auth.expects(:ntlm).never
488
+ new_soap_request.build
489
+ end
490
+ end
491
+ end
492
+
493
+ end