Commit 4fde95f
Changed files (3)
lib
saml
spec
lib/saml/kit/logout_request.rb
@@ -3,6 +3,27 @@ module Saml
class LogoutRequest
def initialize(xml)
@xml = xml
+ @xml_hash = Hash.from_xml(xml)
+ end
+
+ def issuer
+ @xml_hash['LogoutRequest']['Issuer']
+ end
+
+ def issue_instant
+ @xml_hash['LogoutRequest']['IssueInstant']
+ end
+
+ def version
+ @xml_hash['LogoutRequest']['Version']
+ end
+
+ def destination
+ @xml_hash['LogoutRequest']['Destination']
+ end
+
+ def name_id
+ @xml_hash['LogoutRequest']['NameID']
end
def to_xml
@@ -29,7 +50,7 @@ module Saml
xml.LogoutRequest logout_request_options do
xml.Issuer issuer
signature.template(xml)
- xml.NameID name_id_options, user.name_id_for(self)
+ xml.NameID name_id_options, user.name_id_for(name_id_format)
end
end
end
lib/saml/kit/response.rb
@@ -233,7 +233,7 @@ module Saml
xml.Assertion(assertion_options) do
xml.Issuer issuer
xml.Subject do
- xml.NameID user.name_id_for(request), Format: request.name_id_format
+ xml.NameID user.name_id_for(request.name_id_format), Format: request.name_id_format
xml.SubjectConfirmation Method: Namespaces::BEARER do
xml.SubjectConfirmationData "", subject_confirmation_data_options
end
spec/saml/logout_request_spec.rb
@@ -1,6 +1,34 @@
require 'spec_helper'
RSpec.describe Saml::Kit::LogoutRequest do
+ subject { builder.build }
+ let(:builder) { described_class::Builder.new(user) }
+ let(:user) { double(:user, name_id_for: name_id) }
+ let(:name_id) { SecureRandom.uuid }
+
+ it 'parses the issuer' do
+ builder.issuer = FFaker::Internet.http_url
+ expect(subject.issuer).to eql(builder.issuer)
+ end
+
+ it 'parses the issue instant' do
+ travel_to 1.second.from_now
+ expect(subject.issue_instant).to eql(Time.now.utc.iso8601)
+ end
+
+ it 'parses the version' do
+ expect(subject.version).to eql("2.0")
+ end
+
+ it 'parses the destination' do
+ builder.destination = FFaker::Internet.http_url
+ expect(subject.destination).to eql(builder.destination)
+ end
+
+ it 'parses the name_id' do
+ expect(subject.name_id).to eql(name_id)
+ end
+
describe described_class::Builder do
subject { described_class.new(user) }
let(:user) { double(:user, name_id_for: name_id) }