Commit 4343d46

mo <mo.khan@gmail.com>
2018-02-26 01:05:54
xpath to parse document ID
1 parent 753276b
Changed files (2)
lib
saml
spec
lib/saml/kit/document.rb
@@ -29,7 +29,7 @@ module Saml
 
       # Returns the ID for the SAML document.
       def id
-        root.fetch('ID', nil)
+        at_xpath('./*/@ID').try(:value)
       end
 
       # Returns the Issuer for the SAML document.
spec/saml/kit/document_spec.rb
@@ -1,4 +1,16 @@
 RSpec.describe Saml::Kit::Document do
+  subject do
+    Saml::Kit::AuthenticationRequest.build do |x|
+      x.id = id
+      x.issuer = issuer
+    end
+  end
+  let(:id) { Xml::Kit::Id.generate }
+  let(:issuer) { FFaker::Internet.uri("https") }
+
+  specify { expect(subject.id).to eql(id) }
+  specify { expect(subject.issuer).to eql(issuer) }
+
   describe '.to_saml_document' do
     subject { described_class }