Skip to content

Commit

Permalink
add test for X-Forwarded-Host header
Browse files Browse the repository at this point in the history
  • Loading branch information
edvakf committed Apr 18, 2016
1 parent e98c961 commit 4871168
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions spec/swagger_v2/x_forwarded_host.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4871168

Please sign in to comment.