diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-12 10:17:34 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-12 10:17:34 +0000 |
commit | 3a6238c2e23454c462ccd229b1802583e657bfd0 (patch) | |
tree | 808c1151b9916516e41cea4869791cbf3dab345f /spec/lib/gitlab/url_blocker_spec.rb | |
parent | c301cf0ca5fbb998c22be5d8033e77be4bf0a451 (diff) | |
download | gitlab-ce-3a6238c2e23454c462ccd229b1802583e657bfd0.tar.gz |
Add latest changes from gitlab-org/gitlab@14-9-stable-ee
Diffstat (limited to 'spec/lib/gitlab/url_blocker_spec.rb')
-rw-r--r-- | spec/lib/gitlab/url_blocker_spec.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/lib/gitlab/url_blocker_spec.rb b/spec/lib/gitlab/url_blocker_spec.rb index 57b0297a0a0..8f505606e04 100644 --- a/spec/lib/gitlab/url_blocker_spec.rb +++ b/spec/lib/gitlab/url_blocker_spec.rb @@ -43,6 +43,7 @@ RSpec.describe Gitlab::UrlBlocker, :stub_invalid_dns_only do let(:import_url) { "#{host}/external-diffs/merge_request_diffs/mr-1/diff-1" } let(:enabled_object_storage_setting) do { + 'enabled' => true, 'object_store' => { 'enabled' => true, @@ -81,6 +82,49 @@ RSpec.describe Gitlab::UrlBlocker, :stub_invalid_dns_only do let(:expected_hostname) { nil } end end + + context 'when LFS object storage is enabled' do + let(:lfs_config) do + { + 'enabled' => lfs_enabled, + # This nesting of Settingslogic is necessary to trigger the bug + 'object_store' => Settingslogic.new({ 'enabled' => true }) + } + end + + let(:config) do + { + 'gitlab' => Gitlab.config.gitlab, + 'repositories' => { 'storages' => { 'default' => 'test' } }, + 'lfs' => Settingslogic.new(lfs_config) + } + end + + let(:host) { 'http://127.0.0.1:9000' } + let(:settings) { Settingslogic.new(config) } + + before do + allow(Gitlab).to receive(:config).and_return(settings) + # Triggers Settingslogic bug: https://gitlab.com/gitlab-org/gitlab/-/issues/286873 + settings.repositories.storages.default + end + + context 'when LFS is disabled' do + let(:lfs_enabled) { false } + + it 'raises an error' do + expect { subject }.to raise_error(described_class::BlockedUrlError) + end + end + + context 'when LFS is enabled with no connection endpoint' do + let(:lfs_enabled) { true } + + it 'raises an error' do + expect { subject }.to raise_error(described_class::BlockedUrlError) + end + end + end end context 'when allow_object_storage is false' do |