Commit 8da3e75
Changed files (6)
lib
saml
kit
builders
spec
saml
kit
builders
lib/saml/kit/builders/templates/null.builder
@@ -0,0 +1,1 @@
+# frozen_string_literal: true
lib/saml/kit/builders/null.rb
@@ -0,0 +1,13 @@
+
+# frozen_string_literal: true
+
+module Saml
+ module Kit
+ module Builders
+ # This class is responsible for rendering an empty xml element
+ class Null
+ include XmlTemplatable
+ end
+ end
+ end
+end
lib/saml/kit/builders/response.rb
@@ -32,6 +32,10 @@ module Saml
Saml::Kit::Response.new(to_xml, request_id: request.try(:id), configuration: configuration)
end
+ def assertion=(value)
+ @assertion = value ? value : Null.new
+ end
+
def assertion
@assertion ||=
begin
lib/saml/kit/builders.rb
@@ -8,6 +8,7 @@ require 'saml/kit/builders/identity_provider_metadata'
require 'saml/kit/builders/logout_request'
require 'saml/kit/builders/logout_response'
require 'saml/kit/builders/metadata'
+require 'saml/kit/builders/null'
require 'saml/kit/builders/response'
require 'saml/kit/builders/service_provider_metadata'
spec/saml/kit/builders/response_spec.rb
@@ -45,6 +45,12 @@ RSpec.describe Saml::Kit::Builders::Response do
result = subject.build
expect(result.status_message).to eql('Invalid message signature')
end
+
+ it 'builds a response without an assertion' do
+ subject.assertion = nil
+ result = subject.build
+ expect(result.assertion).not_to be_present
+ end
end
describe '#to_xml' do
.reek
@@ -63,7 +63,7 @@ ControlParameter:
- Saml::Kit::Metadata#to_xml
- Saml::Kit::Signature#to_xml
TooManyInstanceVariables:
- max_instance_variables: 12
+ max_instance_variables: 15
TooManyMethods:
max_methods: 30
TooManyStatements: