Commit 68eab43

mo <mo.khan@gmail.com>
2017-12-10 18:20:10
use method_missing to delegate to idp.
1 parent 00ca0d9
Changed files (2)
lib/saml/kit/composite_metadata.rb
@@ -9,10 +9,6 @@ module Saml
         @identity_provider = Saml::Kit::IdentityProviderMetadata.new(xml)
       end
 
-      def single_sign_on_services
-        identity_provider.single_sign_on_services
-      end
-
       def assertion_consumer_services
         service_provider.assertion_consumer_services
       end
@@ -25,6 +21,15 @@ module Saml
           Saml::Kit::Bindings.create_for(binding, location)
         end
       end
+
+      def method_missing(name, *args)
+        puts [name, args].inspect
+        if identity_provider.respond_to?(name)
+          identity_provider.public_send(name, *args)
+        else
+          super
+        end
+      end
     end
   end
 end
spec/saml/composite_metadata_spec.rb
@@ -18,6 +18,7 @@ RSpec.describe Saml::Kit::CompositeMetadata do
     <NameIDFormat>#{Saml::Kit::Namespaces::PERSISTENT}</NameIDFormat>
     <SingleSignOnService Binding="#{post_binding}" Location="#{sign_on_service}"/>
     <SingleSignOnService Binding="#{redirect_binding}" Location="#{sign_on_service}"/>
+    <Attribute xmlns="#{Saml::Kit::Namespaces::ASSERTION}" Name="id" ></Attribute>
   </IDPSSODescriptor>
   <Organization>
     <OrganizationName xml:lang="en">Acme, Inc</OrganizationName>
@@ -39,4 +40,16 @@ RSpec.describe Saml::Kit::CompositeMetadata do
       ])
     end
   end
+
+  describe "#single_sign_on_service_for" do
+    it 'returns the post binding' do
+      expect(subject.single_sign_on_service_for(binding: :http_post)).to eql(
+        Saml::Kit::Bindings::HttpPost.new(location: sign_on_service)
+      )
+    end
+  end
+
+  it { expect(subject.want_authn_requests_signed).to be_truthy }
+  it { expect(subject.attributes).to match_array([name: 'id', format: nil]) }
+  it { expect(subject.login_request_for(binding: :http_post)).to be_present }
 end