Commit e2444c8f authored by Dmytro Zaporozhets (DZ)'s avatar Dmytro Zaporozhets (DZ)

Merge branch 'remove-namespace_project_container_registry_index-json' into 'master'

Remove JSON endpoint for project container index

See merge request gitlab-org/gitlab!52407
parents 968be533 4b4faaa3
...@@ -6,22 +6,11 @@ module Projects ...@@ -6,22 +6,11 @@ module Projects
include PackagesHelper include PackagesHelper
before_action :authorize_update_container_image!, only: [:destroy] before_action :authorize_update_container_image!, only: [:destroy]
before_action :ensure_root_container_repository!, only: [:index]
def index def index
respond_to do |format| respond_to do |format|
format.html format.html { ensure_root_container_repository! }
format.json do format.json { render_404 }
@images = ContainerRepositoriesFinder.new(user: current_user, subject: project, params: params.slice(:name))
.execute
track_package_event(:list_repositories, :container)
serializer = ContainerRepositoriesSerializer
.new(project: project, current_user: current_user)
render json: serializer.with_pagination(request, response).represent(@images)
end
end end
end end
......
---
title: Remove JSON endpoint for project container index
merge_request: 52407
author: Takuya Noguchi
type: other
...@@ -16,19 +16,19 @@ RSpec.describe Projects::Registry::RepositoriesController do ...@@ -16,19 +16,19 @@ RSpec.describe Projects::Registry::RepositoriesController do
project.add_developer(user) project.add_developer(user)
end end
shared_examples 'with name parameter' do shared_examples 'renders 200 for html and 404 for json' do
let_it_be(:repo) { create(:container_repository, project: project, name: 'my_searched_image') } it 'successfully renders container repositories', :snowplow do
let_it_be(:another_repo) { create(:container_repository, project: project, name: 'bar') } go_to_index
it 'returns the searched repo' do
go_to_index(format: :json, params: { name: 'my_searched_image' })
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.length).to eq 1 # event tracked in GraphQL API: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/44926
expect(json_response.first).to include( expect_no_snowplow_event
'id' => repo.id, end
'name' => repo.name
) it 'returns 404 for request in json format' do
go_to_index(format: :json)
expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -50,33 +50,12 @@ RSpec.describe Projects::Registry::RepositoriesController do ...@@ -50,33 +50,12 @@ RSpec.describe Projects::Registry::RepositoriesController do
tags: %w[rc1 latest]) tags: %w[rc1 latest])
end end
it 'successfully renders container repositories', :snowplow do
go_to_index
expect_no_snowplow_event
expect(response).to have_gitlab_http_status(:ok)
end
it 'tracks the event', :snowplow do
go_to_index(format: :json)
expect_snowplow_event(category: anything, action: 'list_repositories')
end
it 'creates a root container repository' do it 'creates a root container repository' do
expect { go_to_index }.to change { ContainerRepository.all.count }.by(1) expect { go_to_index }.to change { ContainerRepository.all.count }.by(1)
expect(ContainerRepository.first).to be_root_repository expect(ContainerRepository.first).to be_root_repository
end end
it 'json has a list of projects' do it_behaves_like 'renders 200 for html and 404 for json'
go_to_index(format: :json)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('registry/repositories')
expect(response).to include_pagination_headers
end
it_behaves_like 'with name parameter'
end end
context 'when there are no tags for this repository' do context 'when there are no tags for this repository' do
...@@ -84,22 +63,11 @@ RSpec.describe Projects::Registry::RepositoriesController do ...@@ -84,22 +63,11 @@ RSpec.describe Projects::Registry::RepositoriesController do
stub_container_registry_tags(repository: :any, tags: []) stub_container_registry_tags(repository: :any, tags: [])
end end
it 'successfully renders container repositories' do
go_to_index
expect(response).to have_gitlab_http_status(:ok)
end
it 'does not ensure root container repository' do it 'does not ensure root container repository' do
expect { go_to_index }.not_to change { ContainerRepository.all.count } expect { go_to_index }.not_to change { ContainerRepository.all.count }
end end
it 'responds with json if asked' do it_behaves_like 'renders 200 for html and 404 for json'
go_to_index(format: :json)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_kind_of(Array)
end
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment