savon 0.5.3 → 0.6.0

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.
@@ -2,24 +2,9 @@ require "spec_helper"
2
2
 
3
3
  describe Savon::WSSE do
4
4
  before do
5
- @wsse = new_wsse_instance
6
- @wsse_username = "gorilla"
7
- @wsse_password = "secret"
8
- end
9
-
10
- def new_wsse_instance(credentials = {})
11
- wsse = Class.new
12
- class << wsse
13
- include Savon::WSSE
14
- attr_accessor :options
15
- end
16
- wsse.options = { :wsse => {} }
17
- wsse
18
- end
19
-
20
- def wsse_options(digest = false)
21
- { :wsse => { :username => @wsse_username,
22
- :password => @wsse_password, :digest => digest } }
5
+ @wsse = Savon::WSSE.new
6
+ @username = "gorilla"
7
+ @password = "secret"
23
8
  end
24
9
 
25
10
  describe "WSENamespace" do
@@ -37,26 +22,28 @@ describe Savon::WSSE do
37
22
  end
38
23
 
39
24
  describe "@username" do
40
- it "defaults to nil" do
41
- Savon::WSSE.username.should be_nil
25
+ it "defaults to an empty String" do
26
+ Savon::WSSE.username.should be_a String
27
+ Savon::WSSE.username.should be_empty
42
28
  end
43
29
 
44
30
  it "has accessor methods" do
45
31
  Savon::WSSE.username = "gorilla"
46
32
  Savon::WSSE.username.should == "gorilla"
47
- Savon::WSSE.username = nil
33
+ Savon::WSSE.username = ""
48
34
  end
49
35
  end
50
36
 
51
37
  describe "@password" do
52
- it "defaults to nil" do
53
- Savon::WSSE.password.should be_nil
38
+ it "defaults to an empty String" do
39
+ Savon::WSSE.password.should be_a String
40
+ Savon::WSSE.password.should be_empty
54
41
  end
55
42
 
56
43
  it "has accessor methods" do
57
44
  Savon::WSSE.password = "secret"
58
45
  Savon::WSSE.password.should == "secret"
59
- Savon::WSSE.password = nil
46
+ Savon::WSSE.password = ""
60
47
  end
61
48
  end
62
49
 
@@ -72,84 +59,91 @@ describe Savon::WSSE do
72
59
  end
73
60
  end
74
61
 
75
- describe "wsse?" do
76
- describe "returns true in case WSSE credentials are available" do
77
- it "via options" do
78
- @wsse.options = wsse_options
79
- @wsse.wsse?.should be_true
80
- end
81
-
82
- it "via defaults" do
83
- Savon::WSSE.username = "gorilla"
84
- Savon::WSSE.password = "secret"
62
+ describe "username" do
63
+ it "defaults to an empty String" do
64
+ @wsse.username.should be_a String
65
+ @wsse.username.should be_empty
66
+ end
85
67
 
86
- @wsse.wsse?.should be_true
87
- end
68
+ it "has accessor methods" do
69
+ @wsse.username = "gorilla"
70
+ @wsse.username.should == "gorilla"
71
+ @wsse.username = nil
88
72
  end
73
+ end
89
74
 
90
- describe "returns false in case WSSE credentials are missing or incomplete" do
91
- it "via options" do
92
- @wsse.wsse?.should be_false
75
+ describe "password" do
76
+ it "defaults to an empty String" do
77
+ @wsse.password.should be_a String
78
+ @wsse.password.should be_empty
79
+ end
93
80
 
94
- new_wsse_instance(:wsse => { :username => @wsse_username }).wsse?.
95
- should be_false
81
+ it "has accessor methods" do
82
+ @wsse.password = "secret"
83
+ @wsse.password.should == "secret"
84
+ @wsse.password = nil
85
+ end
86
+ end
96
87
 
97
- new_wsse_instance(:wsse => { :password => @wsse_password }).wsse?.
98
- should be_false
99
- end
88
+ describe "digest" do
89
+ it "defaults to false" do
90
+ @wsse.digest?.should be_false
91
+ end
100
92
 
101
- it "via defaults" do
102
- Savon::WSSE.username = @wsse_username
103
- @wsse.wsse?.should be_false
104
-
105
- Savon::WSSE.username = nil
106
- Savon::WSSE.password = @wsse_password
107
- @wsse.wsse?.should be_false
108
- end
93
+ it "has accessor methods" do
94
+ @wsse.digest = true
95
+ @wsse.digest?.should == true
96
+ @wsse.digest = false
109
97
  end
110
98
  end
111
99
 
112
- describe "wsse_header" do
100
+ describe "header" do
113
101
  describe "returns the XML for a WSSE authentication header" do
