savon 2.7.2 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 090044c5ed3b652b05e9725efd589d989debdfe2
4
- data.tar.gz: 66e3b163f648dfee8822abdf628705641fe34170
3
+ metadata.gz: 7adbc53fe80bb807f76d542112ff55db6da480e9
4
+ data.tar.gz: 0536349c41007db20291ca8e7dad28c125666066
5
5
  SHA512:
6
- metadata.gz: fca34525f579049113cf5dd7f6d6ae647bec2c82d73cbd7884012a5bd85af9d6fd43653d76a20f83b181727f9c2c56e6828e5bc8a242904703fb1e00ff1da5df
7
- data.tar.gz: 51d75ad87da2e6a9c0617987418eb00d36cafd27ee3ba840eb08c8034fecd12a22537e7c5fed13e127e705a6927b8a0738d986370142a705dd545804af93bea8
6
+ metadata.gz: 741e08c1b5fba53b3588c52e454e50bfb14eb73c6ed463fc994468e62e77720dc574fabd2506fc51f4cb1f192fd7774bc63574467579e562eba4e8a4f95eb712
7
+ data.tar.gz: b4c4144f0714a3f49bfcae8e304d7031bc46d396b0ee45334a84a73ebb06dcbf5036468bf784c95eb6090456ecf933e89c71c29c8a3556b3732ec9200ef7214f
@@ -1,3 +1,10 @@
1
+ # 2.8.0 (2014-11-12)
2
+
3
+ * Feature : [#620](https://github.com/savonrb/savon/pull/620) add #build_request method that builds the actual XML request body, but does not submit it. Useful for debugging, possibly.
4
+ * Fix : Loosened dependencies on Gyoku, Nori, Akami, and other Savon-dependency gems
5
+ * Feature: [#636](https://github.com/savonrb/savon/pull/636) Set HTTPI.logger when Savon's logger is configured.
6
+ * Feature: [#639](https://github.com/savonrb/savon/issues/639) Allow setting any SSL version that OpenSSL provides. See [the relevant HTTPI issue](https://github.com/savonrb/httpi/pull/136) for more information.
7
+
1
8
  # 2.7.2 (2014-09-23)
2
9
 
3
10
  Fix : Preserve false values (https://github.com/savonrb/savon/issues/321)
@@ -41,6 +41,10 @@ module Savon
41
41
  @wsdl.service_name
42
42
  end
43
43
 
44
+ def build_request(operation_name, locals = {}, &block)
45
+ operation(operation_name).request(locals, &block)
46
+ end
47
+
44
48
  private
45
49
 
46
50
  def set_globals(globals, block)
@@ -55,6 +55,11 @@ module Savon
55
55
  create_response(response)
56
56
  end
57
57
 
58
+ def request(locals = {}, &block)
59
+ builder = build(locals, &block)
60
+ build_request(builder)
61
+ end
62
+
58
63
  private
59
64
 
60
65
  def create_response(response)
@@ -189,6 +189,7 @@ module Savon
189
189
 
190
190
  # The logger to use. Defaults to a Savon::Logger instance.
191
191
  def logger(logger)
192
+ HTTPI.logger = logger
192
193
  @options[:logger] = logger
193
194
  end
194
195
 
@@ -22,7 +22,7 @@ module Savon
22
22
  alias_method :successful?, :success?
23
23
 
24
24
  def soap_fault?
25
- SOAPFault.present? @http
25
+ SOAPFault.present?(@http, xml)
26
26
  end
27
27
 
28
28
  def http_error?
@@ -77,7 +77,7 @@ module Savon
77
77
  private
78
78
 
79
79
  def build_soap_and_http_errors!
80
- @soap_fault = SOAPFault.new(@http, nori) if soap_fault?
80
+ @soap_fault = SOAPFault.new(@http, nori, xml) if soap_fault?
81
81
  @http_error = HTTPError.new(@http) if http_error?
82
82
  end
83
83
 
@@ -3,20 +3,22 @@ require "savon"
3
3
  module Savon
4
4
  class SOAPFault < Error
5
5
 
6
- def self.present?(http)
7
- fault_node = http.body.include?("Fault>")
8
- soap1_fault = http.body.include?("faultcode>") && http.body.include?("faultstring>")
9
- soap2_fault = http.body.include?("Code>") && http.body.include?("Reason>")
6
+ def self.present?(http, xml = nil)
7
+ xml ||= http.body
8
+ fault_node = xml.include?("Fault>")
9
+ soap1_fault = xml.include?("faultcode>") && xml.include?("faultstring>")
10
+ soap2_fault = xml.include?("Code>") && xml.include?("Reason>")
10
11
 
11
12
  fault_node && (soap1_fault || soap2_fault)
12
13
  end
13
14
 
14
- def initialize(http, nori)
15
+ def initialize(http, nori, xml = nil)
16
+ @xml = xml
15
17
  @http = http
16
18
  @nori = nori
17
19
  end
18
20
 
19
- attr_reader :http, :nori
21
+ attr_reader :http, :nori, :xml
20
22
 
21
23
  def to_s
22
24
  fault = nori.find(to_hash, 'Fault')
@@ -24,7 +26,7 @@ module Savon
24
26
  end
25
27
 
26
28
  def to_hash
27
- parsed = nori.parse(@http.body)
29
+ parsed = nori.parse(xml || http.body)
28
30
  nori.find(parsed, 'Envelope', 'Body')
29
31
  end
30
32
 
@@ -1,3 +1,3 @@
1
1
  module Savon
2
- VERSION = '2.7.2'
2
+ VERSION = '2.8.0'
3
3
  end
@@ -16,11 +16,11 @@ Gem::Specification.new do |s|
16
16
  s.rubyforge_project = s.name
17
17
  s.license = 'MIT'
18
18
 
19
- s.add_dependency "nori", "~> 2.4.0"
20
- s.add_dependency "httpi", "~> 2.2.3"
21
- s.add_dependency "wasabi", "~> 3.3.0"
22
- s.add_dependency "akami", "~> 1.2.0"
23
- s.add_dependency "gyoku", "~> 1.1.0"
19
+ s.add_dependency "nori", "~> 2.4"
20
+ s.add_dependency "httpi", "~> 2.3"
21
+ s.add_dependency "wasabi", "3.3.0"
22
+ s.add_dependency "akami", "~> 1.2"
23
+ s.add_dependency "gyoku", "~> 1.2"
24
24
  s.add_dependency "uuid", "~> 2.3.7"
25
25
 
26
26
  s.add_dependency "builder", ">= 2.1.2"
@@ -170,6 +170,79 @@ describe Savon::Client do
170
170
  end
171
171
  end
172
172
 
173
+ describe "#build_request" do
174
+ it "returns the request without making an actual call" do
175
+ expected_request = mock('request')
176
+ wsdl = Wasabi::Document.new('http://example.com')
177
+
178
+ operation = Savon::Operation.new(
179
+ :authenticate,
180
+ wsdl,
181
+ Savon::GlobalOptions.new
182
+ )
183
+ operation.expects(:request).returns(expected_request)
184
+
185
+ Savon::Operation.expects(:create).with(
186
+ :authenticate,
187
+ instance_of(Wasabi::Document),
188
+ instance_of(Savon::GlobalOptions)
189
+ ).returns(operation)
190
+
191
+ operation.expects(:call).never
192
+
193
+ client = new_client(:endpoint => @server.url(:repeat))
194
+ request = client.build_request(:authenticate) do
195
+ message(:symbol => "AAPL" )
196
+ end
197
+
198
+ expect(request).to eq expected_request
199
+ end
200
+
201
+ it "accepts a block without arguments" do
202
+ client = new_client(:endpoint => @server.url(:repeat))
203
+ request = client.build_request(:authenticate) do
204
+ message(:symbol => "AAPL" )
205
+ end
206
+
207
+ expect(request.body).
208
+ to include('<tns:authenticate><symbol>AAPL</symbol></tns:authenticate>')
209
+ end
210
+
211
+ it "accepts a block with one argument" do
212
+ client = new_client(:endpoint => @server.url(:repeat))
213
+
214
+ # supports instance variables!
215
+ @instance_variable = { :symbol => "AAPL" }
216
+
217
+ request = client.build_request(:authenticate) do |locals|
218
+ locals.message(@instance_variable)
219
+ end
220
+
221
+ expect(request.body).
222
+ to include("<tns:authenticate><symbol>AAPL</symbol></tns:authenticate>")
223
+ end
224
+
225
+ it "accepts argument for the message tag" do
226
+ client = new_client(:endpoint => @server.url(:repeat))
227
+ request = client.build_request(:authenticate, :attributes => { "ID" => "ABC321" })
228
+
229
+ expect(request.body).
230
+ to include("<tns:authenticate ID=\"ABC321\"></tns:authenticate>")
231
+ end
232
+
233
+ it "raises when the operation name is not a symbol" do
234
+ expect { new_client.build_request("not a symbol") }.to raise_error
235
+ end
236
+
237
+ it "raises when given an unknown option via the Hash syntax" do
238
+ expect { new_client.build_request(:authenticate, :invalid_local_option => true) }.to raise_error
239
+ end
240
+
241
+ it "raises when given an unknown option via the block syntax" do
242
+ expect { new_client.build_request(:authenticate) { another_invalid_local_option true } }.to raise_error
243
+ end
244
+ end
245
+
173
246
  def new_http_response(options = {})
174
247
  defaults = { :code => 200, :headers => {}, :body => Fixture.response(:authentication) }
175
248
  response = defaults.merge options
@@ -192,6 +192,15 @@ describe Savon::Operation do
192
192
  end
193
193
  end
194
194
 
195
+ describe "#request" do
196
+ it "returns the request" do
197
+ operation = new_operation(:verify_address, wsdl, globals)
198
+ request = operation.request
199
+
200
+ expect(request.body).to include('<tns:VerifyAddress></tns:VerifyAddress>')
201
+ end
202
+ end
203
+
195
204
  def with_multipart_mocked
196
205
  multipart_response = Class.new { def initialize(*args); end }
197
206
  multipart_mock = Module.new
@@ -325,6 +325,15 @@ describe "Options" do
325
325
 
326
326
  expect(logger).to eq(custom_logger)
327
327
  end
328
+
329
+ it "sets the logger of HTTPI as well" do
330
+ custom_logger = Logger.new($stdout)
331
+
332
+ client = new_client(:logger => custom_logger, :log => true)
333
+
334
+ expect(HTTPI.logger).to be custom_logger
335
+ end
336
+
328
337
  end
329
338
 
330
339
  context "global :log_level" do
@@ -502,6 +511,7 @@ describe "Options" do
502
511
 
503
512
  # filter out logs we're not interested in
504
513
  client.globals[:logger].expects(:info).at_least_once
514
+ client.globals[:logger].expects(:debug).at_least_once
505
515
 
506
516
  # check whether the password is filtered
507
517
  client.globals[:logger].expects(:debug).with { |message|
@@ -521,6 +531,7 @@ describe "Options" do
521
531
 
522
532
  # filter out logs we're not interested in
523
533
  client.globals[:logger].expects(:info).at_least_once
534
+ client.globals[:logger].expects(:debug).at_least_once
524
535
 
525
536
  # check whether the message is pretty printed
526
537
  client.globals[:logger].expects(:debug).with { |message|
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.7.2
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Harrington
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-23 00:00:00.000000000 Z
11
+ date: 2014-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nori
@@ -16,40 +16,40 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.4.0
19
+ version: '2.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.4.0
26
+ version: '2.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: httpi
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.2.3
33
+ version: '2.3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.2.3
40
+ version: '2.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: wasabi
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - '='
46
46
  - !ruby/object:Gem::Version
47
47
  version: 3.3.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - '='
53
53
  - !ruby/object:Gem::Version
54
54
  version: 3.3.0
55
55
  - !ruby/object:Gem::Dependency
@@ -58,28 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.2.0
61
+ version: '1.2'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.2.0
68
+ version: '1.2'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: gyoku
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.1.0
75
+ version: '1.2'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.1.0
82
+ version: '1.2'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: uuid
85
85
  requirement: !ruby/object:Gem::Requirement