savon 0.6.6 → 0.6.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/CHANGELOG +7 -3
  2. data/README.textile +12 -0
  3. data/Rakefile +0 -0
  4. data/VERSION +1 -1
  5. data/lib/savon.rb +1 -1
  6. data/lib/savon/client.rb +15 -9
  7. data/lib/savon/core_ext.rb +0 -0
  8. data/lib/savon/core_ext/datetime.rb +0 -0
  9. data/lib/savon/core_ext/hash.rb +0 -0
  10. data/lib/savon/core_ext/object.rb +7 -0
  11. data/lib/savon/core_ext/string.rb +0 -0
  12. data/lib/savon/core_ext/symbol.rb +0 -0
  13. data/lib/savon/core_ext/uri.rb +0 -0
  14. data/lib/savon/request.rb +47 -21
  15. data/lib/savon/response.rb +12 -13
  16. data/lib/savon/soap.rb +9 -11
  17. data/lib/savon/wsdl.rb +20 -22
  18. data/lib/savon/wsse.rb +39 -37
  19. data/spec/endpoint_helper.rb +0 -0
  20. data/spec/fixtures/multiple_user_response.xml +0 -0
  21. data/spec/fixtures/soap_fault.xml +0 -0
  22. data/spec/fixtures/soap_fault12.xml +18 -0
  23. data/spec/fixtures/user_fixture.rb +4 -0
  24. data/spec/fixtures/user_response.xml +0 -0
  25. data/spec/fixtures/user_wsdl.xml +0 -0
  26. data/spec/http_stubs.rb +0 -0
  27. data/spec/savon/client_spec.rb +27 -3
  28. data/spec/savon/core_ext/datetime_spec.rb +0 -0
  29. data/spec/savon/core_ext/hash_spec.rb +2 -3
  30. data/spec/savon/core_ext/object_spec.rb +14 -0
  31. data/spec/savon/core_ext/string_spec.rb +0 -0
  32. data/spec/savon/core_ext/symbol_spec.rb +0 -0
  33. data/spec/savon/core_ext/uri_spec.rb +0 -0
  34. data/spec/savon/request_spec.rb +48 -2
  35. data/spec/savon/response_spec.rb +6 -0
  36. data/spec/savon/savon_spec.rb +0 -0
  37. data/spec/savon/soap_spec.rb +0 -0
  38. data/spec/savon/wsdl_spec.rb +0 -0
  39. data/spec/savon/wsse_spec.rb +0 -0
  40. data/spec/spec_helper.rb +0 -0
  41. metadata +14 -13
data/CHANGELOG CHANGED
@@ -1,7 +1,11 @@
1
1
  == 0.6.6 (2009-12-14)
2
- * Default to use the name of the SOAP action (the method called in a client) in lowerCamelCase for SOAP action and input
3
- when Savon::WSDL is disabled. You still need to specify soap.action and maybe soap.input in case your SOAP actions are
4
- named any different.
2
+ * Default to use the name of the SOAP action (the method called in a client) in lowerCamelCase for SOAP action
3
+ and input when Savon::WSDL is disabled. You still need to specify soap.action and maybe soap.input in case
4
+ your SOAP actions are named any different.
5
+ * Implemented support for a proxy server. The proxy URI can be set through an optional Hash of options passed
6
+ to instantiating Savon::Client (Dave Woodward <dave@futuremint.com>)
7
+ * Implemented support for SSL client authentication. Settings can be set through an optional Hash of arguments
8
+ passed to instantiating Savon::Client (colonhyphenp)
5
9
 
6
10
  == 0.6.5 (2009-12-13)
7
11
  * Added an open_timeout method to Savon::Request.
@@ -49,6 +49,18 @@ end
49
49
 
50
50
  p. More information: "WSSE":http://wiki.github.com/rubiii/savon/wsse
51
51
 
