ruby-saml 0.8.10 → 0.8.15
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.
Potentially problematic release.
This version of ruby-saml might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +3 -1
- data/Rakefile +0 -14
- data/lib/onelogin/ruby-saml/authrequest.rb +3 -2
- data/lib/onelogin/ruby-saml/logoutrequest.rb +3 -0
- data/lib/onelogin/ruby-saml/logoutresponse.rb +1 -24
- data/lib/onelogin/ruby-saml/response.rb +206 -20
- data/lib/onelogin/ruby-saml/setting_error.rb +6 -0
- data/lib/onelogin/ruby-saml/settings.rb +26 -0
- data/lib/onelogin/ruby-saml/slo_logoutresponse.rb +3 -2
- data/lib/onelogin/ruby-saml/utils.rb +90 -0
- data/lib/onelogin/ruby-saml/version.rb +1 -1
- data/lib/xml_security.rb +222 -87
- data/test/certificates/ruby-saml-2.crt +15 -0
- data/test/logoutrequest_test.rb +124 -126
- data/test/logoutresponse_test.rb +22 -28
- data/test/response_test.rb +348 -129
- data/test/responses/adfs_response_xmlns.xml +45 -0
- data/test/responses/encrypted_new_attack.xml.base64 +1 -0
- data/test/responses/invalids/multiple_signed.xml.base64 +1 -0
- data/test/responses/invalids/no_signature.xml.base64 +1 -0
- data/test/responses/invalids/response_with_concealed_signed_assertion.xml +51 -0
- data/test/responses/invalids/response_with_doubled_signed_assertion.xml +49 -0
- data/test/responses/invalids/signature_wrapping_attack.xml.base64 +1 -0
- data/test/responses/response_with_concealed_signed_assertion.xml +51 -0
- data/test/responses/response_with_doubled_signed_assertion.xml +49 -0
- data/test/responses/response_with_signed_assertion_3.xml +30 -0
- data/test/responses/response_with_signed_message_and_assertion.xml +34 -0
- data/test/responses/response_with_undefined_recipient.xml.base64 +1 -0
- data/test/responses/response_wrapped.xml.base64 +150 -0
- data/test/responses/valid_response.xml.base64 +1 -0
- data/test/responses/valid_response_without_x509certificate.xml.base64 +1 -0
- data/test/settings_test.rb +5 -5
- data/test/test_helper.rb +110 -41
- data/test/utils_test.rb +10 -10
- data/test/xml_security_test.rb +359 -68
- metadata +38 -5
@@ -0,0 +1,15 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIICVDCCAb2gAwIBAgIBADANBgkqhkiG9w0BAQ0FADBHMQswCQYDVQQGEwJ1czEQ
|
3
|
+
MA4GA1UECAwHZXhhbXBsZTEQMA4GA1UECgwHZXhhbXBsZTEUMBIGA1UEAwwLZXhh
|
4
|
+
bXBsZS5jb20wHhcNMTcwNDA3MDgzMDAzWhcNMjcwNDA1MDgzMDAzWjBHMQswCQYD
|
5
|
+
VQQGEwJ1czEQMA4GA1UECAwHZXhhbXBsZTEQMA4GA1UECgwHZXhhbXBsZTEUMBIG
|
6
|
+
A1UEAwwLZXhhbXBsZS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKhP
|
7
|
+
S4/0azxbQekHHewQGKD7Pivr3CDpsrKxY3xlVanxj427OwzOb5KUVzsDEazumt6s
|
8
|
+
ZFY8HfidsjXY4EYA4ZzyL7ciIAR5vlAsIYN9nJ4AwVDnN/RjVwj+TN6BqWPLpVIp
|
9
|
+
Hc6Dl005HyE0zJnk1DZDn2tQVrIzbD3FhCp7YeotAgMBAAGjUDBOMB0GA1UdDgQW
|
10
|
+
BBRYZx4thASfNvR/E7NsCF2IaZ7wIDAfBgNVHSMEGDAWgBRYZx4thASfNvR/E7Ns
|
11
|
+
CF2IaZ7wIDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBDQUAA4GBACz4aobx9aG3
|
12
|
+
kh+rNyrlgM3K6dYfnKG1/YH5sJCAOvg8kDr0fQAQifH8lFVWumKUMoAe0bFTfwWt
|
13
|
+
p/VJ8MprrEJth6PFeZdczpuv+fpLcNj2VmNVJqvQYvS4m36OnBFh1QFZW8UrbFIf
|
14
|
+
dtm2nuZ+twSKqfKwjLdqcoX0p39h7Uw/
|
15
|
+
-----END CERTIFICATE-----
|
data/test/logoutrequest_test.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
|
2
|
-
require 'uuid'
|
3
2
|
|
4
3
|
class LogoutRequestTest < Minitest::Test
|
5
4
|
|
@@ -29,7 +28,7 @@ class LogoutRequestTest < Minitest::Test
|
|
29
28
|
end
|
30
29
|
|
31
30
|
it "set sessionindex" do
|
32
|
-
sessionidx =
|
31
|
+
sessionidx = random_id
|
33
32
|
settings.sessionindex = sessionidx
|
34
33
|
|
35
34
|
unauth_url = OneLogin::RubySaml::Logoutrequest.new.create(settings, { :name_id => "there" })
|
@@ -78,169 +77,168 @@ class LogoutRequestTest < Minitest::Test
|
|
78
77
|
assert_match %r[ID='#{unauth_req.uuid}'], inflated
|
79
78
|
end
|
80
79
|
end
|
81
|
-
end
|
82
80
|
|
83
|
-
describe "when the settings indicate to sign (embedded) logout request" do
|
84
81
|
|
85
|
-
|
86
|
-
# sign the logout request
|
87
|
-
settings.security[:logout_requests_signed] = true
|
88
|
-
settings.security[:embed_sign] = true
|
89
|
-
settings.certificate = ruby_saml_cert_text
|
90
|
-
settings.private_key = ruby_saml_key_text
|
91
|
-
end
|
82
|
+
describe "when the settings indicate to sign (embedded) logout request" do
|
92
83
|
|
93
|
-
|
94
|
-
|
95
|
-
|
84
|
+
before do
|
85
|
+
# sign the logout request
|
86
|
+
settings.security[:logout_requests_signed] = true
|
87
|
+
settings.security[:embed_sign] = true
|
88
|
+
settings.certificate = ruby_saml_cert_text
|
89
|
+
settings.private_key = ruby_saml_key_text
|
90
|
+
end
|
96
91
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
end
|
92
|
+
it "doesn't sign through create_xml_document" do
|
93
|
+
unauth_req = OneLogin::RubySaml::Logoutrequest.new
|
94
|
+
inflated = unauth_req.create_xml_document(settings).to_s
|
101
95
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
96
|
+
refute_match %r[<ds:SignatureValue>([a-zA-Z0-9/+=]+)</ds:SignatureValue>], inflated
|
97
|
+
refute_match %r[<ds:SignatureMethod Algorithm='http://www.w3.org/2000/09/xmldsig#rsa-sha1'/>], inflated
|
98
|
+
refute_match %r[<ds:DigestMethod Algorithm='http://www.w3.org/2000/09/xmldsig#sha1'/>], inflated
|
99
|
+
end
|
106
100
|
|
107
|
-
|
108
|
-
|
109
|
-
|
101
|
+
it "sign unsigned request" do
|
102
|
+
unauth_req = OneLogin::RubySaml::Logoutrequest.new
|
103
|
+
unauth_req_doc = unauth_req.create_xml_document(settings)
|
104
|
+
inflated = unauth_req_doc.to_s
|
110
105
|
|
111
|
-
|
106
|
+
refute_match %r[<ds:SignatureValue>([a-zA-Z0-9/+=]+)</ds:SignatureValue>], inflated
|
107
|
+
refute_match %r[<ds:SignatureMethod Algorithm='http://www.w3.org/2000/09/xmldsig#rsa-sha1'/>], inflated
|
108
|
+
refute_match %r[<ds:DigestMethod Algorithm='http://www.w3.org/2000/09/xmldsig#sha1'/>], inflated
|
112
109
|
|
113
|
-
|
114
|
-
assert_match %r[<ds:SignatureMethod Algorithm='http://www.w3.org/2000/09/xmldsig#rsa-sha1'/>], inflated
|
115
|
-
assert_match %r[<ds:DigestMethod Algorithm='http://www.w3.org/2000/09/xmldsig#sha1'/>], inflated
|
116
|
-
end
|
110
|
+
inflated = unauth_req.sign_document(unauth_req_doc, settings).to_s
|
117
111
|
|
118
|
-
|
119
|
-
|
120
|
-
|
112
|
+
assert_match %r[<ds:SignatureValue>([a-zA-Z0-9/+=]+)</ds:SignatureValue>], inflated
|
113
|
+
assert_match %r[<ds:SignatureMethod Algorithm='http://www.w3.org/2000/09/xmldsig#rsa-sha1'/>], inflated
|
114
|
+
assert_match %r[<ds:DigestMethod Algorithm='http://www.w3.org/2000/09/xmldsig#sha1'/>], inflated
|
115
|
+
end
|
121
116
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
end
|
117
|
+
it "signs through create_logout_request_xml_doc" do
|
118
|
+
unauth_req = OneLogin::RubySaml::Logoutrequest.new
|
119
|
+
inflated = unauth_req.create_logout_request_xml_doc(settings).to_s
|
126
120
|
|
127
|
-
|
128
|
-
|
121
|
+
assert_match %r[<ds:SignatureValue>([a-zA-Z0-9/+=]+)</ds:SignatureValue>], inflated
|
122
|
+
assert_match %r[<ds:SignatureMethod Algorithm='http://www.w3.org/2000/09/xmldsig#rsa-sha1'/>], inflated
|
123
|
+
assert_match %r[<ds:DigestMethod Algorithm='http://www.w3.org/2000/09/xmldsig#sha1'/>], inflated
|
124
|
+
end
|
129
125
|
|
130
|
-
|
131
|
-
|
126
|
+
it "created a signed logout request" do
|
127
|
+
settings.compress_request = true
|
132
128
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
129
|
+
unauth_req = OneLogin::RubySaml::Logoutrequest.new
|
130
|
+
unauth_url = unauth_req.create(settings)
|
131
|
+
|
132
|
+
inflated = decode_saml_request_payload(unauth_url)
|
133
|
+
assert_match %r[<ds:SignatureValue>([a-zA-Z0-9/+=]+)</ds:SignatureValue>], inflated
|
134
|
+
assert_match %r[<ds:SignatureMethod Algorithm='http://www.w3.org/2000/09/xmldsig#rsa-sha1'/>], inflated
|
135
|
+
assert_match %r[<ds:DigestMethod Algorithm='http://www.w3.org/2000/09/xmldsig#sha1'/>], inflated
|
136
|
+
end
|
138
137
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
138
|
+
it "create a signed logout request with 256 digest and signature method" do
|
139
|
+
settings.compress_request = false
|
140
|
+
settings.security[:signature_method] = XMLSecurity::Document::RSA_SHA256
|
141
|
+
settings.security[:digest_method] = XMLSecurity::Document::SHA256
|
143
142
|
|
144
|
-
|
145
|
-
|
143
|
+
params = OneLogin::RubySaml::Logoutrequest.new.create_params(settings)
|
144
|
+
request_xml = Base64.decode64(params["SAMLRequest"])
|
146
145
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
146
|
+
assert_match %r[<ds:SignatureValue>([a-zA-Z0-9/+=]+)</ds:SignatureValue>], request_xml
|
147
|
+
assert_match %r[<ds:SignatureMethod Algorithm='http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'/>], request_xml
|
148
|
+
assert_match %r[<ds:DigestMethod Algorithm='http://www.w3.org/2001/04/xmlenc#sha256'/>], request_xml
|
149
|
+
end
|
151
150
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
151
|
+
it "create a signed logout request with 512 digest and signature method RSA_SHA384" do
|
152
|
+
settings.compress_request = false
|
153
|
+
settings.security[:signature_method] = XMLSecurity::Document::RSA_SHA384
|
154
|
+
settings.security[:digest_method] = XMLSecurity::Document::SHA512
|
156
155
|
|
157
|
-
|
158
|
-
|
156
|
+
params = OneLogin::RubySaml::Logoutrequest.new.create_params(settings)
|
157
|
+
request_xml = Base64.decode64(params["SAMLRequest"])
|
159
158
|
|
160
|
-
|
161
|
-
|
162
|
-
|
159
|
+
assert_match %r[<ds:SignatureValue>([a-zA-Z0-9/+=]+)</ds:SignatureValue>], request_xml
|
160
|
+
assert_match %r[<ds:SignatureMethod Algorithm='http://www.w3.org/2001/04/xmldsig-more#rsa-sha384'/>], request_xml
|
161
|
+
assert_match %r[<ds:DigestMethod Algorithm='http://www.w3.org/2001/04/xmlenc#sha512'/>], request_xml
|
162
|
+
end
|
163
163
|
end
|
164
|
-
end
|
165
164
|
|
166
|
-
|
165
|
+
describe "#create_params when the settings indicate to sign the logout request" do
|
167
166
|
|
168
|
-
|
167
|
+
let(:cert) { OpenSSL::X509::Certificate.new(ruby_saml_cert_text) }
|
169
168
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
169
|
+
before do
|
170
|
+
# sign the logout request
|
171
|
+
settings.security[:logout_requests_signed] = true
|
172
|
+
settings.security[:embed_sign] = false
|
173
|
+
settings.certificate = ruby_saml_cert_text
|
174
|
+
settings.private_key = ruby_saml_key_text
|
175
|
+
end
|
177
176
|
|
178
|
-
|
179
|
-
|
177
|
+
it "create a signature parameter with RSA_SHA1 / SHA1 and validate it" do
|
178
|
+
settings.security[:signature_method] = XMLSecurity::Document::RSA_SHA1
|
180
179
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
180
|
+
params = OneLogin::RubySaml::Logoutrequest.new.create_params(settings, :RelayState => 'http://example.com')
|
181
|
+
assert params['SAMLRequest']
|
182
|
+
assert params[:RelayState]
|
183
|
+
assert params['Signature']
|
184
|
+
assert_equal params['SigAlg'], XMLSecurity::Document::RSA_SHA1
|
186
185
|
|
187
|
-
|
188
|
-
|
189
|
-
|
186
|
+
query_string = "SAMLRequest=#{CGI.escape(params['SAMLRequest'])}"
|
187
|
+
query_string << "&RelayState=#{CGI.escape(params[:RelayState])}"
|
188
|
+
query_string << "&SigAlg=#{CGI.escape(params['SigAlg'])}"
|
190
189
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
190
|
+
signature_algorithm = XMLSecurity::BaseDocument.new.algorithm(params['SigAlg'])
|
191
|
+
assert_equal signature_algorithm, OpenSSL::Digest::SHA1
|
192
|
+
assert cert.public_key.verify(signature_algorithm.new, Base64.decode64(params['Signature']), query_string)
|
193
|
+
end
|
195
194
|
|
196
|
-
|
197
|
-
|
195
|
+
it "create a signature parameter with RSA_SHA256 / SHA256 and validate it" do
|
196
|
+
settings.security[:signature_method] = XMLSecurity::Document::RSA_SHA256
|
198
197
|
|
199
|
-
|
200
|
-
|
201
|
-
|
198
|
+
params = OneLogin::RubySaml::Logoutrequest.new.create_params(settings, :RelayState => 'http://example.com')
|
199
|
+
assert params['Signature']
|
200
|
+
assert_equal params['SigAlg'], XMLSecurity::Document::RSA_SHA256
|
202
201
|
|
203
|
-
|
204
|
-
|
205
|
-
|
202
|
+
query_string = "SAMLRequest=#{CGI.escape(params['SAMLRequest'])}"
|
203
|
+
query_string << "&RelayState=#{CGI.escape(params[:RelayState])}"
|
204
|
+
query_string << "&SigAlg=#{CGI.escape(params['SigAlg'])}"
|
206
205
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
206
|
+
signature_algorithm = XMLSecurity::BaseDocument.new.algorithm(params['SigAlg'])
|
207
|
+
assert_equal signature_algorithm, OpenSSL::Digest::SHA256
|
208
|
+
assert cert.public_key.verify(signature_algorithm.new, Base64.decode64(params['Signature']), query_string)
|
209
|
+
end
|
211
210
|
|
212
|
-
|
213
|
-
|
211
|
+
it "create a signature parameter with RSA_SHA384 / SHA384 and validate it" do
|
212
|
+
settings.security[:signature_method] = XMLSecurity::Document::RSA_SHA384
|
214
213
|
|
215
|
-
|
216
|
-
|
217
|
-
|
214
|
+
params = OneLogin::RubySaml::Logoutrequest.new.create_params(settings, :RelayState => 'http://example.com')
|
215
|
+
assert params['Signature']
|
216
|
+
assert_equal params['SigAlg'], XMLSecurity::Document::RSA_SHA384
|
218
217
|
|
219
|
-
|
220
|
-
|
221
|
-
|
218
|
+
query_string = "SAMLRequest=#{CGI.escape(params['SAMLRequest'])}"
|
219
|
+
query_string << "&RelayState=#{CGI.escape(params[:RelayState])}"
|
220
|
+
query_string << "&SigAlg=#{CGI.escape(params['SigAlg'])}"
|
222
221
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
222
|
+
signature_algorithm = XMLSecurity::BaseDocument.new.algorithm(params['SigAlg'])
|
223
|
+
assert_equal signature_algorithm, OpenSSL::Digest::SHA384
|
224
|
+
assert cert.public_key.verify(signature_algorithm.new, Base64.decode64(params['Signature']), query_string)
|
225
|
+
end
|
227
226
|
|
228
|
-
|
229
|
-
|
227
|
+
it "create a signature parameter with RSA_SHA512 / SHA512 and validate it" do
|
228
|
+
settings.security[:signature_method] = XMLSecurity::Document::RSA_SHA512
|
230
229
|
|
231
|
-
|
232
|
-
|
233
|
-
|
230
|
+
params = OneLogin::RubySaml::Logoutrequest.new.create_params(settings, :RelayState => 'http://example.com')
|
231
|
+
assert params['Signature']
|
232
|
+
assert_equal params['SigAlg'], XMLSecurity::Document::RSA_SHA512
|
234
233
|
|
235
|
-
|
236
|
-
|
237
|
-
|
234
|
+
query_string = "SAMLRequest=#{CGI.escape(params['SAMLRequest'])}"
|
235
|
+
query_string << "&RelayState=#{CGI.escape(params[:RelayState])}"
|
236
|
+
query_string << "&SigAlg=#{CGI.escape(params['SigAlg'])}"
|
238
237
|
|
239
|
-
|
240
|
-
|
241
|
-
|
238
|
+
signature_algorithm = XMLSecurity::BaseDocument.new.algorithm(params['SigAlg'])
|
239
|
+
assert_equal signature_algorithm, OpenSSL::Digest::SHA512
|
240
|
+
assert cert.public_key.verify(signature_algorithm.new, Base64.decode64(params['Signature']), query_string)
|
241
|
+
end
|
242
242
|
end
|
243
|
-
|
244
243
|
end
|
245
|
-
|
246
244
|
end
|
data/test/logoutresponse_test.rb
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
|
2
|
-
require
|
3
|
-
require 'responses/logoutresponse_fixtures'
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "responses/logoutresponse_fixtures"))
|
4
3
|
|
5
|
-
class LogoutResponseTest < Test
|
4
|
+
class LogoutResponseTest < Minitest::Test
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
describe "Logoutresponse" do
|
7
|
+
|
8
|
+
describe "#new" do
|
9
|
+
it "raise an exception when response is initialized with nil" do
|
10
10
|
assert_raises(ArgumentError) { OneLogin::RubySaml::Logoutresponse.new(nil) }
|
11
11
|
end
|
12
|
-
|
12
|
+
it "default to empty settings" do
|
13
13
|
logoutresponse = OneLogin::RubySaml::Logoutresponse.new( valid_response)
|
14
14
|
assert logoutresponse.settings.nil?
|
15
15
|
end
|
16
|
-
|
16
|
+
it "accept constructor-injected settings" do
|
17
17
|
logoutresponse = OneLogin::RubySaml::Logoutresponse.new(valid_response, settings)
|
18
18
|
assert !logoutresponse.settings.nil?
|
19
19
|
end
|
20
|
-
|
20
|
+
it "accept constructor-injected options" do
|
21
21
|
logoutresponse = OneLogin::RubySaml::Logoutresponse.new(valid_response, nil, { :foo => :bar} )
|
22
22
|
assert !logoutresponse.options.empty?
|
23
23
|
end
|
24
|
-
|
24
|
+
it "support base64 encoded responses" do
|
25
25
|
expected_response = valid_response
|
26
26
|
logoutresponse = OneLogin::RubySaml::Logoutresponse.new(Base64.encode64(expected_response), settings)
|
27
27
|
|
@@ -29,8 +29,8 @@ class LogoutResponseTest < Test::Unit::TestCase
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
describe "#validate" do
|
33
|
+
it "validate the response" do
|
34
34
|
in_relation_to_request_id = random_id
|
35
35
|
|
36
36
|
logoutresponse = OneLogin::RubySaml::Logoutresponse.new(valid_response({:uuid => in_relation_to_request_id}), settings)
|
@@ -43,7 +43,7 @@ class LogoutResponseTest < Test::Unit::TestCase
|
|
43
43
|
assert logoutresponse.success?
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
it "invalidate responses with wrong id when given option :matches_uuid" do
|
47
47
|
|
48
48
|
expected_request_id = "_some_other_expected_uuid"
|
49
49
|
opts = { :matches_request_id => expected_request_id}
|
@@ -51,10 +51,10 @@ class LogoutResponseTest < Test::Unit::TestCase
|
|
51
51
|
logoutresponse = OneLogin::RubySaml::Logoutresponse.new(valid_response, settings, opts)
|
52
52
|
|
53
53
|
assert !logoutresponse.validate
|
54
|
-
|
54
|
+
assert expected_request_id != logoutresponse.in_response_to
|
55
55
|
end
|
56
56
|
|
57
|
-
|
57
|
+
it "invalidate responses with wrong request status" do
|
58
58
|
logoutresponse = OneLogin::RubySaml::Logoutresponse.new(unsuccessful_response, settings)
|
59
59
|
|
60
60
|
assert !logoutresponse.validate
|
@@ -62,8 +62,8 @@ class LogoutResponseTest < Test::Unit::TestCase
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
|
66
|
-
|
65
|
+
describe "#validate!" do
|
66
|
+
it "validates good responses" do
|
67
67
|
in_relation_to_request_id = random_id
|
68
68
|
|
69
69
|
logoutresponse = OneLogin::RubySaml::Logoutresponse.new(valid_response({:uuid => in_relation_to_request_id}), settings)
|
@@ -71,7 +71,7 @@ class LogoutResponseTest < Test::Unit::TestCase
|
|
71
71
|
logoutresponse.validate!
|
72
72
|
end
|
73
73
|
|
74
|
-
|
74
|
+
it "raises validation error when matching for wrong request id" do
|
75
75
|
|
76
76
|
expected_request_id = "_some_other_expected_id"
|
77
77
|
opts = { :matches_request_id => expected_request_id}
|
@@ -81,19 +81,19 @@ class LogoutResponseTest < Test::Unit::TestCase
|
|
81
81
|
assert_raises(OneLogin::RubySaml::ValidationError) { logoutresponse.validate! }
|
82
82
|
end
|
83
83
|
|
84
|
-
|
84
|
+
it "raise validation error for wrong request status" do
|
85
85
|
logoutresponse = OneLogin::RubySaml::Logoutresponse.new(unsuccessful_response, settings)
|
86
86
|
|
87
87
|
assert_raises(OneLogin::RubySaml::ValidationError) { logoutresponse.validate! }
|
88
88
|
end
|
89
89
|
|
90
|
-
|
90
|
+
it "raise validation error when in bad state" do
|
91
91
|
# no settings
|
92
92
|
logoutresponse = OneLogin::RubySaml::Logoutresponse.new(unsuccessful_response)
|
93
93
|
assert_raises(OneLogin::RubySaml::ValidationError) { logoutresponse.validate! }
|
94
94
|
end
|
95
95
|
|
96
|
-
|
96
|
+
it "raise validation error when in lack of sp_entity_id setting" do
|
97
97
|
bad_settings = settings
|
98
98
|
bad_settings.issuer = nil
|
99
99
|
bad_settings.sp_entity_id = nil
|
@@ -101,7 +101,7 @@ class LogoutResponseTest < Test::Unit::TestCase
|
|
101
101
|
assert_raises(OneLogin::RubySaml::ValidationError) { logoutresponse.validate! }
|
102
102
|
end
|
103
103
|
|
104
|
-
|
104
|
+
it "raise error for invalid xml" do
|
105
105
|
logoutresponse = OneLogin::RubySaml::Logoutresponse.new(invalid_xml_response, settings)
|
106
106
|
|
107
107
|
assert_raises(OneLogin::RubySaml::ValidationError) { logoutresponse.validate! }
|
@@ -109,10 +109,4 @@ class LogoutResponseTest < Test::Unit::TestCase
|
|
109
109
|
end
|
110
110
|
|
111
111
|
end
|
112
|
-
|
113
|
-
# logoutresponse fixtures
|
114
|
-
def random_id
|
115
|
-
"_#{UUID.new.generate}"
|
116
|
-
end
|
117
|
-
|
118
112
|
end
|