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>2021-10-20 11:43:02 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-10-20 11:43:02 +0300
commitd9ab72d6080f594d0b3cae15f14b3ef2c6c638cb (patch)
tree2341ef426af70ad1e289c38036737e04b0aa5007 /spec/lib/container_registry
parentd6e514dd13db8947884cd58fe2a9c2a063400a9b (diff)
Add latest changes from gitlab-org/gitlab@14-4-stable-eev14.4.0-rc42
Diffstat (limited to 'spec/lib/container_registry')
-rw-r--r--spec/lib/container_registry/client_spec.rb94
-rw-r--r--spec/lib/container_registry/tag_spec.rb20
2 files changed, 74 insertions, 40 deletions
diff --git a/spec/lib/container_registry/client_spec.rb b/spec/lib/container_registry/client_spec.rb
index 9d6f4db537d..47a8fcf5dd0 100644
--- a/spec/lib/container_registry/client_spec.rb
+++ b/spec/lib/container_registry/client_spec.rb
@@ -111,6 +111,49 @@ RSpec.describe ContainerRegistry::Client do
it_behaves_like 'handling timeouts'
end
+ shared_examples 'handling repository info' do
+ context 'when the check is successful' do
+ context 'when using the GitLab container registry' do
+ before do
+ stub_registry_info(headers: {
+ 'GitLab-Container-Registry-Version' => '2.9.1-gitlab',
+ 'GitLab-Container-Registry-Features' => 'a,b,c'
+ })
+ end
+
+ it 'identifies the vendor as "gitlab"' do
+ expect(subject).to include(vendor: 'gitlab')
+ end
+
+ it 'identifies version and features' do
+ expect(subject).to include(version: '2.9.1-gitlab', features: %w[a b c])
+ end
+ end
+
+ context 'when using a third-party container registry' do
+ before do
+ stub_registry_info
+ end
+
+ it 'identifies the vendor as "other"' do
+ expect(subject).to include(vendor: 'other')
+ end
+
+ it 'does not identify version or features' do
+ expect(subject).to include(version: nil, features: [])
+ end
+ end
+ end
+
+ context 'when the check is not successful' do
+ it 'does not identify vendor, version or features' do
+ stub_registry_info(status: 500)
+
+ expect(subject).to eq({})
+ end
+ end
+ end
+
describe '#repository_manifest' do
subject { client.repository_manifest('group/test', 'mytag') }
@@ -316,46 +359,7 @@ RSpec.describe ContainerRegistry::Client do
describe '#registry_info' do
subject { client.registry_info }
- context 'when the check is successful' do
- context 'when using the GitLab container registry' do
- before do
- stub_registry_info(headers: {
- 'GitLab-Container-Registry-Version' => '2.9.1-gitlab',
- 'GitLab-Container-Registry-Features' => 'a,b,c'
- })
- end
-
- it 'identifies the vendor as "gitlab"' do
- expect(subject).to include(vendor: 'gitlab')
- end
-
- it 'identifies version and features' do
- expect(subject).to include(version: '2.9.1-gitlab', features: %w[a b c])
- end
- end
-
- context 'when using a third-party container registry' do
- before do
- stub_registry_info
- end
-
- it 'identifies the vendor as "other"' do
- expect(subject).to include(vendor: 'other')
- end
-
- it 'does not identify version or features' do
- expect(subject).to include(version: nil, features: [])
- end
- end
- end
-
- context 'when the check is not successful' do
- it 'does not identify vendor, version or features' do
- stub_registry_info(status: 500)
-
- expect(subject).to eq({})
- end
- end
+ it_behaves_like 'handling repository info'
end
describe '.supports_tag_delete?' do
@@ -418,6 +422,16 @@ RSpec.describe ContainerRegistry::Client do
end
end
+ describe '.registry_info' do
+ subject { described_class.registry_info }
+
+ before do
+ stub_container_registry_config(enabled: true, api_url: registry_api_url, key: 'spec/fixtures/x509_certificate_pk.key')
+ end
+
+ it_behaves_like 'handling repository info'
+ end
+
def stub_upload(path, content, digest, status = 200)
stub_request(:post, "#{registry_api_url}/v2/#{path}/blobs/uploads/")
.with(headers: headers_with_accept_types)
diff --git a/spec/lib/container_registry/tag_spec.rb b/spec/lib/container_registry/tag_spec.rb
index d696b61ac9d..d6e6b254dd9 100644
--- a/spec/lib/container_registry/tag_spec.rb
+++ b/spec/lib/container_registry/tag_spec.rb
@@ -60,6 +60,20 @@ RSpec.describe ContainerRegistry::Tag do
end
context 'manifest processing' do
+ shared_examples 'using the value manually set on created_at' do
+ let(:value) { 5.seconds.ago }
+
+ before do
+ tag.created_at = value
+ end
+
+ it 'does not use the config' do
+ expect(tag).not_to receive(:config)
+
+ expect(subject).to eq(value)
+ end
+ end
+
context 'schema v1' do
before do
stub_request(:get, 'http://registry.gitlab/v2/group/test/manifests/tag')
@@ -93,6 +107,8 @@ RSpec.describe ContainerRegistry::Tag do
subject { tag.created_at }
it { is_expected.to be_nil }
+
+ it_behaves_like 'using the value manually set on created_at'
end
end
end
@@ -117,6 +133,8 @@ RSpec.describe ContainerRegistry::Tag do
subject { tag.created_at }
it { is_expected.to be_nil }
+
+ it_behaves_like 'using the value manually set on created_at'
end
end
@@ -154,6 +172,8 @@ RSpec.describe ContainerRegistry::Tag do
subject { tag.created_at }
it { is_expected.not_to be_nil }
+
+ it_behaves_like 'using the value manually set on created_at'
end
end