Commit 13e735dd authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'secure-files-limit' into 'master'

Adding Secure Files upload limit

See merge request gitlab-org/gitlab!82858
parents 003eaa49 3710372c
...@@ -3,10 +3,14 @@ ...@@ -3,10 +3,14 @@
module Ci module Ci
class SecureFile < Ci::ApplicationRecord class SecureFile < Ci::ApplicationRecord
include FileStoreMounter include FileStoreMounter
include Limitable
FILE_SIZE_LIMIT = 5.megabytes.freeze FILE_SIZE_LIMIT = 5.megabytes.freeze
CHECKSUM_ALGORITHM = 'sha256' CHECKSUM_ALGORITHM = 'sha256'
self.limit_scope = :project
self.limit_name = 'project_ci_secure_files'
belongs_to :project, optional: false belongs_to :project, optional: false
validates :file, presence: true, file_size: { maximum: FILE_SIZE_LIMIT } validates :file, presence: true, file_size: { maximum: FILE_SIZE_LIMIT }
......
# frozen_string_literal: true
class AddProjectCiSecureFilesToPlanLimits < Gitlab::Database::Migration[1.0]
def change
add_column(:plan_limits, :project_ci_secure_files, :integer, default: 100, null: false)
end
end
2dad53754682d9d4e8338978336807255503746b82795afb812b3b65b7335ca8
\ No newline at end of file
...@@ -18612,7 +18612,8 @@ CREATE TABLE plan_limits ( ...@@ -18612,7 +18612,8 @@ CREATE TABLE plan_limits (
external_audit_event_destinations integer DEFAULT 5 NOT NULL, external_audit_event_destinations integer DEFAULT 5 NOT NULL,
dotenv_variables integer DEFAULT 20 NOT NULL, dotenv_variables integer DEFAULT 20 NOT NULL,
dotenv_size integer DEFAULT 5120 NOT NULL, dotenv_size integer DEFAULT 5120 NOT NULL,
pipeline_triggers integer DEFAULT 25000 NOT NULL pipeline_triggers integer DEFAULT 25000 NOT NULL,
project_ci_secure_files integer DEFAULT 100 NOT NULL
); );
CREATE SEQUENCE plan_limits_id_seq CREATE SEQUENCE plan_limits_id_seq
...@@ -17,6 +17,10 @@ RSpec.describe Ci::SecureFile do ...@@ -17,6 +17,10 @@ RSpec.describe Ci::SecureFile do
it_behaves_like 'having unique enum values' it_behaves_like 'having unique enum values'
it_behaves_like 'includes Limitable concern' do
subject { build(:ci_secure_file, project: create(:project)) }
end
describe 'validations' do describe 'validations' do
it { is_expected.to validate_presence_of(:checksum) } it { is_expected.to validate_presence_of(:checksum) }
it { is_expected.to validate_presence_of(:file_store) } it { is_expected.to validate_presence_of(:file_store) }
......
...@@ -23,7 +23,7 @@ RSpec.shared_examples 'includes Limitable concern' do ...@@ -23,7 +23,7 @@ RSpec.shared_examples 'includes Limitable concern' do
context 'with an existing model' do context 'with an existing model' do
before do before do
subject.dup.save! subject.clone.save!
end end
it 'cannot create new models exceeding the plan limits' do it 'cannot create new models exceeding the plan limits' do
......
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