mirror of
https://github.com/ruby/ruby.git
synced 2025-09-16 00:54:01 +02:00
[rubygems/rubygems] Remove @credential_redacted instance variable
c3bb52eb5c
This commit is contained in:
parent
7067005f23
commit
aa898b4206
Notes:
git
2021-08-31 19:06:55 +09:00
2 changed files with 0 additions and 36 deletions
|
@ -8,7 +8,6 @@ class Gem::PrintableUri
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(original_uri)
|
def initialize(original_uri)
|
||||||
@credential_redacted = false
|
|
||||||
@original_uri = original_uri
|
@original_uri = original_uri
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -27,10 +26,6 @@ class Gem::PrintableUri
|
||||||
@uri.respond_to?(:password=)
|
@uri.respond_to?(:password=)
|
||||||
end
|
end
|
||||||
|
|
||||||
def credential_redacted?
|
|
||||||
@credential_redacted
|
|
||||||
end
|
|
||||||
|
|
||||||
def original_password
|
def original_password
|
||||||
@original_uri.password
|
@original_uri.password
|
||||||
end
|
end
|
||||||
|
@ -44,13 +39,10 @@ class Gem::PrintableUri
|
||||||
def redact_credential
|
def redact_credential
|
||||||
if token?
|
if token?
|
||||||
@uri.user = 'REDACTED'
|
@uri.user = 'REDACTED'
|
||||||
@credential_redacted = true
|
|
||||||
elsif oauth_basic?
|
elsif oauth_basic?
|
||||||
@uri.user = 'REDACTED'
|
@uri.user = 'REDACTED'
|
||||||
@credential_redacted = true
|
|
||||||
elsif password?
|
elsif password?
|
||||||
@uri.password = 'REDACTED'
|
@uri.password = 'REDACTED'
|
||||||
@credential_redacted = true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -23,34 +23,6 @@ class TestPrintableUri < Gem::TestCase
|
||||||
assert_equal false, Gem::PrintableUri.parse_uri("https://www.example.com:80index").valid_uri?
|
assert_equal false, Gem::PrintableUri.parse_uri("https://www.example.com:80index").valid_uri?
|
||||||
end
|
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
|
def test_original_password_user_pass
|
||||||
assert_equal "pass", Gem::PrintableUri.parse_uri("https://user:pass@example.com").original_password
|
assert_equal "pass", Gem::PrintableUri.parse_uri("https://user:pass@example.com").original_password
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue