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:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-17 19:05:49 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-17 19:05:49 +0300
commit43a25d93ebdabea52f99b05e15b06250cd8f07d7 (patch)
treedceebdc68925362117480a5d672bcff122fb625b /spec/lib/object_storage
parent20c84b99005abd1c82101dfeff264ac50d2df211 (diff)
Add latest changes from gitlab-org/gitlab@16-0-stable-eev16.0.0-rc42
Diffstat (limited to 'spec/lib/object_storage')
-rw-r--r--spec/lib/object_storage/config_spec.rb9
-rw-r--r--spec/lib/object_storage/direct_upload_spec.rb2
-rw-r--r--spec/lib/object_storage/pending_direct_upload_spec.rb70
3 files changed, 78 insertions, 3 deletions
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