From 43a25d93ebdabea52f99b05e15b06250cd8f07d7 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 17 May 2023 16:05:49 +0000 Subject: Add latest changes from gitlab-org/gitlab@16-0-stable-ee --- spec/lib/object_storage/config_spec.rb | 9 ++- spec/lib/object_storage/direct_upload_spec.rb | 2 +- .../object_storage/pending_direct_upload_spec.rb | 70 ++++++++++++++++++++++ 3 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 spec/lib/object_storage/pending_direct_upload_spec.rb (limited to 'spec/lib/object_storage') diff --git a/spec/lib/object_storage/config_spec.rb b/spec/lib/object_storage/config_spec.rb index 2a81142ea44..412fcb9b6b8 100644 --- a/spec/lib/object_storage/config_spec.rb +++ b/spec/lib/object_storage/config_spec.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'spec_helper' require 'rspec-parameterized' require 'fog/core' -RSpec.describe ObjectStorage::Config do +RSpec.describe ObjectStorage::Config, feature_category: :shared do using RSpec::Parameterized::TableSyntax let(:region) { 'us-east-1' } @@ -130,6 +130,11 @@ RSpec.describe ObjectStorage::Config do it { expect(subject.provider).to eq('AWS') } it { expect(subject.aws?).to be true } it { expect(subject.google?).to be false } + it { expect(subject.credentials).to eq(credentials) } + + context 'with FIPS enabled', :fips_mode do + it { expect(subject.credentials).to eq(credentials.merge(disable_content_md5_validation: true)) } + end end context 'with Google credentials' do diff --git a/spec/lib/object_storage/direct_upload_spec.rb b/spec/lib/object_storage/direct_upload_spec.rb index 82eede96deb..4fcc0e3f306 100644 --- a/spec/lib/object_storage/direct_upload_spec.rb +++ b/spec/lib/object_storage/direct_upload_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe ObjectStorage::DirectUpload do +RSpec.describe ObjectStorage::DirectUpload, feature_category: :shared do let(:region) { 'us-east-1' } let(:path_style) { false } let(:use_iam_profile) { false } diff --git a/spec/lib/object_storage/pending_direct_upload_spec.rb b/spec/lib/object_storage/pending_direct_upload_spec.rb new file mode 100644 index 00000000000..af08b9c8188 --- /dev/null +++ b/spec/lib/object_storage/pending_direct_upload_spec.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ObjectStorage::PendingDirectUpload, :clean_gitlab_redis_shared_state, feature_category: :shared do + let(:location_identifier) { :artifacts } + let(:path) { 'some/path/123' } + + describe '.prepare' do + it 'creates a redis entry for the given location identifier and path' do + freeze_time do + described_class.prepare(location_identifier, path) + + ::Gitlab::Redis::SharedState.with do |redis| + key = described_class.key(location_identifier, path) + expect(redis.hget('pending_direct_uploads', key)).to eq(Time.current.utc.to_i.to_s) + end + end + end + end + + describe '.exists?' do + let(:path) { 'some/path/123' } + + subject { described_class.exists?(given_identifier, given_path) } + + before do + described_class.prepare(location_identifier, path) + end + + context 'when there is a matching redis entry for the given path under the location identifier' do + let(:given_identifier) { location_identifier } + let(:given_path) { path } + + it { is_expected.to eq(true) } + end + + context 'when there is a matching redis entry for the given path under a different location identifier' do + let(:given_identifier) { :uploads } + let(:given_path) { path } + + it { is_expected.to eq(false) } + end + + context 'when there is no matching redis entry for the given path under the location identifier' do + let(:given_identifier) { location_identifier } + let(:given_path) { 'wrong/path/123' } + + it { is_expected.to eq(false) } + end + end + + describe '.complete' do + it 'deletes the redis entry for the given path' do + described_class.prepare(location_identifier, path) + + expect(described_class.exists?(location_identifier, path)).to eq(true) + + described_class.complete(location_identifier, path) + + expect(described_class.exists?(location_identifier, path)).to eq(false) + end + end + + describe '.key' do + subject { described_class.key(location_identifier, path) } + + it { is_expected.to eq("#{location_identifier}:#{path}") } + end +end -- cgit v1.2.3