Commit de1b7707 authored by Steve Abrams's avatar Steve Abrams Committed by Dmitriy Zaporozhets

Conan Skeleton API

The initial structure for the Conan API endpoints
is set up to allow for future API development.
parent bb397198
# frozen_string_literal: true
module API
class ConanPackages < Grape::API
before do
not_found! unless Feature.enabled?(:conan_package_registry)
end
helpers ::API::Helpers::PackagesHelpers
before do
require_packages_enabled!
require_conan_authentication!
end
desc 'Ping the Conan API' do
detail 'This feature was introduced in GitLab 12.2'
end
get 'packages/conan/v1/ping' do
nil
end
end
end
......@@ -23,6 +23,12 @@ module API
def authorize_destroy_package!
authorize!(:destroy_package, user_project)
end
def require_conan_authentication!
# TODO: implement Conan server authentication
# To be implemented in https://gitlab.com/gitlab-org/gitlab-ee/issues/12568
unauthorized!
end
end
end
end
......@@ -23,6 +23,7 @@ module EE
mount ::API::License
mount ::API::ProjectMirror
mount ::API::ProjectPushRule
mount ::API::ConanPackages
mount ::API::MavenPackages
mount ::API::NpmPackages
mount ::API::Packages
......
# frozen_string_literal: true
require 'spec_helper'
describe API::ConanPackages do
set(:guest) { create(:user) }
let(:api_user) { guest }
before do
stub_licensed_features(packages: true)
end
describe 'GET /api/v4/packages/conan/v1/ping' do
let(:url) { '/packages/conan/v1/ping' }
subject { get api(url, api_user) }
context 'feature flag disabled' do
before do
stub_feature_flags(conan_package_registry: false)
end
it 'returns not found' do
subject
expect(response).to have_gitlab_http_status(404)
end
end
context 'feature flag enabled' do
it 'rejects with no authorization' do
subject
expect(response).to have_gitlab_http_status(401)
end
context 'packages feature disabled' do
it 'fails' do
stub_packages_setting(enabled: false)
subject
expect(response).to have_gitlab_http_status(404)
end
end
end
end
end
......@@ -37,5 +37,9 @@ module EE
def stub_elasticsearch_setting(messages)
allow(::Gitlab.config.elasticsearch).to receive_messages(to_settings(messages))
end
def stub_packages_setting(messages)
allow(::Gitlab.config.packages).to receive_messages(to_settings(messages))
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