debian-mirror-gitlab/spec/lib/container_registry/registry_spec.rb

46 lines
1.1 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2016-06-02 11:05:42 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe ContainerRegistry::Registry do
2016-06-02 11:05:42 +05:30
let(:path) { nil }
2022-05-07 20:08:51 +05:30
let(:registry_api_url) { 'http://example.com' }
let(:registry) { described_class.new(registry_api_url, path: path) }
2016-06-02 11:05:42 +05:30
subject { registry }
2022-05-07 20:08:51 +05:30
before do
stub_container_registry_config(enabled: true, api_url: registry_api_url, key: 'spec/fixtures/x509_certificate_pk.key')
end
2016-06-02 11:05:42 +05:30
it { is_expected.to respond_to(:client) }
it { is_expected.to respond_to(:uri) }
it { is_expected.to respond_to(:path) }
2017-08-17 22:00:37 +05:30
it { expect(subject).not_to be_nil }
2016-06-02 11:05:42 +05:30
2020-03-13 15:44:24 +05:30
describe '#path' do
2016-06-02 11:05:42 +05:30
subject { registry.path }
context 'path from URL' do
it { is_expected.to eq('example.com') }
end
context 'custom path' do
let(:path) { 'registry.example.com' }
it { is_expected.to eq(path) }
end
end
2022-04-04 11:22:00 +05:30
describe '#gitlab_api_client' do
subject { registry.gitlab_api_client }
it 'returns a GitLabApiClient with an import token' do
expect(Auth::ContainerRegistryAuthenticationService).to receive(:import_access_token)
expect(subject).to be_instance_of(ContainerRegistry::GitlabApiClient)
end
end
2016-06-02 11:05:42 +05:30
end