Commit 68db87a

mo <mo@mokhan.ca>
2017-11-18 01:59:29
include the request id in the response.
1 parent 7943293
Changed files (2)
lib
saml
spec
lib/saml/kit/response.rb
@@ -196,7 +196,7 @@ module Saml
         end
 
         def build
-          Response.new(to_xml)
+          Response.new(to_xml, request_id: request.id)
         end
 
         private
spec/saml/response_spec.rb
@@ -208,4 +208,16 @@ RSpec.describe Saml::Kit::Response do
       expect(subject.errors[:audience]).to be_present
     end
   end
+
+  describe described_class::Builder do
+    subject { described_class.new(user, request) }
+    let(:user) { double(:user, name_id_for: SecureRandom.uuid, assertion_attributes_for: []) }
+    let(:request) { double(:request, id: SecureRandom.uuid, acs_url: FFaker::Internet.http_url, provider: nil, name_id_format: Saml::Kit::Namespaces::PERSISTENT, issuer: FFaker::Internet.http_url) }
+
+    describe "#build" do
+      it 'builds a response with the request_id' do
+        expect(subject.build.request_id).to eql(request.id)
+      end
+    end
+  end
 end