114
- it "with WSSE credentials specified via options" do
115
- @wsse.options = wsse_options
116
- wsse_header = @wsse.wsse_header Builder::XmlMarkup.new
117
-
118
- wsse_header.should include_security_namespaces
119
- wsse_header.should include @wsse_username
120
- wsse_header.should include @wsse_password
102
+ it "with WSSE credentials specified" do
103
+ @wsse.username = @username
104
+ @wsse.password = @password
105
+ header = @wsse.header
106
+
107
+ header.should include_security_namespaces
108
+ header.should include @username
109
+ header.should include @password
121
110
  end
122
111
 
123
112
  it "with WSSE credentials specified via defaults" do
124
- Savon::WSSE.username = @wsse_username
125
- Savon::WSSE.password = @wsse_password
126
- wsse_header = @wsse.wsse_header Builder::XmlMarkup.new
113
+ Savon::WSSE.username = @username
114
+ Savon::WSSE.password = @password
115
+ header = @wsse.header
116
+
117
+ header.should include_security_namespaces
118
+ header.should include @username
119
+ header.should include @password
127
120
 
128
- wsse_header.should include_security_namespaces
129
- wsse_header.should include @wsse_username
130
- wsse_header.should include @wsse_password
121
+ Savon::WSSE.username = ""
122
+ Savon::WSSE.password = ""
131
123
  end
132
124
  end
133
125
 
134
126
  describe "returns the XML for a WSSE digest header if specified" do
135
- before {}
136
- it "via options" do
137
- @wsse.options = wsse_options :for_digest
138
- wsse_header = @wsse.wsse_header Builder::XmlMarkup.new
127
+ it "via accessors" do
128
+ @wsse.username = @username
129
+ @wsse.password = @password
130
+ @wsse.digest = true
131
+ header = @wsse.header
139
132
 
140
- wsse_header.should include_security_namespaces
141
- wsse_header.should include @wsse_username
142
- wsse_header.should_not include @wsse_password
133
+ header.should include_security_namespaces
134
+ header.should include @username
135
+ header.should_not include @password
143
136
  end
144
137
 
145
138
  it "via defaults" do
139
+ @wsse.username = @username
140
+ @wsse.password = @password
146
141
  Savon::WSSE.digest = true
147
- @wsse.options = wsse_options
148
- wsse_header = @wsse.wsse_header Builder::XmlMarkup.new
142
+ header = @wsse.header
149
143
 
150
- wsse_header.should include_security_namespaces
151
- wsse_header.should include @wsse_username
152
- wsse_header.should_not include @wsse_password
144
+ header.should include_security_namespaces
145
+ header.should include @username
146
+ header.should_not include @password
153
147
  end
154
148
  end
155
149
 
@@ -161,9 +155,4 @@ describe Savon::WSSE do
161
155
  end
162
156
  end
163
157
 
164
- after do
165
- Savon::WSSE.username = nil
166
- Savon::WSSE.password = nil
167
- Savon::WSSE.digest = false
168
- end
169
- end
158
+ end
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.5.3
4
+ version: 0.6.0
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-11-30 00:00:00 +01:00
12
+ date: 2009-12-06 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -84,8 +84,8 @@ files:
84
84
  - lib/savon/core_ext/symbol.rb
85
85
  - lib/savon/core_ext/uri.rb
86
86
  - lib/savon/request.rb
87
+ - lib/savon/response.rb
87
88
  - lib/savon/soap.rb
88
- - lib/savon/validation.rb
89
89
  - lib/savon/wsdl.rb
90
90
  - lib/savon/wsse.rb
91
91
  - spec/fixtures/multiple_user_response.xml
@@ -102,9 +102,9 @@ files:
102
102
  - spec/savon/core_ext/symbol_spec.rb
103
103
  - spec/savon/core_ext/uri_spec.rb
104
104
  - spec/savon/request_spec.rb
105
+ - spec/savon/response_spec.rb
105
106
  - spec/savon/savon_spec.rb
106
107
  - spec/savon/soap_spec.rb
107
- - spec/savon/validation_spec.rb
108
108
  - spec/savon/wsdl_spec.rb
109
109
  - spec/savon/wsse_spec.rb
110
110
  - spec/spec_helper.rb
@@ -152,9 +152,9 @@ test_files:
152
152
  - spec/savon/core_ext/symbol_spec.rb
153
153
  - spec/savon/core_ext/uri_spec.rb
154
154
  - spec/savon/request_spec.rb
155
+ - spec/savon/response_spec.rb
155
156
  - spec/savon/savon_spec.rb
156
157
  - spec/savon/soap_spec.rb
157
- - spec/savon/validation_spec.rb
158
158
  - spec/savon/wsdl_spec.rb
159
159
  - spec/savon/wsse_spec.rb
160
160
  - spec/spec_helper.rb
@@ -1,57 +0,0 @@
1
- module Savon
2
- module Validation
3
-
4
- # Validates a given +value+ of a given +type+. Raises an ArgumentError
5
- # in case the value is not valid.
6
- def validate!(type, value)
7
- case type
8
- when :endpoint then validate_endpoint value
9
- when :soap_version then validate_soap_version value
10
- when :soap_body then validate_soap_body value
11
- when :response_process then validate_response_process value
12
- when :wsse_credentials then validate_wsse_credentials value
13
- end
14
- true
15
- end
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
-
25
- private
26
-
27
- # Validates a given +endpoint+.
28
- def validate_endpoint(endpoint)
29
- invalid! :endpoint, endpoint unless /^(http|https):\/\// === endpoint
30
- end
31
-
32
- # Validates a given +soap_version+.
33
- def validate_soap_version(soap_version)
34
- invalid! :soap_version, soap_version unless SOAPVersions.include? soap_version
35
- end
36
-
37
- # Validates a given +soap_body+.
38
- def validate_soap_body(soap_body)
39
- invalid! :soap_body, soap_body unless
40
- soap_body.kind_of?(Hash) || soap_body.respond_to?(:to_s)
41
- end
42
-
43
- # Validates a given +response_process+.
44
- def validate_response_process(response_process)
45
- invalid! :response_process, response_process unless
46
- response_process.respond_to? :call
47
- end
48
-
49
- # Validates a given Hash of +wsse_credentials+.
50
- def validate_wsse_credentials(wsse)
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
- end
55
-
56
- end
57
- end
@@ -1,88 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Savon::Validation do
4
- before do
5
- @validation = Class.new
6
- class << @validation
7
- include Savon::Validation
8
- end
9
- end
10
-
11
- describe "validate!" do
12
- describe ":endpoint" do
13
- it "returns true for valid endpoints" do
14
- @validation.validate!(:endpoint, "http://example.com").should be_true
15
- end
16
-
17
- it "raises an ArgumentError in case of invalid endpoints" do
18
- lambda { @validation.validate! :endpoint, "invalid" }.
19
- should raise_error ArgumentError
20
- end
21
- end
22
-
23
- describe ":soap_version" do
24
- it "returns true for valid SOAP versions" do
25
- Savon::SOAPVersions.each do |soap_version|
26
- @validation.validate!(:soap_version, soap_version).should be_true
27
- end
28
- end
29
-
30
- it "raises an ArgumentError in case of invalid SOAP versions" do
31
- [5, 9, nil, false, "upcoming"].each do |soap_version|
32
- lambda { @validation.validate! :soap_version, soap_version }.
33
- should raise_error ArgumentError
34
- end
35
- end
36
- end
37
-
38
- describe ":soap_body" do
39
- it "returns true for Hashes" do
40
- @validation.validate!(:soap_body, {}).should be_true
41
- end
42
-
43
- it "returns true for Objects responding to to_s" do
44
- [123, "body", Time.now].each do |soap_body|
45
- lambda { @validation.validate!(:soap_body, soap_body) }.should be_true
46
- end
47
- end
48
-
49
- it "raises an ArgumentError in case of an invalid SOAP body" do
50
- singleton = "pretending like there is no such thing as to_s"
51
- def singleton.respond_to?(method)
52
- false
53
- end
54
-
55
- lambda { @validation.validate! :endpoint, singleton }.
56
- should raise_error ArgumentError
57
- end
58
- end
59
-
60
- describe ":response_process" do
61
- it "returns true for Objects responding to call" do
62
- @validation.validate!(:response_process, Proc.new {}).should be_true
63
- end
64
-
65
- it "raises an ArgumentError for an invalid response process" do
66
- [123, "block", [], {}].each do |response_process|
67
- lambda { @validation.validate! :response_process, response_process }.
68
- should raise_error ArgumentError
69
- end
70
- end
71
- end
72
-
73
- describe ":wsse_credentials" do
74
- it "returns true for valid WSSE credentials" do
75
- wsse_credentials = { :username => "user", :password => "secret" }
76
- @validation.validate!(:wsse_credentials, wsse_credentials).should be_true
77
- end
78
-
79
- it "returns false for invalid WSSE credentials" do
80
- [{ :username => "user" }, { :password => "secret" }].each do |wsse_credentials|
81
- lambda { @validation.validate! :wsse_credentials, wsse_credentials }.
82
- should raise_error ArgumentError
83
- end
84
- end
85
- end
86
-
87
- end
88
- end