diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-19 14:01:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-19 14:01:45 +0300 |
commit | 9297025d0b7ddf095eb618dfaaab2ff8f2018d8b (patch) | |
tree | 865198c01d1824a9b098127baa3ab980c9cd2c06 /spec/lib/gitlab/workhorse_spec.rb | |
parent | 6372471f43ee03c05a7c1f8b0c6ac6b8a7431dbe (diff) |
Add latest changes from gitlab-org/gitlab@16-7-stable-eev16.7.0-rc42
Diffstat (limited to 'spec/lib/gitlab/workhorse_spec.rb')
-rw-r--r-- | spec/lib/gitlab/workhorse_spec.rb | 57 |
1 files changed, 44 insertions, 13 deletions
diff --git a/spec/lib/gitlab/workhorse_spec.rb b/spec/lib/gitlab/workhorse_spec.rb index d77763f89be..0d5ec5690a9 100644 --- a/spec/lib/gitlab/workhorse_spec.rb +++ b/spec/lib/gitlab/workhorse_spec.rb @@ -480,6 +480,14 @@ RSpec.describe Gitlab::Workhorse, feature_category: :shared do describe '.send_url' do let(:url) { 'http://example.com' } + let(:expected_params) do + { + 'URL' => url, + 'AllowRedirects' => false, + 'Body' => '', + 'Method' => 'GET' + } + end it 'sets the header correctly' do key, command, params = decode_workhorse_header( @@ -488,12 +496,7 @@ RSpec.describe Gitlab::Workhorse, feature_category: :shared do expect(key).to eq("Gitlab-Workhorse-Send-Data") expect(command).to eq("send-url") - expect(params).to eq({ - 'URL' => url, - 'AllowRedirects' => false, - 'Body' => '', - 'Method' => 'GET' - }.deep_stringify_keys) + expect(params).to eq(expected_params) end context 'when body, headers and method are specified' do @@ -501,6 +504,14 @@ RSpec.describe Gitlab::Workhorse, feature_category: :shared do let(:headers) { { Authorization: ['Bearer token'] } } let(:method) { 'POST' } + let(:expected_params) do + super().merge( + 'Body' => body, + 'Header' => headers, + 'Method' => method + ).deep_stringify_keys + end + it 'sets the header correctly' do key, command, params = decode_workhorse_header( described_class.send_url(url, body: body, headers: headers, method: method) @@ -508,13 +519,33 @@ RSpec.describe Gitlab::Workhorse, feature_category: :shared do expect(key).to eq("Gitlab-Workhorse-Send-Data") expect(command).to eq("send-url") - expect(params).to eq({ - 'URL' => url, - 'AllowRedirects' => false, - 'Body' => body, - 'Header' => headers, - 'Method' => method - }.deep_stringify_keys) + expect(params).to eq(expected_params) + end + end + + context 'when timeouts are set' do + let(:timeouts) { { open: '5', read: '5' } } + let(:expected_params) { super().merge('DialTimeout' => '5s', 'ResponseHeaderTimeout' => '5s') } + + it 'sets the header correctly' do + key, command, params = decode_workhorse_header(described_class.send_url(url, timeouts: timeouts)) + + expect(key).to eq("Gitlab-Workhorse-Send-Data") + expect(command).to eq("send-url") + expect(params).to eq(expected_params) + end + end + + context 'when an response statuses are set' do + let(:response_statuses) { { error: :service_unavailable, timeout: :bad_request } } + let(:expected_params) { super().merge('ErrorResponseStatus' => 503, 'TimeoutResponseStatus' => 400) } + + it 'sets the header correctly' do + key, command, params = decode_workhorse_header(described_class.send_url(url, response_statuses: response_statuses)) + + expect(key).to eq("Gitlab-Workhorse-Send-Data") + expect(command).to eq("send-url") + expect(params).to eq(expected_params) end end end |