debian-mirror-gitlab/spec/requests/api/group_container_repositories_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

72 lines
2.1 KiB
Ruby
Raw Permalink Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe API::GroupContainerRepositories, feature_category: :container_registry do
2019-12-26 22:10:19 +05:30
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-10-12 21:52:04 +05:30
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 }
2021-11-18 22:05:49 +05:30
let(:params) { {} }
2019-10-12 21:52:04 +05:30
before do
group.add_reporter(reporter)
group.add_guest(guest)
stub_container_registry_config(enabled: true)
2021-11-18 22:05:49 +05:30
stub_container_registry_info
2019-10-12 21:52:04 +05:30
root_repository
test_repository
end
describe 'GET /groups/:id/registry/repositories' do
let(:url) { "/groups/#{group.id}/registry/repositories" }
2023-03-04 22:38:38 +05:30
let(:snowplow_gitlab_standard_context) do
{ user: api_user, namespace: group, property: 'i_package_container_user' }
end
2019-10-12 21:52:04 +05:30
2022-07-16 23:28:13 +05:30
subject { get api(url, api_user) }
2019-10-12 21:52:04 +05:30
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
2021-01-03 14:25:43 +05:30
it_behaves_like 'a package tracking event', described_class.name, 'list_repositories'
2019-12-26 22:10:19 +05:30
2019-10-12 21:52:04 +05:30
context 'with invalid group id' do
2020-04-22 19:07:51 +05:30
let(:url) { "/groups/#{non_existing_record_id}/registry/repositories" }
2019-10-12 21:52:04 +05:30
it 'returns not found' do
subject
expect(response).to have_gitlab_http_status(:not_found)
end
end
2023-01-13 00:05:48 +05:30
context 'with URL-encoded path of the group' do
let(:url) { "/groups/#{group.full_path}/registry/repositories" }
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
end
2019-10-12 21:52:04 +05:30
end
end