ruby-saml 1.9.0 → 1.15.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ruby-saml might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/.github/workflows/test.yml +43 -0
- data/{changelog.md → CHANGELOG.md} +72 -1
- data/LICENSE +2 -1
- data/README.md +439 -212
- data/UPGRADING.md +149 -0
- data/lib/onelogin/ruby-saml/attributes.rb +24 -1
- data/lib/onelogin/ruby-saml/authrequest.rb +27 -11
- data/lib/onelogin/ruby-saml/idp_metadata_parser.rb +285 -184
- data/lib/onelogin/ruby-saml/logging.rb +3 -3
- data/lib/onelogin/ruby-saml/logoutrequest.rb +27 -12
- data/lib/onelogin/ruby-saml/logoutresponse.rb +27 -11
- data/lib/onelogin/ruby-saml/metadata.rb +62 -17
- data/lib/onelogin/ruby-saml/response.rb +87 -38
- data/lib/onelogin/ruby-saml/saml_message.rb +16 -8
- data/lib/onelogin/ruby-saml/setting_error.rb +6 -0
- data/lib/onelogin/ruby-saml/settings.rb +123 -52
- data/lib/onelogin/ruby-saml/slo_logoutrequest.rb +33 -31
- data/lib/onelogin/ruby-saml/slo_logoutresponse.rb +44 -21
- data/lib/onelogin/ruby-saml/utils.rb +101 -9
- data/lib/onelogin/ruby-saml/version.rb +1 -1
- data/lib/xml_security.rb +41 -15
- data/ruby-saml.gemspec +49 -13
- metadata +71 -308
- data/.travis.yml +0 -32
- data/test/certificates/certificate1 +0 -12
- data/test/certificates/certificate_without_head_foot +0 -1
- data/test/certificates/formatted_certificate +0 -14
- data/test/certificates/formatted_chained_certificate +0 -42
- data/test/certificates/formatted_private_key +0 -12
- data/test/certificates/formatted_rsa_private_key +0 -12
- data/test/certificates/invalid_certificate1 +0 -1
- data/test/certificates/invalid_certificate2 +0 -1
- data/test/certificates/invalid_certificate3 +0 -12
- data/test/certificates/invalid_chained_certificate1 +0 -1
- data/test/certificates/invalid_private_key1 +0 -1
- data/test/certificates/invalid_private_key2 +0 -1
- data/test/certificates/invalid_private_key3 +0 -10
- data/test/certificates/invalid_rsa_private_key1 +0 -1
- data/test/certificates/invalid_rsa_private_key2 +0 -1
- data/test/certificates/invalid_rsa_private_key3 +0 -10
- data/test/certificates/ruby-saml-2.crt +0 -15
- data/test/certificates/ruby-saml.crt +0 -14
- data/test/certificates/ruby-saml.key +0 -15
- data/test/idp_metadata_parser_test.rb +0 -579
- data/test/logging_test.rb +0 -62
- data/test/logout_requests/invalid_slo_request.xml +0 -6
- data/test/logout_requests/slo_request.xml +0 -4
- data/test/logout_requests/slo_request.xml.base64 +0 -1
- data/test/logout_requests/slo_request_deflated.xml.base64 +0 -1
- data/test/logout_requests/slo_request_with_name_id_format.xml +0 -4
- data/test/logout_requests/slo_request_with_session_index.xml +0 -5
- data/test/logout_responses/logoutresponse_fixtures.rb +0 -67
- data/test/logoutrequest_test.rb +0 -226
- data/test/logoutresponse_test.rb +0 -402
- data/test/metadata/idp_descriptor.xml +0 -26
- data/test/metadata/idp_descriptor_2.xml +0 -56
- data/test/metadata/idp_descriptor_3.xml +0 -14
- data/test/metadata/idp_descriptor_4.xml +0 -72
- data/test/metadata/idp_metadata_different_sign_and_encrypt_cert.xml +0 -72
- data/test/metadata/idp_metadata_multi_certs.xml +0 -75
- data/test/metadata/idp_metadata_multi_signing_certs.xml +0 -52
- data/test/metadata/idp_metadata_same_sign_and_encrypt_cert.xml +0 -71
- data/test/metadata/idp_multiple_descriptors.xml +0 -53
- data/test/metadata/no_idp_descriptor.xml +0 -21
- data/test/metadata_test.rb +0 -331
- data/test/request_test.rb +0 -323
- data/test/response_test.rb +0 -1619
- data/test/responses/adfs_response_sha1.xml +0 -46
- data/test/responses/adfs_response_sha256.xml +0 -46
- data/test/responses/adfs_response_sha384.xml +0 -46
- data/test/responses/adfs_response_sha512.xml +0 -46
- data/test/responses/adfs_response_xmlns.xml +0 -45
- data/test/responses/attackxee.xml +0 -13
- data/test/responses/invalids/duplicated_attributes.xml.base64 +0 -1
- data/test/responses/invalids/empty_destination.xml.base64 +0 -1
- data/test/responses/invalids/empty_nameid.xml.base64 +0 -1
- data/test/responses/invalids/encrypted_new_attack.xml.base64 +0 -1
- data/test/responses/invalids/invalid_audience.xml.base64 +0 -1
- data/test/responses/invalids/invalid_issuer_assertion.xml.base64 +0 -1
- data/test/responses/invalids/invalid_issuer_message.xml.base64 +0 -1
- data/test/responses/invalids/invalid_signature_position.xml.base64 +0 -1
- data/test/responses/invalids/invalid_subjectconfirmation_inresponse.xml.base64 +0 -1
- data/test/responses/invalids/invalid_subjectconfirmation_nb.xml.base64 +0 -1
- data/test/responses/invalids/invalid_subjectconfirmation_noa.xml.base64 +0 -1
- data/test/responses/invalids/invalid_subjectconfirmation_recipient.xml.base64 +0 -1
- data/test/responses/invalids/multiple_assertions.xml.base64 +0 -2
- data/test/responses/invalids/multiple_signed.xml.base64 +0 -1
- data/test/responses/invalids/no_authnstatement.xml.base64 +0 -1
- data/test/responses/invalids/no_conditions.xml.base64 +0 -1
- data/test/responses/invalids/no_id.xml.base64 +0 -1
- data/test/responses/invalids/no_issuer_assertion.xml.base64 +0 -1
- data/test/responses/invalids/no_issuer_response.xml.base64 +0 -1
- data/test/responses/invalids/no_nameid.xml.base64 +0 -1
- data/test/responses/invalids/no_saml2.xml.base64 +0 -1
- data/test/responses/invalids/no_signature.xml.base64 +0 -1
- data/test/responses/invalids/no_status.xml.base64 +0 -1
- data/test/responses/invalids/no_status_code.xml.base64 +0 -1
- data/test/responses/invalids/no_subjectconfirmation_data.xml.base64 +0 -1
- data/test/responses/invalids/no_subjectconfirmation_method.xml.base64 +0 -1
- data/test/responses/invalids/response_invalid_signed_element.xml.base64 +0 -1
- data/test/responses/invalids/response_with_concealed_signed_assertion.xml +0 -51
- data/test/responses/invalids/response_with_doubled_signed_assertion.xml +0 -49
- data/test/responses/invalids/signature_wrapping_attack.xml.base64 +0 -1
- data/test/responses/invalids/status_code_responder.xml.base64 +0 -1
- data/test/responses/invalids/status_code_responer_and_msg.xml.base64 +0 -1
- data/test/responses/invalids/wrong_spnamequalifier.xml.base64 +0 -1
- data/test/responses/no_signature_ns.xml +0 -48
- data/test/responses/open_saml_response.xml +0 -56
- data/test/responses/response_assertion_wrapped.xml.base64 +0 -93
- data/test/responses/response_audience_self_closed_tag.xml.base64 +0 -1
- data/test/responses/response_double_status_code.xml.base64 +0 -1
- data/test/responses/response_encrypted_attrs.xml.base64 +0 -1
- data/test/responses/response_encrypted_nameid.xml.base64 +0 -1
- data/test/responses/response_eval.xml +0 -7
- data/test/responses/response_no_cert_and_encrypted_attrs.xml +0 -29
- data/test/responses/response_node_text_attack.xml.base64 +0 -1
- data/test/responses/response_node_text_attack2.xml.base64 +0 -1
- data/test/responses/response_node_text_attack3.xml.base64 +0 -1
- data/test/responses/response_unsigned_xml_base64 +0 -1
- data/test/responses/response_with_ampersands.xml +0 -139
- data/test/responses/response_with_ampersands.xml.base64 +0 -93
- data/test/responses/response_with_ds_namespace_at_the_root.xml.base64 +0 -1
- data/test/responses/response_with_multiple_attribute_statements.xml +0 -72
- data/test/responses/response_with_multiple_attribute_values.xml +0 -67
- data/test/responses/response_with_retrieval_method.xml +0 -26
- data/test/responses/response_with_saml2_namespace.xml.base64 +0 -102
- data/test/responses/response_with_signed_assertion.xml.base64 +0 -66
- data/test/responses/response_with_signed_assertion_2.xml.base64 +0 -1
- data/test/responses/response_with_signed_assertion_3.xml +0 -30
- data/test/responses/response_with_signed_message_and_assertion.xml +0 -34
- data/test/responses/response_with_undefined_recipient.xml.base64 +0 -1
- data/test/responses/response_without_attributes.xml.base64 +0 -79
- data/test/responses/response_without_reference_uri.xml.base64 +0 -1
- data/test/responses/response_wrapped.xml.base64 +0 -150
- data/test/responses/signed_message_encrypted_signed_assertion.xml.base64 +0 -1
- data/test/responses/signed_message_encrypted_unsigned_assertion.xml.base64 +0 -1
- data/test/responses/signed_nameid_in_atts.xml +0 -47
- data/test/responses/signed_unqual_nameid_in_atts.xml +0 -47
- data/test/responses/simple_saml_php.xml +0 -71
- data/test/responses/starfield_response.xml.base64 +0 -1
- data/test/responses/test_sign.xml +0 -43
- data/test/responses/unsigned_encrypted_adfs.xml +0 -23
- data/test/responses/unsigned_message_aes128_encrypted_signed_assertion.xml.base64 +0 -1
- data/test/responses/unsigned_message_aes192_encrypted_signed_assertion.xml.base64 +0 -1
- data/test/responses/unsigned_message_aes256_encrypted_signed_assertion.xml.base64 +0 -1
- data/test/responses/unsigned_message_des192_encrypted_signed_assertion.xml.base64 +0 -1
- data/test/responses/unsigned_message_encrypted_assertion_without_saml_namespace.xml.base64 +0 -1
- data/test/responses/unsigned_message_encrypted_signed_assertion.xml.base64 +0 -1
- data/test/responses/unsigned_message_encrypted_unsigned_assertion.xml.base64 +0 -1
- data/test/responses/valid_response.xml.base64 +0 -1
- data/test/responses/valid_response_with_formatted_x509certificate.xml.base64 +0 -1
- data/test/responses/valid_response_without_x509certificate.xml.base64 +0 -1
- data/test/saml_message_test.rb +0 -56
- data/test/settings_test.rb +0 -329
- data/test/slo_logoutrequest_test.rb +0 -448
- data/test/slo_logoutresponse_test.rb +0 -199
- data/test/test_helper.rb +0 -327
- data/test/utils_test.rb +0 -254
- data/test/xml_security_test.rb +0 -421
data/test/settings_test.rb
DELETED
@@ -1,329 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
|
2
|
-
|
3
|
-
require 'onelogin/ruby-saml/settings'
|
4
|
-
|
5
|
-
class SettingsTest < Minitest::Test
|
6
|
-
|
7
|
-
describe "Settings" do
|
8
|
-
before do
|
9
|
-
@settings = OneLogin::RubySaml::Settings.new
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should provide getters and settings" do
|
13
|
-
accessors = [
|
14
|
-
:idp_entity_id, :idp_sso_target_url, :idp_slo_target_url,
|
15
|
-
:idp_cert, :idp_cert_fingerprint, :idp_cert_fingerprint_algorithm, :idp_cert_multi,
|
16
|
-
:idp_attribute_names, :issuer, :assertion_consumer_service_url, :assertion_consumer_service_binding,
|
17
|
-
:single_logout_service_url, :single_logout_service_binding,
|
18
|
-
:sp_name_qualifier, :name_identifier_format, :name_identifier_value,
|
19
|
-
:sessionindex, :attributes_index, :passive, :force_authn,
|
20
|
-
:compress_request, :double_quote_xml_attribute_values, :protocol_binding,
|
21
|
-
:security, :certificate, :private_key,
|
22
|
-
:authn_context, :authn_context_comparison, :authn_context_decl_ref,
|
23
|
-
:assertion_consumer_logout_service_url,
|
24
|
-
:assertion_consumer_logout_service_binding
|
25
|
-
]
|
26
|
-
|
27
|
-
accessors.each do |accessor|
|
28
|
-
value = Kernel.rand
|
29
|
-
@settings.send("#{accessor}=".to_sym, value)
|
30
|
-
assert_equal value, @settings.send(accessor)
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
it "create settings from hash" do
|
36
|
-
config = {
|
37
|
-
:assertion_consumer_service_url => "http://app.muda.no/sso",
|
38
|
-
:issuer => "http://muda.no",
|
39
|
-
:sp_name_qualifier => "http://sso.muda.no",
|
40
|
-
:idp_sso_target_url => "http://sso.muda.no/sso",
|
41
|
-
:idp_slo_target_url => "http://sso.muda.no/slo",
|
42
|
-
:idp_cert_fingerprint => "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00",
|
43
|
-
:name_identifier_format => "urn:oasis:names:tc:SAML:2.0:nameid-format:transient",
|
44
|
-
:attributes_index => 30,
|
45
|
-
:passive => true,
|
46
|
-
:protocol_binding => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST'
|
47
|
-
}
|
48
|
-
@settings = OneLogin::RubySaml::Settings.new(config)
|
49
|
-
|
50
|
-
config.each do |k,v|
|
51
|
-
assert_equal v, @settings.send(k)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
it "configure attribute service attributes correctly" do
|
56
|
-
@settings.attribute_consuming_service.configure do
|
57
|
-
service_name "Test Service"
|
58
|
-
add_attribute :name => "Name", :name_format => "Name Format", :friendly_name => "Friendly Name"
|
59
|
-
end
|
60
|
-
|
61
|
-
assert_equal @settings.attribute_consuming_service.configured?, true
|
62
|
-
assert_equal @settings.attribute_consuming_service.name, "Test Service"
|
63
|
-
assert_equal @settings.attribute_consuming_service.attributes, [{:name => "Name", :name_format => "Name Format", :friendly_name => "Friendly Name" }]
|
64
|
-
end
|
65
|
-
|
66
|
-
it "does not modify default security settings" do
|
67
|
-
settings = OneLogin::RubySaml::Settings.new
|
68
|
-
settings.security[:authn_requests_signed] = true
|
69
|
-
settings.security[:embed_sign] = true
|
70
|
-
settings.security[:digest_method] = XMLSecurity::Document::SHA256
|
71
|
-
settings.security[:signature_method] = XMLSecurity::Document::RSA_SHA256
|
72
|
-
|
73
|
-
new_settings = OneLogin::RubySaml::Settings.new
|
74
|
-
assert_equal new_settings.security[:authn_requests_signed], false
|
75
|
-
assert_equal new_settings.security[:embed_sign], false
|
76
|
-
assert_equal new_settings.security[:digest_method], XMLSecurity::Document::SHA1
|
77
|
-
assert_equal new_settings.security[:signature_method], XMLSecurity::Document::RSA_SHA1
|
78
|
-
end
|
79
|
-
|
80
|
-
it "overrides only provided security attributes passing a second parameter" do
|
81
|
-
config = {
|
82
|
-
:security => {
|
83
|
-
:metadata_signed => true
|
84
|
-
}
|
85
|
-
}
|
86
|
-
|
87
|
-
@default_attributes = OneLogin::RubySaml::Settings::DEFAULTS
|
88
|
-
|
89
|
-
@settings = OneLogin::RubySaml::Settings.new(config, true)
|
90
|
-
assert_equal @settings.security[:metadata_signed], true
|
91
|
-
assert_equal @settings.security[:digest_method], @default_attributes[:security][:digest_method]
|
92
|
-
end
|
93
|
-
|
94
|
-
it "doesn't override only provided security attributes without passing a second parameter" do
|
95
|
-
config = {
|
96
|
-
:security => {
|
97
|
-
:metadata_signed => true
|
98
|
-
}
|
99
|
-
}
|
100
|
-
|
101
|
-
@default_attributes = OneLogin::RubySaml::Settings::DEFAULTS
|
102
|
-
|
103
|
-
@settings = OneLogin::RubySaml::Settings.new(config)
|
104
|
-
assert_equal @settings.security[:metadata_signed], true
|
105
|
-
assert_nil @settings.security[:digest_method]
|
106
|
-
end
|
107
|
-
|
108
|
-
describe "#single_logout_service_url" do
|
109
|
-
it "when single_logout_service_url is nil but assertion_consumer_logout_service_url returns its value" do
|
110
|
-
@settings.single_logout_service_url = nil
|
111
|
-
@settings.assertion_consumer_logout_service_url = "http://app.muda.no/sls"
|
112
|
-
|
113
|
-
assert_equal "http://app.muda.no/sls", @settings.single_logout_service_url
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
describe "#single_logout_service_binding" do
|
118
|
-
it "when single_logout_service_binding is nil but assertion_consumer_logout_service_binding returns its value" do
|
119
|
-
@settings.single_logout_service_binding = nil
|
120
|
-
@settings.assertion_consumer_logout_service_binding = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
|
121
|
-
|
122
|
-
assert_equal "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect", @settings.single_logout_service_binding
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
describe "#get_idp_cert" do
|
127
|
-
it "returns nil when the cert is an empty string" do
|
128
|
-
@settings.idp_cert = ""
|
129
|
-
assert_nil @settings.get_idp_cert
|
130
|
-
end
|
131
|
-
|
132
|
-
it "returns nil when the cert is nil" do
|
133
|
-
@settings.idp_cert = nil
|
134
|
-
assert_nil @settings.get_idp_cert
|
135
|
-
end
|
136
|
-
|
137
|
-
it "returns the certificate when it is valid" do
|
138
|
-
@settings.idp_cert = ruby_saml_cert_text
|
139
|
-
assert @settings.get_idp_cert.kind_of? OpenSSL::X509::Certificate
|
140
|
-
end
|
141
|
-
|
142
|
-
it "raises when the certificate is not valid" do
|
143
|
-
# formatted but invalid cert
|
144
|
-
@settings.idp_cert = read_certificate("formatted_certificate")
|
145
|
-
assert_raises(OpenSSL::X509::CertificateError) {
|
146
|
-
@settings.get_idp_cert
|
147
|
-
}
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
describe "#get_idp_cert_multi" do
|
152
|
-
it "returns nil when the value is empty" do
|
153
|
-
@settings.idp_cert = {}
|
154
|
-
assert_nil @settings.get_idp_cert_multi
|
155
|
-
end
|
156
|
-
|
157
|
-
it "returns nil when the idp_cert_multi is nil or empty" do
|
158
|
-
@settings.idp_cert_multi = nil
|
159
|
-
assert_nil @settings.get_idp_cert_multi
|
160
|
-
end
|
161
|
-
|
162
|
-
it "returns partial hash when contains some values" do
|
163
|
-
empty_multi = {
|
164
|
-
:signing => [],
|
165
|
-
:encryption => []
|
166
|
-
}
|
167
|
-
|
168
|
-
@settings.idp_cert_multi = {
|
169
|
-
:signing => []
|
170
|
-
}
|
171
|
-
assert_equal empty_multi, @settings.get_idp_cert_multi
|
172
|
-
|
173
|
-
@settings.idp_cert_multi = {
|
174
|
-
:encryption => []
|
175
|
-
}
|
176
|
-
assert_equal empty_multi, @settings.get_idp_cert_multi
|
177
|
-
|
178
|
-
@settings.idp_cert_multi = {
|
179
|
-
:signing => [],
|
180
|
-
:encryption => []
|
181
|
-
}
|
182
|
-
assert_equal empty_multi, @settings.get_idp_cert_multi
|
183
|
-
|
184
|
-
@settings.idp_cert_multi = {
|
185
|
-
:yyy => [],
|
186
|
-
:zzz => []
|
187
|
-
}
|
188
|
-
assert_equal empty_multi, @settings.get_idp_cert_multi
|
189
|
-
end
|
190
|
-
|
191
|
-
it "returns the hash with certificates when values were valid" do
|
192
|
-
certificates = ruby_saml_cert_text
|
193
|
-
@settings.idp_cert_multi = {
|
194
|
-
:signing => [ruby_saml_cert_text],
|
195
|
-
:encryption => [ruby_saml_cert_text],
|
196
|
-
}
|
197
|
-
|
198
|
-
assert @settings.get_idp_cert_multi.kind_of? Hash
|
199
|
-
assert @settings.get_idp_cert_multi[:signing].kind_of? Array
|
200
|
-
assert @settings.get_idp_cert_multi[:encryption].kind_of? Array
|
201
|
-
assert @settings.get_idp_cert_multi[:signing][0].kind_of? OpenSSL::X509::Certificate
|
202
|
-
assert @settings.get_idp_cert_multi[:encryption][0].kind_of? OpenSSL::X509::Certificate
|
203
|
-
end
|
204
|
-
|
205
|
-
it "raises when there is a cert in idp_cert_multi not valid" do
|
206
|
-
certificate = read_certificate("formatted_certificate")
|
207
|
-
|
208
|
-
@settings.idp_cert_multi = {
|
209
|
-
:signing => [],
|
210
|
-
:encryption => []
|
211
|
-
}
|
212
|
-
@settings.idp_cert_multi[:signing].push(certificate)
|
213
|
-
@settings.idp_cert_multi[:encryption].push(certificate)
|
214
|
-
|
215
|
-
assert_raises(OpenSSL::X509::CertificateError) {
|
216
|
-
@settings.get_idp_cert_multi
|
217
|
-
}
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
describe "#get_sp_cert" do
|
222
|
-
it "returns nil when the cert is an empty string" do
|
223
|
-
@settings.certificate = ""
|
224
|
-
assert_nil @settings.get_sp_cert
|
225
|
-
end
|
226
|
-
|
227
|
-
it "returns nil when the cert is nil" do
|
228
|
-
@settings.certificate = nil
|
229
|
-
assert_nil @settings.get_sp_cert
|
230
|
-
end
|
231
|
-
|
232
|
-
it "returns the certificate when it is valid" do
|
233
|
-
@settings.certificate = ruby_saml_cert_text
|
234
|
-
assert @settings.get_sp_cert.kind_of? OpenSSL::X509::Certificate
|
235
|
-
end
|
236
|
-
|
237
|
-
it "raises when the certificate is not valid" do
|
238
|
-
# formatted but invalid cert
|
239
|
-
@settings.certificate = read_certificate("formatted_certificate")
|
240
|
-
assert_raises(OpenSSL::X509::CertificateError) {
|
241
|
-
@settings.get_sp_cert
|
242
|
-
}
|
243
|
-
end
|
244
|
-
|
245
|
-
end
|
246
|
-
|
247
|
-
describe "#get_sp_cert_new" do
|
248
|
-
it "returns nil when the cert is an empty string" do
|
249
|
-
@settings.certificate_new = ""
|
250
|
-
assert_nil @settings.get_sp_cert_new
|
251
|
-
end
|
252
|
-
|
253
|
-
it "returns nil when the cert is nil" do
|
254
|
-
@settings.certificate_new = nil
|
255
|
-
assert_nil @settings.get_sp_cert_new
|
256
|
-
end
|
257
|
-
|
258
|
-
it "returns the certificate when it is valid" do
|
259
|
-
@settings.certificate_new = ruby_saml_cert_text
|
260
|
-
assert @settings.get_sp_cert_new.kind_of? OpenSSL::X509::Certificate
|
261
|
-
end
|
262
|
-
|
263
|
-
it "raises when the certificate is not valid" do
|
264
|
-
# formatted but invalid cert
|
265
|
-
@settings.certificate_new = read_certificate("formatted_certificate")
|
266
|
-
assert_raises(OpenSSL::X509::CertificateError) {
|
267
|
-
@settings.get_sp_cert_new
|
268
|
-
}
|
269
|
-
end
|
270
|
-
|
271
|
-
end
|
272
|
-
|
273
|
-
describe "#get_sp_key" do
|
274
|
-
it "returns nil when the private key is an empty string" do
|
275
|
-
@settings.private_key = ""
|
276
|
-
assert_nil @settings.get_sp_key
|
277
|
-
end
|
278
|
-
|
279
|
-
it "returns nil when the private key is nil" do
|
280
|
-
@settings.private_key = nil
|
281
|
-
assert_nil @settings.get_sp_key
|
282
|
-
end
|
283
|
-
|
284
|
-
it "returns the private key when it is valid" do
|
285
|
-
@settings.private_key = ruby_saml_key_text
|
286
|
-
assert @settings.get_sp_key.kind_of? OpenSSL::PKey::RSA
|
287
|
-
end
|
288
|
-
|
289
|
-
it "raises when the private key is not valid" do
|
290
|
-
# formatted but invalid rsa private key
|
291
|
-
@settings.private_key = read_certificate("formatted_rsa_private_key")
|
292
|
-
assert_raises(OpenSSL::PKey::RSAError) {
|
293
|
-
@settings.get_sp_key
|
294
|
-
}
|
295
|
-
end
|
296
|
-
|
297
|
-
end
|
298
|
-
|
299
|
-
describe "#get_fingerprint" do
|
300
|
-
it "get the fingerprint value when cert and fingerprint in settings are nil" do
|
301
|
-
@settings.idp_cert_fingerprint = nil
|
302
|
-
@settings.idp_cert = nil
|
303
|
-
fingerprint = @settings.get_fingerprint
|
304
|
-
assert_nil fingerprint
|
305
|
-
end
|
306
|
-
|
307
|
-
it "get the fingerprint value when there is a cert at the settings" do
|
308
|
-
@settings.idp_cert_fingerprint = nil
|
309
|
-
@settings.idp_cert = ruby_saml_cert_text
|
310
|
-
fingerprint = @settings.get_fingerprint
|
311
|
-
assert fingerprint.downcase == ruby_saml_cert_fingerprint.downcase
|
312
|
-
end
|
313
|
-
|
314
|
-
it "get the fingerprint value when there is a fingerprint at the settings" do
|
315
|
-
@settings.idp_cert_fingerprint = ruby_saml_cert_fingerprint
|
316
|
-
@settings.idp_cert = nil
|
317
|
-
fingerprint = @settings.get_fingerprint
|
318
|
-
assert fingerprint.downcase == ruby_saml_cert_fingerprint.downcase
|
319
|
-
end
|
320
|
-
|
321
|
-
it "get the fingerprint value when there are cert and fingerprint at the settings" do
|
322
|
-
@settings.idp_cert_fingerprint = ruby_saml_cert_fingerprint
|
323
|
-
@settings.idp_cert = ruby_saml_cert_text
|
324
|
-
fingerprint = @settings.get_fingerprint
|
325
|
-
assert fingerprint.downcase == ruby_saml_cert_fingerprint.downcase
|
326
|
-
end
|
327
|
-
end
|
328
|
-
end
|
329
|
-
end
|