Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid capitalization issues in SS hosts #174

Merged
merged 1 commit into from
Aug 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions scope/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ def ss_hosts_parser(hosts):
# Raise if credentials are not present
if not parts.username or not parts.password:
raise ValueError("Missing credentials for SS host: %s" % host)
url = "%s://%s" % (parts.scheme, parts.hostname)
if parts.port:
url = "%s:%s" % (url, parts.port)
# Use netloc instead of hostname and port to maintain capitalization
url = "%s://%s" % (parts.scheme, parts.netloc.split("@")[1])
parsed_hosts[url] = {"user": parts.username, "secret": parts.password}
return parsed_hosts

Expand Down
2 changes: 2 additions & 0 deletions scope/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ def test_ss_hosts_parser_success(self):
hosts = [
"http://user:secret@localhost:62081",
"https://user:[email protected]",
"https://user:[email protected]:8000",
]
parsed_hosts = helpers.ss_hosts_parser(hosts)
expected_hosts = {
"http://localhost:62081": {"user": "user", "secret": "secret"},
"https://192.168.1.128": {"user": "user", "secret": "secret"},
"https://HOST.com:8000": {"user": "user", "secret": "secret"},
}
self.assertEqual(parsed_hosts, expected_hosts)

Expand Down