savon-xaop 0.7.2.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.
- data/CHANGELOG +124 -0
- data/README.textile +75 -0
- data/Rakefile +45 -0
- data/lib/savon/client.rb +84 -0
- data/lib/savon/core_ext/datetime.rb +8 -0
- data/lib/savon/core_ext/hash.rb +78 -0
- data/lib/savon/core_ext/net_http.rb +20 -0
- data/lib/savon/core_ext/object.rb +21 -0
- data/lib/savon/core_ext/string.rb +47 -0
- data/lib/savon/core_ext/symbol.rb +8 -0
- data/lib/savon/core_ext/uri.rb +10 -0
- data/lib/savon/core_ext.rb +3 -0
- data/lib/savon/request.rb +160 -0
- data/lib/savon/response.rb +108 -0
- data/lib/savon/soap.rb +176 -0
- data/lib/savon/wsdl.rb +122 -0
- data/lib/savon/wsse.rb +136 -0
- data/lib/savon.rb +34 -0
- data/spec/basic_spec_helper.rb +12 -0
- data/spec/endpoint_helper.rb +22 -0
- data/spec/fixtures/response/response_fixture.rb +36 -0
- data/spec/fixtures/response/xml/authentication.xml +14 -0
- data/spec/fixtures/response/xml/multi_ref.xml +39 -0
- data/spec/fixtures/response/xml/soap_fault.xml +8 -0
- data/spec/fixtures/response/xml/soap_fault12.xml +18 -0
- data/spec/fixtures/wsdl/wsdl_fixture.rb +37 -0
- data/spec/fixtures/wsdl/xml/authentication.xml +63 -0
- data/spec/fixtures/wsdl/xml/namespaced_actions.xml +307 -0
- data/spec/fixtures/wsdl/xml/no_namespace.xml +115 -0
- data/spec/http_stubs.rb +23 -0
- data/spec/integration/http_basic_auth_spec.rb +16 -0
- data/spec/integration/server.rb +51 -0
- data/spec/savon/client_spec.rb +77 -0
- data/spec/savon/core_ext/datetime_spec.rb +12 -0
- data/spec/savon/core_ext/hash_spec.rb +138 -0
- data/spec/savon/core_ext/net_http_spec.rb +38 -0
- data/spec/savon/core_ext/object_spec.rb +40 -0
- data/spec/savon/core_ext/string_spec.rb +68 -0
- data/spec/savon/core_ext/symbol_spec.rb +11 -0
- data/spec/savon/core_ext/uri_spec.rb +15 -0
- data/spec/savon/request_spec.rb +89 -0
- data/spec/savon/response_spec.rb +137 -0
- data/spec/savon/savon_spec.rb +23 -0
- data/spec/savon/soap_spec.rb +171 -0
- data/spec/savon/wsdl_spec.rb +84 -0
- data/spec/savon/wsse_spec.rb +132 -0
- data/spec/spec_helper.rb +5 -0
- metadata +175 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Savon::Request do
|
4
|
+
before { @request = Savon::Request.new EndpointHelper.wsdl_endpoint }
|
5
|
+
|
6
|
+
it "contains the ContentType for each supported SOAP version" do
|
7
|
+
Savon::SOAPVersions.each do |soap_version|
|
8
|
+
Savon::Request::ContentType[soap_version].should be_a(String)
|
9
|
+
Savon::Request::ContentType[soap_version].should_not be_empty
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# defaults to log request and response. disabled for spec execution
|
14
|
+
|
15
|
+
it "has both getter and setter for whether to log (global setting)" do
|
16
|
+
Savon::Request.log = true
|
17
|
+
Savon::Request.log?.should be_true
|
18
|
+
Savon::Request.log = false
|
19
|
+
Savon::Request.log?.should be_false
|
20
|
+
end
|
21
|
+
|
22
|
+
it "defaults to use a Logger instance for logging" do
|
23
|
+
Savon::Request.logger.should be_a(Logger)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "has both getter and setter for the logger to use (global setting)" do
|
27
|
+
Savon::Request.logger = nil
|
28
|
+
Savon::Request.logger.should be_nil
|
29
|
+
Savon::Request.logger = Logger.new STDOUT
|
30
|
+
end
|
31
|
+
|
32
|
+
it "defaults to :debug for logging" do
|
33
|
+
Savon::Request.log_level.should == :debug
|
34
|
+
end
|
35
|
+
|
36
|
+
it "has both getter and setter for the log level to use (global setting)" do
|
37
|
+
Savon::Request.log_level = :info
|
38
|
+
Savon::Request.log_level.should == :info
|
39
|
+
Savon::Request.log_level = :debug
|
40
|
+
end
|
41
|
+
|
42
|
+
it "is initialized with a SOAP endpoint String" do
|
43
|
+
Savon::Request.new EndpointHelper.wsdl_endpoint
|
44
|
+
end
|
45
|
+
|
46
|
+
it "has a getter for the SOAP endpoint URI" do
|
47
|
+
@request.endpoint.should == URI(EndpointHelper.wsdl_endpoint)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should have a getter for the proxy URI" do
|
51
|
+
@request.proxy.should == URI("")
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should have a getter for the HTTP headers which defaults to an empty Hash" do
|
55
|
+
@request.headers.should == {}
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should have a setter for the HTTP headers" do
|
59
|
+
headers = { "some" => "thing" }
|
60
|
+
|
61
|
+
@request.headers = headers
|
62
|
+
@request.headers.should == headers
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should return the Net::HTTP object" do
|
66
|
+
@request.http.should be_kind_of(Net::HTTP)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should have a method for setting HTTP basic auth credentials" do
|
70
|
+
@request.basic_auth "user", "password"
|
71
|
+
end
|
72
|
+
|
73
|
+
it "retrieves the WSDL document and returns the Net::HTTP response" do
|
74
|
+
wsdl_response = @request.wsdl
|
75
|
+
|
76
|
+
wsdl_response.should be_a(Net::HTTPResponse)
|
77
|
+
wsdl_response.body.should == WSDLFixture.authentication
|
78
|
+
end
|
79
|
+
|
80
|
+
it "executes a SOAP request and returns the Net::HTTP response" do
|
81
|
+
soap = Savon::SOAP.new
|
82
|
+
soap.endpoint = URI EndpointHelper.wsdl_endpoint
|
83
|
+
soap_response = @request.soap soap
|
84
|
+
|
85
|
+
soap_response.should be_a(Net::HTTPResponse)
|
86
|
+
soap_response.body.should == ResponseFixture.authentication
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Savon::Response do
|
4
|
+
before { @response = Savon::Response.new http_response_mock }
|
5
|
+
|
6
|
+
it "defaults to raises both Savon::SOAPFault and Savon::HTTPError" do
|
7
|
+
Savon::Response.raise_errors?.should be_true
|
8
|
+
end
|
9
|
+
|
10
|
+
it "has both getter and setter for whether to raise errors (global setting)" do
|
11
|
+
Savon::Response.raise_errors = false
|
12
|
+
Savon::Response.raise_errors?.should == false
|
13
|
+
Savon::Response.raise_errors = true
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "initialize" do
|
17
|
+
it "expects a Net::HTTPResponse" do
|
18
|
+
Savon::Response.new http_response_mock
|
19
|
+
end
|
20
|
+
|
21
|
+
it "raises a Savon::SOAPFault in case of a SOAP fault" do
|
22
|
+
lambda { savon_response_with :soap_fault }.should raise_error(Savon::SOAPFault)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "does not raise a Savon::SOAPFault in case the default is turned off" do
|
26
|
+
Savon::Response.raise_errors = false
|
27
|
+
savon_response_with :soap_fault
|
28
|
+
Savon::Response.raise_errors = true
|
29
|
+
end
|
30
|
+
|
31
|
+
it "raises a Savon::HTTPError in case of an HTTP error" do
|
32
|
+
lambda { savon_response_with :http_error }.should raise_error(Savon::HTTPError)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "does not raise a Savon::HTTPError in case the default is turned off" do
|
36
|
+
Savon::Response.raise_errors = false
|
37
|
+
savon_response_with :http_error
|
38
|
+
Savon::Response.raise_errors = true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "soap_fault?" do
|
43
|
+
before { Savon::Response.raise_errors = false }
|
44
|
+
|
45
|
+
it "does not return true in case the response seems to be ok" do
|
46
|
+
@response.soap_fault?.should_not be_true
|
47
|
+
end
|
48
|
+
|
49
|
+
it "returns true in case of a SOAP fault" do
|
50
|
+
savon_response_with(:soap_fault).soap_fault?.should be_true
|
51
|
+
end
|
52
|
+
|
53
|
+
after { Savon::Response.raise_errors = true }
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "soap_fault" do
|
57
|
+
before { Savon::Response.raise_errors = false }
|
58
|
+
|
59
|
+
it "returns the SOAP fault message in case of a SOAP fault" do
|
60
|
+
savon_response_with(:soap_fault).soap_fault.
|
61
|
+
should == "(soap:Server) Fault occurred while processing."
|
62
|
+
end
|
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
|
+
|
69
|
+
after { Savon::Response.raise_errors = true }
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "http_error?" do
|
73
|
+
before { Savon::Response.raise_errors = false }
|
74
|
+
|
75
|
+
it "does not return true in case the response seems to be ok" do
|
76
|
+
@response.http_error?.should_not be_true
|
77
|
+
end
|
78
|
+
|
79
|
+
it "returns true in case of an HTTP error" do
|
80
|
+
savon_response_with(:http_error).http_error?.should be_true
|
81
|
+
end
|
82
|
+
|
83
|
+
after { Savon::Response.raise_errors = true }
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "http_error" do
|
87
|
+
before { Savon::Response.raise_errors = false }
|
88
|
+
|
89
|
+
it "returns the HTTP error message in case of an HTTP error" do
|
90
|
+
savon_response_with(:http_error).http_error.should == "Not found (404)"
|
91
|
+
end
|
92
|
+
|
93
|
+
after { Savon::Response.raise_errors = true }
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should return the SOAP response body as a Hash" do
|
97
|
+
@response.to_hash[:authenticate_response][:return].should ==
|
98
|
+
ResponseFixture.authentication(:to_hash)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should return a Hash for a SOAP multiRef response" do
|
102
|
+
@response = Savon::Response.new http_response_mock(200, ResponseFixture.multi_ref, "OK")
|
103
|
+
|
104
|
+
@response.to_hash[:list_response].should be_a(Hash)
|
105
|
+
@response.to_hash[:multi_ref].should be_an(Array)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should return the raw SOAP response body" do
|
109
|
+
@response.to_xml.should == ResponseFixture.authentication
|
110
|
+
@response.to_s.should == ResponseFixture.authentication
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should return the Net::HTTP response object" do
|
114
|
+
@response.http.should be_a(Mocha::Mock)
|
115
|
+
@response.http.should respond_to(:code)
|
116
|
+
@response.http.should respond_to(:message)
|
117
|
+
@response.http.should respond_to(:body)
|
118
|
+
end
|
119
|
+
|
120
|
+
def savon_response_with(error_type)
|
121
|
+
mock = case error_type
|
122
|
+
when :soap_fault then http_response_mock 200, ResponseFixture.soap_fault
|
123
|
+
when :soap_fault12 then http_response_mock 200, ResponseFixture.soap_fault12
|
124
|
+
when :http_error then http_response_mock 404, "", "Not found"
|
125
|
+
end
|
126
|
+
Savon::Response.new mock
|
127
|
+
end
|
128
|
+
|
129
|
+
def http_response_mock(code = 200, body = nil, message = "OK")
|
130
|
+
body ||= ResponseFixture.authentication
|
131
|
+
mock = mock "Net::HTTPResponse"
|
132
|
+
mock.stubs :code => code.to_s, :message => message,
|
133
|
+
:content_type => "text/html", :body => body
|
134
|
+
mock
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Savon do
|
4
|
+
|
5
|
+
it "contains an Array of supported SOAP versions" do
|
6
|
+
Savon::SOAPVersions.should be_an(Array)
|
7
|
+
Savon::SOAPVersions.should_not be_empty
|
8
|
+
end
|
9
|
+
|
10
|
+
it "contains the xs:dateTime format" do
|
11
|
+
Savon::SOAPDateTimeFormat.should be_a(String)
|
12
|
+
Savon::SOAPDateTimeFormat.should_not be_empty
|
13
|
+
|
14
|
+
DateTime.new(2012, 03, 22, 16, 22, 33).strftime(Savon::SOAPDateTimeFormat).
|
15
|
+
should == "2012-03-22T16:22:33"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "contains a Regexp matching the xs:dateTime format" do
|
19
|
+
Savon::SOAPDateTimeRegexp.should be_a(Regexp)
|
20
|
+
(Savon::SOAPDateTimeRegexp === "2012-03-22T16:22:33").should be_true
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Savon::SOAP do
|
4
|
+
before do
|
5
|
+
@soap = Savon::SOAP.new
|
6
|
+
@soap.action = WSDLFixture.authentication(:operations)[:authenticate][:action]
|
7
|
+
end
|
8
|
+
|
9
|
+
it "contains the SOAP namespace for each supported SOAP version" do
|
10
|
+
Savon::SOAPVersions.each do |soap_version|
|
11
|
+
Savon::SOAP::SOAPNamespace[soap_version].should be_a(String)
|
12
|
+
Savon::SOAP::SOAPNamespace[soap_version].should_not be_empty
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it "contains the Content-Types for each supported SOAP version" do
|
17
|
+
Savon::SOAPVersions.each do |soap_version|
|
18
|
+
Savon::SOAP::ContentType[soap_version].should be_a(String)
|
19
|
+
Savon::SOAP::ContentType[soap_version].should_not be_empty
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it "defaults to SOAP 1.1" do
|
24
|
+
Savon::SOAP.version.should == 1
|
25
|
+
end
|
26
|
+
|
27
|
+
it "has both getter and setter for the SOAP version to use (global setting)" do
|
28
|
+
[2, 1].each do |soap_version|
|
29
|
+
Savon::SOAP.version = soap_version
|
30
|
+
Savon::SOAP.version.should == soap_version
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it "has a setter for the Savon::WSSE" do
|
35
|
+
@soap.wsse = Savon::WSSE.new
|
36
|
+
end
|
37
|
+
|
38
|
+
it "is has both getter and setter for the SOAP action" do
|
39
|
+
@soap.action.should == WSDLFixture.authentication(:operations)[:authenticate][:action]
|
40
|
+
|
41
|
+
@soap.action = "someAction"
|
42
|
+
@soap.action.should == "someAction"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "has a setter for the SOAP input" do
|
46
|
+
@soap.input = "FindUserRequest"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "has both getter and setter for global SOAP headers" do
|
50
|
+
header = { "some" => "header" }
|
51
|
+
Savon::SOAP.header = header
|
52
|
+
Savon::SOAP.header.should == header
|
53
|
+
|
54
|
+
Savon::SOAP.header = {}
|
55
|
+
end
|
56
|
+
|
57
|
+
it "has both getter and setter for the SOAP header" do
|
58
|
+
@soap.header.should be_a(Hash)
|
59
|
+
@soap.header.should be_empty
|
60
|
+
|
61
|
+
@soap.header = { "specialAuthKey" => "secret" }
|
62
|
+
@soap.header.should == { "specialAuthKey" => "secret" }
|
63
|
+
end
|
64
|
+
|
65
|
+
it "has a getter for the SOAP body, expecting a Hash or an XML String" do
|
66
|
+
@soap.body = { :id => 666 }
|
67
|
+
@soap.body = "<id>666</id>"
|
68
|
+
end
|
69
|
+
|
70
|
+
it "has a setter for specifying a Hash of namespaces" do
|
71
|
+
namespaces = { "xmlns:env" => "http://example.com" }
|
72
|
+
@soap.namespaces = namespaces
|
73
|
+
@soap.namespaces.should == namespaces
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "has a getter for namespaces" do
|
77
|
+
it "which defaults to include the SOAP 1.1 namespace" do
|
78
|
+
@soap.namespaces.should == { "xmlns:env" => Savon::SOAP::SOAPNamespace[1] }
|
79
|
+
end
|
80
|
+
|
81
|
+
it "which contains the SOAP 1.2 namespace if specified" do
|
82
|
+
@soap.version = 2
|
83
|
+
@soap.namespaces.should == { "xmlns:env" => Savon::SOAP::SOAPNamespace[2] }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
it "has both getter and setter for global namespaces" do
|
88
|
+
namespaces = { "some" => "namespace" }
|
89
|
+
Savon::SOAP.namespaces = namespaces
|
90
|
+
Savon::SOAP.namespaces.should == namespaces
|
91
|
+
|
92
|
+
Savon::SOAP.namespaces = {}
|
93
|
+
end
|
94
|
+
|
95
|
+
it "has a convenience method for setting the 'xmlns:wsdl' namespace" do
|
96
|
+
@soap.namespaces.should == { "xmlns:env" => "http://schemas.xmlsoap.org/soap/envelope/" }
|
97
|
+
|
98
|
+
@soap.namespace = "http://example.com"
|
99
|
+
@soap.namespaces.should include("xmlns:env" => "http://schemas.xmlsoap.org/soap/envelope/")
|
100
|
+
@soap.namespaces.should include("xmlns:wsdl" => "http://example.com")
|
101
|
+
end
|
102
|
+
|
103
|
+
it "has both getter and setter for the SOAP endpoint" do
|
104
|
+
@soap.endpoint.should be_nil
|
105
|
+
|
106
|
+
soap_endpoint = URI EndpointHelper.soap_endpoint
|
107
|
+
@soap.endpoint = soap_endpoint
|
108
|
+
@soap.endpoint.should == soap_endpoint
|
109
|
+
end
|
110
|
+
|
111
|
+
it "has a getter for the SOAP version to use which defaults to SOAP 1.1" do
|
112
|
+
@soap.version.should == Savon::SOAP.version
|
113
|
+
end
|
114
|
+
|
115
|
+
it "has a setter for specifying the SOAP version to use" do
|
116
|
+
@soap.version = 2
|
117
|
+
@soap.version.should == 2
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "to_xml" do
|
121
|
+
after { Savon::SOAP.version = 1 }
|
122
|
+
|
123
|
+
it "returns the XML for a SOAP request" do
|
124
|
+
@soap.namespaces["xmlns:wsdl"] = "http://v1_0.ws.auth.order.example.com/"
|
125
|
+
@soap.body = { :id => 666 }
|
126
|
+
|
127
|
+
@soap.to_xml.should include('xmlns:wsdl="http://v1_0.ws.auth.order.example.com/"')
|
128
|
+
@soap.to_xml.should include('xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"')
|
129
|
+
@soap.to_xml.should include('<wsdl:authenticate><id>666</id></wsdl:authenticate>')
|
130
|
+
end
|
131
|
+
|
132
|
+
it "caches the XML, returning the same Object every time" do
|
133
|
+
@soap.to_xml.object_id.should == @soap.to_xml.object_id
|
134
|
+
end
|
135
|
+
|
136
|
+
it "uses the SOAP namespace for the specified SOAP version" do
|
137
|
+
@soap.version = 2
|
138
|
+
@soap.to_xml.should include(Savon::SOAP::SOAPNamespace[2])
|
139
|
+
end
|
140
|
+
|
141
|
+
it "uses the SOAP namespace for the default SOAP version otherwise" do
|
142
|
+
Savon::SOAP.version = 2
|
143
|
+
@soap.to_xml.should include(Savon::SOAP::SOAPNamespace[2])
|
144
|
+
end
|
145
|
+
|
146
|
+
it "merges global and per request headers defined as Hashes" do
|
147
|
+
Savon::SOAP.header = { "API-KEY" => "secret", "SOME-KEY" => "something" }
|
148
|
+
@soap.header["SOME-KEY"] = "somethingelse"
|
149
|
+
|
150
|
+
@soap.to_xml.should include("<API-KEY>secret</API-KEY>")
|
151
|
+
@soap.to_xml.should include("<SOME-KEY>somethingelse</SOME-KEY>")
|
152
|
+
end
|
153
|
+
|
154
|
+
it "joins global and per request headers defined as Strings" do
|
155
|
+
Savon::SOAP.header = "<API-KEY>secret</API-KEY>"
|
156
|
+
@soap.header = "<SOME-KEY>somethingelse</SOME-KEY>"
|
157
|
+
|
158
|
+
@soap.to_xml.should include("<API-KEY>secret</API-KEY>")
|
159
|
+
@soap.to_xml.should include("<SOME-KEY>somethingelse</SOME-KEY>")
|
160
|
+
end
|
161
|
+
|
162
|
+
it "merges the global and per request namespaces" do
|
163
|
+
Savon::SOAP.namespaces = { "xmlns:wsdl" => "namespace", "xmlns:v1" => "v1namespace" }
|
164
|
+
@soap.namespaces["xmlns:v1"] = "newV1namespace"
|
165
|
+
|
166
|
+
@soap.to_xml.should include('xmlns:wsdl="namespace"')
|
167
|
+
@soap.to_xml.should include('xmlns:v1="newV1namespace"')
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Savon::WSDL do
|
4
|
+
describe "a common WSDL document" do
|
5
|
+
before { @wsdl = new_wsdl }
|
6
|
+
|
7
|
+
it "is initialized with a Savon::Request object" do
|
8
|
+
Savon::WSDL.new Savon::Request.new(EndpointHelper.wsdl_endpoint)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "is enabled by default" do
|
12
|
+
@wsdl.enabled?.should be_true
|
13
|
+
end
|
14
|
+
|
15
|
+
it "has a getter for the namespace URI" do
|
16
|
+
@wsdl.namespace_uri.should == WSDLFixture.authentication(:namespace_uri)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "has a getter for returning an Array of available SOAP actions" do
|
20
|
+
WSDLFixture.authentication(:operations).keys.each do |soap_action|
|
21
|
+
@wsdl.soap_actions.should include(soap_action)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "has a getter for returning a Hash of available SOAP operations" do
|
26
|
+
@wsdl.operations.should == WSDLFixture.authentication(:operations)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "responds to SOAP actions while still behaving as usual otherwise" do
|
30
|
+
WSDLFixture.authentication(:operations).keys.each do |soap_action|
|
31
|
+
@wsdl.respond_to?(soap_action).should be_true
|
32
|
+
end
|
33
|
+
|
34
|
+
@wsdl.respond_to?(:object_id).should be_true
|
35
|
+
@wsdl.respond_to?(:some_undefined_method).should be_false
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns the raw WSDL document for to_s" do
|
39
|
+
@wsdl.to_s.should == WSDLFixture.authentication
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "a WSDL document having core sections without a namespace" do
|
44
|
+
before { @wsdl = new_wsdl :no_namespace }
|
45
|
+
|
46
|
+
it "returns the namespace URI" do
|
47
|
+
@wsdl.namespace_uri.should == WSDLFixture.no_namespace(:namespace_uri)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "returns an Array of available SOAP actions" do
|
51
|
+
WSDLFixture.no_namespace(:operations).keys.each do |soap_action|
|
52
|
+
@wsdl.soap_actions.should include(soap_action)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it "returns a Hash of SOAP operations" do
|
57
|
+
@wsdl.operations.should == WSDLFixture.no_namespace(:operations)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "a WSDL document with namespaced SOAP actions" do
|
62
|
+
before { @wsdl = new_wsdl :namespaced_actions }
|
63
|
+
|
64
|
+
it "returns the namespace URI" do
|
65
|
+
@wsdl.namespace_uri.should == WSDLFixture.namespaced_actions(:namespace_uri)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "returns an Array of available SOAP actions" do
|
69
|
+
WSDLFixture.namespaced_actions(:operations).keys.each do |soap_action|
|
70
|
+
@wsdl.soap_actions.should include(soap_action)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
it "returns a Hash of SOAP operations" do
|
75
|
+
@wsdl.operations.should == WSDLFixture.namespaced_actions(:operations)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def new_wsdl(fixture = nil)
|
80
|
+
endpoint = fixture ? EndpointHelper.wsdl_endpoint(fixture) : EndpointHelper.wsdl_endpoint
|
81
|
+
Savon::WSDL.new Savon::Request.new(endpoint)
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Savon::WSSE do
|
4
|
+
before do
|
5
|
+
Savon::WSSE.username, Savon::WSSE.password, Savon::WSSE.digest = nil, nil, false
|
6
|
+
@wsse, @username, @password = Savon::WSSE.new, "gorilla", "secret"
|
7
|
+
end
|
8
|
+
|
9
|
+
it "contains the namespace for WS Security Secext" do
|
10
|
+
Savon::WSSE::WSENamespace.should be_a(String)
|
11
|
+
Savon::WSSE::WSENamespace.should_not be_empty
|
12
|
+
end
|
13
|
+
|
14
|
+
it "contains the namespace for WS Security Utility" do
|
15
|
+
Savon::WSSE::WSUNamespace.should be_a(String)
|
16
|
+
Savon::WSSE::WSUNamespace.should_not be_empty
|
17
|
+
end
|
18
|
+
|
19
|
+
it "defaults to nil for the WSSE username (global setting)" do
|
20
|
+
Savon::WSSE.username.should be_nil
|
21
|
+
end
|
22
|
+
|
23
|
+
it "has both getter and setter for the WSSE username (global setting)" do
|
24
|
+
Savon::WSSE.username = "gorilla"
|
25
|
+
Savon::WSSE.username.should == "gorilla"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "defaults to nil for the WSSE password (global setting)" do
|
29
|
+
Savon::WSSE.password.should be_nil
|
30
|
+
end
|
31
|
+
|
32
|
+
it "has both getter and setter for the WSSE password (global setting)" do
|
33
|
+
Savon::WSSE.password = "secret"
|
34
|
+
Savon::WSSE.password.should == "secret"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "defaults to nil for whether to use WSSE digest (global setting)" do
|
38
|
+
Savon::WSSE.digest?.should be_false
|
39
|
+
end
|
40
|
+
|
41
|
+
it "has both getter and setter for whether to use WSSE digest (global setting)" do
|
42
|
+
Savon::WSSE.digest = true
|
43
|
+
Savon::WSSE.digest?.should == true
|
44
|
+
end
|
45
|
+
|
46
|
+
it "defaults to nil for the WSSE username" do
|
47
|
+
@wsse.username.should be_nil
|
48
|
+
end
|
49
|
+
|
50
|
+
it "has both getter and setter for the WSSE username" do
|
51
|
+
@wsse.username = "gorilla"
|
52
|
+
@wsse.username.should == "gorilla"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "defaults to nil for the WSSE password" do
|
56
|
+
@wsse.password.should be_nil
|
57
|
+
end
|
58
|
+
|
59
|
+
it "has both getter and setter for the WSSE password" do
|
60
|
+
@wsse.password = "secret"
|
61
|
+
@wsse.password.should == "secret"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "defaults to nil for whether to use WSSE digest" do
|
65
|
+
@wsse.digest?.should be_false
|
66
|
+
end
|
67
|
+
|
68
|
+
it "has both getter and setter for whether to use WSSE digest" do
|
69
|
+
@wsse.digest = true
|
70
|
+
@wsse.digest?.should == true
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "header" do
|
74
|
+
describe "returns the XML for a WSSE authentication header" do
|
75
|
+
it "with WSSE credentials specified" do
|
76
|
+
@wsse.username = @username
|
77
|
+
@wsse.password = @password
|
78
|
+
header = @wsse.header
|
79
|
+
|
80
|
+
header.should include_security_namespaces
|
81
|
+
header.should include(@username)
|
82
|
+
header.should include(@password)
|
83
|
+
header.should include(Savon::WSSE::PasswordTextURI)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "with WSSE credentials specified via defaults" do
|
87
|
+
Savon::WSSE.username = @username
|
88
|
+
Savon::WSSE.password = @password
|
89
|
+
header = @wsse.header
|
90
|
+
|
91
|
+
header.should include_security_namespaces
|
92
|
+
header.should include(@username)
|
93
|
+
header.should include(@password)
|
94
|
+
header.should include(Savon::WSSE::PasswordTextURI)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "returns the XML for a WSSE digest header if specified" do
|
99
|
+
it "via accessors" do
|
100
|
+
@wsse.username = @username
|
101
|
+
@wsse.password = @password
|
102
|
+
@wsse.digest = true
|
103
|
+
header = @wsse.header
|
104
|
+
|
105
|
+
header.should include_security_namespaces
|
106
|
+
header.should include(@username)
|
107
|
+
header.should_not include(@password)
|
108
|
+
header.should include(Savon::WSSE::PasswordDigestURI)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "via defaults" do
|
112
|
+
@wsse.username = @username
|
113
|
+
@wsse.password = @password
|
114
|
+
Savon::WSSE.digest = true
|
115
|
+
header = @wsse.header
|
116
|
+
|
117
|
+
header.should include_security_namespaces
|
118
|
+
header.should include(@username)
|
119
|
+
header.should_not include(@password)
|
120
|
+
header.should include(Savon::WSSE::PasswordDigestURI)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def include_security_namespaces
|
125
|
+
simple_matcher("include security namespaces") do |given|
|
126
|
+
given.should include(Savon::WSSE::WSENamespace)
|
127
|
+
given.should include(Savon::WSSE::WSUNamespace)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|