Skip to content

Commit

Permalink
Release 0.23.1 (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin-b authored Jan 7, 2025
2 parents f4c70b2 + e001f07 commit 3693b11
Show file tree
Hide file tree
Showing 19 changed files with 2,709 additions and 1,782 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
rm -Rf httpx_auth
- name: Install wheel
run: |
python -m pip install dist/httpx_auth-0.23.0-py3-none-any.whl --force-reinstall
python -m pip install dist/httpx_auth-0.23.1-py3-none-any.whl --force-reinstall
python -c 'import httpx_auth'
- name: Install source distribution
run: |
python -m pip install dist/httpx_auth-0.23.0.tar.gz --force-reinstall
python -m pip install dist/httpx_auth-0.23.1.tar.gz --force-reinstall
python -c 'import httpx_auth'
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.23.1] - 2025-01-07
### Fixed
- Test suite should now run even if port 5000 is used by another process. Thanks to [`commonism`](https://github.com/commonism).

## [0.23.0] - 2025-01-07
### Fixed
- Bearer tokens with nested JSON string are now properly handled. Thanks to [`Patrick Rodrigues`](https://github.com/pythrick).
Expand Down Expand Up @@ -262,7 +266,8 @@ Note that a few changes were made:
### Added
- Placeholder for port of requests_auth to httpx

[Unreleased]: https://github.com/Colin-b/httpx_auth/compare/v0.23.0...HEAD
[Unreleased]: https://github.com/Colin-b/httpx_auth/compare/v0.23.1...HEAD
[0.23.1]: https://github.com/Colin-b/httpx_auth/compare/v0.23.0...v0.23.1
[0.23.0]: https://github.com/Colin-b/httpx_auth/compare/v0.22.0...v0.23.0
[0.22.0]: https://github.com/Colin-b/httpx_auth/compare/v0.21.0...v0.22.0
[0.21.0]: https://github.com/Colin-b/httpx_auth/compare/v0.20.0...v0.21.0
Expand Down
2 changes: 1 addition & 1 deletion httpx_auth/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Major should be incremented in case there is a breaking change. (eg: 2.5.8 -> 3.0.0)
# Minor should be incremented in case there is an enhancement. (eg: 2.5.8 -> 2.6.0)
# Patch should be incremented in case there is a bug fix. (eg: 2.5.8 -> 2.5.9)
__version__ = "0.23.0"
__version__ = "0.23.1"
68 changes: 44 additions & 24 deletions tests/features/multi_auth/test_add_operator_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,17 +315,19 @@ async def test_oauth2_client_credential_and_multiple_authentication_can_be_combi

@pytest.mark.asyncio
async def test_oauth2_authorization_code_and_api_key_authentication_can_be_combined(
token_cache, httpx_mock: HTTPXMock, browser_mock: BrowserMock
token_cache, httpx_mock: HTTPXMock, browser_mock: BrowserMock, unused_tcp_port: int
):
authorization_code_auth = httpx_auth.OAuth2AuthorizationCode(
"https://provide_code", "https://provide_access_token"
"https://provide_code",
"https://provide_access_token",
redirect_uri_port=unused_tcp_port,
)
api_key_auth = httpx_auth.HeaderApiKey("my_provided_api_key")
auth = authorization_code_auth + api_key_auth

tab = browser_mock.add_response(
opened_url="https://provide_code?response_type=code&state=ce9c755b41b5e3c5b64c70598715d5de271023a53f39a67a70215d265d11d2bfb6ef6e9c701701e998e69cbdbf2cee29fd51d2a950aa05f59a20cf4a646099d5&redirect_uri=http%3A%2F%2Flocalhost%3A5000%2F",
reply_url="http://localhost:5000#code=SplxlOBeZQQYbYS6WxSbIA&state=ce9c755b41b5e3c5b64c70598715d5de271023a53f39a67a70215d265d11d2bfb6ef6e9c701701e998e69cbdbf2cee29fd51d2a950aa05f59a20cf4a646099d5",
opened_url=f"https://provide_code?response_type=code&state=ce9c755b41b5e3c5b64c70598715d5de271023a53f39a67a70215d265d11d2bfb6ef6e9c701701e998e69cbdbf2cee29fd51d2a950aa05f59a20cf4a646099d5&redirect_uri=http%3A%2F%2Flocalhost%3A{unused_tcp_port}%2F",
reply_url=f"http://localhost:{unused_tcp_port}#code=SplxlOBeZQQYbYS6WxSbIA&state=ce9c755b41b5e3c5b64c70598715d5de271023a53f39a67a70215d265d11d2bfb6ef6e9c701701e998e69cbdbf2cee29fd51d2a950aa05f59a20cf4a646099d5",
)

httpx_mock.add_response(
Expand Down Expand Up @@ -357,10 +359,12 @@ async def test_oauth2_authorization_code_and_api_key_authentication_can_be_combi

@pytest.mark.asyncio
async def test_oauth2_authorization_code_and_multiple_authentication_can_be_combined(
token_cache, httpx_mock: HTTPXMock, browser_mock: BrowserMock
token_cache, httpx_mock: HTTPXMock, browser_mock: BrowserMock, unused_tcp_port: int
):
authorization_code_auth = httpx_auth.OAuth2AuthorizationCode(
"https://provide_code", "https://provide_access_token"
"https://provide_code",
"https://provide_access_token",
redirect_uri_port=unused_tcp_port,
)
api_key_auth = httpx_auth.HeaderApiKey("my_provided_api_key")
api_key_auth2 = httpx_auth.HeaderApiKey(
Expand All @@ -369,8 +373,8 @@ async def test_oauth2_authorization_code_and_multiple_authentication_can_be_comb
auth = authorization_code_auth + (api_key_auth + api_key_auth2)

tab = browser_mock.add_response(
opened_url="https://provide_code?response_type=code&state=ce9c755b41b5e3c5b64c70598715d5de271023a53f39a67a70215d265d11d2bfb6ef6e9c701701e998e69cbdbf2cee29fd51d2a950aa05f59a20cf4a646099d5&redirect_uri=http%3A%2F%2Flocalhost%3A5000%2F",
reply_url="http://localhost:5000#code=SplxlOBeZQQYbYS6WxSbIA&state=ce9c755b41b5e3c5b64c70598715d5de271023a53f39a67a70215d265d11d2bfb6ef6e9c701701e998e69cbdbf2cee29fd51d2a950aa05f59a20cf4a646099d5",
opened_url=f"https://provide_code?response_type=code&state=ce9c755b41b5e3c5b64c70598715d5de271023a53f39a67a70215d265d11d2bfb6ef6e9c701701e998e69cbdbf2cee29fd51d2a950aa05f59a20cf4a646099d5&redirect_uri=http%3A%2F%2Flocalhost%3A{unused_tcp_port}%2F",
reply_url=f"http://localhost:{unused_tcp_port}#code=SplxlOBeZQQYbYS6WxSbIA&state=ce9c755b41b5e3c5b64c70598715d5de271023a53f39a67a70215d265d11d2bfb6ef6e9c701701e998e69cbdbf2cee29fd51d2a950aa05f59a20cf4a646099d5",
)

httpx_mock.add_response(
Expand Down Expand Up @@ -403,20 +407,26 @@ async def test_oauth2_authorization_code_and_multiple_authentication_can_be_comb

@pytest.mark.asyncio
async def test_oauth2_pkce_and_api_key_authentication_can_be_combined(
token_cache, httpx_mock: HTTPXMock, browser_mock: BrowserMock, monkeypatch
token_cache,
httpx_mock: HTTPXMock,
browser_mock: BrowserMock,
monkeypatch,
unused_tcp_port: int,
):
monkeypatch.setattr(
httpx_auth._oauth2.authorization_code_pkce.os, "urandom", lambda x: b"1" * 63
)
pkce_auth = httpx_auth.OAuth2AuthorizationCodePKCE(
"https://provide_code", "https://provide_access_token"
"https://provide_code",
"https://provide_access_token",
redirect_uri_port=unused_tcp_port,
)
api_key_auth = httpx_auth.HeaderApiKey("my_provided_api_key")
auth = pkce_auth + api_key_auth

tab = browser_mock.add_response(
opened_url="https://provide_code?response_type=code&state=ce9c755b41b5e3c5b64c70598715d5de271023a53f39a67a70215d265d11d2bfb6ef6e9c701701e998e69cbdbf2cee29fd51d2a950aa05f59a20cf4a646099d5&redirect_uri=http%3A%2F%2Flocalhost%3A5000%2F&code_challenge=5C_ph_KZ3DstYUc965SiqmKAA-ShvKF4Ut7daKd3fjc&code_challenge_method=S256",
reply_url="http://localhost:5000#code=SplxlOBeZQQYbYS6WxSbIA&state=ce9c755b41b5e3c5b64c70598715d5de271023a53f39a67a70215d265d11d2bfb6ef6e9c701701e998e69cbdbf2cee29fd51d2a950aa05f59a20cf4a646099d5",
opened_url=f"https://provide_code?response_type=code&state=ce9c755b41b5e3c5b64c70598715d5de271023a53f39a67a70215d265d11d2bfb6ef6e9c701701e998e69cbdbf2cee29fd51d2a950aa05f59a20cf4a646099d5&redirect_uri=http%3A%2F%2Flocalhost%3A{unused_tcp_port}%2F&code_challenge=5C_ph_KZ3DstYUc965SiqmKAA-ShvKF4Ut7daKd3fjc&code_challenge_method=S256",
reply_url=f"http://localhost:{unused_tcp_port}#code=SplxlOBeZQQYbYS6WxSbIA&state=ce9c755b41b5e3c5b64c70598715d5de271023a53f39a67a70215d265d11d2bfb6ef6e9c701701e998e69cbdbf2cee29fd51d2a950aa05f59a20cf4a646099d5",
)

httpx_mock.add_response(
Expand Down Expand Up @@ -448,13 +458,19 @@ async def test_oauth2_pkce_and_api_key_authentication_can_be_combined(

@pytest.mark.asyncio
async def test_oauth2_pkce_and_multiple_authentication_can_be_combined(
token_cache, httpx_mock: HTTPXMock, browser_mock: BrowserMock, monkeypatch
token_cache,
httpx_mock: HTTPXMock,
browser_mock: BrowserMock,
monkeypatch,
unused_tcp_port: int,
):
monkeypatch.setattr(
httpx_auth._oauth2.authorization_code_pkce.os, "urandom", lambda x: b"1" * 63
)
pkce_auth = httpx_auth.OAuth2AuthorizationCodePKCE(
"https://provide_code", "https://provide_access_token"
"https://provide_code",
"https://provide_access_token",
redirect_uri_port=unused_tcp_port,
)
api_key_auth = httpx_auth.HeaderApiKey("my_provided_api_key")
api_key_auth2 = httpx_auth.HeaderApiKey(
Expand All @@ -463,8 +479,8 @@ async def test_oauth2_pkce_and_multiple_authentication_can_be_combined(
auth = pkce_auth + (api_key_auth + api_key_auth2)

tab = browser_mock.add_response(
opened_url="https://provide_code?response_type=code&state=ce9c755b41b5e3c5b64c70598715d5de271023a53f39a67a70215d265d11d2bfb6ef6e9c701701e998e69cbdbf2cee29fd51d2a950aa05f59a20cf4a646099d5&redirect_uri=http%3A%2F%2Flocalhost%3A5000%2F&code_challenge=5C_ph_KZ3DstYUc965SiqmKAA-ShvKF4Ut7daKd3fjc&code_challenge_method=S256",
reply_url="http://localhost:5000#code=SplxlOBeZQQYbYS6WxSbIA&state=ce9c755b41b5e3c5b64c70598715d5de271023a53f39a67a70215d265d11d2bfb6ef6e9c701701e998e69cbdbf2cee29fd51d2a950aa05f59a20cf4a646099d5",
opened_url=f"https://provide_code?response_type=code&state=ce9c755b41b5e3c5b64c70598715d5de271023a53f39a67a70215d265d11d2bfb6ef6e9c701701e998e69cbdbf2cee29fd51d2a950aa05f59a20cf4a646099d5&redirect_uri=http%3A%2F%2Flocalhost%3A{unused_tcp_port}%2F&code_challenge=5C_ph_KZ3DstYUc965SiqmKAA-ShvKF4Ut7daKd3fjc&code_challenge_method=S256",
reply_url=f"http://localhost:{unused_tcp_port}#code=SplxlOBeZQQYbYS6WxSbIA&state=ce9c755b41b5e3c5b64c70598715d5de271023a53f39a67a70215d265d11d2bfb6ef6e9c701701e998e69cbdbf2cee29fd51d2a950aa05f59a20cf4a646099d5",
)

httpx_mock.add_response(
Expand Down Expand Up @@ -497,9 +513,11 @@ async def test_oauth2_pkce_and_multiple_authentication_can_be_combined(

@pytest.mark.asyncio
async def test_oauth2_implicit_and_api_key_authentication_can_be_combined(
token_cache, httpx_mock: HTTPXMock, browser_mock: BrowserMock
token_cache, httpx_mock: HTTPXMock, browser_mock: BrowserMock, unused_tcp_port: int
):
implicit_auth = httpx_auth.OAuth2Implicit("https://provide_token")
implicit_auth = httpx_auth.OAuth2Implicit(
"https://provide_token", redirect_uri_port=unused_tcp_port
)
api_key_auth = httpx_auth.HeaderApiKey("my_provided_api_key")
auth = implicit_auth + api_key_auth

Expand All @@ -508,8 +526,8 @@ async def test_oauth2_implicit_and_api_key_authentication_can_be_combined(
) + datetime.timedelta(hours=1)
token = create_token(expiry_in_1_hour)
tab = browser_mock.add_response(
opened_url="https://provide_token?response_type=token&state=bee505cb6ceb14b9f6ac3573cd700b3b3e965004078d7bb57c7b92df01e448c992a7a46b4804164fc998ea166ece3f3d5849ca2405c4a548f43b915b0677231c&redirect_uri=http%3A%2F%2Flocalhost%3A5000%2F",
reply_url="http://localhost:5000",
opened_url=f"https://provide_token?response_type=token&state=bee505cb6ceb14b9f6ac3573cd700b3b3e965004078d7bb57c7b92df01e448c992a7a46b4804164fc998ea166ece3f3d5849ca2405c4a548f43b915b0677231c&redirect_uri=http%3A%2F%2Flocalhost%3A{unused_tcp_port}%2F",
reply_url=f"http://localhost:{unused_tcp_port}",
data=f"access_token={token}&state=bee505cb6ceb14b9f6ac3573cd700b3b3e965004078d7bb57c7b92df01e448c992a7a46b4804164fc998ea166ece3f3d5849ca2405c4a548f43b915b0677231c",
)

Expand All @@ -530,9 +548,11 @@ async def test_oauth2_implicit_and_api_key_authentication_can_be_combined(

@pytest.mark.asyncio
async def test_oauth2_implicit_and_multiple_authentication_can_be_combined(
token_cache, httpx_mock: HTTPXMock, browser_mock: BrowserMock
token_cache, httpx_mock: HTTPXMock, browser_mock: BrowserMock, unused_tcp_port: int
):
implicit_auth = httpx_auth.OAuth2Implicit("https://provide_token")
implicit_auth = httpx_auth.OAuth2Implicit(
"https://provide_token", redirect_uri_port=unused_tcp_port
)
api_key_auth = httpx_auth.HeaderApiKey("my_provided_api_key")
api_key_auth2 = httpx_auth.HeaderApiKey(
"my_provided_api_key2", header_name="X-Api-Key2"
Expand All @@ -544,8 +564,8 @@ async def test_oauth2_implicit_and_multiple_authentication_can_be_combined(
) + datetime.timedelta(hours=1)
token = create_token(expiry_in_1_hour)
tab = browser_mock.add_response(
opened_url="https://provide_token?response_type=token&state=bee505cb6ceb14b9f6ac3573cd700b3b3e965004078d7bb57c7b92df01e448c992a7a46b4804164fc998ea166ece3f3d5849ca2405c4a548f43b915b0677231c&redirect_uri=http%3A%2F%2Flocalhost%3A5000%2F",
reply_url="http://localhost:5000",
opened_url=f"https://provide_token?response_type=token&state=bee505cb6ceb14b9f6ac3573cd700b3b3e965004078d7bb57c7b92df01e448c992a7a46b4804164fc998ea166ece3f3d5849ca2405c4a548f43b915b0677231c&redirect_uri=http%3A%2F%2Flocalhost%3A{unused_tcp_port}%2F",
reply_url=f"http://localhost:{unused_tcp_port}",
data=f"access_token={token}&state=bee505cb6ceb14b9f6ac3573cd700b3b3e965004078d7bb57c7b92df01e448c992a7a46b4804164fc998ea166ece3f3d5849ca2405c4a548f43b915b0677231c",
)

Expand Down
Loading

0 comments on commit 3693b11

Please sign in to comment.