diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2021-08-24 12:02:29 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-08-31 19:06:14 +0900 |
commit | 1e290c31f4fdfd330b9cd1d5c7fe61efa4ab066c (patch) | |
tree | 0d3e58f3df45c7ab430375fe27550db6f6df6a65 /test/rubygems/test_gem_uri.rb | |
parent | f0c6cc14b10616a61d3113dd5a88291fe915461b (diff) |
[rubygems/rubygems] Merge `Gem::UriParser` and `Gem::PrintableUri` into a `Gem::Uri` class
The new class is a wrapper on top of an URI. And then, when you want
credentials redacted, you call `#redacted` that returns a copy of itself,
but with credentials redacted.
https://github.com/rubygems/rubygems/commit/9581c2740a
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4789
Diffstat (limited to 'test/rubygems/test_gem_uri.rb')
-rw-r--r-- | test/rubygems/test_gem_uri.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_uri.rb b/test/rubygems/test_gem_uri.rb new file mode 100644 index 0000000000..0c70443f32 --- /dev/null +++ b/test/rubygems/test_gem_uri.rb @@ -0,0 +1,32 @@ +require_relative 'helper' +require 'rubygems/uri' + +class TestUri < Gem::TestCase + def test_to_s_not_string + assert_equal "not_a_uri", Gem::Uri.new(:not_a_uri).to_s + end + + def test_to_s_invalid_uri + assert_equal "https://www.example.com:80index", Gem::Uri.new("https://www.example.com:80index").to_s + end + + def test_redacted_with_user_pass + assert_equal "https://user:REDACTED@example.com", Gem::Uri.new("https://user:pass@example.com").redacted.to_s + end + + def test_redacted_with_token + assert_equal "https://REDACTED@example.com", Gem::Uri.new("https://token@example.com").redacted.to_s + end + + def test_redacted_with_user_x_oauth_basic + assert_equal "https://REDACTED:x-oauth-basic@example.com", Gem::Uri.new("https://token:x-oauth-basic@example.com").redacted.to_s + end + + def test_redacted_without_credential + assert_equal "https://www.example.com", Gem::Uri.new("https://www.example.com").redacted.to_s + end + + def test_redacted_with_invalid_uri + assert_equal "https://www.example.com:80index", Gem::Uri.new("https://www.example.com:80index").redacted.to_s + end +end |