52
+ h3. SSL Client Authentication
53
+
54
+ p. Savon::Client can accept SSL client certificates, as well as verify the validity of a server certificate. Syntax inspired by Adam Wiggin's "Rest-Client":http://github.com/adamwiggins/rest-client
55
+
56
+ bc. client = Savon::Client.new(
57
+ 'https://example.org/wsdl',
58
+ :ssl_client_cert => OpenSSL::X509::Certificate.new(File.read("client_cert.pem")),
59
+ :ssl_client_key => OpenSSL::PKey::RSA.new(File.read("client_key.pem"), "password if one exists"),
60
+ :ssl_ca_file => "cacert.pem",
61
+ :ssl_verify => OpenSSL::SSL::VERIFY_PEER
62
+ )
63
+
52
64
  h3. The Response object
53
65
 
54
66
  p. Savon::Response represents the HTTP and SOAP response. It contains and raises errors in case of an HTTP error or SOAP fault (unless disabled). Also you can get the response as XML (for parsing it with an XML library) or translated into a Hash.
data/Rakefile CHANGED
File without changes
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.6
1
+ 0.6.7
@@ -18,7 +18,7 @@ module Savon
18
18
  end
19
19
 
20
20
  # standard libs
21
- %w(logger net/http net/https uri base64 digest/sha1 rexml/document).each do |lib|
21
+ %w(logger net/http net/https openssl uri base64 digest/sha1 rexml/document).each do |lib|
22
22
  require lib
23
23
  end
24
24
 
@@ -6,17 +6,23 @@ module Savon
6
6
  # with SOAP services and XML.
7
7
  class Client
8
8
 
9
- # Defines whether to use Savon::WSDL.
10
- @wsdl = true
9
+ # Global setting of whether to use Savon::WSDL.
10
+ @@wsdl = true
11
11
 
12
- class << self
13
- # Accessor for whether to use Savon::WSDL.
14
- attr_accessor :wsdl
12
+ # Sets the global setting of whether to use Savon::WSDL.
13
+ def self.wsdl=(wsdl)
14
+ @@wsdl = wsdl
15
15
  end
16
16
 
17
- # Expects a SOAP +endpoint+ String.
18
- def initialize(endpoint)
19
- @request = Request.new endpoint
17
+ # Returns the global setting of whether to use Savon::WSDL.
18
+ def self.wsdl?
19
+ @@wsdl
20
+ end
21
+
22
+ # Expects a SOAP +endpoint+ String. Also accepts an optional Hash of
23
+ # +options+ for specifying a proxy server and SSL client authentication.
24
+ def initialize(endpoint,options = {})
25
+ @request = Request.new endpoint, options
20
26
  @wsdl = WSDL.new @request
21
27
  end
22
28
 
@@ -28,7 +34,7 @@ module Savon
28
34
 
29
35
  # Returns whether to use Savon::WSDL.
30
36
  def wsdl?
31
- self.class.wsdl && @wsdl
37
+ self.class.wsdl? && @wsdl
32
38
  end
33
39
 
34
40
  # Returns +true+ for available methods and SOAP actions.
File without changes
File without changes
File without changes
@@ -1,5 +1,12 @@
1
1
  class Object
2
2
 
3
+ # Returns +true+ if the Object is false, empty, or a whitespace string.
4
+ # For example, "", false, nil, [], and {} are blank.
5
+ # Implementation from ActiveSupport.
6
+ def blank?
7
+ respond_to?(:empty?) ? empty? : !self
8
+ end unless defined? blank?
9
+
3
10
  # Returns the Object as a SOAP request compliant key.
4
11
  def to_soap_key
5
12
  to_s
File without changes
File without changes
File without changes
@@ -8,43 +8,59 @@ module Savon
8
8
  # Content-Types by SOAP version.
9
9
  ContentType = { 1 => "text/xml", 2 => "application/soap+xml" }
10
10
 
11
- # Defines whether to log HTTP requests.
12
- @log = true
11
+ # Whether to log HTTP requests.
12
+ @@log = true
13
13
 
14
14
  # The default logger.
15
- @logger = Logger.new STDOUT
15
+ @@logger = Logger.new STDOUT
16
16
 
17
17
  # The default log level.
18
- @log_level = :debug
18
+ @@log_level = :debug
19
19
 
20
- class << self
21
- # Sets whether to log HTTP requests.
22
- attr_writer :log
20
+ # Sets whether to log HTTP requests.
21
+ def self.log=(log)
22
+ @@log = log
23
+ end
23
24
 
24
- # Returns whether to log HTTP requests.
25
- def log?
26
- @log
27
- end
25
+ # Returns whether to log HTTP requests.
26
+ def self.log?
27
+ @@log
28
+ end
29
+
30
+ # Sets the logger.
31
+ def self.logger=(logger)
32
+ @@logger = logger
33
+ end
28
34
 
29
- # Accessor for the default logger.
30
- attr_accessor :logger
35
+ # Returns the logger.
36
+ def self.logger
37
+ @@logger
38
+ end
31
39
 
32
- # Accessor for the default log level.
33
- attr_accessor :log_level
40
+ # Sets the log level.
41
+ def self.log_level=(log_level)
42
+ @@log_level = log_level
34
43
  end
35
44
 
36
- # Expects an endpoint String. Raises an exception in case the given
37
- # +endpoint+ does not seem to be valid.
38
- def initialize(endpoint)
39
- raise ArgumentError, "Invalid endpoint: #{endpoint}" unless
40
- /^(http|https):\/\// === endpoint
45
+ # Returns the log level.
46
+ def self.log_level
47
+ @@log_level
48
+ end
41
49
 
50
+ # Expects a SOAP +endpoint+ String. Also accepts an optional Hash of
51
+ # +options+ for specifying a proxy server and SSL client authentication.
52
+ def initialize(endpoint, options = {})
42
53
  @endpoint = URI endpoint
54
+ @proxy = options[:proxy] ? URI(options[:proxy]) : URI("")
55
+ @ssl = options[:ssl] if options[:ssl]
43
56
  end
44
57
 
45
58
  # Returns the endpoint URI.
46
59
  attr_reader :endpoint
47
60
 
61
+ # Returns the proxy URI.
62
+ attr_reader :proxy
63
+
48
64
  # Sets the open timeout for HTTP requests.
49
65
  def open_timeout=(sec)
50
66
  http.open_timeout = sec
@@ -90,12 +106,22 @@ module Savon
90
106
  # Returns a Net::HTTP instance.
91
107
  def http
92
108
  unless @http
93
- @http ||= Net::HTTP.new @endpoint.host, @endpoint.port
109
+ @http ||= Net::HTTP::Proxy(@proxy.host, @proxy.port).new @endpoint.host, @endpoint.port
94
110
  @http.use_ssl = true if @endpoint.ssl?
111
+ @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
112
+ add_ssl_authentication if @ssl
95
113
  end
96
114
  @http
97
115
  end
98
116
 
117
+ # Adds SSL client authentication to the +@http+ instance.
118
+ def add_ssl_authentication
119
+ @http.verify_mode = @ssl[:verify] if @ssl[:verify].kind_of? Integer
120
+ @http.cert = @ssl[:client_cert] if @ssl[:client_cert]
121
+ @http.key = @ssl[:client_key] if @ssl[:client_key]
122
+ @http.ca_file = @ssl[:ca_file] if @ssl[:ca_file]
123
+ end
124
+
99
125
  # Returns a Hash containing the header for an HTTP request.
100
126
  def http_header
101
127
  { "Content-Type" => ContentType[@soap.version], "SOAPAction" => @soap.action }
@@ -5,19 +5,17 @@ module Savon
5
5
  # Represents the HTTP and SOAP response.
6
6
  class Response
7
7
 
8
- # The default of whether to raise errors.
9
- @raise_errors = true
8
+ # The global setting of whether to raise errors.
9
+ @@raise_errors = true
10
10
 
11
- class << self
12
-
13
- # Sets the default of whether to raise errors.
14
- attr_writer :raise_errors
15
-
16
- # Returns the default of whether to raise errors.
17
- def raise_errors?
18
- @raise_errors
19
- end
11
+ # Sets the global setting of whether to raise errors.
12
+ def self.raise_errors=(raise_errors)
13
+ @@raise_errors = raise_errors
14
+ end
20
15
 
16
+ # Returns the global setting of whether to raise errors.
17
+ def self.raise_errors?
18
+ @@raise_errors
21
19
  end
22
20
 
23
21
  # Expects a Net::HTTPResponse and handles errors.
@@ -90,8 +88,9 @@ module Savon
90
88
  def soap_fault_message_by_version(soap_fault)
91
89
  if soap_fault.keys.include? "faultcode"
92
90
  "(#{soap_fault['faultcode']}) #{soap_fault['faultstring']}"
93
- elsif soap_fault.keys.include? "code"
94
- "(#{soap_fault['code']['value']}) #{soap_fault['reason']['text']}"
91
+ elsif soap_fault.keys.include? "Code"
92
+ # SOAP 1.2 error code element is capitalized, see: http://www.w3.org/TR/soap12-part1/#faultcodeelement
93
+ "(#{soap_fault['Code']['Value']}) #{soap_fault['Reason']['Text']}"
95
94
  end
96
95
  end
97
96
 
@@ -14,19 +14,17 @@ module Savon
14
14
  # Content-Types by SOAP version.
15
15
  ContentType = { 1 => "text/xml", 2 => "application/soap+xml" }
16
16
 
17
- # The default SOAP version.
18
- @version = 1
17
+ # The global SOAP version.
18
+ @@version = 1
19
19
 
20
- class << self
21
-
22
- # Returns the default SOAP version.
23
- attr_reader :version
24
-
25
- # Sets the default SOAP version.
26
- def version=(version)
27
- @version = version if Savon::SOAPVersions.include? version
28
- end
20
+ # Returns the global SOAP version.
21
+ def self.version
22
+ @@version
23
+ end
29
24
 
25
+ # Sets the global SOAP version.
26
+ def self.version=(version)
27
+ @@version = version if Savon::SOAPVersions.include? version
30
28
  end
31
29
 
32
30
  # Sets the WSSE options.
@@ -55,9 +55,11 @@ module Savon
55
55
  # Stream listener for parsing the WSDL document.
56
56
  class WSDLStream
57
57
 
58
- # Initializer, sets an empty Hash of operations.
58
+ # Defines the main sections of a WSDL document.
59
+ Sections = %w(definitions types message portType binding service)
60
+
59
61
  def initialize
60
- @operations = {}
62
+ @depth, @operations = 0, {}
61
63
  end
62
64
 
63
65
  # Returns the namespace URI from the WSDL document.
@@ -66,32 +68,28 @@ module Savon
66
68
  # Returns the SOAP operations found in the WSDL document.
67
69
  attr_reader :operations
68
70
 
69
- # Hook method called when the stream parser encounters a tag.
70
- def tag_start(name, attrs)
71
- section_from name
71
+ # Hook method called when the stream parser encounters a starting tag.
72
+ def tag_start(tag, attrs)
73
+ @depth += 1
74
+ tag = tag.strip_namespace
75
+
76
+ @section = tag.to_sym if @depth <= 2 && Sections.include?(tag)
72
77
  @namespace_uri ||= attrs["targetNamespace"] if @section == :definitions
73
- operation_from name, attrs if @section == :binding && /.+:operation/ === name
78
+
79
+ operation_from tag, attrs if @section == :binding && tag == "operation"
74
80
  end
75
81
 
76
- # Sets the current section of the WSDL document from a given tag +name+.
77
- def section_from(name)
78
- section = case name
79
- when "wsdl:definitions" then :definitions
80
- when "wsdl:types" then :types
81
- when "wsdl:message" then :message
82
- when "wsdl:portType" then :port_type
83
- when "wsdl:binding" then :binding
84
- when "wsdl:service" then :service
85
- end
86
- @section = section if section
82
+ # Hook method called when the stream parser encounters a closing tag.
83
+ def tag_end(tag)
84
+ @depth -= 1
87
85
  end
88
86
 
89
87
  # Stores available operations from a given tag +name+ and +attrs+.
90
- def operation_from(name, attrs)
91
- if name == "wsdl:operation"
92
- @action = attrs["name"]
93
- elsif /.+:operation/ === name
94
- @action = attrs["soapAction"] if attrs["soapAction"] && !attrs["soapAction"].empty?
88
+ def operation_from(tag, attrs)
89
+ @action = attrs["name"] if attrs["name"]
90
+
91
+ if attrs["soapAction"]
92
+ @action = attrs["soapAction"] unless attrs["soapAction"].blank?
95
93
  input = @action.split("/").last
96
94
  @operations[input.snakecase.to_sym] = { :action => @action, :input => input }
97
95
  end
@@ -11,77 +11,79 @@ module Savon
11
11
  # Namespace for WS Security Utility.
12
12
  WSUNamespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
13
13
 
14
- # Default WSSE username.
15
- @username = nil
14
+ # Global WSSE username.
15
+ @@username = nil
16
16
 
17
- # Default WSSE password.
18
- @password = nil
19
-
20
- # Default for whether to use WSSE digest.
21
- @digest = false
22
-
23
- class << self
17
+ # Returns the global WSSE username.
18
+ def self.username
19
+ @@username
20
+ end
24
21
 
25
- # Returns the default WSSE username.
26
- attr_reader :username
22
+ # Sets the global WSSE username.
23
+ def self.username=(username)
24
+ @@username = username.to_s if username.respond_to? :to_s
25
+ @@username = nil if username.nil?
26
+ end
27
27
 
28
- # Sets the default WSSE username.
29
- def username=(username)
30
- @username = username.to_s if username.respond_to? :to_s
31
- @username = nil if username.nil?
32
- end
28
+ # Global WSSE password.
29
+ @@password = nil
33
30
 
34
- # Returns the default WSSE password.
35
- attr_reader :password
31
+ # Returns the global WSSE password.
32
+ def self.password
33
+ @@password
34
+ end
36
35
 
37
- # Sets the default WSSE password.
38
- def password=(password)
39
- @password = password.to_s if password.respond_to? :to_s
40
- @password = nil if password.nil?
41
- end
36
+ # Sets the global WSSE password.
37
+ def self.password=(password)
38
+ @@password = password.to_s if password.respond_to? :to_s
39
+ @@password = nil if password.nil?
40
+ end
42
41
 
43
- # Sets whether to use WSSE digest by default.
44
- attr_writer :digest
42
+ # Global setting of whether to use WSSE digest.
43
+ @@digest = false
45
44
 
46
- # Returns whether to use WSSE digest by default.
47
- def digest?
48
- @digest
49
- end
45
+ # Returns the global setting of whether to use WSSE digest.
46
+ def self.digest?
47
+ @@digest
48
+ end
50
49
 
50
+ # Global setting of whether to use WSSE digest.
51
+ def self.digest=(digest)
52
+ @@digest = digest
51
53
  end
52
54
 
53
- # Sets the WSSE username.
55
+ # Sets the WSSE username per request.
54
56
  def username=(username)
55
57
  @username = username.to_s if username.respond_to? :to_s
56
58
  @username = nil if username.nil?
57
59
  end
58
60
 
59
- # Returns the WSSE username. Defaults to the global default.
61
+ # Returns the WSSE username. Defaults to the global setting.
60
62
  def username
61
63
  @username || self.class.username
62
64
  end
63
65
 
64
- # Sets the WSSE password.
66
+ # Sets the WSSE password per request.
65
67
  def password=(password)
66
68
  @password = password.to_s if password.respond_to? :to_s
67
69
  @password = nil if password.nil?
68
70
  end
69
71
 
70
- # Returns the WSSE password. Defaults to the global default.
72
+ # Returns the WSSE password. Defaults to the global setting.
71
73
  def password
72
74
  @password || self.class.password
73
75
  end
74
76
 
75
- # Sets whether to use WSSE digest.
77
+ # Sets whether to use WSSE digest per request.
76
78
  attr_writer :digest
77
79
 
78
- # Returns whether to use WSSE digest. Defaults to the global default.
80
+ # Returns whether to use WSSE digest. Defaults to the global setting.
79
81
  def digest?
80
82
  @digest || self.class.digest?
81
83
  end
82
84
 
83
- # Returns the XML for a WSSE header or an empty String unless username
84
- # and password are specified.
85
+ # Returns the XML for a WSSE header or an empty String unless both
86
+ # username and password were specified.
85
87
  def header
86
88
  return "" unless username && password
87
89
 
File without changes
File without changes
File without changes
@@ -0,0 +1,18 @@
1
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:m="http://www.example.org/timeouts">
2
+ <soap:Body>
3
+ <soap:Fault>
4
+ <Code>
5
+ <Value>soap:Sender</Value>
6
+ <Subcode>
7
+ <Value>m:MessageTimeout</Value>
8
+ </Subcode>
9
+ </Code>
10
+ <Reason>
11
+ <Text xml:lang="en">Sender Timeout</Text>
12
+ </Reason>
13
+ <Detail>
14
+ <m:MaxTime>P5M</m:MaxTime>
15
+ </Detail>
16
+ </soap:Fault>
17
+ </soap:Body>
18
+ </soap:Envelope>
@@ -46,6 +46,10 @@ class UserFixture
46
46
  def soap_fault
47
47
  load_fixture :soap_fault
48
48
  end
49
+
50
+ def soap_fault12
51
+ load_fixture :soap_fault12
52
+ end
49
53
 
50
54
  private
51
55
 
File without changes
File without changes
File without changes
@@ -7,8 +7,8 @@ describe Savon::Client do
7
7
  Savon::Client.new EndpointHelper.wsdl_endpoint
8
8
  end
9
9
 
10
- it "raises an ArgumentError when initialized with an invalid endpoint" do
11
- lambda { Savon::Client.new "invalid" }.should raise_error ArgumentError
10
+ it "accepts an optional proxy URI passed in via options" do
11
+ Savon::Client.new EndpointHelper.wsdl_endpoint, :proxy => 'http://proxy'
12
12
  end
13
13
 
14
14
  it "has a getter for accessing the Savon::WSDL" do
@@ -40,6 +40,11 @@ describe Savon::Client do
40
40
  @client.find_user.should be_a Savon::Response
41
41
  end
42
42
 
43
+ it "dispatches SOAP calls via method_missing without using WSDL" do
44
+ @client.wsdl = false
45
+ @client.find_user.should be_a Savon::Response
46
+ end
47
+
43
48
  it "raises a Savon::SOAPFault in case of a SOAP fault" do
44
49
  client = Savon::Client.new EndpointHelper.wsdl_endpoint(:soap_fault)
45
50
  lambda { client.find_user }.should raise_error Savon::SOAPFault
@@ -65,4 +70,23 @@ describe Savon::Client do
65
70
  lambda { @client.some_undefined_method }.should raise_error NoMethodError
66
71
  end
67
72
 
68
- end
73
+ it "passes ssl options to request" do
74
+ @client.request.class.class_eval { attr_reader :ssl }
75
+
76
+ client = Savon::Client.new(
77
+ EndpointHelper.wsdl_endpoint,
78
+ :ssl => {
79
+ :client_cert => "client cert",
80
+ :client_key => "client key",
81
+ :ca_file => "ca file",
82
+ :verify => OpenSSL::SSL::VERIFY_PEER
83
+ }
84
+ )
85
+
86
+ client.request.ssl[:client_cert].should == "client cert"
87
+ client.request.ssl[:client_key].should == "client key"
88
+ client.request.ssl[:ca_file].should == "ca file"
89
+ client.request.ssl[:verify].should == OpenSSL::SSL::VERIFY_PEER
90
+ end
91
+
92
+ end
File without changes
@@ -81,9 +81,8 @@ describe Hash do
81
81
 
82
82
  it "calls to_s on Strings even if they respond to to_datetime" do
83
83
  singleton = "gorilla"
84
- def singleton.to_datetime
85
- UserFixture.datetime_object
86
- end
84
+ singleton.expects( :to_s ).returns singleton
85
+ singleton.expects( :to_datetime ).never
87
86
 
88
87
  { :name => singleton }.to_soap_xml.should == "<name>gorilla</name>"
89
88
  end
@@ -2,6 +2,20 @@ require "spec_helper"
2
2
 
3
3
  describe Object do
4
4
 
5
+ describe "blank?" do
6
+ it "returns true for Objects perceived to be blank" do
7
+ ["", false, nil, [], {}].each do |object|
8
+ object.should be_blank
9
+ end
10
+ end
11
+
12
+ it "returns false for every other Object" do
13
+ ["!blank", true, [:a], {:a => "b"}].each do |object|
14
+ object.should_not be_blank
15
+ end
16
+ end
17
+ end
18
+
5
19
  describe "to_soap_key" do
6
20
  it "calls to_s for every Object" do
7
21
  Object.to_soap_key.should == Object.to_s
File without changes
File without changes
File without changes
@@ -43,14 +43,18 @@ describe Savon::Request do
43
43
  Savon::Request.new EndpointHelper.wsdl_endpoint
44
44
  end
45
45
 
46
- it "raises an ArgumentError when initialized with an invalid endpoint" do
47
- lambda { Savon::Request.new "invalid" }.should raise_error ArgumentError
46
+ it "ccepts an optional proxy URI passed in via options" do
47
+ Savon::Request.new EndpointHelper.wsdl_endpoint, :proxy => "http://localhost:8080"
48
48
  end
49
49
 
50
50
  it "has a getter for the SOAP endpoint URI" do
51
51
  @request.endpoint.should == URI(EndpointHelper.wsdl_endpoint)
52
52
  end
53
53
 
54
+ it "should have a getter for the proxy URI" do
55
+ @request.proxy.should == URI("")
56
+ end
57
+
54
58
  it "has a setter for specifying an open_timeout" do
55
59
  @request.open_timeout = 30
56
60
  end
@@ -72,5 +76,47 @@ describe Savon::Request do
72
76
  soap_response.should be_a Net::HTTPResponse
73
77
  soap_response.body.should == UserFixture.user_response
74
78
  end
79
+
80
+ describe "Savon::Request SSL" do
81
+ before { @request.class.class_eval { public "http" } }
82
+
83
+ it "defaults to not setting ssl parameters" do
84
+ http = @request.http
85
+ http.cert.should be_nil
86
+ http.key.should be_nil
87
+ http.ca_file.should be_nil
88
+ http.verify_mode.should == OpenSSL::SSL::VERIFY_NONE
89
+ end
90
+
91
+ it "sets client cert in http object when set in request constructor" do
92
+ request = Savon::Request.new(EndpointHelper.wsdl_endpoint, :ssl => {
93
+ :client_cert => "client cert"
94
+ })
95
+ request.http.cert.should == "client cert"
96
+ end
97
+
98
+ it "sets ca cert in http object when set in request constructor" do
99
+ request = Savon::Request.new(EndpointHelper.wsdl_endpoint, :ssl => {
100
+ :client_key => "client key"
101
+ })
102
+ request.http.key.should == "client key"
103
+ end
104
+
105
+ it "sets client cert in http object when set in request constructor" do
106
+ request = Savon::Request.new(EndpointHelper.wsdl_endpoint, :ssl => {
107
+ :ca_file => "ca file"
108
+ })
109
+ request.http.ca_file.should == "ca file"
110
+ end
75
111
 
112
+ it "sets client cert in http object when set in request constructor" do
113
+ request = Savon::Request.new(EndpointHelper.wsdl_endpoint, :ssl => {
114
+ :verify => OpenSSL::SSL::VERIFY_PEER
115
+ })
116
+ request.http.verify_mode.should == OpenSSL::SSL::VERIFY_PEER
117
+ end
118
+
119
+ after { @request.class.class_eval { private "http" } }
120
+ end
121
+
76
122
  end
@@ -61,6 +61,11 @@ describe Savon::Response do
61
61
  should == "(soap:Server) Fault occurred while processing."
62
62
  end
63
63
 
64
+ it "returns the SOAP fault message in case of a SOAP 1.2 fault" do
65
+ savon_response_with(:soap_fault12).soap_fault.
66
+ should == "(soap:Sender) Sender Timeout"
67
+ end
68
+
64
69
  after { Savon::Response.raise_errors = true }
65
70
  end
66
71
 
@@ -100,6 +105,7 @@ describe Savon::Response do
100
105
  def savon_response_with(error_type)
101
106
  mock = case error_type
102
107
  when :soap_fault then http_response_mock(200, UserFixture.soap_fault)
108
+ when :soap_fault12 then http_response_mock(200, UserFixture.soap_fault12)
103
109
  when :http_error then http_response_mock(404, "", "Not found")
104
110
  end
105
111
  Savon::Response.new mock
File without changes
File without changes
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: savon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6
4
+ version: 0.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Harrington
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-14 00:00:00 +01:00
12
+ date: 2009-12-17 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -92,6 +92,7 @@ files:
92
92
  - spec/endpoint_helper.rb
93
93
  - spec/fixtures/multiple_user_response.xml
94
94
  - spec/fixtures/soap_fault.xml
95
+ - spec/fixtures/soap_fault12.xml
95
96
  - spec/fixtures/user_fixture.rb
96
97
  - spec/fixtures/user_response.xml
97
98
  - spec/fixtures/user_wsdl.xml
@@ -143,20 +144,20 @@ signing_key:
143
144
  specification_version: 3
144
145
  summary: Heavy metal Ruby SOAP client library
145
146
  test_files:
146
- - spec/spec_helper.rb
147
147
  - spec/endpoint_helper.rb
148
- - spec/savon/response_spec.rb
149
- - spec/savon/savon_spec.rb
150
- - spec/savon/wsdl_spec.rb
151
- - spec/savon/request_spec.rb
148
+ - spec/fixtures/user_fixture.rb
149
+ - spec/http_stubs.rb
152
150
  - spec/savon/client_spec.rb
153
- - spec/savon/soap_spec.rb
154
- - spec/savon/core_ext/symbol_spec.rb
155
- - spec/savon/core_ext/hash_spec.rb
156
- - spec/savon/core_ext/string_spec.rb
157
151
  - spec/savon/core_ext/datetime_spec.rb
152
+ - spec/savon/core_ext/hash_spec.rb
158
153
  - spec/savon/core_ext/object_spec.rb
154
+ - spec/savon/core_ext/string_spec.rb
155
+ - spec/savon/core_ext/symbol_spec.rb
159
156
  - spec/savon/core_ext/uri_spec.rb
157
+ - spec/savon/request_spec.rb
158
+ - spec/savon/response_spec.rb
159
+ - spec/savon/savon_spec.rb
160
+ - spec/savon/soap_spec.rb
161
+ - spec/savon/wsdl_spec.rb
160
162
  - spec/savon/wsse_spec.rb
161
- - spec/http_stubs.rb
162
- - spec/fixtures/user_fixture.rb
163
+ - spec/spec_helper.rb