Skip to content

Commit 368c2a8

Browse files
test: add case for refresh token
1 parent 4f789a7 commit 368c2a8

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tests/server/fastmcp/auth/test_auth_integration.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ async def test_client_secret_basic_authentication(
10891089
assert "access_token" in token_response
10901090

10911091
@pytest.mark.anyio
1092-
async def test_wrong_auth_method_without_valid_credentials_fails(
1092+
async def test_wrong_auth_method_fails(
10931093
self, test_client: httpx.AsyncClient, mock_oauth_provider: MockOAuthProvider, pkce_challenge: dict[str, str]
10941094
):
10951095
"""Test that using the wrong authentication method fails when credentials are missing."""
@@ -1368,6 +1368,23 @@ async def test_basic_auth_without_client_id_at_body(
13681368
assert response.status_code == 200
13691369
token_response = response.json()
13701370
assert "access_token" in token_response
1371+
assert "refresh_token" in token_response
1372+
1373+
refresh_token = token_response["refresh_token"]
1374+
1375+
# Now, use the refresh token without client_id in body
1376+
response = await test_client.post(
1377+
"/token",
1378+
headers={"Authorization": f"Basic {encoded_credentials}"},
1379+
data={
1380+
"grant_type": "refresh_token",
1381+
# client_id omitted from body
1382+
"refresh_token": refresh_token,
1383+
},
1384+
)
1385+
assert response.status_code == 200
1386+
new_token_response = response.json()
1387+
assert "access_token" in new_token_response
13711388

13721389
@pytest.mark.anyio
13731390
async def test_none_auth_method_public_client(

0 commit comments

Comments
 (0)