-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3345 from candlepin/jhnidek/1878182
RHEL-13375: 1.28 Parse URL properly
- Loading branch information
Showing
8 changed files
with
149 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,16 +137,24 @@ def test_bad_http_scheme(self): | |
local_url) | ||
|
||
def test_colon_but_no_port(self): | ||
# This is correct URL | ||
local_url = "https://myhost.example.com:/myapp" | ||
self.assertRaises(ServerUrlParseErrorPort, | ||
parse_url, | ||
local_url) | ||
username, password, hostname, port, prefix = parse_url(local_url) | ||
self.assertIsNone(username) | ||
self.assertIsNone(password) | ||
self.assertEqual(hostname, "myhost.example.com") | ||
self.assertIsNone(port) | ||
self.assertEqual(prefix, "/myapp") | ||
|
||
def test_colon_but_no_port_no_scheme(self): | ||
# This is correct URL | ||
local_url = "myhost.example.com:/myapp" | ||
self.assertRaises(ServerUrlParseErrorPort, | ||
parse_url, | ||
local_url) | ||
username, password, hostname, port, prefix = parse_url(local_url) | ||
self.assertIsNone(username) | ||
self.assertIsNone(password) | ||
self.assertEqual(hostname, "myhost.example.com") | ||
self.assertIsNone(port) | ||
self.assertEqual(prefix, "/myapp") | ||
|
||
def test_colon_slash_slash_but_nothing_else(self): | ||
local_url = "http://" | ||
|
@@ -273,6 +281,24 @@ def test_bad(self): | |
|
||
class TestParseUrl(unittest.TestCase): | ||
|
||
def test_ipv4_url(self): | ||
local_url = "http://user:[email protected]:3128/prefix" | ||
(username, password, hostname, port, prefix) = parse_url(local_url) | ||
self.assertEqual("user", username) | ||
self.assertEqual("pass", password) | ||
self.assertEqual("192.168.0.10", hostname) | ||
self.assertEqual("3128", port) | ||
self.assertEqual("/prefix", prefix) | ||
|
||
def test_ipv6_url(self): | ||
local_url = "http://user:pass@[2001:db8::dead:beef:1]:3128/prefix" | ||
(username, password, hostname, port, prefix) = parse_url(local_url) | ||
self.assertEqual("user", username) | ||
self.assertEqual("pass", password) | ||
self.assertEqual("2001:db8::dead:beef:1", hostname) | ||
self.assertEqual("3128", port) | ||
self.assertEqual("/prefix", prefix) | ||
|
||
def test_username_password(self): | ||
local_url = "http://user:pass@hostname:1111/prefix" | ||
(username, password, hostname, port, prefix) = parse_url(local_url) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2484,6 +2484,24 @@ def test_list_by_default_with_options_from_super_class(self): | |
self.cc._validate_options() | ||
self.assertTrue(self.cc.options.list) | ||
|
||
def test_proxy_user_and_pass_from_url_overridden_by_cli_options(self): | ||
""" | ||
Test that --proxyuser and --proxypassword have higher priority than --proxy | ||
""" | ||
self.cc.main( | ||
[ | ||
"--proxy", | ||
"https://foo:[email protected]", | ||
"--proxyuser", | ||
"other-user", | ||
"--proxypassword", | ||
"other-password", | ||
] | ||
) | ||
self.cc._validate_options() | ||
self.assertEqual(self.cc.proxy_user, "other-user") | ||
self.assertEqual(self.cc.proxy_password, "other-password") | ||
|
||
def test_add_with_multiple_colons(self): | ||
self.cc.main(["--repo", "x", "--add", "url:http://example.com"]) | ||
self.cc._validate_options() | ||
|
Oops, something went wrong.