Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/checks/global_file_size_check_spec.rb')
-rw-r--r--spec/lib/gitlab/checks/global_file_size_check_spec.rb34
1 files changed, 32 insertions, 2 deletions
diff --git a/spec/lib/gitlab/checks/global_file_size_check_spec.rb b/spec/lib/gitlab/checks/global_file_size_check_spec.rb
index 9ea0c73b1c7..a2b3ee0f761 100644
--- a/spec/lib/gitlab/checks/global_file_size_check_spec.rb
+++ b/spec/lib/gitlab/checks/global_file_size_check_spec.rb
@@ -14,13 +14,13 @@ RSpec.describe Gitlab::Checks::GlobalFileSizeCheck, feature_category: :source_co
it 'does not log' do
expect(subject).not_to receive(:log_timed)
expect(Gitlab::AppJsonLogger).not_to receive(:info)
- expect(Gitlab::Checks::FileSizeCheck::AllowExistingOversizedBlobs).not_to receive(:new)
+ expect(Gitlab::Checks::FileSizeCheck::HookEnvironmentAwareAnyOversizedBlobs).not_to receive(:new)
subject.validate!
end
end
it 'checks for file sizes' do
- expect_next_instance_of(Gitlab::Checks::FileSizeCheck::AllowExistingOversizedBlobs,
+ expect_next_instance_of(Gitlab::Checks::FileSizeCheck::HookEnvironmentAwareAnyOversizedBlobs,
project: project,
changes: changes,
file_size_limit_megabytes: 100
@@ -32,5 +32,35 @@ RSpec.describe Gitlab::Checks::GlobalFileSizeCheck, feature_category: :source_co
expect(Gitlab::AppJsonLogger).to receive(:info).with('Checking for blobs over the file size limit')
subject.validate!
end
+
+ context 'when there are oversized blobs' do
+ let(:blob_double) { instance_double(Gitlab::Git::Blob, size: 10) }
+
+ before do
+ allow_next_instance_of(Gitlab::Checks::FileSizeCheck::HookEnvironmentAwareAnyOversizedBlobs,
+ project: project,
+ changes: changes,
+ file_size_limit_megabytes: 100
+ ) do |check|
+ allow(check).to receive(:find).and_return([blob_double])
+ end
+ end
+
+ it 'logs a message with blob size and raises an exception' do
+ expect(Gitlab::AppJsonLogger).to receive(:info).with('Checking for blobs over the file size limit')
+ expect(Gitlab::AppJsonLogger).to receive(:info).with(message: 'Found blob over global limit', blob_sizes: [10])
+ expect { subject.validate! }.to raise_exception(Gitlab::GitAccess::ForbiddenError)
+ end
+
+ context 'when the enforce_global_file_size_limit feature flag is disabled' do
+ before do
+ stub_feature_flags(enforce_global_file_size_limit: false)
+ end
+
+ it 'does not raise an exception' do
+ expect { subject.validate! }.not_to raise_error
+ end
+ end
+ end
end
end