-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support credentials in URL with empty user, e.g. http://:password@host (
- Loading branch information
Showing
6 changed files
with
20 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Support credentials in URL with empty user, e.g. http://:password@host |
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 |
---|---|---|
|
@@ -389,6 +389,13 @@ def test_basic_auth_from_url(make_request: Any) -> None: | |
assert "python.org" == req.host | ||
|
||
|
||
def test_basic_auth_no_user_from_url(make_request: Any) -> None: | ||
req = make_request("get", "http://:[email protected]") | ||
assert "AUTHORIZATION" in req.headers | ||
assert "Basic OjEyMzQ=" == req.headers["AUTHORIZATION"] | ||
assert "python.org" == req.host | ||
|
||
|
||
def test_basic_auth_from_url_overridden(make_request: Any) -> None: | ||
req = make_request( | ||
"get", "http://[email protected]", auth=aiohttp.BasicAuth("nkim", "1234") | ||
|
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 |
---|---|---|
|
@@ -184,6 +184,13 @@ def test_basic_auth_from_url() -> None: | |
assert auth.password == "pass" | ||
|
||
|
||
def test_basic_auth_no_user_from_url() -> None: | ||
url = URL("http://:[email protected]") | ||
auth = helpers.BasicAuth.from_url(url) | ||
assert auth.login == "" | ||
assert auth.password == "pass" | ||
|
||
|
||
def test_basic_auth_from_not_url() -> None: | ||
with pytest.raises(TypeError): | ||
helpers.BasicAuth.from_url("http://user:[email protected]") | ||
|