savon 2.11.1 → 2.15.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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +132 -73
- data/README.md +35 -20
- data/lib/savon/block_interface.rb +1 -0
- data/lib/savon/builder.rb +126 -30
- data/lib/savon/client.rb +2 -2
- data/lib/savon/header.rb +2 -6
- data/lib/savon/http_error.rb +4 -4
- data/lib/savon/log_message.rb +2 -1
- 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 +22 -19
- data/lib/savon/options.rb +98 -19
- data/lib/savon/qualified_message.rb +29 -27
- data/lib/savon/request.rb +22 -6
- data/lib/savon/request_logger.rb +8 -2
- data/lib/savon/response.rb +58 -10
- data/lib/savon/soap_fault.rb +3 -4
- data/lib/savon/string_utils.rb +17 -0
- data/lib/savon/version.rb +2 -1
- data/lib/savon.rb +2 -0
- metadata +80 -100
- data/.gitignore +0 -14
- data/.travis.yml +0 -15
- data/.yardopts +0 -6
- data/CONTRIBUTING.md +0 -46
- data/Gemfile +0 -18
- 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/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/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 -66
- 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 -28
- 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 -44
- 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 -1064
- data/spec/savon/qualified_message_spec.rb +0 -20
- data/spec/savon/request_logger_spec.rb +0 -37
- data/spec/savon/request_spec.rb +0 -496
- data/spec/savon/response_spec.rb +0 -270
- data/spec/savon/soap_fault_spec.rb +0 -131
- 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
@@ -1,92 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "integration/support/server"
|
3
|
-
|
4
|
-
describe Savon do
|
5
|
-
|
6
|
-
before :all do
|
7
|
-
@server = IntegrationServer.run
|
8
|
-
end
|
9
|
-
|
10
|
-
after :all do
|
11
|
-
@server.stop
|
12
|
-
end
|
13
|
-
|
14
|
-
describe ".observers" do
|
15
|
-
after :each do
|
16
|
-
Savon.observers.clear
|
17
|
-
end
|
18
|
-
|
19
|
-
it "allows to register an observer for every request" do
|
20
|
-
observer = Class.new {
|
21
|
-
|
22
|
-
def notify(operation_name, builder, globals, locals)
|
23
|
-
@operation_name = operation_name
|
24
|
-
|
25
|
-
@builder = builder
|
26
|
-
@globals = globals
|
27
|
-
@locals = locals
|
28
|
-
|
29
|
-
# return nil to execute the request
|
30
|
-
nil
|
31
|
-
end
|
32
|
-
|
33
|
-
attr_reader :operation_name, :builder, :globals, :locals
|
34
|
-
|
35
|
-
}.new
|
36
|
-
|
37
|
-
Savon.observers << observer
|
38
|
-
|
39
|
-
new_client.call(:authenticate)
|
40
|
-
|
41
|
-
expect(observer.operation_name).to eq(:authenticate)
|
42
|
-
|
43
|
-
expect(observer.builder).to be_a(Savon::Builder)
|
44
|
-
expect(observer.globals).to be_a(Savon::GlobalOptions)
|
45
|
-
expect(observer.locals).to be_a(Savon::LocalOptions)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "allows to register an observer which mocks requests" do
|
49
|
-
observer = Class.new {
|
50
|
-
|
51
|
-
def notify(*)
|
52
|
-
# return a response to mock the request
|
53
|
-
HTTPI::Response.new(201, { "X-Result" => "valid" }, "valid!")
|
54
|
-
end
|
55
|
-
|
56
|
-
}.new
|
57
|
-
|
58
|
-
Savon.observers << observer
|
59
|
-
|
60
|
-
response = new_client.call(:authenticate)
|
61
|
-
|
62
|
-
expect(response.http.code).to eq(201)
|
63
|
-
expect(response.http.headers).to eq("X-Result" => "valid")
|
64
|
-
expect(response.http.body).to eq("valid!")
|
65
|
-
end
|
66
|
-
|
67
|
-
it "raises if an observer returns something other than nil or an HTTPI::Response" do
|
68
|
-
observer = Class.new {
|
69
|
-
|
70
|
-
def notify(*)
|
71
|
-
[]
|
72
|
-
end
|
73
|
-
|
74
|
-
}.new
|
75
|
-
|
76
|
-
Savon.observers << observer
|
77
|
-
|
78
|
-
expect { new_client.call(:authenticate) }.
|
79
|
-
to raise_error(Savon::Error, "Observers need to return an HTTPI::Response " \
|
80
|
-
"to mock the request or nil to execute the request.")
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def new_client
|
85
|
-
Savon.client(
|
86
|
-
:endpoint => @server.url(:repeat),
|
87
|
-
:namespace => "http://v1.example.com",
|
88
|
-
:log => false
|
89
|
-
)
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
@@ -1,230 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "integration/support/server"
|
3
|
-
require "json"
|
4
|
-
require "ostruct"
|
5
|
-
|
6
|
-
describe Savon::Operation do
|
7
|
-
|
8
|
-
let(:globals) { Savon::GlobalOptions.new(:endpoint => @server.url(:repeat), :log => false) }
|
9
|
-
let(:wsdl) { Wasabi::Document.new Fixture.wsdl(:taxcloud) }
|
10
|
-
|
11
|
-
let(:no_wsdl) {
|
12
|
-
wsdl = Wasabi::Document.new
|
13
|
-
|
14
|
-
wsdl.endpoint = "http://example.com"
|
15
|
-
wsdl.namespace = "http://v1.example.com"
|
16
|
-
|
17
|
-
wsdl
|
18
|
-
}
|
19
|
-
|
20
|
-
def new_operation(operation_name, wsdl, globals)
|
21
|
-
Savon::Operation.create(operation_name, wsdl, globals)
|
22
|
-
end
|
23
|
-
|
24
|
-
before :all do
|
25
|
-
@server = IntegrationServer.run
|
26
|
-
end
|
27
|
-
|
28
|
-
after :all do
|
29
|
-
@server.stop
|
30
|
-
end
|
31
|
-
|
32
|
-
describe ".create with a WSDL" do
|
33
|
-
it "returns a new operation" do
|
34
|
-
operation = new_operation(:verify_address, wsdl, globals)
|
35
|
-
expect(operation).to be_a(Savon::Operation)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "raises if the operation name is not a Symbol" do
|
39
|
-
expect { new_operation("not a symbol", wsdl, globals) }.
|
40
|
-
to raise_error(ArgumentError, /Expected the first parameter \(the name of the operation to call\) to be a symbol/)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "raises if the operation is not available for the service" do
|
44
|
-
expect { new_operation(:no_such_operation, wsdl, globals) }.
|
45
|
-
to raise_error(Savon::UnknownOperationError, /Unable to find SOAP operation: :no_such_operation/)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "raises if the endpoint cannot be reached" do
|
49
|
-
message = "Error!"
|
50
|
-
response = HTTPI::Response.new(500, {}, message)
|
51
|
-
error = Wasabi::Resolver::HTTPError.new(message, response)
|
52
|
-
Wasabi::Document.any_instance.stubs(:soap_actions).raises(error)
|
53
|
-
|
54
|
-
expect { new_operation(:verify_address, wsdl, globals) }.
|
55
|
-
to raise_error(Savon::HTTPError, /#{message}/)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe ".create without a WSDL" do
|
60
|
-
it "returns a new operation" do
|
61
|
-
operation = new_operation(:verify_address, no_wsdl, globals)
|
62
|
-
expect(operation).to be_a(Savon::Operation)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "#build" do
|
67
|
-
it "returns the Builder" do
|
68
|
-
operation = new_operation(:verify_address, wsdl, globals)
|
69
|
-
builder = operation.build(:message => { :test => 'message' })
|
70
|
-
|
71
|
-
expect(builder).to be_a(Savon::Builder)
|
72
|
-
expect(builder.to_s).to include('<tns:VerifyAddress><tns:test>message</tns:test></tns:VerifyAddress>')
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe "#call" do
|
77
|
-
it "returns a response object" do
|
78
|
-
operation = new_operation(:verify_address, wsdl, globals)
|
79
|
-
expect(operation.call).to be_a(Savon::Response)
|
80
|
-
end
|
81
|
-
|
82
|
-
it "uses the global :endpoint option for the request" do
|
83
|
-
globals.endpoint("http://v1.example.com")
|
84
|
-
HTTPI::Request.any_instance.expects(:url=).with("http://v1.example.com")
|
85
|
-
|
86
|
-
operation = new_operation(:verify_address, wsdl, globals)
|
87
|
-
|
88
|
-
# stub the actual request
|
89
|
-
http_response = HTTPI::Response.new(200, {}, "")
|
90
|
-
operation.expects(:call_with_logging).returns(http_response)
|
91
|
-
|
92
|
-
operation.call
|
93
|
-
end
|
94
|
-
|
95
|
-
it "falls back to use the WSDL's endpoint if the :endpoint option was not set" do
|
96
|
-
globals_without_endpoint = Savon::GlobalOptions.new(:log => false)
|
97
|
-
HTTPI::Request.any_instance.expects(:url=).with(wsdl.endpoint)
|
98
|
-
|
99
|
-
operation = new_operation(:verify_address, wsdl, globals_without_endpoint)
|
100
|
-
|
101
|
-
# stub the actual request
|
102
|
-
http_response = HTTPI::Response.new(200, {}, "")
|
103
|
-
operation.expects(:call_with_logging).returns(http_response)
|
104
|
-
|
105
|
-
operation.call
|
106
|
-
end
|
107
|
-
|
108
|
-
it "sets the Content-Length header" do
|
109
|
-
# XXX: probably the worst spec ever written. refactor! [dh, 2013-01-05]
|
110
|
-
http_request = HTTPI::Request.new
|
111
|
-
http_request.headers.expects(:[]=).with("Content-Length", "312")
|
112
|
-
Savon::SOAPRequest.any_instance.expects(:build).returns(http_request)
|
113
|
-
|
114
|
-
new_operation(:verify_address, wsdl, globals).call
|
115
|
-
end
|
116
|
-
|
117
|
-
it "passes the local :soap_action option to the request builder" do
|
118
|
-
globals.endpoint @server.url(:inspect_request)
|
119
|
-
soap_action = "http://v1.example.com/VerifyAddress"
|
120
|
-
|
121
|
-
operation = new_operation(:verify_address, wsdl, globals)
|
122
|
-
response = operation.call(:soap_action => soap_action)
|
123
|
-
|
124
|
-
actual_soap_action = inspect_request(response).soap_action
|
125
|
-
expect(actual_soap_action).to eq(%("#{soap_action}"))
|
126
|
-
end
|
127
|
-
|
128
|
-
it "uses the local :cookies option" do
|
129
|
-
globals.endpoint @server.url(:inspect_request)
|
130
|
-
cookies = [HTTPI::Cookie.new("some-cookie=choc-chip")]
|
131
|
-
|
132
|
-
HTTPI::Request.any_instance.expects(:set_cookies).with(cookies)
|
133
|
-
|
134
|
-
operation = new_operation(:verify_address, wsdl, globals)
|
135
|
-
operation.call(:cookies => cookies)
|
136
|
-
end
|
137
|
-
|
138
|
-
it "passes nil to the request builder if the :soap_action was set to nil" do
|
139
|
-
globals.endpoint @server.url(:inspect_request)
|
140
|
-
|
141
|
-
operation = new_operation(:verify_address, wsdl, globals)
|
142
|
-
response = operation.call(:soap_action => nil)
|
143
|
-
|
144
|
-
actual_soap_action = inspect_request(response).soap_action
|
145
|
-
expect(actual_soap_action).to be_nil
|
146
|
-
end
|
147
|
-
|
148
|
-
it "gets the SOAP action from the WSDL if available" do
|
149
|
-
globals.endpoint @server.url(:inspect_request)
|
150
|
-
|
151
|
-
operation = new_operation(:verify_address, wsdl, globals)
|
152
|
-
response = operation.call
|
153
|
-
|
154
|
-
actual_soap_action = inspect_request(response).soap_action
|
155
|
-
expect(actual_soap_action).to eq('"http://taxcloud.net/VerifyAddress"')
|
156
|
-
end
|
157
|
-
|
158
|
-
it "falls back to Gyoku if both option and WSDL are not available" do
|
159
|
-
globals.endpoint @server.url(:inspect_request)
|
160
|
-
|
161
|
-
operation = new_operation(:authenticate, no_wsdl, globals)
|
162
|
-
response = operation.call
|
163
|
-
|
164
|
-
actual_soap_action = inspect_request(response).soap_action
|
165
|
-
expect(actual_soap_action).to eq(%("authenticate"))
|
166
|
-
end
|
167
|
-
|
168
|
-
it "returns a Savon::Multipart::Response if available and requested globally" do
|
169
|
-
globals.multipart true
|
170
|
-
|
171
|
-
with_multipart_mocked do
|
172
|
-
operation = new_operation(:authenticate, no_wsdl, globals)
|
173
|
-
response = operation.call
|
174
|
-
|
175
|
-
expect(response).to be_a(Savon::Multipart::Response)
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
it "returns a Savon::Multipart::Response if available and requested locally" do
|
180
|
-
with_multipart_mocked do
|
181
|
-
operation = new_operation(:authenticate, no_wsdl, globals)
|
182
|
-
response = operation.call(:multipart => true)
|
183
|
-
|
184
|
-
expect(response).to be_a(Savon::Multipart::Response)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
it "raises if savon-multipart is not available and it was requested globally" do
|
189
|
-
globals.multipart true
|
190
|
-
|
191
|
-
operation = new_operation(:authenticate, no_wsdl, globals)
|
192
|
-
|
193
|
-
expect { operation.call }.
|
194
|
-
to raise_error RuntimeError, /Unable to find Savon::Multipart/
|
195
|
-
end
|
196
|
-
|
197
|
-
it "raises if savon-multipart is not available and it was requested locally" do
|
198
|
-
operation = new_operation(:authenticate, no_wsdl, globals)
|
199
|
-
|
200
|
-
expect { operation.call(:multipart => true) }.
|
201
|
-
to raise_error RuntimeError, /Unable to find Savon::Multipart/
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
describe "#request" do
|
206
|
-
it "returns the request" do
|
207
|
-
operation = new_operation(:verify_address, wsdl, globals)
|
208
|
-
request = operation.request
|
209
|
-
|
210
|
-
expect(request.body).to include('<tns:VerifyAddress></tns:VerifyAddress>')
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
def with_multipart_mocked
|
215
|
-
multipart_response = Class.new { def initialize(*args); end }
|
216
|
-
multipart_mock = Module.new
|
217
|
-
multipart_mock.const_set('Response', multipart_response)
|
218
|
-
|
219
|
-
Savon.const_set('Multipart', multipart_mock)
|
220
|
-
|
221
|
-
yield
|
222
|
-
ensure
|
223
|
-
Savon.send(:remove_const, :Multipart) if Savon.const_defined? :Multipart
|
224
|
-
end
|
225
|
-
|
226
|
-
def inspect_request(response)
|
227
|
-
hash = JSON.parse(response.http.body)
|
228
|
-
OpenStruct.new(hash)
|
229
|
-
end
|
230
|
-
end
|