Fix specs
This commit is contained in:
parent
0a6c3494b0
commit
ac6992ba68
3 changed files with 10 additions and 2 deletions
|
@ -787,6 +787,8 @@ describe Project, models: true do
|
||||||
describe '#container_registry_repository' do
|
describe '#container_registry_repository' do
|
||||||
let(:project) { create(:empty_project) }
|
let(:project) { create(:empty_project) }
|
||||||
|
|
||||||
|
before { stub_container_registry_config(enabled: true) }
|
||||||
|
|
||||||
subject { project.container_registry_repository }
|
subject { project.container_registry_repository }
|
||||||
|
|
||||||
it { is_expected.to_not be_nil }
|
it { is_expected.to_not be_nil }
|
||||||
|
|
|
@ -50,6 +50,11 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
shared_examples 'an unauthorized' do
|
||||||
|
it { is_expected.to include(http_status: 401) }
|
||||||
|
it { is_expected.to_not include(:token) }
|
||||||
|
end
|
||||||
|
|
||||||
shared_examples 'a forbidden' do
|
shared_examples 'a forbidden' do
|
||||||
it { is_expected.to include(http_status: 403) }
|
it { is_expected.to include(http_status: 403) }
|
||||||
it { is_expected.to_not include(:token) }
|
it { is_expected.to_not include(:token) }
|
||||||
|
@ -116,7 +121,7 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
|
||||||
{ offline_token: true }
|
{ offline_token: true }
|
||||||
end
|
end
|
||||||
|
|
||||||
it_behaves_like 'a forbidden'
|
it_behaves_like 'an unauthorized'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'allow to pull and push images' do
|
context 'allow to pull and push images' do
|
||||||
|
@ -179,7 +184,7 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
|
||||||
{ offline_token: true }
|
{ offline_token: true }
|
||||||
end
|
end
|
||||||
|
|
||||||
it_behaves_like 'a forbidden'
|
it_behaves_like 'an unauthorized'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for invalid scope' do
|
context 'for invalid scope' do
|
||||||
|
|
|
@ -27,6 +27,7 @@ module StubGitlabCalls
|
||||||
|
|
||||||
def stub_container_registry_config(registry_settings)
|
def stub_container_registry_config(registry_settings)
|
||||||
allow(Gitlab.config.registry).to receive_messages(registry_settings)
|
allow(Gitlab.config.registry).to receive_messages(registry_settings)
|
||||||
|
allow(Auth::ContainerRegistryAuthenticationService).to receive(:full_access_token).and_return('token')
|
||||||
end
|
end
|
||||||
|
|
||||||
def stub_container_registry_tags(*tags)
|
def stub_container_registry_tags(*tags)
|
||||||
|
|
Loading…
Reference in a new issue