-
Notifications
You must be signed in to change notification settings - Fork 620
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preserve brackets around literal IPv6 hosts (#2552)
- Loading branch information
1 parent
e640956
commit 65b4f85
Showing
3 changed files
with
29 additions
and
5 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
27 changes: 27 additions & 0 deletions
27
util/opentelemetry-util-http/tests/test_remove_credentials.py
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import unittest | ||
|
||
from opentelemetry.util.http import remove_url_credentials | ||
|
||
|
||
class TestRemoveUrlCredentials(unittest.TestCase): | ||
def test_remove_no_credentials(self): | ||
url = "http://opentelemetry.io:8080/test/path?query=value" | ||
cleaned_url = remove_url_credentials(url) | ||
self.assertEqual(cleaned_url, url) | ||
|
||
def test_remove_credentials(self): | ||
url = "http://someuser:[email protected]:8080/test/path?query=value" | ||
cleaned_url = remove_url_credentials(url) | ||
self.assertEqual( | ||
cleaned_url, "http://opentelemetry.io:8080/test/path?query=value" | ||
) | ||
|
||
def test_remove_credentials_ipv4_literal(self): | ||
url = "http://someuser:[email protected]:8080/test/path?query=value" | ||
cleaned_url = remove_url_credentials(url) | ||
self.assertEqual(cleaned_url, "http://127.0.0.1:8080/test/path?query=value") | ||
|
||
def test_remove_credentials_ipv6_literal(self): | ||
url = "http://someuser:somepass@[::1]:8080/test/path?query=value" | ||
cleaned_url = remove_url_credentials(url) | ||
self.assertEqual(cleaned_url, "http://[::1]:8080/test/path?query=value") |