Skip to content

Commit 4871168

Browse files
committed
add test for X-Forwarded-Host header
1 parent e98c961 commit 4871168

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

spec/swagger_v2/x_forwarded_host.rb

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require 'spec_helper'
2+
3+
describe 'respect X-Forwarded-Host over Host header' do
4+
include_context "the api entities"
5+
6+
before :all do
7+
module TheApi
8+
class EmptyApi < Grape::API
9+
format :json
10+
11+
add_swagger_documentation
12+
end
13+
end
14+
end
15+
16+
def app
17+
TheApi::EmptyApi
18+
end
19+
20+
subject do
21+
header 'Host', 'dummy.example.com'
22+
header 'X-Forwarded-Host', 'real.example.com'
23+
get '/swagger_doc'
24+
JSON.parse(last_response.body)
25+
end
26+
27+
specify do
28+
expect(subject['host']).to eq 'real.example.com'
29+
end
30+
end

0 commit comments

Comments
 (0)