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>2020-06-02 21:08:32 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-02 21:08:32 +0300
commitf3e7bc80608c100227030030a6a601897f8e4ff9 (patch)
tree65afc2ae0ee2ccf7cf8d4efbf44077f816cade09 /spec/tasks/gitlab
parenteea1fbf9f980fed108601412b63e627d3eebd46d (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/tasks/gitlab')
-rw-r--r--spec/tasks/gitlab/container_registry_rake_spec.rb27
1 files changed, 26 insertions, 1 deletions
diff --git a/spec/tasks/gitlab/container_registry_rake_spec.rb b/spec/tasks/gitlab/container_registry_rake_spec.rb
index 216f914c5d0..41fc348aa24 100644
--- a/spec/tasks/gitlab/container_registry_rake_spec.rb
+++ b/spec/tasks/gitlab/container_registry_rake_spec.rb
@@ -4,6 +4,7 @@ require 'rake_helper'
describe 'gitlab:container_registry namespace rake tasks' do
let_it_be(:application_settings) { Gitlab::CurrentSettings }
+ let_it_be(:api_url) { 'http://registry.gitlab' }
before :all do
Rake.application.rake_require 'tasks/gitlab/container_registry'
@@ -11,7 +12,8 @@ describe 'gitlab:container_registry namespace rake tasks' do
describe 'configure' do
before do
- stub_container_registry_config(enabled: true, api_url: 'http://registry.gitlab')
+ stub_access_token
+ stub_container_registry_config(enabled: true, api_url: api_url)
end
shared_examples 'invalid config' do
@@ -37,6 +39,24 @@ describe 'gitlab:container_registry namespace rake tasks' do
it_behaves_like 'invalid config'
end
+ context 'when creating a registry client instance' do
+ let(:token) { 'foo' }
+ let(:client) { ContainerRegistry::Client.new(api_url, token: token) }
+
+ before do
+ stub_registry_info({})
+ end
+
+ it 'uses a token with no access permissions' do
+ expect(Auth::ContainerRegistryAuthenticationService)
+ .to receive(:access_token).with([], []).and_return(token)
+ expect(ContainerRegistry::Client)
+ .to receive(:new).with(api_url, token: token).and_return(client)
+
+ run_rake_task('gitlab:container_registry:configure')
+ end
+ end
+
context 'when unabled to detect the container registry type' do
it 'fails and raises an error message' do
stub_registry_info({})
@@ -79,6 +99,11 @@ describe 'gitlab:container_registry namespace rake tasks' do
end
end
+ def stub_access_token
+ allow(Auth::ContainerRegistryAuthenticationService)
+ .to receive(:access_token).with([], []).and_return('foo')
+ end
+
def stub_registry_info(output)
allow_next_instance_of(ContainerRegistry::Client) do |client|
allow(client).to receive(:registry_info).and_return(output)