From aa898b420676633cf36f95b8f97b10d6cac59141 Mon Sep 17 00:00:00 2001 From: Daniel Niknam Date: Mon, 23 Aug 2021 23:51:07 +1000 Subject: [PATCH] [rubygems/rubygems] Remove @credential_redacted instance variable https://github.com/rubygems/rubygems/commit/c3bb52eb5c --- lib/rubygems/printable_uri.rb | 8 ------- test/rubygems/test_gem_printable_uri.rb | 28 ------------------------- 2 files changed, 36 deletions(-) diff --git a/lib/rubygems/printable_uri.rb b/lib/rubygems/printable_uri.rb index 3690e0b68f..f719f4d1a1 100644 --- a/lib/rubygems/printable_uri.rb +++ b/lib/rubygems/printable_uri.rb @@ -8,7 +8,6 @@ class Gem::PrintableUri end def initialize(original_uri) - @credential_redacted = false @original_uri = original_uri end @@ -27,10 +26,6 @@ class Gem::PrintableUri @uri.respond_to?(:password=) end - def credential_redacted? - @credential_redacted - end - def original_password @original_uri.password end @@ -44,13 +39,10 @@ class Gem::PrintableUri def redact_credential if token? @uri.user = 'REDACTED' - @credential_redacted = true elsif oauth_basic? @uri.user = 'REDACTED' - @credential_redacted = true elsif password? @uri.password = 'REDACTED' - @credential_redacted = true end end diff --git a/test/rubygems/test_gem_printable_uri.rb b/test/rubygems/test_gem_printable_uri.rb index c9127a42df..9f49d6538c 100644 --- a/test/rubygems/test_gem_printable_uri.rb +++ b/test/rubygems/test_gem_printable_uri.rb @@ -23,34 +23,6 @@ class TestPrintableUri < Gem::TestCase assert_equal false, Gem::PrintableUri.parse_uri("https://www.example.com:80index").valid_uri? end - def test_credential_redacted_with_user_pass - assert_equal true, Gem::PrintableUri.parse_uri("https://user:pass@example.com").credential_redacted? - end - - def test_credential_redacted_with_token - assert_equal true, Gem::PrintableUri.parse_uri("https://token@example.com").credential_redacted? - end - - def test_credential_redacted_with_user_x_oauth_basic - assert_equal true, Gem::PrintableUri.parse_uri("https://token:x-oauth-basic@example.com").credential_redacted? - end - - def test_credential_redacted_without_credential - assert_equal false, Gem::PrintableUri.parse_uri("https://www.example.com").credential_redacted? - end - - def test_credential_redacted_with_empty_uri_object - assert_equal false, Gem::PrintableUri.parse_uri(URI("")).credential_redacted? - end - - def test_credential_redacted_with_valid_uri_object - assert_equal true, Gem::PrintableUri.parse_uri(URI("https://user:pass@example.com")).credential_redacted? - end - - def test_credential_redacted_with_other_objects - assert_equal false, Gem::PrintableUri.parse_uri(Object.new).credential_redacted? - end - def test_original_password_user_pass assert_equal "pass", Gem::PrintableUri.parse_uri("https://user:pass@example.com").original_password end