Commit 1604c8d

mo <mo.khan@gmail.com>
2017-12-10 18:55:15
implement inspect.
1 parent 8ac6fd1
Changed files (3)
lib/saml/kit/bindings/binding.rb
@@ -41,6 +41,10 @@ module Saml
           "#{location}#{binding}"
         end
 
+        def inspect
+          to_h.inspect
+        end
+
         protected
 
         def saml_param_from(params)
lib/saml/kit/certificate.rb
@@ -48,6 +48,14 @@ module Saml
         value
       end
 
+      def to_h
+        { use: @use, x509: @value }
+      end
+
+      def inspect
+        to_h.inspect
+      end
+
       def self.to_x509(value)
         OpenSSL::X509::Certificate.new(Base64.decode64(value))
       rescue OpenSSL::X509::CertificateError => error
spec/saml/composite_metadata_spec.rb
@@ -124,15 +124,30 @@ RSpec.describe Saml::Kit::CompositeMetadata do
       Saml::Kit::Bindings::HttpPost.new(location: idp_logout_service),
     ])
   end
+  it do
+    expect(subject.service_for(type: 'SingleLogoutService', binding: :http_post)).to eql(
+      Saml::Kit::Bindings::HttpPost.new(location: sp_logout_service)
+    )
+  end
   it do
     expect(subject.services('AssertionConsumerService')).to match_array([
       Saml::Kit::Bindings::HttpPost.new(location: assertion_consumer_service),
     ])
   end
+  it do
+    expect(subject.service_for(type: 'AssertionConsumerService', binding: :http_post)).to eql(
+      Saml::Kit::Bindings::HttpPost.new(location: assertion_consumer_service),
+    )
+  end
   it do
     expect(subject.services('SingleSignOnService')).to match_array([
       Saml::Kit::Bindings::HttpPost.new(location: sign_on_service),
       Saml::Kit::Bindings::HttpRedirect.new(location: sign_on_service),
     ])
   end
+  it do
+    expect(subject.service_for(type: 'SingleSignOnService', binding: :http_post)).to eql(
+      Saml::Kit::Bindings::HttpPost.new(location: sign_on_service),
+    )
+  end
 end