Commit 5b6523a

mo <mo.khan@gmail.com>
2017-11-12 23:34:48
allow idp to build login and logout requests.
1 parent 4573fe2
lib/saml/kit/identity_provider_metadata.rb
@@ -39,8 +39,8 @@ module Saml
         end
       end
 
-      def build_authentication_request
-        builder = AuthenticationRequest::Builder.new(sign: want_authn_requests_signed)
+      def build_request(type)
+        builder = type::Builder.new(sign: want_authn_requests_signed)
         yield builder if block_given?
         builder.build
       end
lib/saml/kit/logout_request.rb
@@ -77,6 +77,14 @@ module Saml
         to_h[name]['Signature'].present?
       end
 
+      def to_s
+        to_xml
+      end
+
+      def serialize
+        Saml::Kit::Content.encode_raw_saml(to_xml)
+      end
+
       private
 
       def registry
spec/saml/identity_provider_metadata_spec.rb
@@ -265,21 +265,21 @@ RSpec.describe Saml::Kit::IdentityProviderMetadata do
     end
   end
 
-  describe "#build_authentication_request" do
+  describe "#build_request" do
     let(:builder) { described_class::Builder.new }
 
     it 'it signs the authentication request when the idp metadata demands it' do
       builder.want_authn_requests_signed = true
       subject = builder.build
 
-      expect(subject.build_authentication_request).to be_signed
+      expect(subject.build_request(Saml::Kit::AuthenticationRequest)).to be_signed
     end
 
     it 'does not sign the authentication request when the idp does not require it' do
       builder.want_authn_requests_signed = false
       subject = builder.build
 
-      expect(subject.build_authentication_request).to_not be_signed
+      expect(subject.build_request(Saml::Kit::AuthenticationRequest)).to_not be_signed
     end
   end
 end