2019-08-05 16:00:50 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe API::GroupContainerRepositories do
|
2019-11-04 10:07:36 -05:00
|
|
|
let_it_be(:group) { create(:group, :private) }
|
|
|
|
let_it_be(:project) { create(:project, :private, group: group) }
|
|
|
|
let_it_be(:reporter) { create(:user) }
|
|
|
|
let_it_be(:guest) { create(:user) }
|
2019-08-05 16:00:50 -04:00
|
|
|
|
|
|
|
let(:root_repository) { create(:container_repository, :root, project: project) }
|
|
|
|
let(:test_repository) { create(:container_repository, project: project) }
|
|
|
|
|
|
|
|
let(:users) do
|
|
|
|
{
|
|
|
|
anonymous: nil,
|
|
|
|
guest: guest,
|
|
|
|
reporter: reporter
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:api_user) { reporter }
|
|
|
|
|
|
|
|
before do
|
|
|
|
group.add_reporter(reporter)
|
|
|
|
group.add_guest(guest)
|
|
|
|
|
|
|
|
stub_container_registry_config(enabled: true)
|
|
|
|
|
|
|
|
root_repository
|
|
|
|
test_repository
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET /groups/:id/registry/repositories' do
|
|
|
|
let(:url) { "/groups/#{group.id}/registry/repositories" }
|
|
|
|
|
|
|
|
subject { get api(url, api_user) }
|
|
|
|
|
|
|
|
it_behaves_like 'rejected container repository access', :guest, :forbidden
|
|
|
|
it_behaves_like 'rejected container repository access', :anonymous, :not_found
|
|
|
|
|
|
|
|
it_behaves_like 'returns repositories for allowed users', :reporter, 'group' do
|
|
|
|
let(:object) { group }
|
|
|
|
end
|
|
|
|
|
2020-09-30 08:09:53 -04:00
|
|
|
it_behaves_like 'a package tracking event', described_class.name, 'list_repositories'
|
2019-11-12 04:06:14 -05:00
|
|
|
|
2019-08-05 16:00:50 -04:00
|
|
|
context 'with invalid group id' do
|
2020-04-01 11:07:45 -04:00
|
|
|
let(:url) { "/groups/#{non_existing_record_id}/registry/repositories" }
|
2019-08-05 16:00:50 -04:00
|
|
|
|
|
|
|
it 'returns not found' do
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(response).to have_gitlab_http_status(:not_found)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|