savon-SU 2.11.1b
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.travis.yml +15 -0
- data/.yardopts +6 -0
- data/CHANGELOG.md +1098 -0
- data/CONTRIBUTING.md +46 -0
- data/Gemfile +18 -0
- data/LICENSE +20 -0
- data/README.md +69 -0
- data/Rakefile +14 -0
- data/donate.png +0 -0
- data/lib/savon.rb +27 -0
- data/lib/savon/block_interface.rb +26 -0
- data/lib/savon/builder.rb +205 -0
- data/lib/savon/client.rb +102 -0
- data/lib/savon/core_ext/string.rb +29 -0
- data/lib/savon/header.rb +93 -0
- data/lib/savon/http_error.rb +27 -0
- data/lib/savon/log_message.rb +52 -0
- data/lib/savon/message.rb +37 -0
- data/lib/savon/mock.rb +5 -0
- data/lib/savon/mock/expectation.rb +80 -0
- data/lib/savon/mock/spec_helper.rb +62 -0
- data/lib/savon/model.rb +84 -0
- data/lib/savon/operation.rb +144 -0
- data/lib/savon/options.rb +410 -0
- data/lib/savon/qualified_message.rb +50 -0
- data/lib/savon/request.rb +97 -0
- data/lib/savon/request_logger.rb +48 -0
- data/lib/savon/response.rb +113 -0
- data/lib/savon/soap_fault.rb +50 -0
- data/lib/savon/version.rb +3 -0
- data/savon-SU.gemspec +46 -0
- data/spec/fixtures/gzip/message.gz +0 -0
- data/spec/fixtures/response/another_soap_fault.xml +14 -0
- data/spec/fixtures/response/authentication.xml +14 -0
- data/spec/fixtures/response/f5.xml +39 -0
- data/spec/fixtures/response/header.xml +13 -0
- data/spec/fixtures/response/list.xml +18 -0
- data/spec/fixtures/response/multi_ref.xml +39 -0
- data/spec/fixtures/response/soap_fault.xml +8 -0
- data/spec/fixtures/response/soap_fault12.xml +18 -0
- data/spec/fixtures/response/soap_fault_funky.xml +8 -0
- data/spec/fixtures/response/taxcloud.xml +1 -0
- data/spec/fixtures/ssl/client_cert.pem +16 -0
- data/spec/fixtures/ssl/client_encrypted_key.pem +30 -0
- data/spec/fixtures/ssl/client_encrypted_key_cert.pem +24 -0
- data/spec/fixtures/ssl/client_key.pem +15 -0
- data/spec/fixtures/wsdl/authentication.xml +63 -0
- data/spec/fixtures/wsdl/betfair.xml +2981 -0
- data/spec/fixtures/wsdl/edialog.xml +15416 -0
- data/spec/fixtures/wsdl/interhome.xml +2137 -0
- data/spec/fixtures/wsdl/lower_camel.xml +52 -0
- data/spec/fixtures/wsdl/multiple_namespaces.xml +92 -0
- data/spec/fixtures/wsdl/multiple_types.xml +60 -0
- data/spec/fixtures/wsdl/no_message_tag.xml +1267 -0
- data/spec/fixtures/wsdl/taxcloud.xml +934 -0
- data/spec/fixtures/wsdl/team_software.xml +1 -0
- data/spec/fixtures/wsdl/vies.xml +176 -0
- data/spec/fixtures/wsdl/wasmuth.xml +153 -0
- data/spec/integration/centra_spec.rb +66 -0
- data/spec/integration/email_example_spec.rb +32 -0
- data/spec/integration/random_quote_spec.rb +23 -0
- data/spec/integration/ratp_example_spec.rb +28 -0
- data/spec/integration/stockquote_example_spec.rb +28 -0
- data/spec/integration/support/application.rb +82 -0
- data/spec/integration/support/server.rb +84 -0
- data/spec/integration/temperature_example_spec.rb +46 -0
- data/spec/integration/zipcode_example_spec.rb +42 -0
- data/spec/savon/builder_spec.rb +137 -0
- data/spec/savon/client_spec.rb +271 -0
- data/spec/savon/core_ext/string_spec.rb +37 -0
- data/spec/savon/features/message_tag_spec.rb +61 -0
- data/spec/savon/http_error_spec.rb +49 -0
- data/spec/savon/log_message_spec.rb +44 -0
- data/spec/savon/message_spec.rb +70 -0
- data/spec/savon/mock_spec.rb +174 -0
- data/spec/savon/model_spec.rb +182 -0
- data/spec/savon/observers_spec.rb +92 -0
- data/spec/savon/operation_spec.rb +230 -0
- data/spec/savon/options_spec.rb +1064 -0
- data/spec/savon/qualified_message_spec.rb +20 -0
- data/spec/savon/request_logger_spec.rb +37 -0
- data/spec/savon/request_spec.rb +496 -0
- data/spec/savon/response_spec.rb +270 -0
- data/spec/savon/soap_fault_spec.rb +131 -0
- data/spec/spec_helper.rb +30 -0
- data/spec/support/adapters.rb +48 -0
- data/spec/support/endpoint.rb +25 -0
- data/spec/support/fixture.rb +39 -0
- data/spec/support/integration.rb +9 -0
- data/spec/support/stdout.rb +25 -0
- metadata +317 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "RATP example" do
|
4
|
+
|
5
|
+
it "retrieves information about a specific station" do
|
6
|
+
client = Savon.client do
|
7
|
+
# The WSDL document provided by the service.
|
8
|
+
wsdl "http://www.ratp.fr/wsiv/services/Wsiv?wsdl"
|
9
|
+
|
10
|
+
# Lower timeouts so these specs don't take forever when the service is not available.
|
11
|
+
open_timeout 10
|
12
|
+
read_timeout 10
|
13
|
+
|
14
|
+
# Disable logging for cleaner spec output.
|
15
|
+
log false
|
16
|
+
end
|
17
|
+
|
18
|
+
# XXX: the service seems to rely on the order of arguments.
|
19
|
+
# try to fix this with the new wsdl parser.
|
20
|
+
response = call_and_fail_gracefully(client, :get_stations) do
|
21
|
+
message(:station => { :id => 1975 }, :limit => 1)
|
22
|
+
end
|
23
|
+
|
24
|
+
station_name = response.body[:get_stations_response][:return][:stations][:name]
|
25
|
+
expect(station_name).to eq("Cite")
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Stockquote example" do
|
4
|
+
|
5
|
+
it "returns the result in a CDATA tag" do
|
6
|
+
client = Savon.client(
|
7
|
+
# The WSDL document provided by the service.
|
8
|
+
:wsdl => "http://www.webservicex.net/stockquote.asmx?WSDL",
|
9
|
+
|
10
|
+
# Lower timeouts so these specs don't take forever when the service is not available.
|
11
|
+
:open_timeout => 10,
|
12
|
+
:read_timeout => 10,
|
13
|
+
|
14
|
+
# Disable logging for cleaner spec output.
|
15
|
+
:log => false
|
16
|
+
)
|
17
|
+
|
18
|
+
response = call_and_fail_gracefully(client, :get_quote, :message => { :symbol => "AAPL" })
|
19
|
+
|
20
|
+
cdata = response.body[:get_quote_response][:get_quote_result]
|
21
|
+
|
22
|
+
nori_options = { :convert_tags_to => lambda { |tag| tag.snakecase.to_sym } }
|
23
|
+
result = Nori.new(nori_options).parse(cdata)
|
24
|
+
|
25
|
+
expect(result[:stock_quotes][:stock][:symbol]).to eq("AAPL")
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require "rack/builder"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
class IntegrationServer
|
5
|
+
|
6
|
+
def self.respond_with(options = {})
|
7
|
+
code = options.fetch(:code, 200)
|
8
|
+
body = options.fetch(:body, "")
|
9
|
+
headers = { "Content-Type" => "text/plain", "Content-Length" => body.size.to_s }
|
10
|
+
|
11
|
+
[code, headers, [body]]
|
12
|
+
end
|
13
|
+
|
14
|
+
Application = Rack::Builder.new do
|
15
|
+
|
16
|
+
map "/" do
|
17
|
+
run lambda { |env|
|
18
|
+
IntegrationServer.respond_with :body => env["REQUEST_METHOD"].downcase
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
map "/repeat" do
|
23
|
+
run lambda { |env|
|
24
|
+
# stupid way of extracting the value from a query string (e.g. "code=500") [dh, 2012-12-08]
|
25
|
+
IntegrationServer.respond_with :body => env["rack.input"].read
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
map "/404" do
|
30
|
+
run lambda { |env|
|
31
|
+
IntegrationServer.respond_with :code => 404, :body => env["rack.input"].read
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
map "/timeout" do
|
36
|
+
run lambda { |env|
|
37
|
+
sleep 2
|
38
|
+
IntegrationServer.respond_with :body => "timeout"
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
map "/inspect_request" do
|
43
|
+
run lambda { |env|
|
44
|
+
body = {
|
45
|
+
:soap_action => env["HTTP_SOAPACTION"],
|
46
|
+
:cookie => env["HTTP_COOKIE"],
|
47
|
+
:x_token => env["HTTP_X_TOKEN"],
|
48
|
+
:content_type => env["CONTENT_TYPE"]
|
49
|
+
}
|
50
|
+
|
51
|
+
IntegrationServer.respond_with :body => JSON.dump(body)
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
map "/basic_auth" do
|
56
|
+
use Rack::Auth::Basic, "basic-realm" do |username, password|
|
57
|
+
username == "admin" && password == "secret"
|
58
|
+
end
|
59
|
+
|
60
|
+
run lambda { |env|
|
61
|
+
IntegrationServer.respond_with :body => "basic-auth"
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
map "/digest_auth" do
|
66
|
+
unprotected_app = lambda { |env|
|
67
|
+
IntegrationServer.respond_with :body => "digest-auth"
|
68
|
+
}
|
69
|
+
|
70
|
+
realm = 'digest-realm'
|
71
|
+
app = Rack::Auth::Digest::MD5.new(unprotected_app) do |username|
|
72
|
+
username == 'admin' ? Digest::MD5.hexdigest("admin:#{realm}:secret") : nil
|
73
|
+
end
|
74
|
+
app.realm = realm
|
75
|
+
app.opaque = 'this-should-be-secret'
|
76
|
+
app.passwords_hashed = true
|
77
|
+
|
78
|
+
run app
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require "puma"
|
2
|
+
require "puma/minissl"
|
3
|
+
|
4
|
+
require "integration/support/application"
|
5
|
+
|
6
|
+
class IntegrationServer
|
7
|
+
|
8
|
+
def self.run(options = {})
|
9
|
+
server = new(options)
|
10
|
+
server.run
|
11
|
+
server
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.ssl_ca_file; integration_fixture("ca_all.pem") end
|
15
|
+
def self.ssl_key_file; integration_fixture("server.key") end
|
16
|
+
def self.ssl_cert_file; integration_fixture("server.cert") end
|
17
|
+
|
18
|
+
def self.integration_fixture(file)
|
19
|
+
file = File.expand_path("../../fixtures/#{file}", __FILE__)
|
20
|
+
raise "No such file '#{file}'" unless File.exist? file
|
21
|
+
file
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(options = {})
|
25
|
+
@app = Application
|
26
|
+
@host = options.fetch(:host, "localhost")
|
27
|
+
@port = options.fetch(:port, 17172)
|
28
|
+
@ssl = options.fetch(:ssl, false)
|
29
|
+
|
30
|
+
@server = Puma::Server.new(app, events)
|
31
|
+
|
32
|
+
if ssl?
|
33
|
+
add_ssl_listener
|
34
|
+
else
|
35
|
+
add_tcp_listener
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
attr_reader :app, :host, :port, :server
|
40
|
+
|
41
|
+
def url(path = "")
|
42
|
+
protocol = ssl? ? "https" : "http"
|
43
|
+
File.join "#{protocol}://#{host}:#{port}/", path.to_s
|
44
|
+
end
|
45
|
+
|
46
|
+
def ssl?
|
47
|
+
@ssl
|
48
|
+
end
|
49
|
+
|
50
|
+
def run
|
51
|
+
server.run
|
52
|
+
end
|
53
|
+
|
54
|
+
def stop
|
55
|
+
server.stop(true)
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def events
|
61
|
+
Puma::Events.new($stdout, $stderr)
|
62
|
+
end
|
63
|
+
|
64
|
+
def add_tcp_listener
|
65
|
+
server.add_tcp_listener(host, port)
|
66
|
+
rescue Errno::EADDRINUSE
|
67
|
+
raise "Panther is already running at #{url}"
|
68
|
+
end
|
69
|
+
|
70
|
+
def add_ssl_listener
|
71
|
+
server.add_ssl_listener(host, port, ssl_context)
|
72
|
+
end
|
73
|
+
|
74
|
+
def ssl_context
|
75
|
+
context = Puma::MiniSSL::Context.new
|
76
|
+
|
77
|
+
context.key = IntegrationServer.ssl_key_file
|
78
|
+
context.cert = IntegrationServer.ssl_cert_file
|
79
|
+
context.verify_mode = Puma::MiniSSL::VERIFY_PEER
|
80
|
+
|
81
|
+
context
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Temperature example" do
|
4
|
+
|
5
|
+
it "converts 30 degrees celsius to 86 degrees fahrenheit" do
|
6
|
+
client = Savon.client do
|
7
|
+
# The WSDL document provided by the service.
|
8
|
+
wsdl "http://www.webservicex.net/ConvertTemperature.asmx?WSDL"
|
9
|
+
|
10
|
+
# Needed because (up until now), Savon doesn't match XS types to Hash keys,
|
11
|
+
# but defaults to convert Hash message Symbols (like :from_unit) to lowerCamelCase.
|
12
|
+
# The service expects these to be CamelCase instead. Look at Savon's log output
|
13
|
+
# and compare it with an example request generated by soapUI.
|
14
|
+
convert_request_keys_to :camelcase
|
15
|
+
|
16
|
+
# Lower timeouts so these specs don't take forever when the service is not available.
|
17
|
+
open_timeout 10
|
18
|
+
read_timeout 10
|
19
|
+
|
20
|
+
# Disable logging for cleaner spec output.
|
21
|
+
log false
|
22
|
+
end
|
23
|
+
|
24
|
+
response = call_and_fail_gracefully(client, :convert_temp) do
|
25
|
+
# For the corrent values to pass for :from_unit and :to_unit, I searched the WSDL for
|
26
|
+
# the "FromUnit" type which is a "TemperatureUnit" enumeration that looks like this:
|
27
|
+
#
|
28
|
+
# <s:simpleType name="TemperatureUnit">
|
29
|
+
# <s:restriction base="s:string">
|
30
|
+
# <s:enumeration value="degreeCelsius"/>
|
31
|
+
# <s:enumeration value="degreeFahrenheit"/>
|
32
|
+
# <s:enumeration value="degreeRankine"/>
|
33
|
+
# <s:enumeration value="degreeReaumur"/>
|
34
|
+
# <s:enumeration value="kelvin"/>
|
35
|
+
# </s:restriction>
|
36
|
+
# </s:simpleType>
|
37
|
+
#
|
38
|
+
# Support for XS schema types needs to be improved.
|
39
|
+
message(:temperature => 30, :from_unit => "degreeCelsius", :to_unit => "degreeFahrenheit")
|
40
|
+
end
|
41
|
+
|
42
|
+
fahrenheit = response.body[:convert_temp_response][:convert_temp_result]
|
43
|
+
expect(fahrenheit).to eq("86")
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "ZIP code example" do
|
4
|
+
|
5
|
+
it "supports threads making requests simultaneously" do
|
6
|
+
client = Savon.client(
|
7
|
+
# The WSDL document provided by the service.
|
8
|
+
:wsdl => "http://www.thomas-bayer.com/axis2/services/BLZService?wsdl",
|
9
|
+
|
10
|
+
# Lower timeouts so these specs don't take forever when the service is not available.
|
11
|
+
:open_timeout => 10,
|
12
|
+
:read_timeout => 10,
|
13
|
+
|
14
|
+
# Disable logging for cleaner spec output.
|
15
|
+
:log => false
|
16
|
+
)
|
17
|
+
|
18
|
+
mutex = Mutex.new
|
19
|
+
|
20
|
+
request_data = [70070010, 24050110, 20050550]
|
21
|
+
threads_waiting = request_data.size
|
22
|
+
|
23
|
+
threads = request_data.map do |blz|
|
24
|
+
thread = Thread.new do
|
25
|
+
response = call_and_fail_gracefully client, :get_bank, :message => { :blz => blz }
|
26
|
+
Thread.current[:value] = response.body[:get_bank_response][:details]
|
27
|
+
mutex.synchronize { threads_waiting -= 1 }
|
28
|
+
end
|
29
|
+
|
30
|
+
thread.abort_on_exception = true
|
31
|
+
thread
|
32
|
+
end
|
33
|
+
|
34
|
+
sleep(1) until threads_waiting == 0
|
35
|
+
|
36
|
+
threads.each(&:kill)
|
37
|
+
values = threads.map { |thr| thr[:value] }.compact
|
38
|
+
|
39
|
+
expect(values.uniq.size).to eq(values.size)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Savon::Builder do
|
4
|
+
|
5
|
+
subject(:builder) { Savon::Builder.new(:authenticate, wsdl, globals, locals) }
|
6
|
+
|
7
|
+
let(:globals) { Savon::GlobalOptions.new }
|
8
|
+
let(:locals) { Savon::LocalOptions.new }
|
9
|
+
let(:wsdl) { Wasabi::Document.new Fixture.wsdl(:authentication) }
|
10
|
+
let(:no_wsdl) { Wasabi::Document.new }
|
11
|
+
|
12
|
+
describe "#pretty" do
|
13
|
+
it "returns the pretty printed request" do
|
14
|
+
expect(builder.pretty).to include("<env:Body>\n <tns:authenticate/>")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#to_s" do
|
19
|
+
it "includes the global :env_namespace if it's available" do
|
20
|
+
globals[:env_namespace] = :soapenv
|
21
|
+
expect(builder.to_s).to include("<soapenv:Envelope")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "defaults to include the default envelope namespace of :env" do
|
25
|
+
expect(builder.to_s).to include("<env:Envelope")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "includes the target namespace from the WSDL" do
|
29
|
+
expect(builder.to_s).to include('xmlns:tns="http://v1_0.ws.auth.order.example.com/"')
|
30
|
+
end
|
31
|
+
|
32
|
+
it "includes the target namespace from the global :namespace if it's available" do
|
33
|
+
globals[:namespace] = "http://v1.example.com"
|
34
|
+
expect(builder.to_s).to include('xmlns:tns="http://v1.example.com"')
|
35
|
+
end
|
36
|
+
|
37
|
+
it "includes the local :message_tag if available" do
|
38
|
+
locals[:message_tag] = "doAuthenticate"
|
39
|
+
expect(builder.to_s).to include("<tns:doAuthenticate>")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "includes the message tag from the WSDL if its available" do
|
43
|
+
expect(builder.to_s).to include("<tns:authenticate>")
|
44
|
+
end
|
45
|
+
|
46
|
+
it "includes a message tag created by Gyoku if both option and WSDL are missing" do
|
47
|
+
globals[:namespace] = "http://v1.example.com"
|
48
|
+
|
49
|
+
locals = Savon::LocalOptions.new
|
50
|
+
builder = Savon::Builder.new(:authenticate, no_wsdl, globals, locals)
|
51
|
+
|
52
|
+
expect(builder.to_s).to include("<wsdl:authenticate>")
|
53
|
+
end
|
54
|
+
|
55
|
+
it "uses the global :namespace_identifier option if it's available" do
|
56
|
+
globals[:namespace_identifier] = :v1
|
57
|
+
expect(builder.to_s).to include("<v1:authenticate>")
|
58
|
+
end
|
59
|
+
|
60
|
+
it "uses the WSDL's namespace_identifier if the global option was not specified" do
|
61
|
+
expect(builder.to_s).to include("<tns:authenticate>")
|
62
|
+
end
|
63
|
+
|
64
|
+
it "uses the default :wsdl identifier if both option and WSDL were not specified" do
|
65
|
+
globals[:namespace] = "http://v1.example.com"
|
66
|
+
|
67
|
+
builder = Savon::Builder.new(:authenticate, no_wsdl, globals, locals)
|
68
|
+
expect(builder.to_s).to include("<wsdl:authenticate>")
|
69
|
+
end
|
70
|
+
|
71
|
+
it "uses the global :element_form_default option if it's available " do
|
72
|
+
globals[:element_form_default] = :qualified
|
73
|
+
locals[:message] = { :username => "luke", :password => "secret" }
|
74
|
+
|
75
|
+
expect(builder.to_s).to include("<tns:username>luke</tns:username>")
|
76
|
+
end
|
77
|
+
|
78
|
+
it "uses the WSDL's element_form_default value if the global option was set specified" do
|
79
|
+
locals[:message] = { :username => "luke", :password => "secret" }
|
80
|
+
wsdl.element_form_default = :qualified
|
81
|
+
|
82
|
+
expect(builder.to_s).to include("<tns:username>luke</tns:username>")
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "#wsse_signature" do
|
86
|
+
fixture_dir = File.join(File.dirname(__FILE__), '..', 'fixtures', 'ssl')
|
87
|
+
|
88
|
+
let(:cert) { File.join(fixture_dir, 'client_cert.pem') }
|
89
|
+
let(:private_key) { File.join(fixture_dir, 'client_key.pem') }
|
90
|
+
let(:signature) do
|
91
|
+
Akami::WSSE::Signature.new(
|
92
|
+
Akami::WSSE::Certs.new(
|
93
|
+
:cert_file => cert,
|
94
|
+
:private_key_file => private_key
|
95
|
+
)
|
96
|
+
)
|
97
|
+
end
|
98
|
+
let(:globals) { Savon::GlobalOptions.new(wsse_signature: signature) }
|
99
|
+
|
100
|
+
subject(:signed_message_nn) {Nokogiri::XML(builder.to_s).remove_namespaces!}
|
101
|
+
subject(:signed_message) {Nokogiri::XML(builder.to_s)}
|
102
|
+
|
103
|
+
it "should contain a header" do
|
104
|
+
expect(signed_message_nn.xpath('/Envelope/Header').size).to eq(1)
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should contain a wsse:Security" do
|
108
|
+
expect(signed_message_nn.xpath('/Envelope/Header/Security').size).to eq(1)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should have a Body[@wsu:Id]" do
|
112
|
+
#must investigate: acts funny in mri ruby
|
113
|
+
#expect(signed_message.xpath('//soapenv:Body', soapenv: "http://schemas.xmlsoap.org/soap/envelope/").attribute('ws:Id').value).to include('Body-')
|
114
|
+
expect(signed_message_nn.xpath('//Body').attr('Id').value).to include('Body-')
|
115
|
+
end
|
116
|
+
|
117
|
+
it "signature should be valid" do
|
118
|
+
certs = Akami::WSSE::Certs.new(:cert_file => cert, :private_key_file => private_key)
|
119
|
+
signature_value = signed_message_nn.xpath('//SignatureValue').text
|
120
|
+
signed_info_fragment = signed_message.xpath('//default:SignedInfo', default: "http://www.w3.org/2000/09/xmldsig#").to_xml
|
121
|
+
data = Nokogiri::XML(signed_info_fragment){|config| config.options = Nokogiri::XML::ParseOptions::NOBLANKS}
|
122
|
+
data.root.default_namespace='http://www.w3.org/2000/09/xmldsig#'
|
123
|
+
|
124
|
+
signed_info = data.canonicalize Nokogiri::XML::XML_C14N_EXCLUSIVE_1_0
|
125
|
+
|
126
|
+
signature = certs.private_key.sign(OpenSSL::Digest::SHA1.new, signed_info)
|
127
|
+
expect(Base64.encode64(signature).gsub("\n", '')).to eq(signature_value)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe '#body_attributes' do
|
133
|
+
it 'should not be nil' do
|
134
|
+
expect(builder.body_attributes).to eq({})
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|