summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_uri.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/rubygems/test_gem_uri.rb')
-rw-r--r--test/rubygems/test_gem_uri.rb32
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:[email protected]", Gem::Uri.new("https://user:[email protected]").redacted.to_s
+ end
+
+ def test_redacted_with_token
+ assert_equal "https://[email protected]", Gem::Uri.new("https://[email protected]").redacted.to_s
+ end
+
+ def test_redacted_with_user_x_oauth_basic
+ assert_equal "https://REDACTED:[email protected]", Gem::Uri.new("https://token:[email protected]").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