[前][次][番号順一覧][スレッド一覧]

ruby-changes:71646

From: Ashley <ko1@a...>
Date: Wed, 6 Apr 2022 08:55:17 +0900 (JST)
Subject: [ruby-changes:71646] b75b67f113 (master): [rubygems/rubygems] Use YAML

https://git.ruby-lang.org/ruby.git/commit/?id=b75b67f113

From b75b67f1136363ea54e9f79a4d63a9a355312f26 Mon Sep 17 00:00:00 2001
From: Ashley Ellis Pierce <anellis12@g...>
Date: Thu, 24 Feb 2022 15:50:17 +0000
Subject: [rubygems/rubygems] Use YAML

https://github.com/rubygems/rubygems/commit/6122e8cac5
---
 lib/rubygems/gemcutter_utilities.rb               | 6 +++---
 test/rubygems/test_gem_commands_push_command.rb   | 4 ++--
 test/rubygems/test_gem_commands_signin_command.rb | 4 ++--
 test/rubygems/test_gem_gemcutter_utilities.rb     | 4 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb
index 2779880121..3a60b654d6 100644
--- a/lib/rubygems/gemcutter_utilities.rb
+++ b/lib/rubygems/gemcutter_utilities.rb
@@ -1,7 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/gemcutter_utilities.rb#L1
 # frozen_string_literal: true
 require_relative 'remote_fetcher'
 require_relative 'text'
-require 'json'
 
 ##
 # Utility methods for using the RubyGems API.
@@ -283,11 +282,12 @@ module Gem::GemcutterUtilities https://github.com/ruby/ruby/blob/trunk/lib/rubygems/gemcutter_utilities.rb#L282
   end
 
   def get_user_mfa_level(email, password)
-    response = rubygems_api_request(:get, "api/v1/profile/me") do |request|
+    response = rubygems_api_request(:get, "api/v1/profile/me.yaml") do |request|
       request.basic_auth email, password
     end
     with_response response do |resp|
-      JSON.parse(resp.body)["mfa"]
+      body = Gem::SafeYAML.load clean_text(resp.body)
+      body["mfa"]
     end
   end
 
diff --git a/test/rubygems/test_gem_commands_push_command.rb b/test/rubygems/test_gem_commands_push_command.rb
index 7efbcc77b4..1bbd341eca 100644
--- a/test/rubygems/test_gem_commands_push_command.rb
+++ b/test/rubygems/test_gem_commands_push_command.rb
@@ -435,7 +435,7 @@ class TestGemCommandsPushCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_push_command.rb#L435
 
     response_mfa_enabled = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry."
     response_success     = 'Successfully registered gem: freewill (1.0.0)'
-    response_profile     = {"mfa" => "disabled"}.to_json
+    response_profile     = "mfa: disabled\n"
 
     @fetcher.data["#{@host}/api/v1/gems"] = [
       [response_success, 200, "OK"],
@@ -446,7 +446,7 @@ class TestGemCommandsPushCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_push_command.rb#L446
       ["", 200, "OK"],
     ]
 
-    @fetcher.data["#{@host}/api/v1/profile/me"] = [
+    @fetcher.data["#{@host}/api/v1/profile/me.yaml"] = [
       [response_profile, 200, "OK"],
     ]
 
diff --git a/test/rubygems/test_gem_commands_signin_command.rb b/test/rubygems/test_gem_commands_signin_command.rb
index 524378f200..0c92b22718 100644
--- a/test/rubygems/test_gem_commands_signin_command.rb
+++ b/test/rubygems/test_gem_commands_signin_command.rb
@@ -196,7 +196,7 @@ class TestGemCommandsSigninCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_signin_command.rb#L196
   def util_capture(ui_stub = nil, host = nil, api_key = nil, fetcher = Gem::FakeFetcher.new, mfa_level = "disabled")
     api_key        ||= 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
     response         = [api_key, 200, 'OK']
-    profile_response = [{"mfa" => mfa_level}.to_json, 200, 'OK']
+    profile_response = [ "mfa: #{mfa_level}\n" , 200, 'OK']
     email            = 'you@e...'
     password         = 'secret'
 
@@ -204,7 +204,7 @@ class TestGemCommandsSigninCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_signin_command.rb#L204
     ENV['RUBYGEMS_HOST']       = host || Gem::DEFAULT_HOST
     data_key                   = "#{ENV['RUBYGEMS_HOST']}/api/v1/api_key"
     fetcher.data[data_key]     = response
-    profile                    = "#{ENV['RUBYGEMS_HOST']}/api/v1/profile/me"
+    profile                    = "#{ENV['RUBYGEMS_HOST']}/api/v1/profile/me.yaml"
     fetcher.data[profile]      = profile_response
     Gem::RemoteFetcher.fetcher = fetcher
 
diff --git a/test/rubygems/test_gem_gemcutter_utilities.rb b/test/rubygems/test_gem_gemcutter_utilities.rb
index b3d105d3ad..667aba4701 100644
--- a/test/rubygems/test_gem_gemcutter_utilities.rb
+++ b/test/rubygems/test_gem_gemcutter_utilities.rb
@@ -229,7 +229,7 @@ class TestGemGemcutterUtilities < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_gemcutter_utilities.rb#L229
   def util_sign_in(response, host = nil, args = [], extra_input = '')
     email            = 'you@e...'
     password         = 'secret'
-    profile_response = [{"mfa" => "disabled"}.to_json, 200, 'OK']
+    profile_response = [ "mfa: disabled\n" , 200, 'OK']
 
     if host
       ENV['RUBYGEMS_HOST'] = host
@@ -239,7 +239,7 @@ class TestGemGemcutterUtilities < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_gemcutter_utilities.rb#L239
 
     @fetcher = Gem::FakeFetcher.new
     @fetcher.data["#{host}/api/v1/api_key"] = response
-    @fetcher.data["#{host}/api/v1/profile/me"] = profile_response
+    @fetcher.data["#{host}/api/v1/profile/me.yaml"] = 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)
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]