summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAshley Ellis Pierce <anellis12@gmail.com>2022-02-24 15:16:32 +0000
committergit <svn-admin@ruby-lang.org>2022-04-06 08:54:58 +0900
commitbb3ecdba6a48e9c82b651e74debcec1a10081126 (patch)
tree19b116e60c7fb5d81bea1386e019aa99d5754461 /test
parent75083704bfeac2fb2a3e104389cd10ddf752b7d2 (diff)
[rubygems/rubygems] Accomodate gem hosts without profile/me endpoint
https://github.com/rubygems/rubygems/commit/31b6dcf5d3
Diffstat (limited to 'test')
-rw-r--r--test/rubygems/test_gem_commands_signin_command.rb32
-rw-r--r--test/rubygems/test_gem_gemcutter_utilities.rb2
2 files changed, 33 insertions, 1 deletions
diff --git a/test/rubygems/test_gem_commands_signin_command.rb b/test/rubygems/test_gem_commands_signin_command.rb
index bdd7690c41..524378f200 100644
--- a/test/rubygems/test_gem_commands_signin_command.rb
+++ b/test/rubygems/test_gem_commands_signin_command.rb
@@ -159,6 +159,38 @@ class TestGemCommandsSigninCommand < Gem::TestCase
assert_equal api_key, credentials[:rubygems_api_key]
end
+ def test_execute_on_gemserver_without_profile_me_endpoint
+ host = 'http://some-gemcutter-compatible-host.org'
+
+ email = 'you@example.com'
+ password = 'secret'
+ api_key = '1234'
+ fetcher = Gem::RemoteFetcher.fetcher
+
+ key_name_ui = Gem::MockGemUi.new "#{email}\n#{password}\ntest-key\n\ny\n\n\n\n\n\ny"
+
+ # Set the expected response for the Web-API supplied
+ ENV['RUBYGEMS_HOST'] = host
+ data_key = "#{ENV['RUBYGEMS_HOST']}/api/v1/api_key"
+ fetcher.data[data_key] = [api_key, 200, 'OK']
+
+ use_ui key_name_ui do
+ @cmd.execute
+ end
+
+ user = ENV["USER"] || ENV["USERNAME"]
+
+ assert_match "API Key name [#{Socket.gethostname}-#{user}", key_name_ui.output
+ assert_match "index_rubygems [y/N]", key_name_ui.output
+ assert_match "push_rubygem [y/N]", key_name_ui.output
+ assert_match "yank_rubygem [y/N]", key_name_ui.output
+ assert_match "add_owner [y/N]", key_name_ui.output
+ assert_match "remove_owner [y/N]", key_name_ui.output
+ assert_match "access_webhooks [y/N]", key_name_ui.output
+ assert_match "show_dashboard [y/N]", key_name_ui.output
+ assert_equal "name=test-key&push_rubygem=true", fetcher.last_request.body
+ end
+
# Utility method to capture IO/UI within the block passed
def util_capture(ui_stub = nil, host = nil, api_key = nil, fetcher = Gem::FakeFetcher.new, mfa_level = "disabled")
diff --git a/test/rubygems/test_gem_gemcutter_utilities.rb b/test/rubygems/test_gem_gemcutter_utilities.rb
index 2e3e598ef4..b3d105d3ad 100644
--- a/test/rubygems/test_gem_gemcutter_utilities.rb
+++ b/test/rubygems/test_gem_gemcutter_utilities.rb
@@ -239,7 +239,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
@fetcher = Gem::FakeFetcher.new
@fetcher.data["#{host}/api/v1/api_key"] = response
- @fetcher.data["#{host}/api/v1/profile"] = profile_response
+ @fetcher.data["#{host}/api/v1/profile/me"] = profile_response
Gem::RemoteFetcher.fetcher = @fetcher
@sign_in_ui = Gem::MockGemUi.new("#{email}\n#{password}\n\n\n\n\n\n\n\n\n" + extra_input)