Commit 4c28988

mo <mo@mokhan.ca>
2018-10-22 16:30:12
ensure encrypted assertion forwards changes to assertion tag: v1.0.26
1 parent e393cc8
Changed files (3)
lib
spec
saml
kit
lib/saml/kit/builders/encrypted_assertion.rb
@@ -10,13 +10,18 @@ module Saml
         extend Forwardable
 
         attr_reader :assertion
+        attr_accessor :destination
         def_delegators :@response_builder,
           :configuration,
           :encryption_certificate
 
         def_delegators :@assertion,
           :default_name_id_format,
-          :default_name_id_format=
+          :default_name_id_format=,
+          :destination=,
+          :embed_signature,
+          :issuer=,
+          :now=
 
         def initialize(response_builder, assertion)
           @response_builder = response_builder
lib/saml/kit/builders/response.rb
@@ -52,6 +52,17 @@ module Saml
             end
         end
 
+        def encrypt=(value)
+          super(value)
+          return if @assertion.nil?
+
+          if value
+            @assertion = EncryptedAssertion.new(self, assertion) if assertion.is_a?(Assertion)
+          elsif assertion.is_a?(EncryptedAssertion)
+            @assertion = assertion.assertion if assertion.is_a?(EncryptedAssertion)
+          end
+        end
+
         def destination=(value)
           @destination = value
           assertion.destination = value
spec/saml/kit/builders/response_spec.rb
@@ -76,6 +76,8 @@ RSpec.describe Saml::Kit::Builders::Response do
       allow(Saml::Kit.configuration).to receive(:entity_id).and_return(issuer)
       subject.destination = assertion_consumer_service_url
       subject.encrypt = false
+      subject.encrypt = true
+      subject.encrypt = false
       hash = Hash.from_xml(subject.to_xml)
 
       expect(hash['Response']['ID']).to be_present