diff --git a/app/controllers/api/v1/release_engines/rubygems/compact_index_controller.rb b/app/controllers/api/v1/release_engines/rubygems/compact_index_controller.rb index b24690dbbc..6ccfab1933 100644 --- a/app/controllers/api/v1/release_engines/rubygems/compact_index_controller.rb +++ b/app/controllers/api/v1/release_engines/rubygems/compact_index_controller.rb @@ -10,6 +10,12 @@ class Rubygems::CompactIndexController < Api::V1::BaseController before_action :set_packages, only: %i[versions names] before_action :set_package, only: %i[info] + def ping + skip_verify_authorized! + + head :ok + end + def versions authorize! packages, to: :index? diff --git a/config/routes.rb b/config/routes.rb index d97a5d8bf0..8b91fa0714 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -74,6 +74,7 @@ get 'versions', to: 'compact_index#versions', as: :rubygems_compact_versions get 'info/:package', to: 'compact_index#info', as: :rubygems_compact_info get 'names', to: 'compact_index#names', as: :rubygems_compact_names + root via: :head, to: 'compact_index#ping', as: :rubygems_compact_ping end end diff --git a/features/api/v1/engines/rubygems/compact_index.feature b/features/api/v1/engines/rubygems/compact_index.feature index d769352658..8f0060b119 100644 --- a/features/api/v1/engines/rubygems/compact_index.feature +++ b/features/api/v1/engines/rubygems/compact_index.feature @@ -7,9 +7,9 @@ Feature: Rubygems simple package index | Test 2 | test2 | And the current account is "test1" And the current account has the following "product" rows: - | id | name | - | 6198261a-48b5-4445-a045-9fed4afc7735 | Test 1 | - | cad3c65c-b6a5-4b3d-bce6-c2280953b8b8 | Test 2 | + | id | name | distribution_strategy | + | 6198261a-48b5-4445-a045-9fed4afc7735 | Test 1 | LICENSED | + | cad3c65c-b6a5-4b3d-bce6-c2280953b8b8 | Test 2 | LICENSED | And the current account has the following "package" rows: | id | product_id | engine | key | | 46e034fe-2312-40f8-bbeb-7d9957fb6fcf | 6198261a-48b5-4445-a045-9fed4afc7735 | rubygems | foo | @@ -87,6 +87,10 @@ Feature: Rubygems simple package index When I send a GET request to "/accounts/test1/engines/rubygems/versions" Then the response status should be "400" + Scenario: Endpoint should respond to ping + When I send a HEAD request to "/accounts/test1/engines/rubygems" + Then the response status should be "200" + Scenario: Endpoint should return all gems Given I am an admin of account "test1" And I use an authentication token diff --git a/features/step_definitions/request_steps.rb b/features/step_definitions/request_steps.rb index 0a246260c6..d100e2cbdb 100644 --- a/features/step_definitions/request_steps.rb +++ b/features/step_definitions/request_steps.rb @@ -50,6 +50,24 @@ travel_back end +When /^I send a HEAD request to "([^\"]*)"$/ do |path| + path = parse_path_placeholders(path, account: @account, bearer: @bearer, crypt: @crypt) + + case %r{/accounts/(?[^?#/]+)}.match(path) + in account: id if Keygen.singleplayer? + account = FindByAliasService.call(Account, id:, aliases: :slug) rescue nil + + stub_env 'KEYGEN_ACCOUNT_ID', account&.id + else + end + + unless path.starts_with?('//') + head "//api.keygen.sh/#{@api_version}/#{path.sub(/^\//, '')}" + else + head path + end +end + When /^I send a GET request to "([^\"]*)"$/ do |path| path = parse_path_placeholders(path, account: @account, bearer: @bearer, crypt: @crypt)