From 487116830c9de03031275abfda2c79f1adf603fe Mon Sep 17 00:00:00 2001 From: Atsushi Takayama Date: Tue, 19 Apr 2016 00:21:21 +0900 Subject: [PATCH] add test for X-Forwarded-Host header --- spec/swagger_v2/x_forwarded_host.rb | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 spec/swagger_v2/x_forwarded_host.rb diff --git a/spec/swagger_v2/x_forwarded_host.rb b/spec/swagger_v2/x_forwarded_host.rb new file mode 100644 index 00000000..ebdd3f48 --- /dev/null +++ b/spec/swagger_v2/x_forwarded_host.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +describe 'respect X-Forwarded-Host over Host header' do + include_context "the api entities" + + before :all do + module TheApi + class EmptyApi < Grape::API + format :json + + add_swagger_documentation + end + end + end + + def app + TheApi::EmptyApi + end + + subject do + header 'Host', 'dummy.example.com' + header 'X-Forwarded-Host', 'real.example.com' + get '/swagger_doc' + JSON.parse(last_response.body) + end + + specify do + expect(subject['host']).to eq 'real.example.com' + end +end