diff options
Diffstat (limited to 'test/rubygems/test_gem_commands_yank_command.rb')
-rw-r--r-- | test/rubygems/test_gem_commands_yank_command.rb | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/test/rubygems/test_gem_commands_yank_command.rb b/test/rubygems/test_gem_commands_yank_command.rb index b798eb3689..878b52416e 100644 --- a/test/rubygems/test_gem_commands_yank_command.rb +++ b/test/rubygems/test_gem_commands_yank_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/yank_command' +require_relative "helper" +require "rubygems/commands/yank_command" class TestGemCommandsYankCommand < Gem::TestCase def setup @@ -9,12 +9,12 @@ class TestGemCommandsYankCommand < Gem::TestCase credential_setup @cmd = Gem::Commands::YankCommand.new - @cmd.options[:host] = 'http://example' + @cmd.options[:host] = "http://example" @fetcher = Gem::RemoteFetcher.fetcher - Gem.configuration.rubygems_api_key = 'key' - Gem.configuration.api_keys[:KEY] = 'other' + Gem.configuration.rubygems_api_key = "key" + Gem.configuration.api_keys[:KEY] = "other" end def teardown @@ -30,7 +30,7 @@ class TestGemCommandsYankCommand < Gem::TestCase assert_equal :KEY, @cmd.options[:key] assert_equal "HOST", @cmd.options[:host] assert_nil @cmd.options[:platform] - assert_equal req('= 1.0'), @cmd.options[:version] + assert_equal req("= 1.0"), @cmd.options[:version] end def test_handle_options_missing_argument @@ -42,12 +42,12 @@ class TestGemCommandsYankCommand < Gem::TestCase end def test_execute - yank_uri = 'http://example/api/v1/gems/yank' - @fetcher.data[yank_uri] = ['Successfully yanked', 200, 'OK'] + yank_uri = "http://example/api/v1/gems/yank" + @fetcher.data[yank_uri] = ["Successfully yanked", 200, "OK"] @cmd.options[:args] = %w[a] @cmd.options[:added_platform] = true - @cmd.options[:version] = req('= 1.0') + @cmd.options[:version] = req("= 1.0") use_ui @ui do @cmd.execute @@ -57,82 +57,82 @@ class TestGemCommandsYankCommand < Gem::TestCase assert_match %r{Successfully yanked}, @ui.output platform = Gem.platforms[1] - body = @fetcher.last_request.body.split('&').sort + body = @fetcher.last_request.body.split("&").sort assert_equal %W[gem_name=a platform=#{platform} version=1.0], body - assert_equal 'key', @fetcher.last_request['Authorization'] + assert_equal "key", @fetcher.last_request["Authorization"] 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' + 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'], + [response_fail, 401, "Unauthorized"], + ["Successfully yanked", 200, "OK"], ] @cmd.options[:args] = %w[a] @cmd.options[:added_platform] = true - @cmd.options[:version] = req('= 1.0') + @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 "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'] + 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'] + 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') + @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 "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'] + 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'] + yank_uri = "http://example/api/v1/gems/yank" + @fetcher.data[yank_uri] = ["Successfully yanked", 200, "OK"] @cmd.options[:args] = %w[a] - @cmd.options[:version] = req('= 1.0') + @cmd.options[:version] = req("= 1.0") @cmd.options[:key] = :KEY use_ui @ui do @cmd.execute end - body = @fetcher.last_request.body.split('&').sort + body = @fetcher.last_request.body.split("&").sort assert_equal %w[gem_name=a version=1.0], body - assert_equal 'other', @fetcher.last_request['Authorization'] + assert_equal "other", @fetcher.last_request["Authorization"] end def test_execute_host - host = 'https://other.example' + host = "https://other.example" yank_uri = "#{host}/api/v1/gems/yank" - @fetcher.data[yank_uri] = ['Successfully yanked', 200, 'OK'] + @fetcher.data[yank_uri] = ["Successfully yanked", 200, "OK"] @cmd.options[:args] = %w[a] - @cmd.options[:version] = req('= 1.0') + @cmd.options[:version] = req("= 1.0") @cmd.options[:host] = host use_ui @ui do @@ -142,26 +142,26 @@ class TestGemCommandsYankCommand < Gem::TestCase assert_match %r{Yanking gem from https://other.example}, @ui.output assert_match %r{Successfully yanked}, @ui.output - body = @fetcher.last_request.body.split('&').sort + body = @fetcher.last_request.body.split("&").sort assert_equal %w[gem_name=a version=1.0], body - assert_equal 'key', @fetcher.last_request['Authorization'] + assert_equal "key", @fetcher.last_request["Authorization"] assert_equal [yank_uri], @fetcher.paths end def test_yank_gem_unathorized_api_key response_forbidden = "The API key doesn't have access" - response_success = 'Successfully yanked' - host = 'http://example' + response_success = "Successfully yanked" + host = "http://example" @fetcher.data["#{host}/api/v1/gems/yank"] = [ - [response_forbidden, 403, 'Forbidden'], + [response_forbidden, 403, "Forbidden"], [response_success, 200, "OK"], ] @fetcher.data["#{host}/api/v1/api_key"] = ["", 200, "OK"] @cmd.options[:args] = %w[a] @cmd.options[:added_platform] = true - @cmd.options[:version] = req('= 1.0') + @cmd.options[:version] = req("= 1.0") @cmd.instance_variable_set :@host, host @cmd.instance_variable_set :@scope, :yank_rubygem |