зеркало из https://github.com/github/ruby.git
[rubygems/rubygems] Remove @credential_redacted instance variable
https://github.com/rubygems/rubygems/commit/c3bb52eb5c
This commit is contained in:
Родитель
7067005f23
Коммит
aa898b4206
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче