Skip to content

Commit

Permalink
Add missing responses
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin-b committed Sep 29, 2024
1 parent 63079b8 commit 5298043
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/oauth2/implicit/test_oauth2_implicit_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ async def test_oauth2_implicit_flow_token_is_reused_if_only_nonce_differs(
token_field_name="custom_token",
)

httpx_mock.add_response(
url="https://authorized_only",
method="GET",
match_headers={
"Authorization": f"Bearer {token}",
},
)
async with httpx.AsyncClient() as client:
await client.get("https://authorized_only", auth=auth2)

Expand Down Expand Up @@ -639,6 +646,13 @@ async def test_oauth2_implicit_flow_token_is_reused_if_not_expired(

auth2 = httpx_auth.OAuth2Implicit("https://provide_token")

httpx_mock.add_response(
url="https://authorized_only",
method="GET",
match_headers={
"Authorization": f"Bearer {token}",
},
)
async with httpx.AsyncClient() as client:
await client.get("https://authorized_only", auth=auth2)

Expand Down
14 changes: 14 additions & 0 deletions tests/oauth2/implicit/test_oauth2_implicit_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ def test_oauth2_implicit_flow_token_is_reused_if_only_nonce_differs(
token_field_name="custom_token",
)

httpx_mock.add_response(
url="https://authorized_only",
method="GET",
match_headers={
"Authorization": f"Bearer {token}",
},
)
with httpx.Client() as client:
client.get("https://authorized_only", auth=auth2)

Expand Down Expand Up @@ -616,6 +623,13 @@ def test_oauth2_implicit_flow_token_is_reused_if_not_expired(

auth2 = httpx_auth.OAuth2Implicit("https://provide_token")

httpx_mock.add_response(
url="https://authorized_only",
method="GET",
match_headers={
"Authorization": f"Bearer {token}",
},
)
with httpx.Client() as client:
client.get("https://authorized_only", auth=auth2)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,18 @@ async def test_oauth2_password_credentials_flow_refresh_token_invalid(
match_content=b"grant_type=refresh_token&refresh_token=tGzv3JOkF0XG5Qx2TlKWIA",
)

httpx_mock.add_response(
method="POST",
url="https://provide_access_token",
json={
"access_token": "2YotnFZFEjr1zCsicMWpAA",
"token_type": "example",
"expires_in": "0",
"refresh_token": "tGzv3JOkF0XG5Qx2TlKWIA",
"example_parameter": "example_value",
},
match_content=b"grant_type=password&username=test_user&password=test_pwd",
)
httpx_mock.add_response(
url="https://authorized_only",
method="GET",
Expand Down Expand Up @@ -473,6 +485,13 @@ async def test_oauth2_password_credentials_flow_refresh_token_access_token_not_e
async with httpx.AsyncClient() as client:
await client.get("https://authorized_only", auth=auth)

httpx_mock.add_response(
url="https://authorized_only",
method="GET",
match_headers={
"Authorization": "Bearer 2YotnFZFEjr1zCsicMWpAA",
},
)
# expect Bearer token to remain the same
async with httpx.AsyncClient() as client:
await client.get("https://authorized_only", auth=auth)
Expand Down

0 comments on commit 5298043

Please sign in to comment.