diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-05 03:32:58 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-05 03:32:58 +0000 |
commit | 08f8cfe14e0f8937e3bcf8a22becdc5ce60b920e (patch) | |
tree | 30977064b5f93f9ac5b01b2a676f6d6ffdcec652 /test/rubygems/test_gem_commands_yank_command.rb | |
parent | 593505ac6f802d2b5bff469425b7c76b65cc9b10 (diff) |
Merge RubyGems upstream: 56c0bbb69e4506bda7ef7f447dfec5db820df20b
It fixed the multiple vulnerabilities.
https://blog.rubygems.org/2019/03/05/security-advisories-2019-03.html
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_commands_yank_command.rb')
-rw-r--r-- | test/rubygems/test_gem_commands_yank_command.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_commands_yank_command.rb b/test/rubygems/test_gem_commands_yank_command.rb index 666779a4ac..602b137d48 100644 --- a/test/rubygems/test_gem_commands_yank_command.rb +++ b/test/rubygems/test_gem_commands_yank_command.rb @@ -49,6 +49,7 @@ class TestGemCommandsYankCommand < Gem::TestCase assert_match %r%Yanking gem from http://example%, @ui.output assert_match %r%Successfully yanked%, @ui.output + platform = Gem.platforms[1] body = @fetcher.last_request.body.split('&').sort assert_equal %W[gem_name=a platform=#{platform} version=1.0], body @@ -58,6 +59,50 @@ class TestGemCommandsYankCommand < Gem::TestCase assert_equal [yank_uri], @fetcher.paths end + def test_execute_with_otp_success + response_fail = 'You have enabled multifactor authentication but your request doesn\'t have the correct OTP code. Please check it and retry.' + yank_uri = 'http://example/api/v1/gems/yank' + @fetcher.data[yank_uri] = [ + [response_fail, 401, 'Unauthorized'], + ['Successfully yanked', 200, 'OK'] + ] + + @cmd.options[:args] = %w[a] + @cmd.options[:added_platform] = true + @cmd.options[:version] = req('= 1.0') + + @otp_ui = Gem::MockGemUi.new "111111\n" + use_ui @otp_ui do + @cmd.execute + end + + assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @otp_ui.output + assert_match 'Code: ', @otp_ui.output + assert_match %r%Yanking gem from http://example%, @otp_ui.output + assert_match %r%Successfully yanked%, @otp_ui.output + assert_equal '111111', @fetcher.last_request['OTP'] + end + + def test_execute_with_otp_failure + response = 'You have enabled multifactor authentication but your request doesn\'t have the correct OTP code. Please check it and retry.' + yank_uri = 'http://example/api/v1/gems/yank' + @fetcher.data[yank_uri] = [response, 401, 'Unauthorized'] + + @cmd.options[:args] = %w[a] + @cmd.options[:added_platform] = true + @cmd.options[:version] = req('= 1.0') + + @otp_ui = Gem::MockGemUi.new "111111\n" + use_ui @otp_ui do + @cmd.execute + end + + assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @otp_ui.output + assert_match response, @otp_ui.output + assert_match 'Code: ', @otp_ui.output + assert_equal '111111', @fetcher.last_request['OTP'] + end + def test_execute_key yank_uri = 'http://example/api/v1/gems/yank' @fetcher.data[yank_uri] = ['Successfully yanked', 200, 'OK'] |