Skip to content
Snippets Groups Projects
Commit 393d5a55 authored by Etienne Baqué's avatar Etienne Baqué
Browse files

Updated condition to raise DiskAccessDenied

Updated pages_path in Project class as well.
Updated tests accordingly.
parent 2c6fee12
No related branches found
No related tags found
No related merge requests found
---
title: Deny access to disk storage if pages local store is disabled
merge_request: 55967
author:
type: added
Loading
Loading
@@ -6,9 +6,7 @@ class Settings < ::SimpleDelegator
DiskAccessDenied = Class.new(StandardError)
 
def path
if ::Gitlab::Runtime.web_server? && !::Gitlab::Runtime.test_suite?
raise DiskAccessDenied
end
::Gitlab::ErrorTracking.track_exception(DiskAccessDenied.new) if disk_access_denied?
 
super
end
Loading
Loading
@@ -16,6 +14,14 @@ def path
def local_store
@local_store ||= ::Gitlab::Pages::Stores::LocalStore.new(super)
end
private
def disk_access_denied?
return true unless ::Settings.pages.local_store&.enabled
::Gitlab::Runtime.web_server? && !::Gitlab::Runtime.test_suite?
end
end
end
end
Loading
Loading
@@ -16,8 +16,34 @@
allow(::Gitlab::Runtime).to receive(:web_server?).and_return(true)
end
 
it 'raises a DiskAccessDenied exception' do
expect { subject }.to raise_error(described_class::DiskAccessDenied)
it 'logs a DiskAccessDenied error' do
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
instance_of(described_class::DiskAccessDenied)
)
subject
end
end
context 'when local_store settings does not exist yet' do
before do
allow(Settings.pages).to receive(:local_store).and_return(nil)
end
it { is_expected.to eq('the path') }
end
context 'when local store exists but legacy storage is disabled' do
before do
allow(Settings.pages.local_store).to receive(:enabled).and_return(false)
end
it 'logs a DiskAccessDenied error' do
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
instance_of(described_class::DiskAccessDenied)
)
subject
end
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment