Commit f7caca9b authored by Robert Speicher's avatar Robert Speicher

Merge branch 'make-pages-disk-access-fail-in-web-server' into 'master'

Make Pages disk access fail in web server

Closes #239350

See merge request gitlab-org/gitlab!41751
parents 48f76e10 a5a382a9
......@@ -7,11 +7,7 @@ module Gitlab
def path
if ::Gitlab::Runtime.web_server? && ENV['GITLAB_PAGES_DENY_DISK_ACCESS'] == '1'
begin
raise DiskAccessDenied
rescue DiskAccessDenied => ex
::Gitlab::ErrorTracking.track_exception(ex)
end
raise DiskAccessDenied
end
super
......
......@@ -10,12 +10,6 @@ RSpec.describe Gitlab::Pages::Settings do
it { is_expected.to eq('the path') }
it 'does not track calls' do
expect(::Gitlab::ErrorTracking).not_to receive(:track_exception)
subject
end
context 'when running under a web server' do
before do
allow(::Gitlab::Runtime).to receive(:web_server?).and_return(true)
......@@ -23,24 +17,13 @@ RSpec.describe Gitlab::Pages::Settings do
it { is_expected.to eq('the path') }
it 'does not track calls' do
expect(::Gitlab::ErrorTracking).not_to receive(:track_exception)
subject
end
context 'with the env var' do
before do
stub_env('GITLAB_PAGES_DENY_DISK_ACCESS', '1')
end
it { is_expected.to eq('the path') }
it 'tracks a DiskAccessDenied exception' do
expect(::Gitlab::ErrorTracking).to receive(:track_exception)
.with(instance_of(described_class::DiskAccessDenied)).and_call_original
subject
it 'raises a DiskAccessDenied exception' do
expect { subject }.to raise_error(described_class::DiskAccessDenied)
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment