feat: add async client base, AsyncHTTPClient, AsyncDescopeClient, and async TOTP#1562
feat: add async client base, AsyncHTTPClient, AsyncDescopeClient, and async TOTP#1562LioriE wants to merge 12 commits into
Conversation
46a82d0 to
99839cc
Compare
Coverage reportThe coverage rate went from
Diff Coverage details (click to unfold)descope/_client_base.py
descope/_auth_base.py
descope/init.py
descope/authmethod/totp.py
descope/http_client_async.py
descope/http_client.py
descope/descope_client.py
descope/descope_client_async.py
descope/_http_base.py
descope/authmethod/_totp_base.py
descope/_http_client_base.py
descope/authmethod/totp_async.py
|
Move PUBLIC_KEY_DICT, VALID_REFRESH_TOKEN, VALID_SESSION_TOKEN, and EXPIRED_SESSION_TOKEN from individual test files into testutils.py. Move assert_http_called into conftest.py. Replace old test files with the unified sync/async parity versions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace ~45 three-line dash-banner comment blocks across 8 files with nothing — class names, method names, and docstrings already describe what those banners labelled. The only banner-style block kept is the SOCKS-proxy workaround doc in conftest.py, which is real documentation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@shuni review this async implementation will it scale to all other methods? |
|
🐕 Review complete — View session on Shuni Portal 🐾 |
There was a problem hiding this comment.
🐕 Shuni's Review
POC that extracts shared sync/async base classes and adds AsyncHTTPClient, AsyncDescopeClient, and async TOTP. Clean refactor — the base-class extraction preserves behaviour and sync/async parity is faithful (verified against Auth methods).
Sniffed out 3 issues:
- 1 🟡 MEDIUM: async validate/refresh path runs blocking sync I/O on the event loop
- 2 🟢 LOW: committed sandbox workaround in conftest; verbose
putparity gap
No bugs that break — good bones for a POC! Woof!
| params=params, | ||
| ) | ||
| ) | ||
| self._raise_from_response(response) |
There was a problem hiding this comment.
🟢 LOW: put skips the if self.verbose: self._last_response_var.set(...) capture that get/post/patch/delete all do, so get_last_response() returns a stale response after a PUT. (The sync HTTPClient.put has the same gap, so this preserves parity — but since this is new code it's a cheap spot to fix both.)
|
@shuni follow the example set in this PR follow conventions and patterns set in this PR. perform this in another branch and open a pull request to this branch. |
|
🐕 Uh oh! I ran into an error. Please check the logs for details. |
Summary
_ClientBaseand_AuthBaseto extract shared sync/async logicAsyncHTTPClientwithhttpx.AsyncClientfor non-blocking HTTPAsyncDescopeClientas the async counterpart toDescopeClientAsyncTOTPbacked by a shared_TOTPBaseDescopeClientandTOTPto reuse the new base classesStatus
Draft / POC — async infrastructure is in place; remaining auth methods need to be ported to async.
Test plan
tests/test_async_http_client.py— AsyncHTTPClient unit teststests/test_descope_client_parity.py— sync/async client behaviour paritytests/test_totp_parity.py— sync/async TOTP parity