savon 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/savon/client.rb +1 -0
- data/lib/savon/validation.rb +15 -15
- data/spec/http_stubs.rb +6 -1
- data/spec/savon/wsdl_spec.rb +6 -1
- data/spec/spec_helper_methods.rb +4 -0
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.3
|
data/lib/savon/client.rb
CHANGED
@@ -66,6 +66,7 @@ module Savon
|
|
66
66
|
def method_missing(method, *args, &block) #:doc:
|
67
67
|
soap_action = @wsdl.mapped_soap_actions[method]
|
68
68
|
super unless soap_action
|
69
|
+
#soap_action = "User.GetApiKey"
|
69
70
|
|
70
71
|
soap_body, options = args[0] || {}, args[1] || {}
|
71
72
|
validate_arguments! soap_body, options, block
|
data/lib/savon/validation.rb
CHANGED
@@ -14,43 +14,43 @@ module Savon
|
|
14
14
|
true
|
15
15
|
end
|
16
16
|
|
17
|
+
# Raises an ArgumentError for a given +argument+. Also accepts the invalid
|
18
|
+
# +value+ and adds it to the error message.
|
19
|
+
def invalid!(argument, value = nil)
|
20
|
+
message = "Invalid argument '#{argument}'"
|
21
|
+
message << ": #{value}" if value
|
22
|
+
raise ArgumentError, message
|
23
|
+
end
|
24
|
+
|
17
25
|
private
|
18
26
|
|
19
27
|
# Validates a given +endpoint+.
|
20
28
|
def validate_endpoint(endpoint)
|
21
|
-
invalid :endpoint, endpoint unless /^(http|https):\/\// === endpoint
|
29
|
+
invalid! :endpoint, endpoint unless /^(http|https):\/\// === endpoint
|
22
30
|
end
|
23
31
|
|
24
32
|
# Validates a given +soap_version+.
|
25
33
|
def validate_soap_version(soap_version)
|
26
|
-
invalid :soap_version, soap_version unless SOAPVersions.include? soap_version
|
34
|
+
invalid! :soap_version, soap_version unless SOAPVersions.include? soap_version
|
27
35
|
end
|
28
36
|
|
29
37
|
# Validates a given +soap_body+.
|
30
38
|
def validate_soap_body(soap_body)
|
31
|
-
invalid :soap_body, soap_body unless
|
39
|
+
invalid! :soap_body, soap_body unless
|
32
40
|
soap_body.kind_of?(Hash) || soap_body.respond_to?(:to_s)
|
33
41
|
end
|
34
42
|
|
35
43
|
# Validates a given +response_process+.
|
36
44
|
def validate_response_process(response_process)
|
37
|
-
invalid :response_process, response_process unless
|
45
|
+
invalid! :response_process, response_process unless
|
38
46
|
response_process.respond_to? :call
|
39
47
|
end
|
40
48
|
|
41
49
|
# Validates a given Hash of +wsse_credentials+.
|
42
50
|
def validate_wsse_credentials(wsse)
|
43
|
-
invalid :wsse_credentials unless wsse[:username] && wsse[:password]
|
44
|
-
invalid :wsse_username, wsse[:username] unless wsse[:username].respond_to? :to_s
|
45
|
-
invalid :wsse_password, wsse[:password] unless wsse[:password].respond_to? :to_s
|
46
|
-
end
|
47
|
-
|
48
|
-
# Raises an ArgumentError for a given +argument+. Also accepts the invalid
|
49
|
-
# +value+ and adds it to the error message.
|
50
|
-
def invalid(argument, value = nil)
|
51
|
-
message = "Invalid argument '#{argument}'"
|
52
|
-
message << ": #{value}" if value
|
53
|
-
raise ArgumentError, message
|
51
|
+
invalid! :wsse_credentials unless wsse[:username] && wsse[:password]
|
52
|
+
invalid! :wsse_username, wsse[:username] unless wsse[:username].respond_to? :to_s
|
53
|
+
invalid! :wsse_password, wsse[:password] unless wsse[:password].respond_to? :to_s
|
54
54
|
end
|
55
55
|
|
56
56
|
end
|
data/spec/http_stubs.rb
CHANGED
@@ -17,4 +17,9 @@ FakeWeb.register_uri :post, SpecHelper.soap_soapfault_endpoint, :body => UserFix
|
|
17
17
|
# Register fake WSDL and SOAP request for a Savon::HTTPError.
|
18
18
|
FakeWeb.register_uri :get, SpecHelper.httperror_endpoint, :body => UserFixture.user_wsdl
|
19
19
|
FakeWeb.register_uri :post, SpecHelper.soap_httperror_endpoint, :body => "",
|
20
|
-
:status => ["404", "Not Found"]
|
20
|
+
:status => ["404", "Not Found"]
|
21
|
+
|
22
|
+
# Register fake WSDL and SOAP request for an invalid endpoint.
|
23
|
+
FakeWeb.register_uri :get, SpecHelper.invalid_endpoint, :body => ""
|
24
|
+
FakeWeb.register_uri :post, SpecHelper.soap_invalid_endpoint, :body => "",
|
25
|
+
:status => ["404", "Not Found"]
|
data/spec/savon/wsdl_spec.rb
CHANGED
@@ -19,6 +19,11 @@ describe Savon::WSDL do
|
|
19
19
|
it "returns an Array containing all available SOAP actions" do
|
20
20
|
@wsdl.soap_actions.should == UserFixture.soap_actions.keys
|
21
21
|
end
|
22
|
+
|
23
|
+
it "raises an ArgumentError in case the WSDL seems to be invalid" do
|
24
|
+
wsdl = Savon::WSDL.new Savon::Request.new SpecHelper.invalid_endpoint
|
25
|
+
lambda { wsdl.soap_actions }.should raise_error ArgumentError
|
26
|
+
end
|
22
27
|
end
|
23
28
|
|
24
29
|
describe "mapped_soap_actions" do
|
@@ -33,4 +38,4 @@ describe Savon::WSDL do
|
|
33
38
|
end
|
34
39
|
end
|
35
40
|
|
36
|
-
end
|
41
|
+
end
|
data/spec/spec_helper_methods.rb
CHANGED
@@ -12,6 +12,9 @@ class SpecHelper
|
|
12
12
|
|
13
13
|
@soap_httperror_endpoint = "http://httperror.example.com/UserService"
|
14
14
|
@httperror_endpoint = @soap_httperror_endpoint + "?wsdl"
|
15
|
+
|
16
|
+
@soap_invalid_endpoint = "http://invalid.example.com/UserService"
|
17
|
+
@invalid_endpoint = @soap_invalid_endpoint + "?wsdl"
|
15
18
|
|
16
19
|
@wsse_security_nodes = ["wsse:Security", "wsse:UsernameToken",
|
17
20
|
"wsse:Username", "wsse:Password", "wsse:Nonce", "wsu:Created"]
|
@@ -22,6 +25,7 @@ class SpecHelper
|
|
22
25
|
:soap_multiple_endpoint , :multiple_endpoint,
|
23
26
|
:soap_soapfault_endpoint, :soapfault_endpoint,
|
24
27
|
:soap_httperror_endpoint, :httperror_endpoint,
|
28
|
+
:soap_invalid_endpoint, :invalid_endpoint,
|
25
29
|
:wsse_security_nodes
|
26
30
|
|
27
31
|
end
|