diff options
author | Ashley Ellis Pierce <anellis12@gmail.com> | 2022-07-22 13:11:52 -0400 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-07-23 03:42:59 +0900 |
commit | 244bda7efd507657ada6f18e800d852d1a1569f4 (patch) | |
tree | c4f6a2ac0ad9906b180665b6bda72acb7f223e3b /test | |
parent | e199ae3edcead0271c6da3410eb02acd927739b7 (diff) | |
download | ruby-244bda7efd507657ada6f18e800d852d1a1569f4.tar.gz |
[rubygems/rubygems] Display mfa warnings on gem signin
https://github.com/rubygems/rubygems/commit/4dc77b7099
Co-authored-by: Jenny Shen <jenny.shen@shopify.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/rubygems/test_gem_commands_signin_command.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/test/rubygems/test_gem_commands_signin_command.rb b/test/rubygems/test_gem_commands_signin_command.rb index 0f8e478840..ce745bff20 100644 --- a/test/rubygems/test_gem_commands_signin_command.rb +++ b/test/rubygems/test_gem_commands_signin_command.rb @@ -159,6 +159,20 @@ class TestGemCommandsSigninCommand < Gem::TestCase assert_equal api_key, credentials[:rubygems_api_key] end + def test_execute_with_warnings + email = "you@example.com" + password = "secret" + api_key = "1234" + fetcher = Gem::RemoteFetcher.fetcher + mfa_level = "disabled" + warning = "/[WARNING/] For protection of your account and gems" + + key_name_ui = Gem::MockGemUi.new "#{email}\n#{password}\ntest-key\n\ny\n\n\n\n\n\ny" + util_capture(key_name_ui, nil, api_key, fetcher, mfa_level, warning) { @cmd.execute } + + assert_match warning, key_name_ui.output + end + def test_execute_on_gemserver_without_profile_me_endpoint host = "http://some-gemcutter-compatible-host.org" @@ -193,10 +207,10 @@ class TestGemCommandsSigninCommand < Gem::TestCase # 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") + def util_capture(ui_stub = nil, host = nil, api_key = nil, fetcher = Gem::FakeFetcher.new, mfa_level = "disabled", warning = nil) api_key ||= "a5fdbb6ba150cbb83aad2bb2fede64cf040453903" response = [api_key, 200, "OK"] - profile_response = [ "mfa: #{mfa_level}\n" , 200, "OK"] + profile_response = [ "mfa: #{mfa_level}\nwarning: #{warning}" , 200, "OK"] email = "you@example.com" password = "secret" |