diff options
| author | Douwe Maan <douwe@gitlab.com> | 2017-01-03 10:55:45 +0000 |
|---|---|---|
| committer | Douwe Maan <douwe@gitlab.com> | 2017-01-03 10:55:45 +0000 |
| commit | f61bdfe39c6b0618144f369d5cf4df1099be9948 (patch) | |
| tree | 67f2a2dd350750f246a368d36b11bc8107c9c8a2 /spec | |
| parent | a3712cc18de8283b25c3a8a034ecc8c9b7feca48 (diff) | |
| parent | 3695d162bd68827dbd495cca77db366f81b5893b (diff) | |
| download | gitlab-shell-f61bdfe39c6b0618144f369d5cf4df1099be9948.tar.gz | |
Merge branch 'unix-socket-host' into 'master'
Set a 'Host' header on unix sockets
Closes #72
See merge request !117
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/gitlab_net_spec.rb | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/spec/gitlab_net_spec.rb b/spec/gitlab_net_spec.rb index 3d38231..e3ab16c 100644 --- a/spec/gitlab_net_spec.rb +++ b/spec/gitlab_net_spec.rb @@ -248,24 +248,37 @@ describe GitlabNet, vcr: true do end describe :http_request_for do - let(:get) do - double(Net::HTTP::Get).tap do |get| - Net::HTTP::Get.stub(:new) { get } + context 'with stub' do + let(:get) do + double(Net::HTTP::Get).tap do |get| + Net::HTTP::Get.stub(:new) { get } + end + end + let(:user) { 'user' } + let(:password) { 'password' } + let(:url) { URI 'http://localhost/' } + subject { gitlab_net.send :http_request_for, :get, url } + + before do + gitlab_net.send(:config).http_settings.stub(:[]).with('user') { user } + gitlab_net.send(:config).http_settings.stub(:[]).with('password') { password } + get.should_receive(:basic_auth).with(user, password).once + get.should_receive(:set_form_data).with(hash_including(secret_token: 'a123')).once end + + it { should_not be_nil } end - let(:user) { 'user' } - let(:password) { 'password' } - let(:url) { URI 'http://localhost/' } - subject { gitlab_net.send :http_request_for, :get, url } - before do - gitlab_net.send(:config).http_settings.stub(:[]).with('user') { user } - gitlab_net.send(:config).http_settings.stub(:[]).with('password') { password } - get.should_receive(:basic_auth).with(user, password).once - get.should_receive(:set_form_data).with(hash_including(secret_token: 'a123')).once - end + context 'Unix socket' do + it 'sets the Host header to "localhost"' do + gitlab_net = described_class.new + gitlab_net.should_receive(:secret_token).and_return('a123') - it { should_not be_nil } + request = gitlab_net.send(:http_request_for, :get, URI('http+unix://%2Ffoo')) + + expect(request['Host']).to eq('localhost') + end + end end describe :cert_store do |
