Commit a9463f1

mo <mo.khan@gmail.com>
2018-02-26 02:53:19
parse nameid using xpath.
1 parent 9d41e9d
Changed files (2)
lib/saml/kit/logout_request.rb
@@ -36,7 +36,11 @@ module Saml
 
       # Returns the NameID value.
       def name_id
-        to_h[name]['NameID']
+        at_xpath('./*/saml:NameID').try(:text)
+      end
+
+      def name_id_format
+        at_xpath('./*/saml:NameID/@Format').try(:value)
       end
 
       # Generates a Serialized LogoutResponse using the encoding rules for the specified binding.
spec/saml/kit/logout_request_spec.rb
@@ -25,9 +25,7 @@ RSpec.describe Saml::Kit::LogoutRequest do
     expect(subject.issue_instant).to eql(Time.now.utc)
   end
 
-  it 'parses the version' do
-    expect(subject.version).to eql('2.0')
-  end
+  specify { expect(subject.version).to eql('2.0') }
 
   it 'parses the destination' do
     destination = FFaker::Internet.uri('https')
@@ -37,9 +35,8 @@ RSpec.describe Saml::Kit::LogoutRequest do
     expect(subject.destination).to eql(destination)
   end
 
-  it 'parses the name_id' do
-    expect(subject.name_id).to eql(name_id)
-  end
+  specify { expect(subject.name_id).to eql(name_id) }
+  specify { expect(subject.name_id_format).to eql(Saml::Kit::Namespaces::PERSISTENT) }
 
   describe '#valid?' do
     let(:metadata) do