Commit 35fd692
committed
fix(auth): satisfy pyright + add coverage for Basic auth fallback edges
Two changes to make CI green:
1. token.py: guard the Basic auth fallback assignment so pyright can
narrow client_info.client_id from `str | None` to `str` before it
lands in starlette's FormData (whose values are `UploadFile | str`).
Semantically a no-op — ClientAuthenticator already guarantees a
non-empty client_id reached this point.
2. test_auth_integration.py: cover the two previously-uncovered edges
in client_auth.py's Basic auth fallback (lines 62-66):
- decoded credentials without ':' separator
- malformed base64 in the Authorization header
Both should be silently swallowed so the request surfaces the normal
"Missing client_id" error path rather than a Basic-auth-specific one.
Coverage of src/mcp/server/auth/middleware/client_auth.py is now 100%.
Also restores ruff-format compliance (single blank line between methods).1 parent d425b7c commit 35fd692
2 files changed
Lines changed: 31 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
103 | 105 | | |
104 | 106 | | |
105 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1366 | 1366 | | |
1367 | 1367 | | |
1368 | 1368 | | |
1369 | | - | |
1370 | 1369 | | |
1371 | 1370 | | |
1372 | 1371 | | |
| |||
1454 | 1453 | | |
1455 | 1454 | | |
1456 | 1455 | | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
1457 | 1484 | | |
1458 | 1485 | | |
1459 | 1486 | | |
| |||
0 commit comments