summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHiroshi SHIBATA <[email protected]>2021-07-07 14:07:29 +0900
committerHiroshi SHIBATA <[email protected]>2021-07-07 15:31:52 +0900
commitc082c6eb7c786a432bea23cf78839f64585cb630 (patch)
treee3c608264fe03645e905fe7284d713cff87b87dd /test
parent6e2240a2f954c84ed12357382c9c065ae4b91e11 (diff)
Sync RubyGems and Bundler with upstream
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4634
Diffstat (limited to 'test')
-rw-r--r--test/rubygems/helper.rb2
-rw-r--r--test/rubygems/test_gem_gemcutter_utilities.rb12
2 files changed, 13 insertions, 1 deletions
diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb
index fbdc34e357..36be6a25b7 100644
--- a/test/rubygems/helper.rb
+++ b/test/rubygems/helper.rb
@@ -1595,7 +1595,7 @@ class Object
metaclass.send :undef_method, name
metaclass.send :alias_method, name, new_name
metaclass.send :undef_method, new_name
- end
+ end unless method_defined?(:stub) # lib/resolv/test_dns.rb also has the same method definition
end
require_relative 'utilities'
diff --git a/test/rubygems/test_gem_gemcutter_utilities.rb b/test/rubygems/test_gem_gemcutter_utilities.rb
index 23aff00cbe..0bcd1504e9 100644
--- a/test/rubygems/test_gem_gemcutter_utilities.rb
+++ b/test/rubygems/test_gem_gemcutter_utilities.rb
@@ -14,6 +14,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
Gem.configuration.disable_default_gem_server = nil
ENV['RUBYGEMS_HOST'] = nil
+ ENV['GEM_HOST_OTP_CODE'] = nil
Gem.configuration.rubygems_api_key = nil
@cmd = Gem::Command.new '', 'summary'
@@ -22,6 +23,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
def teardown
ENV['RUBYGEMS_HOST'] = nil
+ ENV['GEM_HOST_OTP_CODE'] = nil
Gem.configuration.rubygems_api_key = nil
credential_teardown
@@ -186,6 +188,16 @@ class TestGemGemcutterUtilities < Gem::TestCase
assert_match %r{Access Denied.}, @sign_in_ui.output
end
+ def test_signin_with_env_otp_code
+ ENV['GEM_HOST_OTP_CODE'] = '111111'
+ api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
+
+ util_sign_in [api_key, 200, 'OK']
+
+ assert_match 'Signed in with API key:', @sign_in_ui.output
+ assert_equal '111111', @fetcher.last_request['OTP']
+ end
+
def test_sign_in_with_correct_otp_code
api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
response_fail = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry."