Commit e5c9314

mo <mo@mokhan.ca>
2018-02-09 20:38:31
implement present?
1 parent 6ffd240
Changed files (2)
lib
spec
lib/saml/kit/assertion.rb
@@ -8,7 +8,7 @@ module Saml
       validate :must_be_active_session
       attr_reader :name
 
-      def initialize(xml_hash, configuration:)
+      def initialize(xml_hash, configuration: Saml::Kit.configuration)
         @name = "Assertion"
         @xml_hash = xml_hash
         @configuration = configuration
@@ -71,6 +71,10 @@ module Saml
         @xml_hash.fetch('Response', {}).fetch('EncryptedAssertion', nil).present?
       end
 
+      def present?
+        assertion.present?
+      end
+
       private
 
       attr_reader :configuration
spec/saml/assertion_spec.rb
@@ -46,4 +46,18 @@ RSpec.describe Saml::Kit::Assertion do
       expect(subject).to_not be_expired
     end
   end
+
+  describe "#present?" do
+    it 'returns false when the assertion is empty' do
+      xml_hash = { 'Response' => { } }
+      subject = described_class.new(xml_hash)
+      expect(subject).to_not be_present
+    end
+
+    it 'returns true when the assertion is present' do
+      xml_hash = { 'Response' => { 'Assertion' => { 'Conditions' => { } } } }
+      subject = described_class.new(xml_hash)
+      expect(subject).to be_present
+    end
+  end
 end