Skip to content

Commit a96218d

Browse files
committed
Add test for urlparse exception in is_valid_client_metadata_url
Add test case with malformed IPv6 URL to cover the exception branch, removing the pragma: no cover comment.
1 parent cb3b500 commit a96218d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/mcp/client/auth/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def is_valid_client_metadata_url(url: str | None) -> bool:
259259
try:
260260
parsed = urlparse(url)
261261
return parsed.scheme == "https" and parsed.path not in ("", "/")
262-
except Exception: # pragma: no cover
262+
except Exception:
263263
return False
264264

265265

tests/client/test_auth.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,6 +1851,8 @@ class TestCIMD:
18511851
# Invalid URLs - None or empty
18521852
(None, False),
18531853
("", False),
1854+
# Invalid URLs - malformed (triggers urlparse exception)
1855+
("https://[invalid-ipv6]:8080/path", False),
18541856
],
18551857
)
18561858
def test_is_valid_client_metadata_url(self, url: str | None, expected: bool):

0 commit comments

Comments
 (0)