diff --git a/lib/saml_idp/request.rb b/lib/saml_idp/request.rb index 5a3a3679..c6420c79 100644 --- a/lib/saml_idp/request.rb +++ b/lib/saml_idp/request.rb @@ -78,10 +78,10 @@ def response_url end def log(msg) - if config.logger.class <= ::Logger - config.logger.info msg - else + if config.logger.respond_to?(:call) config.logger.call msg + else + config.logger.info msg end end @@ -198,4 +198,4 @@ def service_provider_finder end private :service_provider_finder end -end +end \ No newline at end of file diff --git a/spec/lib/saml_idp/request_spec.rb b/spec/lib/saml_idp/request_spec.rb index a989a73c..339ea407 100644 --- a/spec/lib/saml_idp/request_spec.rb +++ b/spec/lib/saml_idp/request_spec.rb @@ -91,6 +91,23 @@ module SamlIdp end end + context 'a Logger-like logger is configured' do + let(:logger) do + Class.new { + def info(msg); end + }.new + end + + before do + allow(logger).to receive(:info) + end + + it 'logs an error message' do + expect(subject.valid?).to be false + expect(logger).to have_received(:info).with('Unable to find service provider for issuer ') + end + end + context 'a logger lambda is configured' do let(:logger) { double } @@ -138,4 +155,4 @@ module SamlIdp end end end -end +end \ No newline at end of file