kl-ruby-saml 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/README.md +24 -24
- data/Rakefile +1 -1
- data/changelog.md +3 -3
- data/kl-ruby-saml.gemspec +4 -4
- data/lib/kl-ruby-saml.rb +1 -0
- data/lib/onelogin/kl-ruby-saml.rb +17 -0
- data/lib/onelogin/{ruby-saml → kl-ruby-saml}/attribute_service.rb +1 -1
- data/lib/onelogin/{ruby-saml → kl-ruby-saml}/attributes.rb +1 -1
- data/lib/onelogin/{ruby-saml → kl-ruby-saml}/authrequest.rb +7 -7
- data/lib/onelogin/{ruby-saml → kl-ruby-saml}/http_error.rb +1 -1
- data/lib/onelogin/{ruby-saml → kl-ruby-saml}/idp_metadata_parser.rb +3 -3
- data/lib/onelogin/{ruby-saml → kl-ruby-saml}/logging.rb +3 -3
- data/lib/onelogin/{ruby-saml → kl-ruby-saml}/logoutrequest.rb +7 -7
- data/lib/onelogin/{ruby-saml → kl-ruby-saml}/logoutresponse.rb +7 -7
- data/lib/onelogin/{ruby-saml → kl-ruby-saml}/metadata.rb +3 -3
- data/lib/onelogin/{ruby-saml → kl-ruby-saml}/response.rb +9 -9
- data/lib/onelogin/{ruby-saml → kl-ruby-saml}/saml_message.rb +2 -2
- data/lib/onelogin/{ruby-saml → kl-ruby-saml}/settings.rb +6 -6
- data/lib/onelogin/{ruby-saml → kl-ruby-saml}/slo_logoutrequest.rb +6 -6
- data/lib/onelogin/{ruby-saml → kl-ruby-saml}/slo_logoutresponse.rb +7 -7
- data/lib/onelogin/{ruby-saml → kl-ruby-saml}/utils.rb +1 -1
- data/lib/onelogin/{ruby-saml → kl-ruby-saml}/validation_error.rb +1 -1
- data/lib/onelogin/kl-ruby-saml/version.rb +5 -0
- data/lib/xml_security.rb +5 -5
- data/test/idp_metadata_parser_test.rb +7 -7
- data/test/logging_test.rb +11 -11
- data/test/logout_responses/logoutresponse_fixtures.rb +1 -1
- data/test/logoutrequest_test.rb +17 -17
- data/test/logoutresponse_test.rb +39 -39
- data/test/metadata_test.rb +5 -5
- data/test/request_test.rb +26 -26
- data/test/response_test.rb +116 -116
- data/test/saml_message_test.rb +4 -4
- data/test/settings_test.rb +19 -19
- data/test/slo_logoutrequest_test.rb +26 -26
- data/test/slo_logoutresponse_test.rb +16 -16
- data/test/test_helper.rb +3 -3
- data/test/utils_test.rb +23 -23
- data/test/xml_security_test.rb +17 -17
- metadata +23 -23
- data/lib/onelogin/ruby-saml.rb +0 -17
- data/lib/onelogin/ruby-saml/version.rb +0 -5
- data/lib/ruby-saml.rb +0 -1
@@ -1,17 +1,17 @@
|
|
1
1
|
require "xml_security"
|
2
|
-
require "onelogin/ruby-saml/saml_message"
|
2
|
+
require "onelogin/kl-ruby-saml/saml_message"
|
3
3
|
|
4
4
|
require "time"
|
5
5
|
|
6
6
|
# Only supports SAML 2.0
|
7
7
|
module OneLogin
|
8
|
-
module
|
8
|
+
module KlRubySaml
|
9
9
|
|
10
10
|
# SAML2 Logout Response (SLO IdP initiated, Parser)
|
11
11
|
#
|
12
12
|
class Logoutresponse < SamlMessage
|
13
13
|
|
14
|
-
# OneLogin::
|
14
|
+
# OneLogin::KlRubySaml::Settings Toolkit settings
|
15
15
|
attr_accessor :settings
|
16
16
|
|
17
17
|
# Array with the causes
|
@@ -25,7 +25,7 @@ module OneLogin
|
|
25
25
|
|
26
26
|
# Constructs the Logout Response. A Logout Response Object that is an extension of the SamlMessage class.
|
27
27
|
# @param response [String] A UUEncoded logout response from the IdP.
|
28
|
-
# @param settings [OneLogin::
|
28
|
+
# @param settings [OneLogin::KlRubySaml::Settings|nil] Toolkit settings
|
29
29
|
# @param options [Hash] Extra parameters.
|
30
30
|
# :matches_request_id It will validate that the logout response matches the ID of the request.
|
31
31
|
# :get_params GET Parameters, including the SAMLResponse
|
@@ -142,7 +142,7 @@ module OneLogin
|
|
142
142
|
return true if success?
|
143
143
|
|
144
144
|
error_msg = 'The status code of the Logout Response was not Success'
|
145
|
-
status_error_msg = OneLogin::
|
145
|
+
status_error_msg = OneLogin::KlRubySaml::Utils.status_error_msg(error_msg, status_code, status_message)
|
146
146
|
append_error(status_error_msg)
|
147
147
|
end
|
148
148
|
|
@@ -215,14 +215,14 @@ module OneLogin
|
|
215
215
|
return true unless options[:get_params].has_key? 'Signature'
|
216
216
|
return true if settings.nil? || settings.get_idp_cert.nil?
|
217
217
|
|
218
|
-
query_string = OneLogin::
|
218
|
+
query_string = OneLogin::KlRubySaml::Utils.build_query(
|
219
219
|
:type => 'SAMLResponse',
|
220
220
|
:data => options[:get_params]['SAMLResponse'],
|
221
221
|
:relay_state => options[:get_params]['RelayState'],
|
222
222
|
:sig_alg => options[:get_params]['SigAlg']
|
223
223
|
)
|
224
224
|
|
225
|
-
valid = OneLogin::
|
225
|
+
valid = OneLogin::KlRubySaml::Utils.verify_signature(
|
226
226
|
:cert => settings.get_idp_cert,
|
227
227
|
:sig_alg => options[:get_params]['SigAlg'],
|
228
228
|
:signature => options[:get_params]['Signature'],
|
@@ -1,18 +1,18 @@
|
|
1
1
|
require "uri"
|
2
2
|
require "uuid"
|
3
3
|
|
4
|
-
require "onelogin/ruby-saml/logging"
|
4
|
+
require "onelogin/kl-ruby-saml/logging"
|
5
5
|
|
6
6
|
# Only supports SAML 2.0
|
7
7
|
module OneLogin
|
8
|
-
module
|
8
|
+
module KlRubySaml
|
9
9
|
|
10
10
|
# SAML2 Metadata. XML Metadata Builder
|
11
11
|
#
|
12
12
|
class Metadata
|
13
13
|
|
14
14
|
# Return SP metadata based on the settings.
|
15
|
-
# @param settings [OneLogin::
|
15
|
+
# @param settings [OneLogin::KlRubySaml::Settings|nil] Toolkit settings
|
16
16
|
# @param pretty_print [Boolean] Pretty print or not the response
|
17
17
|
# (No pretty print if you gonna validate the signature)
|
18
18
|
# @return [String] XML Metadata of the Service Provider
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require "xml_security"
|
2
|
-
require "onelogin/ruby-saml/attributes"
|
2
|
+
require "onelogin/kl-ruby-saml/attributes"
|
3
3
|
|
4
4
|
require "time"
|
5
5
|
require "nokogiri"
|
6
6
|
|
7
7
|
# Only supports SAML 2.0
|
8
8
|
module OneLogin
|
9
|
-
module
|
9
|
+
module KlRubySaml
|
10
10
|
|
11
11
|
# SAML2 Authentication Response. SAML Response
|
12
12
|
#
|
@@ -18,7 +18,7 @@ module OneLogin
|
|
18
18
|
|
19
19
|
# TODO: Settings should probably be initialized too... WDYT?
|
20
20
|
|
21
|
-
# OneLogin::
|
21
|
+
# OneLogin::KlRubySaml::Settings Toolkit settings
|
22
22
|
attr_accessor :settings
|
23
23
|
|
24
24
|
# Array with the causes [Array of strings]
|
@@ -33,7 +33,7 @@ module OneLogin
|
|
33
33
|
|
34
34
|
# Constructs the SAML Response. A Response Object that is an extension of the SamlMessage class.
|
35
35
|
# @param response [String] A UUEncoded SAML response from the IdP.
|
36
|
-
# @param options [Hash] :settings to provide the OneLogin::
|
36
|
+
# @param options [Hash] :settings to provide the OneLogin::KlRubySaml::Settings object
|
37
37
|
# Or some options for the response validation process like skip the conditions validation
|
38
38
|
# with the :skip_conditions, or allow a clock_drift when checking dates with :allowed_clock_drift
|
39
39
|
# or :matches_request_id that will validate that the response matches the ID of the request.
|
@@ -110,16 +110,16 @@ module OneLogin
|
|
110
110
|
# Gets the Attributes from the AttributeStatement element.
|
111
111
|
#
|
112
112
|
# All attributes can be iterated over +attributes.each+ or returned as array by +attributes.all+
|
113
|
-
# For backwards compatibility ruby-saml returns by default only the first value for a given attribute with
|
113
|
+
# For backwards compatibility kl-ruby-saml returns by default only the first value for a given attribute with
|
114
114
|
# attributes['name']
|
115
115
|
# To get all of the attributes, use:
|
116
116
|
# attributes.multi('name')
|
117
117
|
# Or turn off the compatibility:
|
118
|
-
# OneLogin::
|
118
|
+
# OneLogin::KlRubySaml::Attributes.single_value_compatibility = false
|
119
119
|
# Now this will return an array:
|
120
120
|
# attributes['name']
|
121
121
|
#
|
122
|
-
# @return [Attributes] OneLogin::
|
122
|
+
# @return [Attributes] OneLogin::KlRubySaml::Attributes enumerable collection.
|
123
123
|
#
|
124
124
|
def attributes
|
125
125
|
@attr_statements ||= begin
|
@@ -298,7 +298,7 @@ module OneLogin
|
|
298
298
|
return true if success?
|
299
299
|
|
300
300
|
error_msg = 'The status code of the Response was not Success'
|
301
|
-
status_error_msg = OneLogin::
|
301
|
+
status_error_msg = OneLogin::KlRubySaml::Utils.status_error_msg(error_msg, status_code, status_message)
|
302
302
|
append_error(status_error_msg)
|
303
303
|
end
|
304
304
|
|
@@ -696,7 +696,7 @@ module OneLogin
|
|
696
696
|
return validation_error('An ' + encrypt_node.name + ' found and no SP private key found on the settings to decrypt it')
|
697
697
|
end
|
698
698
|
|
699
|
-
elem_plaintext = OneLogin::
|
699
|
+
elem_plaintext = OneLogin::KlRubySaml::Utils.decrypt_data(encrypt_node, settings.get_sp_key)
|
700
700
|
# If we get some problematic noise in the plaintext after decrypting.
|
701
701
|
# This quick regexp parse will grab only the Element and discard the noise.
|
702
702
|
elem_plaintext = elem_plaintext.match(rgrex)[0]
|
@@ -8,7 +8,7 @@ require 'thread'
|
|
8
8
|
|
9
9
|
# Only supports SAML 2.0
|
10
10
|
module OneLogin
|
11
|
-
module
|
11
|
+
module KlRubySaml
|
12
12
|
|
13
13
|
# SAML2 Message
|
14
14
|
#
|
@@ -105,7 +105,7 @@ module OneLogin
|
|
105
105
|
|
106
106
|
# Deflate, base64 encode and url-encode a SAML Message (To be used in the HTTP-redirect binding)
|
107
107
|
# @param saml [String] The plain SAML Message
|
108
|
-
# @param settings [OneLogin::
|
108
|
+
# @param settings [OneLogin::KlRubySaml::Settings|nil] Toolkit settings
|
109
109
|
# @return [String] The deflated and encoded SAML Message (encoded if the compression is requested)
|
110
110
|
#
|
111
111
|
def encode_raw_saml(saml, settings)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require "xml_security"
|
2
|
-
require "onelogin/ruby-saml/attribute_service"
|
3
|
-
require "onelogin/ruby-saml/utils"
|
2
|
+
require "onelogin/kl-ruby-saml/attribute_service"
|
3
|
+
require "onelogin/kl-ruby-saml/utils"
|
4
4
|
|
5
5
|
# Only supports SAML 2.0
|
6
6
|
module OneLogin
|
7
|
-
module
|
7
|
+
module KlRubySaml
|
8
8
|
|
9
9
|
# SAML2 Toolkit Settings
|
10
10
|
#
|
@@ -118,7 +118,7 @@ module OneLogin
|
|
118
118
|
def get_idp_cert
|
119
119
|
return nil if idp_cert.nil? || idp_cert.empty?
|
120
120
|
|
121
|
-
formated_cert = OneLogin::
|
121
|
+
formated_cert = OneLogin::KlRubySaml::Utils.format_cert(idp_cert)
|
122
122
|
OpenSSL::X509::Certificate.new(formated_cert)
|
123
123
|
end
|
124
124
|
|
@@ -127,7 +127,7 @@ module OneLogin
|
|
127
127
|
def get_sp_cert
|
128
128
|
return nil if certificate.nil? || certificate.empty?
|
129
129
|
|
130
|
-
formated_cert = OneLogin::
|
130
|
+
formated_cert = OneLogin::KlRubySaml::Utils.format_cert(certificate)
|
131
131
|
OpenSSL::X509::Certificate.new(formated_cert)
|
132
132
|
end
|
133
133
|
|
@@ -136,7 +136,7 @@ module OneLogin
|
|
136
136
|
def get_sp_key
|
137
137
|
return nil if private_key.nil? || private_key.empty?
|
138
138
|
|
139
|
-
formated_private_key = OneLogin::
|
139
|
+
formated_private_key = OneLogin::KlRubySaml::Utils.format_private_key(private_key)
|
140
140
|
OpenSSL::PKey::RSA.new(formated_private_key)
|
141
141
|
end
|
142
142
|
|
@@ -2,17 +2,17 @@ require 'zlib'
|
|
2
2
|
require 'time'
|
3
3
|
require 'nokogiri'
|
4
4
|
|
5
|
-
require "onelogin/ruby-saml/saml_message"
|
5
|
+
require "onelogin/kl-ruby-saml/saml_message"
|
6
6
|
|
7
7
|
# Only supports SAML 2.0
|
8
8
|
module OneLogin
|
9
|
-
module
|
9
|
+
module KlRubySaml
|
10
10
|
|
11
11
|
# SAML2 Logout Request (SLO IdP initiated, Parser)
|
12
12
|
#
|
13
13
|
class SloLogoutrequest < SamlMessage
|
14
14
|
|
15
|
-
# OneLogin::
|
15
|
+
# OneLogin::KlRubySaml::Settings Toolkit settings
|
16
16
|
attr_accessor :settings
|
17
17
|
|
18
18
|
# Array with the causes [Array of strings]
|
@@ -26,7 +26,7 @@ module OneLogin
|
|
26
26
|
|
27
27
|
# Constructs the Logout Request. A Logout Request Object that is an extension of the SamlMessage class.
|
28
28
|
# @param request [String] A UUEncoded Logout Request from the IdP.
|
29
|
-
# @param options [Hash] :settings to provide the OneLogin::
|
29
|
+
# @param options [Hash] :settings to provide the OneLogin::KlRubySaml::Settings object
|
30
30
|
# Or :allowed_clock_drift for the logout request validation process to allow a clock drift when checking dates with
|
31
31
|
#
|
32
32
|
# @raise [ArgumentError] If Request is nil
|
@@ -232,14 +232,14 @@ module OneLogin
|
|
232
232
|
return true unless options[:get_params].has_key? 'Signature'
|
233
233
|
return true if settings.nil? || settings.get_idp_cert.nil?
|
234
234
|
|
235
|
-
query_string = OneLogin::
|
235
|
+
query_string = OneLogin::KlRubySaml::Utils.build_query(
|
236
236
|
:type => 'SAMLRequest',
|
237
237
|
:data => options[:get_params]['SAMLRequest'],
|
238
238
|
:relay_state => options[:get_params]['RelayState'],
|
239
239
|
:sig_alg => options[:get_params]['SigAlg']
|
240
240
|
)
|
241
241
|
|
242
|
-
valid = OneLogin::
|
242
|
+
valid = OneLogin::KlRubySaml::Utils.verify_signature(
|
243
243
|
:cert => settings.get_idp_cert,
|
244
244
|
:sig_alg => options[:get_params]['SigAlg'],
|
245
245
|
:signature => options[:get_params]['Signature'],
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require "uuid"
|
2
2
|
|
3
|
-
require "onelogin/ruby-saml/logging"
|
4
|
-
require "onelogin/ruby-saml/saml_message"
|
3
|
+
require "onelogin/kl-ruby-saml/logging"
|
4
|
+
require "onelogin/kl-ruby-saml/saml_message"
|
5
5
|
|
6
6
|
# Only supports SAML 2.0
|
7
7
|
module OneLogin
|
8
|
-
module
|
8
|
+
module KlRubySaml
|
9
9
|
|
10
10
|
# SAML2 Logout Response (SLO SP initiated, Parser)
|
11
11
|
#
|
@@ -22,7 +22,7 @@ module OneLogin
|
|
22
22
|
end
|
23
23
|
|
24
24
|
# Creates the Logout Response string.
|
25
|
-
# @param settings [OneLogin::
|
25
|
+
# @param settings [OneLogin::KlRubySaml::Settings|nil] Toolkit settings
|
26
26
|
# @param request_id [String] The ID of the LogoutRequest sent by this SP to the IdP. That ID will be placed as the InResponseTo in the logout response
|
27
27
|
# @param logout_message [String] The Message to be placed as StatusMessage in the logout response
|
28
28
|
# @param params [Hash] Some extra parameters to be added in the GET for example the RelayState
|
@@ -41,7 +41,7 @@ module OneLogin
|
|
41
41
|
end
|
42
42
|
|
43
43
|
# Creates the Get parameters for the logout response.
|
44
|
-
# @param settings [OneLogin::
|
44
|
+
# @param settings [OneLogin::KlRubySaml::Settings|nil] Toolkit settings
|
45
45
|
# @param request_id [String] The ID of the LogoutRequest sent by this SP to the IdP. That ID will be placed as the InResponseTo in the logout response
|
46
46
|
# @param logout_message [String] The Message to be placed as StatusMessage in the logout response
|
47
47
|
# @param params [Hash] Some extra parameters to be added in the GET for example the RelayState
|
@@ -67,7 +67,7 @@ module OneLogin
|
|
67
67
|
|
68
68
|
if settings.security[:logout_responses_signed] && !settings.security[:embed_sign] && settings.private_key
|
69
69
|
params['SigAlg'] = settings.security[:signature_method]
|
70
|
-
url_string = OneLogin::
|
70
|
+
url_string = OneLogin::KlRubySaml::Utils.build_query(
|
71
71
|
:type => 'SAMLResponse',
|
72
72
|
:data => base64_response,
|
73
73
|
:relay_state => relay_state,
|
@@ -86,7 +86,7 @@ module OneLogin
|
|
86
86
|
end
|
87
87
|
|
88
88
|
# Creates the SAMLResponse String.
|
89
|
-
# @param settings [OneLogin::
|
89
|
+
# @param settings [OneLogin::KlRubySaml::Settings|nil] Toolkit settings
|
90
90
|
# @param request_id [String] The ID of the LogoutRequest sent by this SP to the IdP. That ID will be placed as the InResponseTo in the logout response
|
91
91
|
# @param logout_message [String] The Message to be placed as StatusMessage in the logout response
|
92
92
|
# @return [String] The SAMLResponse String.
|
data/lib/xml_security.rb
CHANGED
@@ -29,7 +29,7 @@ require "openssl"
|
|
29
29
|
require 'nokogiri'
|
30
30
|
require "digest/sha1"
|
31
31
|
require "digest/sha2"
|
32
|
-
require "onelogin/ruby-saml/validation_error"
|
32
|
+
require "onelogin/kl-ruby-saml/validation_error"
|
33
33
|
|
34
34
|
module XMLSecurity
|
35
35
|
|
@@ -203,7 +203,7 @@ module XMLSecurity
|
|
203
203
|
if soft
|
204
204
|
return false
|
205
205
|
else
|
206
|
-
raise OneLogin::
|
206
|
+
raise OneLogin::KlRubySaml::ValidationError.new("Certificate element missing in response (ds:X509Certificate)")
|
207
207
|
end
|
208
208
|
end
|
209
209
|
base64_cert = cert_element.text
|
@@ -220,7 +220,7 @@ module XMLSecurity
|
|
220
220
|
# check cert matches registered idp cert
|
221
221
|
if fingerprint != idp_cert_fingerprint.gsub(/[^a-zA-Z0-9]/,"").downcase
|
222
222
|
@errors << "Fingerprint mismatch"
|
223
|
-
return soft ? false : (raise OneLogin::
|
223
|
+
return soft ? false : (raise OneLogin::KlRubySaml::ValidationError.new("Fingerprint mismatch"))
|
224
224
|
end
|
225
225
|
|
226
226
|
validate_signature(base64_cert, soft)
|
@@ -299,7 +299,7 @@ module XMLSecurity
|
|
299
299
|
|
300
300
|
unless digests_match?(hash, digest_value)
|
301
301
|
@errors << "Digest mismatch"
|
302
|
-
return soft ? false : (raise OneLogin::
|
302
|
+
return soft ? false : (raise OneLogin::KlRubySaml::ValidationError.new("Digest mismatch"))
|
303
303
|
end
|
304
304
|
end
|
305
305
|
|
@@ -325,7 +325,7 @@ module XMLSecurity
|
|
325
325
|
|
326
326
|
unless cert.public_key.verify(signature_algorithm.new, signature, canon_string)
|
327
327
|
@errors << "Key validation error"
|
328
|
-
return soft ? false : (raise OneLogin::
|
328
|
+
return soft ? false : (raise OneLogin::KlRubySaml::ValidationError.new("Key validation error"))
|
329
329
|
end
|
330
330
|
|
331
331
|
return true
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
|
2
2
|
|
3
|
-
require 'onelogin/ruby-saml/idp_metadata_parser'
|
3
|
+
require 'onelogin/kl-ruby-saml/idp_metadata_parser'
|
4
4
|
|
5
5
|
class IdpMetadataParserTest < Minitest::Test
|
6
6
|
class MockSuccessResponse < Net::HTTPSuccess
|
@@ -19,7 +19,7 @@ class IdpMetadataParserTest < Minitest::Test
|
|
19
19
|
|
20
20
|
describe "parsing an IdP descriptor file" do
|
21
21
|
it "extract settings details from xml" do
|
22
|
-
idp_metadata_parser = OneLogin::
|
22
|
+
idp_metadata_parser = OneLogin::KlRubySaml::IdpMetadataParser.new
|
23
23
|
|
24
24
|
settings = idp_metadata_parser.parse(idp_metadata)
|
25
25
|
|
@@ -44,7 +44,7 @@ class IdpMetadataParserTest < Minitest::Test
|
|
44
44
|
end
|
45
45
|
|
46
46
|
it "extract settings from remote xml" do
|
47
|
-
idp_metadata_parser = OneLogin::
|
47
|
+
idp_metadata_parser = OneLogin::KlRubySaml::IdpMetadataParser.new
|
48
48
|
settings = idp_metadata_parser.parse_remote(@url)
|
49
49
|
|
50
50
|
assert_equal "https://example.hello.com/access/saml/idp.xml", settings.idp_entity_id
|
@@ -56,7 +56,7 @@ class IdpMetadataParserTest < Minitest::Test
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it "accept self signed certificate if insturcted" do
|
59
|
-
idp_metadata_parser = OneLogin::
|
59
|
+
idp_metadata_parser = OneLogin::KlRubySaml::IdpMetadataParser.new
|
60
60
|
idp_metadata_parser.parse_remote(@url, false)
|
61
61
|
|
62
62
|
assert_equal OpenSSL::SSL::VERIFY_NONE, @http.verify_mode
|
@@ -65,7 +65,7 @@ class IdpMetadataParserTest < Minitest::Test
|
|
65
65
|
|
66
66
|
describe "download failure cases" do
|
67
67
|
it "raises an exception when the url has no scheme" do
|
68
|
-
idp_metadata_parser = OneLogin::
|
68
|
+
idp_metadata_parser = OneLogin::KlRubySaml::IdpMetadataParser.new
|
69
69
|
|
70
70
|
exception = assert_raises(ArgumentError) do
|
71
71
|
idp_metadata_parser.parse_remote("blahblah")
|
@@ -83,9 +83,9 @@ class IdpMetadataParserTest < Minitest::Test
|
|
83
83
|
Net::HTTP.expects(:new).returns(@http)
|
84
84
|
@http.expects(:request).returns(mock_response)
|
85
85
|
|
86
|
-
idp_metadata_parser = OneLogin::
|
86
|
+
idp_metadata_parser = OneLogin::KlRubySaml::IdpMetadataParser.new
|
87
87
|
|
88
|
-
exception = assert_raises(OneLogin::
|
88
|
+
exception = assert_raises(OneLogin::KlRubySaml::HttpError) do
|
89
89
|
idp_metadata_parser.parse_remote("https://example.hello.com/access/saml/idp.xml")
|
90
90
|
end
|
91
91
|
|
data/test/logging_test.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
|
2
2
|
|
3
|
-
require 'onelogin/ruby-saml/logging'
|
3
|
+
require 'onelogin/kl-ruby-saml/logging'
|
4
4
|
|
5
5
|
class LoggingTest < Minitest::Test
|
6
6
|
|
7
7
|
describe "Logging" do
|
8
8
|
before do
|
9
|
-
OneLogin::
|
9
|
+
OneLogin::KlRubySaml::Logging.logger = nil
|
10
10
|
end
|
11
11
|
|
12
12
|
after do
|
13
|
-
OneLogin::
|
13
|
+
OneLogin::KlRubySaml::Logging.logger = ::TEST_LOGGER
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "given no specific logging setup" do
|
17
17
|
it "prints to stdout" do
|
18
|
-
OneLogin::
|
19
|
-
OneLogin::
|
18
|
+
OneLogin::KlRubySaml::Logging::DEFAULT_LOGGER.expects(:debug).with('hi mom')
|
19
|
+
OneLogin::KlRubySaml::Logging.debug('hi mom')
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -36,26 +36,26 @@ class LoggingTest < Minitest::Test
|
|
36
36
|
logger.expects(:debug).with('hi mom')
|
37
37
|
logger.expects(:info).with('sup?')
|
38
38
|
|
39
|
-
OneLogin::
|
40
|
-
OneLogin::
|
39
|
+
OneLogin::KlRubySaml::Logging.debug('hi mom')
|
40
|
+
OneLogin::KlRubySaml::Logging.info('sup?')
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
describe "given a specific Logger" do
|
45
45
|
let(:logger) { mock('Logger') }
|
46
46
|
|
47
|
-
before { OneLogin::
|
47
|
+
before { OneLogin::KlRubySaml::Logging.logger = logger }
|
48
48
|
|
49
49
|
after do
|
50
|
-
OneLogin::
|
50
|
+
OneLogin::KlRubySaml::Logging.logger = ::TEST_LOGGER
|
51
51
|
end
|
52
52
|
|
53
53
|
it "delegates to the object" do
|
54
54
|
logger.expects(:debug).with('hi mom')
|
55
55
|
logger.expects(:info).with('sup?')
|
56
56
|
|
57
|
-
OneLogin::
|
58
|
-
OneLogin::
|
57
|
+
OneLogin::KlRubySaml::Logging.debug('hi mom')
|
58
|
+
OneLogin::KlRubySaml::Logging.info('sup?')
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|