Commit cb4aae5f authored by Michael Kozono's avatar Michael Kozono

Merge branch '8248-remove-conan-feature-flag' into 'master'

Remove conan package registry feature flag

See merge request gitlab-org/gitlab!21152
parents 5631a464 dc0fdadf
---
title: Add support for Conan package management in the package registry
merge_request: 21152
author:
type: added
...@@ -13,8 +13,6 @@ module Packages ...@@ -13,8 +13,6 @@ module Packages
end end
def execute def execute
return ServiceResponse.error(message: 'not found', http_status: :not_found) unless feature_available?
ServiceResponse.success(payload: { results: search_results }) ServiceResponse.success(payload: { results: search_results })
end end
...@@ -38,10 +36,6 @@ module Packages ...@@ -38,10 +36,6 @@ module Packages
sanitized_query sanitized_query
end end
def feature_available?
Feature.enabled?(:conan_package_registry)
end
def search_packages(query) def search_packages(query)
Packages::ConanPackageFinder.new(current_user, query: query).execute.map(&:conan_recipe) Packages::ConanPackageFinder.new(current_user, query: query).execute.map(&:conan_recipe)
end end
......
...@@ -27,7 +27,6 @@ module API ...@@ -27,7 +27,6 @@ module API
CONAN_REVISION_REGEX = Gitlab::Regex.conan_revision_regex CONAN_REVISION_REGEX = Gitlab::Regex.conan_revision_regex
before do before do
not_found! unless Feature.enabled?(:conan_package_registry)
require_packages_enabled! require_packages_enabled!
# Personal access token will be extracted from Bearer or Basic authorization # Personal access token will be extracted from Bearer or Basic authorization
......
...@@ -31,67 +31,53 @@ describe API::ConanPackages do ...@@ -31,67 +31,53 @@ describe API::ConanPackages do
end end
describe 'GET /api/v4/packages/conan/v1/ping' do describe 'GET /api/v4/packages/conan/v1/ping' do
context 'feature flag disabled' do it 'responds with 401 Unauthorized when no token provided' do
before do get api('/packages/conan/v1/ping')
stub_feature_flags(conan_package_registry: false)
end
it 'responds with 404 Not Found' do
get api('/packages/conan/v1/ping')
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:unauthorized)
end
end end
context 'feature flag enabled' do it 'responds with 200 OK when valid token is provided' do
it 'responds with 401 Unauthorized when no token provided' do jwt = build_jwt(personal_access_token)
get api('/packages/conan/v1/ping') get api('/packages/conan/v1/ping'), headers: build_auth_headers(jwt.encoded)
expect(response).to have_gitlab_http_status(:unauthorized) expect(response).to have_gitlab_http_status(:ok)
end expect(response.headers['X-Conan-Server-Capabilities']).to eq("")
end
it 'responds with 200 OK when valid token is provided' do
jwt = build_jwt(personal_access_token)
get api('/packages/conan/v1/ping'), headers: build_auth_headers(jwt.encoded)
expect(response).to have_gitlab_http_status(:ok)
expect(response.headers['X-Conan-Server-Capabilities']).to eq("")
end
it 'responds with 401 Unauthorized when invalid access token ID is provided' do it 'responds with 401 Unauthorized when invalid access token ID is provided' do
jwt = build_jwt(double(id: 12345), user_id: personal_access_token.user_id) jwt = build_jwt(double(id: 12345), user_id: personal_access_token.user_id)
get api('/packages/conan/v1/ping'), headers: build_auth_headers(jwt.encoded) get api('/packages/conan/v1/ping'), headers: build_auth_headers(jwt.encoded)
expect(response).to have_gitlab_http_status(:unauthorized) expect(response).to have_gitlab_http_status(:unauthorized)
end end
it 'responds with 401 Unauthorized when invalid user is provided' do it 'responds with 401 Unauthorized when invalid user is provided' do
jwt = build_jwt(personal_access_token, user_id: 12345) jwt = build_jwt(personal_access_token, user_id: 12345)
get api('/packages/conan/v1/ping'), headers: build_auth_headers(jwt.encoded) get api('/packages/conan/v1/ping'), headers: build_auth_headers(jwt.encoded)
expect(response).to have_gitlab_http_status(:unauthorized) expect(response).to have_gitlab_http_status(:unauthorized)
end end
it 'responds with 401 Unauthorized when the provided JWT is signed with different secret' do it 'responds with 401 Unauthorized when the provided JWT is signed with different secret' do
jwt = build_jwt(personal_access_token, secret: SecureRandom.base64(32)) jwt = build_jwt(personal_access_token, secret: SecureRandom.base64(32))
get api('/packages/conan/v1/ping'), headers: build_auth_headers(jwt.encoded) get api('/packages/conan/v1/ping'), headers: build_auth_headers(jwt.encoded)
expect(response).to have_gitlab_http_status(:unauthorized) expect(response).to have_gitlab_http_status(:unauthorized)
end end
it 'responds with 401 Unauthorized when invalid JWT is provided' do it 'responds with 401 Unauthorized when invalid JWT is provided' do
get api('/packages/conan/v1/ping'), headers: build_auth_headers('invalid-jwt') get api('/packages/conan/v1/ping'), headers: build_auth_headers('invalid-jwt')
expect(response).to have_gitlab_http_status(:unauthorized) expect(response).to have_gitlab_http_status(:unauthorized)
end end
context 'packages feature disabled' do context 'packages feature disabled' do
it 'responds with 404 Not Found' do it 'responds with 404 Not Found' do
stub_packages_setting(enabled: false) stub_packages_setting(enabled: false)
get api('/packages/conan/v1/ping') get api('/packages/conan/v1/ping')
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end
end end
end end
end end
......
...@@ -15,21 +15,6 @@ describe Packages::Conan::SearchService do ...@@ -15,21 +15,6 @@ describe Packages::Conan::SearchService do
end end
describe '#execute' do describe '#execute' do
context 'feature unavailable' do
let(:query) { '' }
before do
stub_feature_flags(conan_package_registry: false)
end
it 'responds with 404 not found' do
result = subject.execute
expect(result.http_status).to eq :not_found
expect(result.message).to eq('not found')
end
end
context 'with wildcard' do context 'with wildcard' do
let(:partial_name) { conan_package.name.first[0, 3] } let(:partial_name) { conan_package.name.first[0, 3] }
let(:query) { "#{partial_name}*" } let(:query) { "#{partial_name}*" }
......
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