diff --git a/descope/__init__.py b/descope/__init__.py index 7e71f2f6..5cd79bea 100644 --- a/descope/__init__.py +++ b/descope/__init__.py @@ -39,3 +39,37 @@ UserPasswordFirebase, UserPasswordPbkdf2, ) + +__all__ = [ + "COOKIE_DATA_NAME", + "REFRESH_SESSION_COOKIE_NAME", + "REFRESH_SESSION_TOKEN_NAME", + "SESSION_COOKIE_NAME", + "SESSION_TOKEN_NAME", + "AccessKeyLoginOptions", + "DeliveryMethod", + "LoginOptions", + "SignUpOptions", + "DescopeClient", + "API_RATE_LIMIT_RETRY_AFTER_HEADER", + "ERROR_TYPE_API_RATE_LIMIT", + "ERROR_TYPE_SERVER_ERROR", + "AuthException", + "RateLimitException", + "AssociatedTenant", + "SAMLIDPAttributeMappingInfo", + "SAMLIDPGroupsMappingInfo", + "SAMLIDPRoleGroupMappingInfo", + "AttributeMapping", + "OIDCAttributeMapping", + "RoleMapping", + "SSOOIDCSettings", + "SSOSAMLSettings", + "SSOSAMLSettingsByMetadata", + "UserObj", + "UserPassword", + "UserPasswordBcrypt", + "UserPasswordDjango", + "UserPasswordFirebase", + "UserPasswordPbkdf2", +] diff --git a/descope/auth.py b/descope/auth.py index bf63c66e..b7c85ba6 100644 --- a/descope/auth.py +++ b/descope/auth.py @@ -16,7 +16,7 @@ except ImportError: from pkg_resources import get_distribution -import requests +import httpx from email_validator import EmailNotValidError, validate_email from jwt import ExpiredSignatureError, ImmatureSignatureError @@ -122,14 +122,14 @@ def do_get( self, uri: str, params=None, - allow_redirects=None, + follow_redirects=None, pswd: str | None = None, - ) -> requests.Response: - response = requests.get( + ) -> httpx.Response: + response = httpx.get( f"{self.base_url}{uri}", headers=self._get_default_headers(pswd), params=params, - allow_redirects=allow_redirects, + follow_redirects=follow_redirects, verify=self.secure, timeout=self.timeout_seconds, ) @@ -142,12 +142,12 @@ def do_post( body: dict | list[dict] | list[str] | None, params=None, pswd: str | None = None, - ) -> requests.Response: - response = requests.post( + ) -> httpx.Response: + response = httpx.post( f"{self.base_url}{uri}", headers=self._get_default_headers(pswd), json=body, - allow_redirects=False, + follow_redirects=False, verify=self.secure, params=params, timeout=self.timeout_seconds, @@ -161,12 +161,12 @@ def do_patch( body: dict | list[dict] | list[str] | None, params=None, pswd: str | None = None, - ) -> requests.Response: - response = requests.patch( + ) -> httpx.Response: + response = httpx.patch( f"{self.base_url}{uri}", headers=self._get_default_headers(pswd), json=body, - allow_redirects=False, + follow_redirects=False, verify=self.secure, params=params, timeout=self.timeout_seconds, @@ -176,12 +176,12 @@ def do_patch( def do_delete( self, uri: str, params=None, pswd: str | None = None - ) -> requests.Response: - response = requests.delete( + ) -> httpx.Response: + response = httpx.delete( f"{self.base_url}{uri}", params=params, headers=self._get_default_headers(pswd), - allow_redirects=False, + follow_redirects=False, verify=self.secure, timeout=self.timeout_seconds, ) @@ -419,7 +419,7 @@ def _raise_from_response(self, response): def _fetch_public_keys(self) -> None: # This function called under mutex protection so no need to acquire it once again - response = requests.get( + response = httpx.get( f"{self.base_url}{EndpointsV2.public_key_path}/{self.project_id}", headers=self._get_default_headers(), verify=self.secure, diff --git a/descope/authmethod/enchantedlink.py b/descope/authmethod/enchantedlink.py index a9419ef0..25cb494d 100644 --- a/descope/authmethod/enchantedlink.py +++ b/descope/authmethod/enchantedlink.py @@ -1,6 +1,6 @@ from __future__ import annotations -import requests +import httpx from descope._auth_base import AuthBase from descope.auth import Auth @@ -197,5 +197,5 @@ def _compose_get_session_body(pending_ref: str) -> dict: return {"pendingRef": pending_ref} @staticmethod - def _get_pending_ref_from_response(response: requests.Response) -> dict: + def _get_pending_ref_from_response(response: httpx.Response) -> dict: return response.json() diff --git a/descope/authmethod/webauthn.py b/descope/authmethod/webauthn.py index 9f3f89b2..df72362e 100644 --- a/descope/authmethod/webauthn.py +++ b/descope/authmethod/webauthn.py @@ -1,6 +1,6 @@ from typing import Iterable, Optional, Union -from requests import Response +from httpx import Response from descope._auth_base import AuthBase from descope.common import ( diff --git a/descope/descope_client.py b/descope/descope_client.py index ddc48878..e2f80796 100644 --- a/descope/descope_client.py +++ b/descope/descope_client.py @@ -2,7 +2,7 @@ from typing import Iterable -import requests +import httpx from descope.auth import Auth # noqa: F401 from descope.authmethod.enchantedlink import EnchantedLink # noqa: F401 @@ -362,7 +362,7 @@ def validate_and_refresh_session( session_token, refresh_token, audience ) - def logout(self, refresh_token: str) -> requests.Response: + def logout(self, refresh_token: str) -> httpx.Response: """ Logout user from current session and revoke the refresh_token. After calling this function, you must invalidate or remove any cookies you have created. @@ -370,7 +370,7 @@ def logout(self, refresh_token: str) -> requests.Response: Args: refresh_token (str): The refresh token - Return value (requests.Response): returns the response from the Descope server + Return value (httpx.Response): returns the response from the Descope server Raise: AuthException: Exception is raised if session is not authorized or another error occurs @@ -385,7 +385,7 @@ def logout(self, refresh_token: str) -> requests.Response: uri = EndpointsV1.logout_path return self._auth.do_post(uri, {}, None, refresh_token) - def logout_all(self, refresh_token: str) -> requests.Response: + def logout_all(self, refresh_token: str) -> httpx.Response: """ Logout user from all active sessions and revoke the refresh_token. After calling this function, you must invalidate or remove any cookies you have created. @@ -393,7 +393,7 @@ def logout_all(self, refresh_token: str) -> requests.Response: Args: refresh_token (str): The refresh token - Return value (requests.Response): returns the response from the Descope server + Return value (httpx.Response): returns the response from the Descope server Raise: AuthException: Exception is raised if session is not authorized or another error occurs @@ -431,7 +431,7 @@ def me(self, refresh_token: str) -> dict: uri = EndpointsV1.me_path response = self._auth.do_get( - uri=uri, params=None, allow_redirects=None, pswd=refresh_token + uri=uri, params=None, follow_redirects=None, pswd=refresh_token ) return response.json() @@ -513,7 +513,7 @@ def history(self, refresh_token: str) -> list[dict]: uri = EndpointsV1.history_path response = self._auth.do_get( - uri=uri, params=None, allow_redirects=None, pswd=refresh_token + uri=uri, params=None, follow_redirects=None, pswd=refresh_token ) return response.json() diff --git a/poetry.lock b/poetry.lock index bcd35d83..41889cd5 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,5 +1,27 @@ # This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +[[package]] +name = "anyio" +version = "4.5.2" +description = "High level compatibility layer for multiple asynchronous event loop implementations" +optional = false +python-versions = ">=3.8" +files = [ + {file = "anyio-4.5.2-py3-none-any.whl", hash = "sha256:c011ee36bc1e8ba40e5a81cb9df91925c218fe9b778554e0b56a21e1b5d4716f"}, + {file = "anyio-4.5.2.tar.gz", hash = "sha256:23009af4ed04ce05991845451e11ef02fc7c5ed29179ac9a420e5ad0ac7ddc5b"}, +] + +[package.dependencies] +exceptiongroup = {version = ">=1.0.2", markers = "python_version < \"3.11\""} +idna = ">=2.8" +sniffio = ">=1.1" +typing-extensions = {version = ">=4.1", markers = "python_version < \"3.11\""} + +[package.extras] +doc = ["Sphinx (>=7.4,<8.0)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme"] +test = ["anyio[trio]", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "truststore (>=0.9.1)", "uvloop (>=0.21.0b1)"] +trio = ["trio (>=0.26.1)"] + [[package]] name = "attrs" version = "24.2.0" @@ -245,120 +267,6 @@ files = [ {file = "chardet-5.2.0.tar.gz", hash = "sha256:1b3b6ff479a8c414bc3fa2c0852995695c4a026dcd6d0633b2dd092ca39c1cf7"}, ] -[[package]] -name = "charset-normalizer" -version = "3.4.0" -description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." -optional = false -python-versions = ">=3.7.0" -files = [ - {file = "charset_normalizer-3.4.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:4f9fc98dad6c2eaa32fc3af1417d95b5e3d08aff968df0cd320066def971f9a6"}, - {file = "charset_normalizer-3.4.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0de7b687289d3c1b3e8660d0741874abe7888100efe14bd0f9fd7141bcbda92b"}, - {file = "charset_normalizer-3.4.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:5ed2e36c3e9b4f21dd9422f6893dec0abf2cca553af509b10cd630f878d3eb99"}, - {file = "charset_normalizer-3.4.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:40d3ff7fc90b98c637bda91c89d51264a3dcf210cade3a2c6f838c7268d7a4ca"}, - {file = "charset_normalizer-3.4.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1110e22af8ca26b90bd6364fe4c763329b0ebf1ee213ba32b68c73de5752323d"}, - {file = "charset_normalizer-3.4.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:86f4e8cca779080f66ff4f191a685ced73d2f72d50216f7112185dc02b90b9b7"}, - {file = "charset_normalizer-3.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7f683ddc7eedd742e2889d2bfb96d69573fde1d92fcb811979cdb7165bb9c7d3"}, - {file = "charset_normalizer-3.4.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:27623ba66c183eca01bf9ff833875b459cad267aeeb044477fedac35e19ba907"}, - {file = "charset_normalizer-3.4.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:f606a1881d2663630ea5b8ce2efe2111740df4b687bd78b34a8131baa007f79b"}, - {file = "charset_normalizer-3.4.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:0b309d1747110feb25d7ed6b01afdec269c647d382c857ef4663bbe6ad95a912"}, - {file = "charset_normalizer-3.4.0-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:136815f06a3ae311fae551c3df1f998a1ebd01ddd424aa5603a4336997629e95"}, - {file = "charset_normalizer-3.4.0-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:14215b71a762336254351b00ec720a8e85cada43b987da5a042e4ce3e82bd68e"}, - {file = "charset_normalizer-3.4.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:79983512b108e4a164b9c8d34de3992f76d48cadc9554c9e60b43f308988aabe"}, - {file = "charset_normalizer-3.4.0-cp310-cp310-win32.whl", hash = "sha256:c94057af19bc953643a33581844649a7fdab902624d2eb739738a30e2b3e60fc"}, - {file = "charset_normalizer-3.4.0-cp310-cp310-win_amd64.whl", hash = "sha256:55f56e2ebd4e3bc50442fbc0888c9d8c94e4e06a933804e2af3e89e2f9c1c749"}, - {file = "charset_normalizer-3.4.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:0d99dd8ff461990f12d6e42c7347fd9ab2532fb70e9621ba520f9e8637161d7c"}, - {file = "charset_normalizer-3.4.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c57516e58fd17d03ebe67e181a4e4e2ccab1168f8c2976c6a334d4f819fe5944"}, - {file = "charset_normalizer-3.4.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:6dba5d19c4dfab08e58d5b36304b3f92f3bd5d42c1a3fa37b5ba5cdf6dfcbcee"}, - {file = "charset_normalizer-3.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bf4475b82be41b07cc5e5ff94810e6a01f276e37c2d55571e3fe175e467a1a1c"}, - {file = "charset_normalizer-3.4.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ce031db0408e487fd2775d745ce30a7cd2923667cf3b69d48d219f1d8f5ddeb6"}, - {file = "charset_normalizer-3.4.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8ff4e7cdfdb1ab5698e675ca622e72d58a6fa2a8aa58195de0c0061288e6e3ea"}, - {file = "charset_normalizer-3.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3710a9751938947e6327ea9f3ea6332a09bf0ba0c09cae9cb1f250bd1f1549bc"}, - {file = "charset_normalizer-3.4.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:82357d85de703176b5587dbe6ade8ff67f9f69a41c0733cf2425378b49954de5"}, - {file = "charset_normalizer-3.4.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:47334db71978b23ebcf3c0f9f5ee98b8d65992b65c9c4f2d34c2eaf5bcaf0594"}, - {file = "charset_normalizer-3.4.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:8ce7fd6767a1cc5a92a639b391891bf1c268b03ec7e021c7d6d902285259685c"}, - {file = "charset_normalizer-3.4.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:f1a2f519ae173b5b6a2c9d5fa3116ce16e48b3462c8b96dfdded11055e3d6365"}, - {file = "charset_normalizer-3.4.0-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:63bc5c4ae26e4bc6be6469943b8253c0fd4e4186c43ad46e713ea61a0ba49129"}, - {file = "charset_normalizer-3.4.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:bcb4f8ea87d03bc51ad04add8ceaf9b0f085ac045ab4d74e73bbc2dc033f0236"}, - {file = "charset_normalizer-3.4.0-cp311-cp311-win32.whl", hash = "sha256:9ae4ef0b3f6b41bad6366fb0ea4fc1d7ed051528e113a60fa2a65a9abb5b1d99"}, - {file = "charset_normalizer-3.4.0-cp311-cp311-win_amd64.whl", hash = "sha256:cee4373f4d3ad28f1ab6290684d8e2ebdb9e7a1b74fdc39e4c211995f77bec27"}, - {file = "charset_normalizer-3.4.0-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:0713f3adb9d03d49d365b70b84775d0a0d18e4ab08d12bc46baa6132ba78aaf6"}, - {file = "charset_normalizer-3.4.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:de7376c29d95d6719048c194a9cf1a1b0393fbe8488a22008610b0361d834ecf"}, - {file = "charset_normalizer-3.4.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:4a51b48f42d9358460b78725283f04bddaf44a9358197b889657deba38f329db"}, - {file = "charset_normalizer-3.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b295729485b06c1a0683af02a9e42d2caa9db04a373dc38a6a58cdd1e8abddf1"}, - {file = "charset_normalizer-3.4.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ee803480535c44e7f5ad00788526da7d85525cfefaf8acf8ab9a310000be4b03"}, - {file = "charset_normalizer-3.4.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3d59d125ffbd6d552765510e3f31ed75ebac2c7470c7274195b9161a32350284"}, - {file = "charset_normalizer-3.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8cda06946eac330cbe6598f77bb54e690b4ca93f593dee1568ad22b04f347c15"}, - {file = "charset_normalizer-3.4.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:07afec21bbbbf8a5cc3651aa96b980afe2526e7f048fdfb7f1014d84acc8b6d8"}, - {file = "charset_normalizer-3.4.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:6b40e8d38afe634559e398cc32b1472f376a4099c75fe6299ae607e404c033b2"}, - {file = "charset_normalizer-3.4.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:b8dcd239c743aa2f9c22ce674a145e0a25cb1566c495928440a181ca1ccf6719"}, - {file = "charset_normalizer-3.4.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:84450ba661fb96e9fd67629b93d2941c871ca86fc38d835d19d4225ff946a631"}, - {file = "charset_normalizer-3.4.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:44aeb140295a2f0659e113b31cfe92c9061622cadbc9e2a2f7b8ef6b1e29ef4b"}, - {file = "charset_normalizer-3.4.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:1db4e7fefefd0f548d73e2e2e041f9df5c59e178b4c72fbac4cc6f535cfb1565"}, - {file = "charset_normalizer-3.4.0-cp312-cp312-win32.whl", hash = "sha256:5726cf76c982532c1863fb64d8c6dd0e4c90b6ece9feb06c9f202417a31f7dd7"}, - {file = "charset_normalizer-3.4.0-cp312-cp312-win_amd64.whl", hash = "sha256:b197e7094f232959f8f20541ead1d9862ac5ebea1d58e9849c1bf979255dfac9"}, - {file = "charset_normalizer-3.4.0-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:dd4eda173a9fcccb5f2e2bd2a9f423d180194b1bf17cf59e3269899235b2a114"}, - {file = "charset_normalizer-3.4.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:e9e3c4c9e1ed40ea53acf11e2a386383c3304212c965773704e4603d589343ed"}, - {file = "charset_normalizer-3.4.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:92a7e36b000bf022ef3dbb9c46bfe2d52c047d5e3f3343f43204263c5addc250"}, - {file = "charset_normalizer-3.4.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:54b6a92d009cbe2fb11054ba694bc9e284dad30a26757b1e372a1fdddaf21920"}, - {file = "charset_normalizer-3.4.0-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1ffd9493de4c922f2a38c2bf62b831dcec90ac673ed1ca182fe11b4d8e9f2a64"}, - {file = "charset_normalizer-3.4.0-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:35c404d74c2926d0287fbd63ed5d27eb911eb9e4a3bb2c6d294f3cfd4a9e0c23"}, - {file = "charset_normalizer-3.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4796efc4faf6b53a18e3d46343535caed491776a22af773f366534056c4e1fbc"}, - {file = "charset_normalizer-3.4.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e7fdd52961feb4c96507aa649550ec2a0d527c086d284749b2f582f2d40a2e0d"}, - {file = "charset_normalizer-3.4.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:92db3c28b5b2a273346bebb24857fda45601aef6ae1c011c0a997106581e8a88"}, - {file = "charset_normalizer-3.4.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:ab973df98fc99ab39080bfb0eb3a925181454d7c3ac8a1e695fddfae696d9e90"}, - {file = "charset_normalizer-3.4.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:4b67fdab07fdd3c10bb21edab3cbfe8cf5696f453afce75d815d9d7223fbe88b"}, - {file = "charset_normalizer-3.4.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:aa41e526a5d4a9dfcfbab0716c7e8a1b215abd3f3df5a45cf18a12721d31cb5d"}, - {file = "charset_normalizer-3.4.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:ffc519621dce0c767e96b9c53f09c5d215578e10b02c285809f76509a3931482"}, - {file = "charset_normalizer-3.4.0-cp313-cp313-win32.whl", hash = "sha256:f19c1585933c82098c2a520f8ec1227f20e339e33aca8fa6f956f6691b784e67"}, - {file = "charset_normalizer-3.4.0-cp313-cp313-win_amd64.whl", hash = "sha256:707b82d19e65c9bd28b81dde95249b07bf9f5b90ebe1ef17d9b57473f8a64b7b"}, - {file = "charset_normalizer-3.4.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:dbe03226baf438ac4fda9e2d0715022fd579cb641c4cf639fa40d53b2fe6f3e2"}, - {file = "charset_normalizer-3.4.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dd9a8bd8900e65504a305bf8ae6fa9fbc66de94178c420791d0293702fce2df7"}, - {file = "charset_normalizer-3.4.0-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b8831399554b92b72af5932cdbbd4ddc55c55f631bb13ff8fe4e6536a06c5c51"}, - {file = "charset_normalizer-3.4.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a14969b8691f7998e74663b77b4c36c0337cb1df552da83d5c9004a93afdb574"}, - {file = "charset_normalizer-3.4.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dcaf7c1524c0542ee2fc82cc8ec337f7a9f7edee2532421ab200d2b920fc97cf"}, - {file = "charset_normalizer-3.4.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:425c5f215d0eecee9a56cdb703203dda90423247421bf0d67125add85d0c4455"}, - {file = "charset_normalizer-3.4.0-cp37-cp37m-musllinux_1_2_aarch64.whl", hash = "sha256:d5b054862739d276e09928de37c79ddeec42a6e1bfc55863be96a36ba22926f6"}, - {file = "charset_normalizer-3.4.0-cp37-cp37m-musllinux_1_2_i686.whl", hash = "sha256:f3e73a4255342d4eb26ef6df01e3962e73aa29baa3124a8e824c5d3364a65748"}, - {file = "charset_normalizer-3.4.0-cp37-cp37m-musllinux_1_2_ppc64le.whl", hash = "sha256:2f6c34da58ea9c1a9515621f4d9ac379871a8f21168ba1b5e09d74250de5ad62"}, - {file = "charset_normalizer-3.4.0-cp37-cp37m-musllinux_1_2_s390x.whl", hash = "sha256:f09cb5a7bbe1ecae6e87901a2eb23e0256bb524a79ccc53eb0b7629fbe7677c4"}, - {file = "charset_normalizer-3.4.0-cp37-cp37m-musllinux_1_2_x86_64.whl", hash = "sha256:0099d79bdfcf5c1f0c2c72f91516702ebf8b0b8ddd8905f97a8aecf49712c621"}, - {file = "charset_normalizer-3.4.0-cp37-cp37m-win32.whl", hash = "sha256:9c98230f5042f4945f957d006edccc2af1e03ed5e37ce7c373f00a5a4daa6149"}, - {file = "charset_normalizer-3.4.0-cp37-cp37m-win_amd64.whl", hash = "sha256:62f60aebecfc7f4b82e3f639a7d1433a20ec32824db2199a11ad4f5e146ef5ee"}, - {file = "charset_normalizer-3.4.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:af73657b7a68211996527dbfeffbb0864e043d270580c5aef06dc4b659a4b578"}, - {file = "charset_normalizer-3.4.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:cab5d0b79d987c67f3b9e9c53f54a61360422a5a0bc075f43cab5621d530c3b6"}, - {file = "charset_normalizer-3.4.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:9289fd5dddcf57bab41d044f1756550f9e7cf0c8e373b8cdf0ce8773dc4bd417"}, - {file = "charset_normalizer-3.4.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6b493a043635eb376e50eedf7818f2f322eabbaa974e948bd8bdd29eb7ef2a51"}, - {file = "charset_normalizer-3.4.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9fa2566ca27d67c86569e8c85297aaf413ffab85a8960500f12ea34ff98e4c41"}, - {file = "charset_normalizer-3.4.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a8e538f46104c815be19c975572d74afb53f29650ea2025bbfaef359d2de2f7f"}, - {file = "charset_normalizer-3.4.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6fd30dc99682dc2c603c2b315bded2799019cea829f8bf57dc6b61efde6611c8"}, - {file = "charset_normalizer-3.4.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2006769bd1640bdf4d5641c69a3d63b71b81445473cac5ded39740a226fa88ab"}, - {file = "charset_normalizer-3.4.0-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:dc15e99b2d8a656f8e666854404f1ba54765871104e50c8e9813af8a7db07f12"}, - {file = "charset_normalizer-3.4.0-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:ab2e5bef076f5a235c3774b4f4028a680432cded7cad37bba0fd90d64b187d19"}, - {file = "charset_normalizer-3.4.0-cp38-cp38-musllinux_1_2_ppc64le.whl", hash = "sha256:4ec9dd88a5b71abfc74e9df5ebe7921c35cbb3b641181a531ca65cdb5e8e4dea"}, - {file = "charset_normalizer-3.4.0-cp38-cp38-musllinux_1_2_s390x.whl", hash = "sha256:43193c5cda5d612f247172016c4bb71251c784d7a4d9314677186a838ad34858"}, - {file = "charset_normalizer-3.4.0-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:aa693779a8b50cd97570e5a0f343538a8dbd3e496fa5dcb87e29406ad0299654"}, - {file = "charset_normalizer-3.4.0-cp38-cp38-win32.whl", hash = "sha256:7706f5850360ac01d80c89bcef1640683cc12ed87f42579dab6c5d3ed6888613"}, - {file = "charset_normalizer-3.4.0-cp38-cp38-win_amd64.whl", hash = "sha256:c3e446d253bd88f6377260d07c895816ebf33ffffd56c1c792b13bff9c3e1ade"}, - {file = "charset_normalizer-3.4.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:980b4f289d1d90ca5efcf07958d3eb38ed9c0b7676bf2831a54d4f66f9c27dfa"}, - {file = "charset_normalizer-3.4.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:f28f891ccd15c514a0981f3b9db9aa23d62fe1a99997512b0491d2ed323d229a"}, - {file = "charset_normalizer-3.4.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a8aacce6e2e1edcb6ac625fb0f8c3a9570ccc7bfba1f63419b3769ccf6a00ed0"}, - {file = "charset_normalizer-3.4.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bd7af3717683bea4c87acd8c0d3d5b44d56120b26fd3f8a692bdd2d5260c620a"}, - {file = "charset_normalizer-3.4.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5ff2ed8194587faf56555927b3aa10e6fb69d931e33953943bc4f837dfee2242"}, - {file = "charset_normalizer-3.4.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e91f541a85298cf35433bf66f3fab2a4a2cff05c127eeca4af174f6d497f0d4b"}, - {file = "charset_normalizer-3.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:309a7de0a0ff3040acaebb35ec45d18db4b28232f21998851cfa709eeff49d62"}, - {file = "charset_normalizer-3.4.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:285e96d9d53422efc0d7a17c60e59f37fbf3dfa942073f666db4ac71e8d726d0"}, - {file = "charset_normalizer-3.4.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:5d447056e2ca60382d460a604b6302d8db69476fd2015c81e7c35417cfabe4cd"}, - {file = "charset_normalizer-3.4.0-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:20587d20f557fe189b7947d8e7ec5afa110ccf72a3128d61a2a387c3313f46be"}, - {file = "charset_normalizer-3.4.0-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:130272c698667a982a5d0e626851ceff662565379baf0ff2cc58067b81d4f11d"}, - {file = "charset_normalizer-3.4.0-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:ab22fbd9765e6954bc0bcff24c25ff71dcbfdb185fcdaca49e81bac68fe724d3"}, - {file = "charset_normalizer-3.4.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:7782afc9b6b42200f7362858f9e73b1f8316afb276d316336c0ec3bd73312742"}, - {file = "charset_normalizer-3.4.0-cp39-cp39-win32.whl", hash = "sha256:2de62e8801ddfff069cd5c504ce3bc9672b23266597d4e4f50eda28846c322f2"}, - {file = "charset_normalizer-3.4.0-cp39-cp39-win_amd64.whl", hash = "sha256:95c3c157765b031331dd4db3c775e58deaee050a3042fcad72cbc4189d7c8dca"}, - {file = "charset_normalizer-3.4.0-py3-none-any.whl", hash = "sha256:fe9f97feb71aa9896b81973a7bbada8c49501dc73e58a10fcef6663af95e5079"}, - {file = "charset_normalizer-3.4.0.tar.gz", hash = "sha256:223217c3d4f82c3ac5e29032b3f1c2eb0fb591b72161f86d93f5719079dae93e"}, -] - [[package]] name = "click" version = "8.1.7" @@ -670,6 +578,63 @@ Werkzeug = ">=3.0.0" async = ["asgiref (>=3.2)"] dotenv = ["python-dotenv"] +[[package]] +name = "h11" +version = "0.14.0" +description = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1" +optional = false +python-versions = ">=3.7" +files = [ + {file = "h11-0.14.0-py3-none-any.whl", hash = "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761"}, + {file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"}, +] + +[[package]] +name = "httpcore" +version = "1.0.6" +description = "A minimal low-level HTTP client." +optional = false +python-versions = ">=3.8" +files = [ + {file = "httpcore-1.0.6-py3-none-any.whl", hash = "sha256:27b59625743b85577a8c0e10e55b50b5368a4f2cfe8cc7bcfa9cf00829c2682f"}, + {file = "httpcore-1.0.6.tar.gz", hash = "sha256:73f6dbd6eb8c21bbf7ef8efad555481853f5f6acdeaff1edb0694289269ee17f"}, +] + +[package.dependencies] +certifi = "*" +h11 = ">=0.13,<0.15" + +[package.extras] +asyncio = ["anyio (>=4.0,<5.0)"] +http2 = ["h2 (>=3,<5)"] +socks = ["socksio (==1.*)"] +trio = ["trio (>=0.22.0,<1.0)"] + +[[package]] +name = "httpx" +version = "0.27.2" +description = "The next generation HTTP client." +optional = false +python-versions = ">=3.8" +files = [ + {file = "httpx-0.27.2-py3-none-any.whl", hash = "sha256:7bb2708e112d8fdd7829cd4243970f0c223274051cb35ee80c03301ee29a3df0"}, + {file = "httpx-0.27.2.tar.gz", hash = "sha256:f7c2be1d2f3c3c3160d441802406b206c2b76f5947b11115e6df10c6c65e66c2"}, +] + +[package.dependencies] +anyio = "*" +certifi = "*" +httpcore = "==1.*" +idna = "*" +sniffio = "*" + +[package.extras] +brotli = ["brotli", "brotlicffi"] +cli = ["click (==8.*)", "pygments (==2.*)", "rich (>=10,<14)"] +http2 = ["h2 (>=3,<5)"] +socks = ["socksio (==1.*)"] +zstd = ["zstandard (>=0.18.0)"] + [[package]] name = "identify" version = "2.6.1" @@ -1106,21 +1071,21 @@ files = [ [[package]] name = "pyjwt" -version = "2.9.0" +version = "2.4.0" description = "JSON Web Token implementation in Python" optional = false -python-versions = ">=3.8" +python-versions = ">=3.6" files = [ - {file = "PyJWT-2.9.0-py3-none-any.whl", hash = "sha256:3b02fb0f44517787776cf48f2ae25d8e14f300e6d7545a4315cee571a415e850"}, - {file = "pyjwt-2.9.0.tar.gz", hash = "sha256:7e1e5b56cc735432a7369cbfa0efe50fa113ebecdc04ae6922deba8b84582d0c"}, + {file = "PyJWT-2.4.0-py3-none-any.whl", hash = "sha256:72d1d253f32dbd4f5c88eaf1fdc62f3a19f676ccbadb9dbc5d07e951b2b26daf"}, + {file = "PyJWT-2.4.0.tar.gz", hash = "sha256:d42908208c699b3b973cbeb01a969ba6a96c821eefb1c5bfe4c390c01d67abba"}, ] [package.dependencies] -cryptography = {version = ">=3.4.0", optional = true, markers = "extra == \"crypto\""} +cryptography = {version = ">=3.3.1", optional = true, markers = "extra == \"crypto\""} [package.extras] -crypto = ["cryptography (>=3.4.0)"] -dev = ["coverage[toml] (==5.0.4)", "cryptography (>=3.4.0)", "pre-commit", "pytest (>=6.0.0,<7.0.0)", "sphinx", "sphinx-rtd-theme", "zope.interface"] +crypto = ["cryptography (>=3.3.1)"] +dev = ["coverage[toml] (==5.0.4)", "cryptography (>=3.3.1)", "mypy", "pre-commit", "pytest (>=6.0.0,<7.0.0)", "sphinx", "sphinx-rtd-theme", "zope.interface"] docs = ["sphinx", "sphinx-rtd-theme", "zope.interface"] tests = ["coverage[toml] (==5.0.4)", "pytest (>=6.0.0,<7.0.0)"] @@ -1227,27 +1192,6 @@ files = [ {file = "pyyaml-6.0.2.tar.gz", hash = "sha256:d584d9ec91ad65861cc08d42e834324ef890a082e591037abe114850ff7bbc3e"}, ] -[[package]] -name = "requests" -version = "2.32.3" -description = "Python HTTP for Humans." -optional = false -python-versions = ">=3.8" -files = [ - {file = "requests-2.32.3-py3-none-any.whl", hash = "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6"}, - {file = "requests-2.32.3.tar.gz", hash = "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760"}, -] - -[package.dependencies] -certifi = ">=2017.4.17" -charset-normalizer = ">=2,<4" -idna = ">=2.5,<4" -urllib3 = ">=1.21.1,<3" - -[package.extras] -socks = ["PySocks (>=1.5.6,!=1.5.7)"] -use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] - [[package]] name = "semantic-version" version = "2.10.0" @@ -1263,6 +1207,17 @@ files = [ dev = ["Django (>=1.11)", "check-manifest", "colorama (<=0.4.1)", "coverage", "flake8", "nose2", "readme-renderer (<25.0)", "tox", "wheel", "zest.releaser[recommended]"] doc = ["Sphinx", "sphinx-rtd-theme"] +[[package]] +name = "sniffio" +version = "1.3.1" +description = "Sniff out which async library your code is running under" +optional = false +python-versions = ">=3.7" +files = [ + {file = "sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2"}, + {file = "sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc"}, +] + [[package]] name = "toml" version = "0.10.2" @@ -1424,4 +1379,4 @@ flask = ["Flask"] [metadata] lock-version = "2.0" python-versions = ">=3.8.1,<4.0" -content-hash = "ea7459a13a2299fe66c433750c4049ee31e4e36afd33b14a696b331cdbe01f66" +content-hash = "38cb484da5a4b4813ee6f8f6c54d6214d71c7fe1e6d88440c893e3903d5de37c" diff --git a/pyproject.toml b/pyproject.toml index ecf3e3a2..50bad95f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,18 +28,15 @@ packages = [{ include = "descope" }] [tool.poetry.extras] Flask = ["Flask"] - [tool.poetry.urls] "Bug Tracker" = "https://github.com/descope/python-sdk/issues" - [tool.poetry.dependencies] python = ">=3.8.1,<4.0" -requests = ">=2.27.0" -pyjwt = { version = ">=2.4.0", extras = ["crypto"] } +pyjwt = { version = "2.4.0", extras = ["crypto"] } email-validator = [{ version = ">=2,<3", python = ">=3.8" }] -liccheck = "^0.9.1" Flask = ">=2" +httpx = "^0.27.2" [tool.poetry.group.dev.dependencies] mock = "5.1.0" diff --git a/requirements.txt b/requirements.txt index 124ecec2..53481031 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,6 @@ +anyio==4.5.2 ; python_full_version >= "3.8.1" and python_version < "4.0" \ + --hash=sha256:23009af4ed04ce05991845451e11ef02fc7c5ed29179ac9a420e5ad0ac7ddc5b \ + --hash=sha256:c011ee36bc1e8ba40e5a81cb9df91925c218fe9b778554e0b56a21e1b5d4716f blinker==1.8.2 ; python_full_version >= "3.8.1" and python_version < "4.0" \ --hash=sha256:1779309f71bf239144b9399d06ae925637cf6634cf6bd131104184531bf67c01 \ --hash=sha256:8f77b09d3bf7c795e969e9486f39c2c5e9c39d4ee07424be2bc594ece9642d83 @@ -72,112 +75,6 @@ cffi==1.17.1 ; python_full_version >= "3.8.1" and python_version < "4.0" and pla --hash=sha256:f79fc4fc25f1c8698ff97788206bb3c2598949bfe0fef03d299eb1b5356ada99 \ --hash=sha256:f7f5baafcc48261359e14bcd6d9bff6d4b28d9103847c9e136694cb0501aef87 \ --hash=sha256:fc48c783f9c87e60831201f2cce7f3b2e4846bf4d8728eabe54d60700b318a0b -charset-normalizer==3.4.0 ; python_full_version >= "3.8.1" and python_version < "4.0" \ - --hash=sha256:0099d79bdfcf5c1f0c2c72f91516702ebf8b0b8ddd8905f97a8aecf49712c621 \ - --hash=sha256:0713f3adb9d03d49d365b70b84775d0a0d18e4ab08d12bc46baa6132ba78aaf6 \ - --hash=sha256:07afec21bbbbf8a5cc3651aa96b980afe2526e7f048fdfb7f1014d84acc8b6d8 \ - --hash=sha256:0b309d1747110feb25d7ed6b01afdec269c647d382c857ef4663bbe6ad95a912 \ - --hash=sha256:0d99dd8ff461990f12d6e42c7347fd9ab2532fb70e9621ba520f9e8637161d7c \ - --hash=sha256:0de7b687289d3c1b3e8660d0741874abe7888100efe14bd0f9fd7141bcbda92b \ - --hash=sha256:1110e22af8ca26b90bd6364fe4c763329b0ebf1ee213ba32b68c73de5752323d \ - --hash=sha256:130272c698667a982a5d0e626851ceff662565379baf0ff2cc58067b81d4f11d \ - --hash=sha256:136815f06a3ae311fae551c3df1f998a1ebd01ddd424aa5603a4336997629e95 \ - --hash=sha256:14215b71a762336254351b00ec720a8e85cada43b987da5a042e4ce3e82bd68e \ - --hash=sha256:1db4e7fefefd0f548d73e2e2e041f9df5c59e178b4c72fbac4cc6f535cfb1565 \ - --hash=sha256:1ffd9493de4c922f2a38c2bf62b831dcec90ac673ed1ca182fe11b4d8e9f2a64 \ - --hash=sha256:2006769bd1640bdf4d5641c69a3d63b71b81445473cac5ded39740a226fa88ab \ - --hash=sha256:20587d20f557fe189b7947d8e7ec5afa110ccf72a3128d61a2a387c3313f46be \ - --hash=sha256:223217c3d4f82c3ac5e29032b3f1c2eb0fb591b72161f86d93f5719079dae93e \ - --hash=sha256:27623ba66c183eca01bf9ff833875b459cad267aeeb044477fedac35e19ba907 \ - --hash=sha256:285e96d9d53422efc0d7a17c60e59f37fbf3dfa942073f666db4ac71e8d726d0 \ - --hash=sha256:2de62e8801ddfff069cd5c504ce3bc9672b23266597d4e4f50eda28846c322f2 \ - --hash=sha256:2f6c34da58ea9c1a9515621f4d9ac379871a8f21168ba1b5e09d74250de5ad62 \ - --hash=sha256:309a7de0a0ff3040acaebb35ec45d18db4b28232f21998851cfa709eeff49d62 \ - --hash=sha256:35c404d74c2926d0287fbd63ed5d27eb911eb9e4a3bb2c6d294f3cfd4a9e0c23 \ - --hash=sha256:3710a9751938947e6327ea9f3ea6332a09bf0ba0c09cae9cb1f250bd1f1549bc \ - --hash=sha256:3d59d125ffbd6d552765510e3f31ed75ebac2c7470c7274195b9161a32350284 \ - --hash=sha256:40d3ff7fc90b98c637bda91c89d51264a3dcf210cade3a2c6f838c7268d7a4ca \ - --hash=sha256:425c5f215d0eecee9a56cdb703203dda90423247421bf0d67125add85d0c4455 \ - --hash=sha256:43193c5cda5d612f247172016c4bb71251c784d7a4d9314677186a838ad34858 \ - --hash=sha256:44aeb140295a2f0659e113b31cfe92c9061622cadbc9e2a2f7b8ef6b1e29ef4b \ - --hash=sha256:47334db71978b23ebcf3c0f9f5ee98b8d65992b65c9c4f2d34c2eaf5bcaf0594 \ - --hash=sha256:4796efc4faf6b53a18e3d46343535caed491776a22af773f366534056c4e1fbc \ - --hash=sha256:4a51b48f42d9358460b78725283f04bddaf44a9358197b889657deba38f329db \ - --hash=sha256:4b67fdab07fdd3c10bb21edab3cbfe8cf5696f453afce75d815d9d7223fbe88b \ - --hash=sha256:4ec9dd88a5b71abfc74e9df5ebe7921c35cbb3b641181a531ca65cdb5e8e4dea \ - --hash=sha256:4f9fc98dad6c2eaa32fc3af1417d95b5e3d08aff968df0cd320066def971f9a6 \ - --hash=sha256:54b6a92d009cbe2fb11054ba694bc9e284dad30a26757b1e372a1fdddaf21920 \ - --hash=sha256:55f56e2ebd4e3bc50442fbc0888c9d8c94e4e06a933804e2af3e89e2f9c1c749 \ - --hash=sha256:5726cf76c982532c1863fb64d8c6dd0e4c90b6ece9feb06c9f202417a31f7dd7 \ - --hash=sha256:5d447056e2ca60382d460a604b6302d8db69476fd2015c81e7c35417cfabe4cd \ - --hash=sha256:5ed2e36c3e9b4f21dd9422f6893dec0abf2cca553af509b10cd630f878d3eb99 \ - --hash=sha256:5ff2ed8194587faf56555927b3aa10e6fb69d931e33953943bc4f837dfee2242 \ - --hash=sha256:62f60aebecfc7f4b82e3f639a7d1433a20ec32824db2199a11ad4f5e146ef5ee \ - --hash=sha256:63bc5c4ae26e4bc6be6469943b8253c0fd4e4186c43ad46e713ea61a0ba49129 \ - --hash=sha256:6b40e8d38afe634559e398cc32b1472f376a4099c75fe6299ae607e404c033b2 \ - --hash=sha256:6b493a043635eb376e50eedf7818f2f322eabbaa974e948bd8bdd29eb7ef2a51 \ - --hash=sha256:6dba5d19c4dfab08e58d5b36304b3f92f3bd5d42c1a3fa37b5ba5cdf6dfcbcee \ - --hash=sha256:6fd30dc99682dc2c603c2b315bded2799019cea829f8bf57dc6b61efde6611c8 \ - --hash=sha256:707b82d19e65c9bd28b81dde95249b07bf9f5b90ebe1ef17d9b57473f8a64b7b \ - --hash=sha256:7706f5850360ac01d80c89bcef1640683cc12ed87f42579dab6c5d3ed6888613 \ - --hash=sha256:7782afc9b6b42200f7362858f9e73b1f8316afb276d316336c0ec3bd73312742 \ - --hash=sha256:79983512b108e4a164b9c8d34de3992f76d48cadc9554c9e60b43f308988aabe \ - --hash=sha256:7f683ddc7eedd742e2889d2bfb96d69573fde1d92fcb811979cdb7165bb9c7d3 \ - --hash=sha256:82357d85de703176b5587dbe6ade8ff67f9f69a41c0733cf2425378b49954de5 \ - --hash=sha256:84450ba661fb96e9fd67629b93d2941c871ca86fc38d835d19d4225ff946a631 \ - --hash=sha256:86f4e8cca779080f66ff4f191a685ced73d2f72d50216f7112185dc02b90b9b7 \ - --hash=sha256:8cda06946eac330cbe6598f77bb54e690b4ca93f593dee1568ad22b04f347c15 \ - --hash=sha256:8ce7fd6767a1cc5a92a639b391891bf1c268b03ec7e021c7d6d902285259685c \ - --hash=sha256:8ff4e7cdfdb1ab5698e675ca622e72d58a6fa2a8aa58195de0c0061288e6e3ea \ - --hash=sha256:9289fd5dddcf57bab41d044f1756550f9e7cf0c8e373b8cdf0ce8773dc4bd417 \ - --hash=sha256:92a7e36b000bf022ef3dbb9c46bfe2d52c047d5e3f3343f43204263c5addc250 \ - --hash=sha256:92db3c28b5b2a273346bebb24857fda45601aef6ae1c011c0a997106581e8a88 \ - --hash=sha256:95c3c157765b031331dd4db3c775e58deaee050a3042fcad72cbc4189d7c8dca \ - --hash=sha256:980b4f289d1d90ca5efcf07958d3eb38ed9c0b7676bf2831a54d4f66f9c27dfa \ - --hash=sha256:9ae4ef0b3f6b41bad6366fb0ea4fc1d7ed051528e113a60fa2a65a9abb5b1d99 \ - --hash=sha256:9c98230f5042f4945f957d006edccc2af1e03ed5e37ce7c373f00a5a4daa6149 \ - --hash=sha256:9fa2566ca27d67c86569e8c85297aaf413ffab85a8960500f12ea34ff98e4c41 \ - --hash=sha256:a14969b8691f7998e74663b77b4c36c0337cb1df552da83d5c9004a93afdb574 \ - --hash=sha256:a8aacce6e2e1edcb6ac625fb0f8c3a9570ccc7bfba1f63419b3769ccf6a00ed0 \ - --hash=sha256:a8e538f46104c815be19c975572d74afb53f29650ea2025bbfaef359d2de2f7f \ - --hash=sha256:aa41e526a5d4a9dfcfbab0716c7e8a1b215abd3f3df5a45cf18a12721d31cb5d \ - --hash=sha256:aa693779a8b50cd97570e5a0f343538a8dbd3e496fa5dcb87e29406ad0299654 \ - --hash=sha256:ab22fbd9765e6954bc0bcff24c25ff71dcbfdb185fcdaca49e81bac68fe724d3 \ - --hash=sha256:ab2e5bef076f5a235c3774b4f4028a680432cded7cad37bba0fd90d64b187d19 \ - --hash=sha256:ab973df98fc99ab39080bfb0eb3a925181454d7c3ac8a1e695fddfae696d9e90 \ - --hash=sha256:af73657b7a68211996527dbfeffbb0864e043d270580c5aef06dc4b659a4b578 \ - --hash=sha256:b197e7094f232959f8f20541ead1d9862ac5ebea1d58e9849c1bf979255dfac9 \ - --hash=sha256:b295729485b06c1a0683af02a9e42d2caa9db04a373dc38a6a58cdd1e8abddf1 \ - --hash=sha256:b8831399554b92b72af5932cdbbd4ddc55c55f631bb13ff8fe4e6536a06c5c51 \ - --hash=sha256:b8dcd239c743aa2f9c22ce674a145e0a25cb1566c495928440a181ca1ccf6719 \ - --hash=sha256:bcb4f8ea87d03bc51ad04add8ceaf9b0f085ac045ab4d74e73bbc2dc033f0236 \ - --hash=sha256:bd7af3717683bea4c87acd8c0d3d5b44d56120b26fd3f8a692bdd2d5260c620a \ - --hash=sha256:bf4475b82be41b07cc5e5ff94810e6a01f276e37c2d55571e3fe175e467a1a1c \ - --hash=sha256:c3e446d253bd88f6377260d07c895816ebf33ffffd56c1c792b13bff9c3e1ade \ - --hash=sha256:c57516e58fd17d03ebe67e181a4e4e2ccab1168f8c2976c6a334d4f819fe5944 \ - --hash=sha256:c94057af19bc953643a33581844649a7fdab902624d2eb739738a30e2b3e60fc \ - --hash=sha256:cab5d0b79d987c67f3b9e9c53f54a61360422a5a0bc075f43cab5621d530c3b6 \ - --hash=sha256:ce031db0408e487fd2775d745ce30a7cd2923667cf3b69d48d219f1d8f5ddeb6 \ - --hash=sha256:cee4373f4d3ad28f1ab6290684d8e2ebdb9e7a1b74fdc39e4c211995f77bec27 \ - --hash=sha256:d5b054862739d276e09928de37c79ddeec42a6e1bfc55863be96a36ba22926f6 \ - --hash=sha256:dbe03226baf438ac4fda9e2d0715022fd579cb641c4cf639fa40d53b2fe6f3e2 \ - --hash=sha256:dc15e99b2d8a656f8e666854404f1ba54765871104e50c8e9813af8a7db07f12 \ - --hash=sha256:dcaf7c1524c0542ee2fc82cc8ec337f7a9f7edee2532421ab200d2b920fc97cf \ - --hash=sha256:dd4eda173a9fcccb5f2e2bd2a9f423d180194b1bf17cf59e3269899235b2a114 \ - --hash=sha256:dd9a8bd8900e65504a305bf8ae6fa9fbc66de94178c420791d0293702fce2df7 \ - --hash=sha256:de7376c29d95d6719048c194a9cf1a1b0393fbe8488a22008610b0361d834ecf \ - --hash=sha256:e7fdd52961feb4c96507aa649550ec2a0d527c086d284749b2f582f2d40a2e0d \ - --hash=sha256:e91f541a85298cf35433bf66f3fab2a4a2cff05c127eeca4af174f6d497f0d4b \ - --hash=sha256:e9e3c4c9e1ed40ea53acf11e2a386383c3304212c965773704e4603d589343ed \ - --hash=sha256:ee803480535c44e7f5ad00788526da7d85525cfefaf8acf8ab9a310000be4b03 \ - --hash=sha256:f09cb5a7bbe1ecae6e87901a2eb23e0256bb524a79ccc53eb0b7629fbe7677c4 \ - --hash=sha256:f19c1585933c82098c2a520f8ec1227f20e339e33aca8fa6f956f6691b784e67 \ - --hash=sha256:f1a2f519ae173b5b6a2c9d5fa3116ce16e48b3462c8b96dfdded11055e3d6365 \ - --hash=sha256:f28f891ccd15c514a0981f3b9db9aa23d62fe1a99997512b0491d2ed323d229a \ - --hash=sha256:f3e73a4255342d4eb26ef6df01e3962e73aa29baa3124a8e824c5d3364a65748 \ - --hash=sha256:f606a1881d2663630ea5b8ce2efe2111740df4b687bd78b34a8131baa007f79b \ - --hash=sha256:fe9f97feb71aa9896b81973a7bbada8c49501dc73e58a10fcef6663af95e5079 \ - --hash=sha256:ffc519621dce0c767e96b9c53f09c5d215578e10b02c285809f76509a3931482 click==8.1.7 ; python_full_version >= "3.8.1" and python_version < "4.0" \ --hash=sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28 \ --hash=sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de @@ -218,9 +115,21 @@ dnspython==2.6.1 ; python_full_version >= "3.8.1" and python_version < "4.0" \ email-validator==2.2.0 ; python_full_version >= "3.8.1" and python_version < "4.0" \ --hash=sha256:561977c2d73ce3611850a06fa56b414621e0c8faa9d66f2611407d87465da631 \ --hash=sha256:cb690f344c617a714f22e66ae771445a1ceb46821152df8e165c5f9a364582b7 +exceptiongroup==1.2.2 ; python_full_version >= "3.8.1" and python_version < "3.11" \ + --hash=sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b \ + --hash=sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc flask==3.0.3 ; python_full_version >= "3.8.1" and python_version < "4.0" \ --hash=sha256:34e815dfaa43340d1d15a5c3a02b8476004037eb4840b34910c6e21679d288f3 \ --hash=sha256:ceb27b0af3823ea2737928a4d99d125a06175b8512c445cbd9a9ce200ef76842 +h11==0.14.0 ; python_full_version >= "3.8.1" and python_version < "4.0" \ + --hash=sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d \ + --hash=sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761 +httpcore==1.0.6 ; python_full_version >= "3.8.1" and python_version < "4.0" \ + --hash=sha256:27b59625743b85577a8c0e10e55b50b5368a4f2cfe8cc7bcfa9cf00829c2682f \ + --hash=sha256:73f6dbd6eb8c21bbf7ef8efad555481853f5f6acdeaff1edb0694289269ee17f +httpx==0.27.2 ; python_full_version >= "3.8.1" and python_version < "4.0" \ + --hash=sha256:7bb2708e112d8fdd7829cd4243970f0c223274051cb35ee80c03301ee29a3df0 \ + --hash=sha256:f7c2be1d2f3c3c3160d441802406b206c2b76f5947b11115e6df10c6c65e66c2 idna==3.10 ; python_full_version >= "3.8.1" and python_version < "4.0" \ --hash=sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9 \ --hash=sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3 @@ -233,9 +142,6 @@ itsdangerous==2.2.0 ; python_full_version >= "3.8.1" and python_version < "4.0" jinja2==3.1.4 ; python_full_version >= "3.8.1" and python_version < "4.0" \ --hash=sha256:4a3aee7acbbe7303aede8e9648d13b8bf88a429282aa6122a993f0ac800cb369 \ --hash=sha256:bc5dd2abb727a5319567b7a813e6a2e7318c39f4f487cfe6c89c6f9c7d25197d -liccheck==0.9.2 ; python_full_version >= "3.8.1" and python_version < "4.0" \ - --hash=sha256:15cbedd042515945fe9d58b62e0a5af2f2a7795def216f163bb35b3016a16637 \ - --hash=sha256:bdc2190f8e95af3c8f9c19edb784ba7d41ecb2bf9189422eae6112bf84c08cd5 markupsafe==2.1.5 ; python_full_version >= "3.8.1" and python_version < "4.0" \ --hash=sha256:00e046b6dd71aa03a41079792f8473dc494d564611a8f89bbbd7cb93295ebdcf \ --hash=sha256:075202fa5b72c86ad32dc7d0b56024ebdbcf2048c0ba09f1cde31bfdd57bcfff \ @@ -300,21 +206,15 @@ markupsafe==2.1.5 ; python_full_version >= "3.8.1" and python_version < "4.0" \ pycparser==2.22 ; python_full_version >= "3.8.1" and python_version < "4.0" and platform_python_implementation != "PyPy" \ --hash=sha256:491c8be9c040f5390f5bf44a5b07752bd07f56edf992381b05c701439eec10f6 \ --hash=sha256:c3702b6d3dd8c7abc1afa565d7e63d53a1d0bd86cdc24edd75470f4de499cfcc -pyjwt[crypto]==2.9.0 ; python_full_version >= "3.8.1" and python_version < "4.0" \ - --hash=sha256:3b02fb0f44517787776cf48f2ae25d8e14f300e6d7545a4315cee571a415e850 \ - --hash=sha256:7e1e5b56cc735432a7369cbfa0efe50fa113ebecdc04ae6922deba8b84582d0c -requests==2.32.3 ; python_full_version >= "3.8.1" and python_version < "4.0" \ - --hash=sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760 \ - --hash=sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6 -semantic-version==2.10.0 ; python_full_version >= "3.8.1" and python_version < "4.0" \ - --hash=sha256:bdabb6d336998cbb378d4b9db3a4b56a1e3235701dc05ea2690d9a997ed5041c \ - --hash=sha256:de78a3b8e0feda74cabc54aab2da702113e33ac9d9eb9d2389bcf1f58b7d9177 -toml==0.10.2 ; python_full_version >= "3.8.1" and python_version < "4.0" \ - --hash=sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b \ - --hash=sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f -urllib3==2.2.3 ; python_full_version >= "3.8.1" and python_version < "4.0" \ - --hash=sha256:ca899ca043dcb1bafa3e262d73aa25c465bfb49e0bd9dd5d59f1d0acba2f8fac \ - --hash=sha256:e7d814a81dad81e6caf2ec9fdedb284ecc9c73076b62654547cc64ccdcae26e9 +pyjwt[crypto]==2.4.0 ; python_full_version >= "3.8.1" and python_version < "4.0" \ + --hash=sha256:72d1d253f32dbd4f5c88eaf1fdc62f3a19f676ccbadb9dbc5d07e951b2b26daf \ + --hash=sha256:d42908208c699b3b973cbeb01a969ba6a96c821eefb1c5bfe4c390c01d67abba +sniffio==1.3.1 ; python_full_version >= "3.8.1" and python_version < "4.0" \ + --hash=sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2 \ + --hash=sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc +typing-extensions==4.12.2 ; python_full_version >= "3.8.1" and python_version < "3.11" \ + --hash=sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d \ + --hash=sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8 werkzeug==3.0.6 ; python_full_version >= "3.8.1" and python_version < "4.0" \ --hash=sha256:1bc0c2310d2fbb07b1dd1105eba2f7af72f322e1e455f2f93c993bee8c8a5f17 \ --hash=sha256:a8dd59d4de28ca70471a34cba79bed5f7ef2e036a76b3ab0835474246eb41f8d diff --git a/tests/management/test_access_key.py b/tests/management/test_access_key.py index c0e907b3..19bbc6fd 100644 --- a/tests/management/test_access_key.py +++ b/tests/management/test_access_key.py @@ -33,7 +33,7 @@ def test_create(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -42,7 +42,7 @@ def test_create(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -83,7 +83,7 @@ def test_create(self): "description": "this is my access key", "permittedIps": ["10.0.0.1", "192.168.1.0/24"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -97,7 +97,7 @@ def test_load(self): ) # Test failed flows - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: mock_get.return_value.ok = False self.assertRaises( AuthException, @@ -106,7 +106,7 @@ def test_load(self): ) # Test success flow - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"key": {"id": "ak1"}}""") @@ -121,7 +121,7 @@ def test_load(self): "Authorization": f"Bearer {self.dummy_project_id}:{self.dummy_management_key}", }, params={"id": "key-id"}, - allow_redirects=None, + follow_redirects=None, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -135,7 +135,7 @@ def test_search_all_users(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -144,7 +144,7 @@ def test_search_all_users(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -166,7 +166,7 @@ def test_search_all_users(self): json={ "tenantIds": ["t1, t2"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -180,7 +180,7 @@ def test_update(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -190,7 +190,7 @@ def test_update(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( client.mgmt.access_key.update( @@ -209,7 +209,7 @@ def test_update(self): "name": "new-name", "description": None, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -223,7 +223,7 @@ def test_deactivate(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -232,7 +232,7 @@ def test_deactivate(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone(client.mgmt.access_key.deactivate("ak1")) mock_post.assert_called_with( @@ -245,7 +245,7 @@ def test_deactivate(self): json={ "id": "ak1", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -259,7 +259,7 @@ def test_activate(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -268,7 +268,7 @@ def test_activate(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone(client.mgmt.access_key.activate("ak1")) mock_post.assert_called_with( @@ -281,7 +281,7 @@ def test_activate(self): json={ "id": "ak1", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -295,7 +295,7 @@ def test_delete(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -304,7 +304,7 @@ def test_delete(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone(client.mgmt.access_key.delete("ak1")) mock_post.assert_called_with( @@ -317,7 +317,7 @@ def test_delete(self): json={ "id": "ak1", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) diff --git a/tests/management/test_audit.py b/tests/management/test_audit.py index ead0065c..8c579326 100644 --- a/tests/management/test_audit.py +++ b/tests/management/test_audit.py @@ -33,7 +33,7 @@ def test_search(self): ) # Test failed search - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -42,7 +42,7 @@ def test_search(self): ) # Test success search - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = { @@ -76,7 +76,7 @@ def test_search(self): }, params=None, json={"noTenants": False}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -90,14 +90,14 @@ def test_create_event(self): ) # Test failed search - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, client.mgmt.audit.create_event, "a", "b", "c", "d" ) # Test success search - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = {} @@ -125,7 +125,7 @@ def test_create_event(self): "type": "info", "data": {"some": "data"}, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) diff --git a/tests/management/test_authz.py b/tests/management/test_authz.py index f99516db..c139bd12 100644 --- a/tests/management/test_authz.py +++ b/tests/management/test_authz.py @@ -31,12 +31,12 @@ def test_save_schema(self): ) # Test failed save_schema - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, client.mgmt.authz.save_schema, {}, True) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone(client.mgmt.authz.save_schema({"name": "kuku"}, True)) mock_post.assert_called_with( @@ -47,7 +47,7 @@ def test_save_schema(self): }, params=None, json={"schema": {"name": "kuku"}, "upgrade": True}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -61,12 +61,12 @@ def test_delete_schema(self): ) # Test failed delete_schema - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, client.mgmt.authz.delete_schema) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone(client.mgmt.authz.delete_schema()) mock_post.assert_called_with( @@ -77,7 +77,7 @@ def test_delete_schema(self): }, params=None, json=None, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -91,12 +91,12 @@ def test_load_schema(self): ) # Test failed load_schema - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, client.mgmt.authz.load_schema) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(client.mgmt.authz.load_schema()) mock_post.assert_called_with( @@ -107,7 +107,7 @@ def test_load_schema(self): }, params=None, json=None, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -121,12 +121,12 @@ def test_save_namespace(self): ) # Test failed save_namespace - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, client.mgmt.authz.save_namespace, {}) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( client.mgmt.authz.save_namespace({"name": "kuku"}, "old", "v1") @@ -143,7 +143,7 @@ def test_save_namespace(self): "oldName": "old", "schemaName": "v1", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -157,12 +157,12 @@ def test_delete_namespace(self): ) # Test failed delete_namespace - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, client.mgmt.authz.delete_namespace, "a") # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone(client.mgmt.authz.delete_namespace("a", "b")) mock_post.assert_called_with( @@ -173,7 +173,7 @@ def test_delete_namespace(self): }, params=None, json={"name": "a", "schemaName": "b"}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -187,14 +187,14 @@ def test_save_relation_definition(self): ) # Test failed save_relation_definition - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, client.mgmt.authz.save_relation_definition, {}, "a" ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( client.mgmt.authz.save_relation_definition( @@ -214,7 +214,7 @@ def test_save_relation_definition(self): "oldName": "old", "schemaName": "v1", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -228,14 +228,14 @@ def test_delete_relation_definition(self): ) # Test failed delete_relation_definition - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, client.mgmt.authz.delete_relation_definition, "a", "b" ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( client.mgmt.authz.delete_relation_definition("a", "b", "c") @@ -248,7 +248,7 @@ def test_delete_relation_definition(self): }, params=None, json={"name": "a", "namespace": "b", "schemaName": "c"}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -262,12 +262,12 @@ def test_create_relations(self): ) # Test failed create_relations - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, client.mgmt.authz.create_relations, []) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( client.mgmt.authz.create_relations( @@ -298,7 +298,7 @@ def test_create_relations(self): } ] }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -312,12 +312,12 @@ def test_delete_relations(self): ) # Test failed delete_relations - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, client.mgmt.authz.delete_relations, []) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( client.mgmt.authz.delete_relations( @@ -348,7 +348,7 @@ def test_delete_relations(self): } ] }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -362,14 +362,14 @@ def test_delete_relations_for_resources(self): ) # Test failed delete_relations_for_resources - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, client.mgmt.authz.delete_relations_for_resources, [] ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone(client.mgmt.authz.delete_relations_for_resources(["r"])) mock_post.assert_called_with( @@ -380,7 +380,7 @@ def test_delete_relations_for_resources(self): }, params=None, json={"resources": ["r"]}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -394,12 +394,12 @@ def test_has_relations(self): ) # Test failed has_relations - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, client.mgmt.authz.has_relations, []) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone( client.mgmt.authz.has_relations( @@ -430,7 +430,7 @@ def test_has_relations(self): } ] }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -444,14 +444,14 @@ def test_who_can_access(self): ) # Test failed who_can_access - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, client.mgmt.authz.who_can_access, "a", "b", "c" ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(client.mgmt.authz.who_can_access("a", "b", "c")) mock_post.assert_called_with( @@ -462,7 +462,7 @@ def test_who_can_access(self): }, params=None, json={"resource": "a", "relationDefinition": "b", "namespace": "c"}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -476,12 +476,12 @@ def test_resource_relations(self): ) # Test failed resource_relations - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, client.mgmt.authz.resource_relations, "a") # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(client.mgmt.authz.resource_relations("a")) mock_post.assert_called_with( @@ -492,7 +492,7 @@ def test_resource_relations(self): }, params=None, json={"resource": "a"}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -506,12 +506,12 @@ def test_targets_relations(self): ) # Test failed targets_relations - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, client.mgmt.authz.targets_relations, ["a"]) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(client.mgmt.authz.targets_relations(["a"])) mock_post.assert_called_with( @@ -522,7 +522,7 @@ def test_targets_relations(self): }, params=None, json={"targets": ["a"]}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -536,14 +536,14 @@ def test_what_can_target_access(self): ) # Test failed what_can_target_access - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, client.mgmt.authz.what_can_target_access, "a" ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(client.mgmt.authz.what_can_target_access("a")) mock_post.assert_called_with( @@ -554,7 +554,7 @@ def test_what_can_target_access(self): }, params=None, json={"target": "a"}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -568,7 +568,7 @@ def test_what_can_target_access_with_relation(self): ) # Test failed what_can_target_access_with_relation - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -579,7 +579,7 @@ def test_what_can_target_access_with_relation(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone( client.mgmt.authz.what_can_target_access_with_relation("a", "b", "c") @@ -592,7 +592,7 @@ def test_what_can_target_access_with_relation(self): }, params=None, json={"target": "a", "relationDefinition": "b", "namespace": "c"}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -606,12 +606,12 @@ def test_get_modified(self): ) # Test failed get_modified - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, client.mgmt.authz.get_modified) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(client.mgmt.authz.get_modified()) mock_post.assert_called_with( @@ -622,7 +622,7 @@ def test_get_modified(self): }, params=None, json={"since": 0}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) diff --git a/tests/management/test_flow.py b/tests/management/test_flow.py index b0951512..9be52e83 100644 --- a/tests/management/test_flow.py +++ b/tests/management/test_flow.py @@ -31,7 +31,7 @@ def test_list_flows(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -39,7 +39,7 @@ def test_list_flows(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(client.mgmt.flow.list_flows()) mock_post.assert_called_with( @@ -50,7 +50,7 @@ def test_list_flows(self): }, params=None, json=None, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -64,7 +64,7 @@ def test_delete_flows(self): ) # Test failed delete flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -73,7 +73,7 @@ def test_delete_flows(self): ) # Test success delete flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(client.mgmt.flow.delete_flows(["flow-1", "flow-2"])) mock_post.assert_called_with( @@ -84,7 +84,7 @@ def test_delete_flows(self): }, params=None, json={"ids": ["flow-1", "flow-2"]}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -98,7 +98,7 @@ def test_export_flow(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -107,7 +107,7 @@ def test_export_flow(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(client.mgmt.flow.export_flow("test")) mock_post.assert_called_with( @@ -120,7 +120,7 @@ def test_export_flow(self): json={ "flowId": "test", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -134,7 +134,7 @@ def test_import_flow(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -145,7 +145,7 @@ def test_import_flow(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone( client.mgmt.flow.import_flow("name", {"name": "test"}, [{"id": "test"}]) @@ -162,7 +162,7 @@ def test_import_flow(self): "flow": {"name": "test"}, "screens": [{"id": "test"}], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -176,12 +176,12 @@ def test_export_theme(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, client.mgmt.flow.export_theme) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(client.mgmt.flow.export_theme()) mock_post.assert_called_with( @@ -192,7 +192,7 @@ def test_export_theme(self): }, params=None, json={}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -206,14 +206,14 @@ def test_import_theme(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, client.mgmt.flow.import_theme, {"id": "test"} ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(client.mgmt.flow.import_theme({"id": "test"})) mock_post.assert_called_with( @@ -224,7 +224,7 @@ def test_import_theme(self): }, params=None, json={"theme": {"id": "test"}}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) diff --git a/tests/management/test_group.py b/tests/management/test_group.py index 27d334c8..81af0145 100644 --- a/tests/management/test_group.py +++ b/tests/management/test_group.py @@ -31,7 +31,7 @@ def test_load_all_groups(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -40,7 +40,7 @@ def test_load_all_groups(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(client.mgmt.group.load_all_groups("someTenantId")) mock_post.assert_called_with( @@ -53,7 +53,7 @@ def test_load_all_groups(self): json={ "tenantId": "someTenantId", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -67,7 +67,7 @@ def test_load_all_groups_for_members(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -76,7 +76,7 @@ def test_load_all_groups_for_members(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone( client.mgmt.group.load_all_groups_for_members( @@ -95,7 +95,7 @@ def test_load_all_groups_for_members(self): "loginIds": ["three", "four"], "userIds": ["one", "two"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -109,7 +109,7 @@ def test_load_all_group_members(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -119,7 +119,7 @@ def test_load_all_group_members(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone( client.mgmt.group.load_all_group_members("someTenantId", "someGroupId") @@ -135,7 +135,7 @@ def test_load_all_group_members(self): "tenantId": "someTenantId", "groupId": "someGroupId", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) diff --git a/tests/management/test_jwt.py b/tests/management/test_jwt.py index db027fa0..b748f5e2 100644 --- a/tests/management/test_jwt.py +++ b/tests/management/test_jwt.py @@ -33,7 +33,7 @@ def test_update_jwt(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, client.mgmt.jwt.update_jwt, "jwt", {"k1": "v1"} @@ -44,7 +44,7 @@ def test_update_jwt(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"jwt": "response"}""") @@ -59,7 +59,7 @@ def test_update_jwt(self): "Authorization": f"Bearer {self.dummy_project_id}:{self.dummy_management_key}", }, json={"jwt": "test", "customClaims": {"k1": "v1"}}, - allow_redirects=False, + follow_redirects=False, verify=True, params=None, timeout=DEFAULT_TIMEOUT_SECONDS, @@ -74,7 +74,7 @@ def test_impersonate(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, client.mgmt.jwt.impersonate, "imp1", "imp2", False @@ -89,7 +89,7 @@ def test_impersonate(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"jwt": "response"}""") @@ -108,7 +108,7 @@ def test_impersonate(self): "impersonatorId": "imp1", "validateConsent": True, }, - allow_redirects=False, + follow_redirects=False, verify=True, params=None, timeout=DEFAULT_TIMEOUT_SECONDS, diff --git a/tests/management/test_permission.py b/tests/management/test_permission.py index 2193b58b..bae6585b 100644 --- a/tests/management/test_permission.py +++ b/tests/management/test_permission.py @@ -33,7 +33,7 @@ def test_create(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -42,7 +42,7 @@ def test_create(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone(client.mgmt.permission.create("P1", "Something")) mock_post.assert_called_with( @@ -56,7 +56,7 @@ def test_create(self): "name": "P1", "description": "Something", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -70,7 +70,7 @@ def test_update(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -80,7 +80,7 @@ def test_update(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( client.mgmt.permission.update( @@ -101,7 +101,7 @@ def test_update(self): "newName": "new-name", "description": "new-description", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -115,7 +115,7 @@ def test_delete(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -124,7 +124,7 @@ def test_delete(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone(client.mgmt.permission.delete("name")) mock_post.assert_called_with( @@ -137,7 +137,7 @@ def test_delete(self): json={ "name": "name", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -151,12 +151,12 @@ def test_load_all(self): ) # Test failed flows - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: mock_get.return_value.ok = False self.assertRaises(AuthException, client.mgmt.permission.load_all) # Test success flow - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -175,7 +175,7 @@ def test_load_all(self): "Authorization": f"Bearer {self.dummy_project_id}:{self.dummy_management_key}", }, params=None, - allow_redirects=None, + follow_redirects=None, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) diff --git a/tests/management/test_project.py b/tests/management/test_project.py index d8d9fd27..efcf86dd 100644 --- a/tests/management/test_project.py +++ b/tests/management/test_project.py @@ -33,7 +33,7 @@ def test_update_name(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -42,7 +42,7 @@ def test_update_name(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone(client.mgmt.project.update_name("new-name")) mock_post.assert_called_with( @@ -55,7 +55,7 @@ def test_update_name(self): json={ "name": "new-name", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -69,7 +69,7 @@ def test_update_tags(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -78,7 +78,7 @@ def test_update_tags(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone(client.mgmt.project.update_tags(["tag1", "tag2"])) mock_post.assert_called_with( @@ -91,7 +91,7 @@ def test_update_tags(self): json={ "tags": ["tag1", "tag2"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -105,7 +105,7 @@ def test_list_projects(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -113,7 +113,7 @@ def test_list_projects(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True json_str = """ @@ -142,7 +142,7 @@ def test_list_projects(self): }, params=None, json={}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -156,7 +156,7 @@ def test_clone(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -167,7 +167,7 @@ def test_clone(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -196,7 +196,7 @@ def test_clone(self): "environment": "production", "tags": ["apple", "banana", "cherry"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -210,7 +210,7 @@ def test_export_project(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -218,7 +218,7 @@ def test_export_project(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -240,7 +240,7 @@ def test_export_project(self): }, params=None, json={}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -254,7 +254,7 @@ def test_import_project(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -265,7 +265,7 @@ def test_import_project(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True mock_post.return_value = network_resp @@ -285,7 +285,7 @@ def test_import_project(self): "foo": "bar", }, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) diff --git a/tests/management/test_role.py b/tests/management/test_role.py index b5170aff..cdfcb2b0 100644 --- a/tests/management/test_role.py +++ b/tests/management/test_role.py @@ -33,7 +33,7 @@ def test_create(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -42,7 +42,7 @@ def test_create(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone(client.mgmt.role.create("R1", "Something", ["P1"], "t1")) mock_post.assert_called_with( @@ -58,7 +58,7 @@ def test_create(self): "permissionNames": ["P1"], "tenantId": "t1", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -72,7 +72,7 @@ def test_update(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -82,7 +82,7 @@ def test_update(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( client.mgmt.role.update( @@ -107,7 +107,7 @@ def test_update(self): "permissionNames": ["P1", "P2"], "tenantId": "t1", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -121,7 +121,7 @@ def test_delete(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -130,7 +130,7 @@ def test_delete(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone(client.mgmt.role.delete("name")) mock_post.assert_called_with( @@ -141,7 +141,7 @@ def test_delete(self): }, params=None, json={"name": "name", "tenantId": None}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -155,12 +155,12 @@ def test_load_all(self): ) # Test failed flows - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: mock_get.return_value.ok = False self.assertRaises(AuthException, client.mgmt.role.load_all) # Test success flow - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -190,7 +190,7 @@ def test_load_all(self): "Authorization": f"Bearer {self.dummy_project_id}:{self.dummy_management_key}", }, params=None, - allow_redirects=None, + follow_redirects=None, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -204,7 +204,7 @@ def test_search(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -214,7 +214,7 @@ def test_search(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -250,7 +250,7 @@ def test_search(self): "roleNameLike": "x", "permissionNames": ["p1", "p2"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) diff --git a/tests/management/test_sso_application.py b/tests/management/test_sso_application.py index d4bc99cd..eac157e8 100644 --- a/tests/management/test_sso_application.py +++ b/tests/management/test_sso_application.py @@ -39,7 +39,7 @@ def test_create_oidc_application(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -49,7 +49,7 @@ def test_create_oidc_application(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"id": "app1"}""") @@ -76,7 +76,7 @@ def test_create_oidc_application(self): "logo": None, "forceAuthentication": True, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -108,7 +108,7 @@ def test_create_saml_application(self): entity_id="", ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -120,7 +120,7 @@ def test_create_saml_application(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"id": "app1"}""") @@ -186,7 +186,7 @@ def test_create_saml_application(self): "forceAuthentication": True, "logoutRedirectUrl": "http://dummy.com/logout", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -200,7 +200,7 @@ def test_update_oidc_application(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -211,7 +211,7 @@ def test_update_oidc_application(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True self.assertIsNone( @@ -235,7 +235,7 @@ def test_update_oidc_application(self): "logo": None, "forceAuthentication": False, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -269,7 +269,7 @@ def test_update_saml_application(self): entity_id="", ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -282,7 +282,7 @@ def test_update_saml_application(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True self.assertIsNone( @@ -348,7 +348,7 @@ def test_update_saml_application(self): "forceAuthentication": False, "logoutRedirectUrl": None, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -362,7 +362,7 @@ def test_delete(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -371,7 +371,7 @@ def test_delete(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone(client.mgmt.sso_application.delete("app1")) mock_post.assert_called_with( @@ -384,7 +384,7 @@ def test_delete(self): json={ "id": "app1", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -398,7 +398,7 @@ def test_load(self): ) # Test failed flows - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: mock_get.return_value.ok = False self.assertRaises( AuthException, @@ -407,7 +407,7 @@ def test_load(self): ) # Test success flow - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -447,7 +447,7 @@ def test_load(self): "Authorization": f"Bearer {self.dummy_project_id}:{self.dummy_management_key}", }, params={"id": "app1"}, - allow_redirects=None, + follow_redirects=None, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -461,12 +461,12 @@ def test_load_all(self): ) # Test failed flows - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: mock_get.return_value.ok = False self.assertRaises(AuthException, client.mgmt.sso_application.load_all) # Test success flow - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -527,7 +527,7 @@ def test_load_all(self): "Authorization": f"Bearer {self.dummy_project_id}:{self.dummy_management_key}", }, params=None, - allow_redirects=None, + follow_redirects=None, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) diff --git a/tests/management/test_sso_settings.py b/tests/management/test_sso_settings.py index e102605a..322499c0 100644 --- a/tests/management/test_sso_settings.py +++ b/tests/management/test_sso_settings.py @@ -40,7 +40,7 @@ def test_delete_settings(self): ) # Test failed flows - with patch("requests.delete") as mock_delete: + with patch("httpx.delete") as mock_delete: mock_delete.return_value.ok = False self.assertRaises( AuthException, @@ -49,7 +49,7 @@ def test_delete_settings(self): ) # Test success flow - with patch("requests.delete") as mock_delete: + with patch("httpx.delete") as mock_delete: network_resp = mock.Mock() network_resp.ok = True @@ -63,7 +63,7 @@ def test_delete_settings(self): **common.default_headers, "Authorization": f"Bearer {self.dummy_project_id}:{self.dummy_management_key}", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -77,7 +77,7 @@ def test_load_settings(self): ) # Test failed flows - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: mock_get.return_value.ok = False self.assertRaises( AuthException, @@ -86,7 +86,7 @@ def test_load_settings(self): ) # Test success flow - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -108,7 +108,7 @@ def test_load_settings(self): "Authorization": f"Bearer {self.dummy_project_id}:{self.dummy_management_key}", }, params={"tenantId": "T2AAAA"}, - allow_redirects=None, + follow_redirects=None, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -122,7 +122,7 @@ def test_configure_oidc_settings(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -136,7 +136,7 @@ def test_configure_oidc_settings(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( client.mgmt.sso.configure_oidc_settings( @@ -207,7 +207,7 @@ def test_configure_oidc_settings(self): }, "domains": ["domain.com"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -221,7 +221,7 @@ def test_configure_saml_settings(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -239,7 +239,7 @@ def test_configure_saml_settings(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( client.mgmt.sso.configure_saml_settings( @@ -297,7 +297,7 @@ def test_configure_saml_settings(self): "redirectUrl": "https://redirect.com", "domains": ["domain.com"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -311,7 +311,7 @@ def test_configure_saml_settings_by_metadata(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -323,7 +323,7 @@ def test_configure_saml_settings_by_metadata(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( client.mgmt.sso.configure_saml_settings_by_metadata( @@ -377,7 +377,7 @@ def test_configure_saml_settings_by_metadata(self): "redirectUrl": "https://redirect.com", "domains": ["domain.com"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -395,7 +395,7 @@ def test_get_settings(self): ) # Test failed flows - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: mock_get.return_value.ok = False self.assertRaises( AuthException, @@ -404,7 +404,7 @@ def test_get_settings(self): ) # Test success flow - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -421,7 +421,7 @@ def test_get_settings(self): "Authorization": f"Bearer {self.dummy_project_id}:{self.dummy_management_key}", }, params={"tenantId": "tenant-id"}, - allow_redirects=None, + follow_redirects=None, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -435,7 +435,7 @@ def test_configure(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -449,7 +449,7 @@ def test_configure(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( client.mgmt.sso.configure( @@ -476,13 +476,13 @@ def test_configure(self): "redirectURL": "https://redirect.com", "domains": ["domain.com"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) # Domain is optional - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( client.mgmt.sso.configure( @@ -508,13 +508,13 @@ def test_configure(self): "redirectURL": "https://redirect.com", "domains": None, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) # Redirect is optional - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( client.mgmt.sso.configure( @@ -541,7 +541,7 @@ def test_configure(self): "redirectURL": "", "domains": ["domain.com"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -555,7 +555,7 @@ def test_configure_via_metadata(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -567,7 +567,7 @@ def test_configure_via_metadata(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( client.mgmt.sso.configure_via_metadata( @@ -590,13 +590,13 @@ def test_configure_via_metadata(self): "redirectURL": "https://redirect.com", "domains": ["domain.com"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) # Test partial arguments - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( client.mgmt.sso.configure_via_metadata( @@ -617,7 +617,7 @@ def test_configure_via_metadata(self): "redirectURL": None, "domains": None, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -631,7 +631,7 @@ def test_mapping(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -642,7 +642,7 @@ def test_mapping(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( client.mgmt.sso.mapping( @@ -673,7 +673,7 @@ def test_mapping(self): "customAttributes": None, }, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) diff --git a/tests/management/test_tenant.py b/tests/management/test_tenant.py index 2b66b892..cdcfc017 100644 --- a/tests/management/test_tenant.py +++ b/tests/management/test_tenant.py @@ -33,7 +33,7 @@ def test_create(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -42,7 +42,7 @@ def test_create(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"id": "t1"}""") @@ -61,13 +61,13 @@ def test_create(self): "id": "t1", "selfProvisioningDomains": ["domain.com"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) # Test success flow with custom attributes - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"id": "t1"}""") @@ -87,7 +87,7 @@ def test_create(self): "selfProvisioningDomains": ["domain.com"], "customAttributes": {"k1": "v1"}, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -101,7 +101,7 @@ def test_update(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -111,7 +111,7 @@ def test_update(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( client.mgmt.tenant.update("t1", "new-name", ["domain.com"]) @@ -128,13 +128,13 @@ def test_update(self): "id": "t1", "selfProvisioningDomains": ["domain.com"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) # Test success flow with custom attributes - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( client.mgmt.tenant.update( @@ -154,7 +154,7 @@ def test_update(self): "selfProvisioningDomains": ["domain.com"], "customAttributes": {"k1": "v1"}, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -168,7 +168,7 @@ def test_delete(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -177,7 +177,7 @@ def test_delete(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone(client.mgmt.tenant.delete("t1", True)) mock_post.assert_called_with( @@ -188,7 +188,7 @@ def test_delete(self): }, params=None, json={"id": "t1", "cascade": True}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -202,7 +202,7 @@ def test_load(self): ) # Test failed flows - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: mock_get.return_value.ok = False self.assertRaises( AuthException, @@ -211,7 +211,7 @@ def test_load(self): ) # Test success flow - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -230,7 +230,7 @@ def test_load(self): "Authorization": f"Bearer {self.dummy_project_id}:{self.dummy_management_key}", }, params={"id": "t1"}, - allow_redirects=None, + follow_redirects=None, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -244,12 +244,12 @@ def test_load_all(self): ) # Test failed flows - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: mock_get.return_value.ok = False self.assertRaises(AuthException, client.mgmt.tenant.load_all) # Test success flow - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -276,7 +276,7 @@ def test_load_all(self): "Authorization": f"Bearer {self.dummy_project_id}:{self.dummy_management_key}", }, params=None, - allow_redirects=None, + follow_redirects=None, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -290,12 +290,12 @@ def test_search_all(self): ) # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, client.mgmt.tenant.search_all) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -331,7 +331,7 @@ def test_search_all(self): "tenantSelfProvisioningDomains": ["spd1"], "customAttributes": {"k1": "v1"}, }, - allow_redirects=False, + follow_redirects=False, verify=True, params=None, timeout=DEFAULT_TIMEOUT_SECONDS, diff --git a/tests/management/test_user.py b/tests/management/test_user.py index 3e3612ba..3be0b298 100644 --- a/tests/management/test_user.py +++ b/tests/management/test_user.py @@ -40,7 +40,7 @@ def setUp(self) -> None: def test_create(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -49,7 +49,7 @@ def test_create(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -93,14 +93,14 @@ def test_create(self): "additionalLoginIds": ["id-1", "id-2"], "ssoAppIDs": ["app1", "app2"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_create_with_verified_parameters(self): # Test success flow with verified email and phone - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -146,14 +146,14 @@ def test_create_with_verified_parameters(self): "additionalLoginIds": None, "ssoAppIDs": None, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_create_test_user(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -162,7 +162,7 @@ def test_create_test_user(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -203,14 +203,14 @@ def test_create_test_user(self): "additionalLoginIds": None, "ssoAppIDs": None, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_invite(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -219,7 +219,7 @@ def test_invite(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -265,14 +265,14 @@ def test_invite(self): "additionalLoginIds": None, "ssoAppIDs": ["app1", "app2"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_invite_batch(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -281,7 +281,7 @@ def test_invite_batch(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"users": [{"id": "u1"}]}""") @@ -361,7 +361,7 @@ def test_invite_batch(self): }, params=None, json=expectedUsers, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -404,7 +404,7 @@ def test_invite_batch(self): }, params=None, json=expectedUsers, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -425,14 +425,14 @@ def test_invite_batch(self): }, params=None, json=expectedUsers, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_update(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -442,7 +442,7 @@ def test_update(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( self.client.mgmt.user.update( @@ -474,12 +474,12 @@ def test_update(self): "additionalLoginIds": None, "ssoAppIDs": ["app1", "app2"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) # Test success flow with verified flags - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone( self.client.mgmt.user.update( @@ -508,14 +508,14 @@ def test_update(self): "additionalLoginIds": None, "ssoAppIDs": None, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_patch(self): # Test failed flows - with patch("requests.patch") as mock_patch: + with patch("httpx.patch") as mock_patch: mock_patch.return_value.ok = False self.assertRaises( AuthException, @@ -525,7 +525,7 @@ def test_patch(self): ) # Test success flow with some params set - with patch("requests.patch") as mock_patch: + with patch("httpx.patch") as mock_patch: mock_patch.return_value.ok = True self.assertIsNone( self.client.mgmt.user.patch( @@ -556,12 +556,12 @@ def test_patch(self): "customAttributes": {"ak": "av"}, "ssoAppIds": ["app1", "app2"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) # Test success flow with other params - with patch("requests.patch") as mock_patch: + with patch("httpx.patch") as mock_patch: mock_patch.return_value.ok = True self.assertIsNone( self.client.mgmt.user.patch( @@ -602,14 +602,14 @@ def test_patch(self): {"tenantId": "tenant2", "roleNames": ["role1", "role2"]}, ], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_delete(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -618,7 +618,7 @@ def test_delete(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone(self.client.mgmt.user.delete("u1")) mock_post.assert_called_with( @@ -631,14 +631,14 @@ def test_delete(self): json={ "loginId": "u1", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_delete_by_user_id(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -647,7 +647,7 @@ def test_delete_by_user_id(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone(self.client.mgmt.user.delete_by_user_id("u1")) mock_post.assert_called_with( @@ -660,14 +660,14 @@ def test_delete_by_user_id(self): json={ "userId": "u1", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_logout(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -676,7 +676,7 @@ def test_logout(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone(self.client.mgmt.user.logout_user("u1")) mock_post.assert_called_with( @@ -689,14 +689,14 @@ def test_logout(self): json={ "loginId": "u1", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_logout_by_user_id(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -705,7 +705,7 @@ def test_logout_by_user_id(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNone(self.client.mgmt.user.logout_user_by_user_id("u1")) mock_post.assert_called_with( @@ -718,14 +718,14 @@ def test_logout_by_user_id(self): json={ "userId": "u1", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_delete_all_test_users(self): # Test failed flows - with patch("requests.delete") as mock_delete: + with patch("httpx.delete") as mock_delete: mock_delete.return_value.ok = False self.assertRaises( AuthException, @@ -733,7 +733,7 @@ def test_delete_all_test_users(self): ) # Test success flow - with patch("requests.delete") as mock_delete: + with patch("httpx.delete") as mock_delete: mock_delete.return_value.ok = True self.assertIsNone(self.client.mgmt.user.delete_all_test_users()) mock_delete.assert_called_with( @@ -743,14 +743,14 @@ def test_delete_all_test_users(self): **common.default_headers, "Authorization": f"Bearer {self.dummy_project_id}:{self.dummy_management_key}", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_load(self): # Test failed flows - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: mock_get.return_value.ok = False self.assertRaises( AuthException, @@ -759,7 +759,7 @@ def test_load(self): ) # Test success flow - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -774,14 +774,14 @@ def test_load(self): "Authorization": f"Bearer {self.dummy_project_id}:{self.dummy_management_key}", }, params={"loginId": "valid-id"}, - allow_redirects=None, + follow_redirects=None, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_load_by_user_id(self): # Test failed flows - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: mock_get.return_value.ok = False self.assertRaises( AuthException, @@ -790,7 +790,7 @@ def test_load_by_user_id(self): ) # Test success flow - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -805,14 +805,14 @@ def test_load_by_user_id(self): "Authorization": f"Bearer {self.dummy_project_id}:{self.dummy_management_key}", }, params={"userId": "user-id"}, - allow_redirects=None, + follow_redirects=None, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_search_all(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -821,7 +821,7 @@ def test_search_all(self): ["r1", "r2"], ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertRaises( AuthException, self.client.mgmt.user.search_all, [], [], -1, 0 @@ -832,7 +832,7 @@ def test_search_all(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -867,13 +867,13 @@ def test_search_all(self): "ssoAppIds": ["app1"], "loginIds": ["l1"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) # Test success flow with text and sort - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -914,13 +914,13 @@ def test_search_all(self): {"desc": False, "field": "bubu"}, ], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) # Test success flow with custom attributes - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -959,14 +959,14 @@ def test_search_all(self): "emails": ["a@b.com"], "phones": ["+111111"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_get_provider_token(self): # Test failed flows - with patch("requests.get") as mock_post: + with patch("httpx.get") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -975,7 +975,7 @@ def test_get_provider_token(self): "p1", ) # Test success flow - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -1003,14 +1003,14 @@ def test_get_provider_token(self): "withRefreshToken": True, "forceRefresh": True, }, - allow_redirects=None, + follow_redirects=None, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_activate(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1019,7 +1019,7 @@ def test_activate(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -1038,14 +1038,14 @@ def test_activate(self): "loginId": "valid-id", "status": "enabled", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_deactivate(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1054,7 +1054,7 @@ def test_deactivate(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -1073,14 +1073,14 @@ def test_deactivate(self): "loginId": "valid-id", "status": "disabled", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_update_login_id(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1090,7 +1090,7 @@ def test_update_login_id(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "a@b.c"}}""") @@ -1109,14 +1109,14 @@ def test_update_login_id(self): "loginId": "valid-id", "newLoginId": "a@b.c", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_update_email(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1126,7 +1126,7 @@ def test_update_email(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -1146,14 +1146,14 @@ def test_update_email(self): "email": "a@b.c", "verified": None, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_update_phone(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1163,7 +1163,7 @@ def test_update_phone(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -1183,14 +1183,14 @@ def test_update_phone(self): "phone": "+18005551234", "verified": True, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_update_display_name(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1200,7 +1200,7 @@ def test_update_display_name(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -1219,14 +1219,14 @@ def test_update_display_name(self): "loginId": "valid-id", "displayName": "foo", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_update_picture(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1236,7 +1236,7 @@ def test_update_picture(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -1255,14 +1255,14 @@ def test_update_picture(self): "loginId": "valid-id", "picture": "foo", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_update_custom_attribute(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1273,7 +1273,7 @@ def test_update_custom_attribute(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -1294,7 +1294,7 @@ def test_update_custom_attribute(self): "attributeKey": "foo", "attributeValue": "bar", }, - allow_redirects=False, + follow_redirects=False, verify=True, params=None, timeout=DEFAULT_TIMEOUT_SECONDS, @@ -1302,7 +1302,7 @@ def test_update_custom_attribute(self): def test_set_roles(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1312,7 +1312,7 @@ def test_set_roles(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -1331,14 +1331,14 @@ def test_set_roles(self): "loginId": "valid-id", "roleNames": ["foo", "bar"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_add_roles(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1348,7 +1348,7 @@ def test_add_roles(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -1367,14 +1367,14 @@ def test_add_roles(self): "loginId": "valid-id", "roleNames": ["foo", "bar"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_remove_roles(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1384,7 +1384,7 @@ def test_remove_roles(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -1403,14 +1403,14 @@ def test_remove_roles(self): "loginId": "valid-id", "roleNames": ["foo", "bar"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_add_sso_apps(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1420,7 +1420,7 @@ def test_add_sso_apps(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -1439,14 +1439,14 @@ def test_add_sso_apps(self): "loginId": "valid-id", "ssoAppIds": ["foo", "bar"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_set_sso_apps(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1456,7 +1456,7 @@ def test_set_sso_apps(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -1475,14 +1475,14 @@ def test_set_sso_apps(self): "loginId": "valid-id", "ssoAppIds": ["foo", "bar"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_remove_sso_apps(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1492,7 +1492,7 @@ def test_remove_sso_apps(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -1511,14 +1511,14 @@ def test_remove_sso_apps(self): "loginId": "valid-id", "ssoAppIds": ["foo", "bar"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_add_tenant(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1528,7 +1528,7 @@ def test_add_tenant(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -1547,14 +1547,14 @@ def test_add_tenant(self): "loginId": "valid-id", "tenantId": "tid", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_remove_tenant(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1564,7 +1564,7 @@ def test_remove_tenant(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -1583,14 +1583,14 @@ def test_remove_tenant(self): "loginId": "valid-id", "tenantId": "tid", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_set_tenant_roles(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1601,7 +1601,7 @@ def test_set_tenant_roles(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -1623,14 +1623,14 @@ def test_set_tenant_roles(self): "tenantId": "tid", "roleNames": ["foo", "bar"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_add_tenant_roles(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1641,7 +1641,7 @@ def test_add_tenant_roles(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -1663,14 +1663,14 @@ def test_add_tenant_roles(self): "tenantId": "tid", "roleNames": ["foo", "bar"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_remove_tenant_roles(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1681,7 +1681,7 @@ def test_remove_tenant_roles(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"user": {"id": "u1"}}""") @@ -1703,14 +1703,14 @@ def test_remove_tenant_roles(self): "tenantId": "tid", "roleNames": ["foo", "bar"], }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_generate_otp_for_test_user(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1720,7 +1720,7 @@ def test_generate_otp_for_test_user(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -1749,14 +1749,14 @@ def test_generate_otp_for_test_user(self): "mfa": False, }, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_user_set_temporary_password(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1766,7 +1766,7 @@ def test_user_set_temporary_password(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True mock_post.return_value = network_resp @@ -1786,14 +1786,14 @@ def test_user_set_temporary_password(self): "password": "some-password", "setActive": False, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_user_set_active_password(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1803,7 +1803,7 @@ def test_user_set_active_password(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True mock_post.return_value = network_resp @@ -1823,14 +1823,14 @@ def test_user_set_active_password(self): "password": "some-password", "setActive": True, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_user_set_password(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1840,7 +1840,7 @@ def test_user_set_password(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True mock_post.return_value = network_resp @@ -1860,14 +1860,14 @@ def test_user_set_password(self): "password": "some-password", "setActive": False, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_user_expire_password(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1876,7 +1876,7 @@ def test_user_expire_password(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True mock_post.return_value = network_resp @@ -1893,14 +1893,14 @@ def test_user_expire_password(self): json={ "loginId": "login-id", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_user_remove_all_passkeys(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1909,7 +1909,7 @@ def test_user_remove_all_passkeys(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True mock_post.return_value = network_resp @@ -1926,14 +1926,14 @@ def test_user_remove_all_passkeys(self): json={ "loginId": "login-id", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_generate_magic_link_for_test_user(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1944,7 +1944,7 @@ def test_generate_magic_link_for_test_user(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -1974,14 +1974,14 @@ def test_generate_magic_link_for_test_user(self): "mfa": False, }, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_generate_enchanted_link_for_test_user(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -1991,7 +1991,7 @@ def test_generate_enchanted_link_for_test_user(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -2021,21 +2021,21 @@ def test_generate_enchanted_link_for_test_user(self): "mfa": False, }, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_generate_embedded_link(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, self.client.mgmt.user.generate_embedded_link, "login-id" ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads("""{"token": "some-token"}""") @@ -2054,7 +2054,7 @@ def test_generate_embedded_link(self): "loginId": "login-id", "customClaims": {"k1": "v1"}, }, - allow_redirects=False, + follow_redirects=False, verify=True, params=None, timeout=DEFAULT_TIMEOUT_SECONDS, @@ -2062,14 +2062,14 @@ def test_generate_embedded_link(self): def test_history(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, self.client.mgmt.user.history, ["user-id-1", "user-id-2"] ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: network_resp = mock.Mock() network_resp.ok = True network_resp.json.return_value = json.loads( @@ -2120,7 +2120,7 @@ def test_history(self): "Authorization": f"Bearer {self.dummy_project_id}:{self.dummy_management_key}", }, json=["user-id-1", "user-id-2"], - allow_redirects=False, + follow_redirects=False, verify=True, params=None, timeout=DEFAULT_TIMEOUT_SECONDS, diff --git a/tests/test_auth.py b/tests/test_auth.py index 40cb1e3b..347d1984 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -111,17 +111,17 @@ def test_fetch_public_key(self): """ # Test failed flows - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: mock_get.return_value.ok = False self.assertRaises(AuthException, auth._fetch_public_keys) - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: mock_get.return_value.ok = True mock_get.return_value.text = "invalid json" self.assertRaises(AuthException, auth._fetch_public_keys) # test success flow - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: mock_get.return_value.ok = True mock_get.return_value.text = valid_keys_response self.assertIsNone(auth._fetch_public_keys()) @@ -353,7 +353,7 @@ def test_refresh_session(self): auth = Auth(self.dummy_project_id, self.public_key_dict) # Test fail flow - with patch("requests.post") as mock_request: + with patch("httpx.post") as mock_request: mock_request.return_value.ok = False self.assertRaises( AuthException, @@ -369,7 +369,7 @@ def test_validate_session_and_refresh_input(self): auth.validate_and_refresh_session(None, None) # Test validate_session with Ratelimit exception - with patch("requests.get") as mock_request: + with patch("httpx.get") as mock_request: mock_request.return_value.ok = False mock_request.return_value.status_code = 429 mock_request.return_value.json.return_value = { @@ -396,7 +396,7 @@ def test_validate_session_and_refresh_input(self): ) # Test refresh_session with Ratelimit exception - with patch("requests.get") as mock_request: + with patch("httpx.get") as mock_request: mock_request.return_value.ok = False mock_request.return_value.status_code = 429 mock_request.return_value.json.return_value = { @@ -427,7 +427,7 @@ def test_exchange_access_key(self): auth = Auth(self.dummy_project_id, self.public_key_dict) # Test fail flow - with patch("requests.post") as mock_request: + with patch("httpx.post") as mock_request: mock_request.return_value.ok = False self.assertRaises( AuthException, @@ -437,7 +437,7 @@ def test_exchange_access_key(self): # Test success flow valid_jwt_token = "eyJhbGciOiJFUzM4NCIsImtpZCI6IlAyQ3R6VWhkcXBJRjJ5czlnZzdtczA2VXZ0QzQiLCJ0eXAiOiJKV1QifQ.eyJkcm4iOiJEU1IiLCJleHAiOjIyNjQ0Mzc1OTYsImlhdCI6MTY1OTYzNzU5NiwiaXNzIjoiUDJDdHpVaGRxcElGMnlzOWdnN21zMDZVdnRDNCIsInN1YiI6IlUyQ3UwajBXUHczWU9pUElTSmI1Mkwwd1VWTWcifQ.WLnlHugvzZtrV9OzBB7SjpCLNRvKF3ImFpVyIN5orkrjO2iyAKg_Rb4XHk9sXGC1aW8puYzLbhE1Jv3kk2hDcKggfE8OaRNRm8byhGFZHnvPJwcP_Ya-aRmfAvCLcKOL" - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True data = {"sessionJwt": valid_jwt_token} @@ -458,7 +458,7 @@ def test_exchange_access_key(self): }, params=None, json={"loginOptions": {"customClaims": {"k1": "v1"}}}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -555,7 +555,7 @@ def test_api_rate_limit_exception(self): auth = Auth(self.dummy_project_id, self.public_key_dict) # Test do_post - with patch("requests.post") as mock_request: + with patch("httpx.post") as mock_request: mock_request.return_value.ok = False mock_request.return_value.status_code = 429 mock_request.return_value.json.return_value = { @@ -581,7 +581,7 @@ def test_api_rate_limit_exception(self): ) # Test do_get - with patch("requests.get") as mock_request: + with patch("httpx.get") as mock_request: mock_request.return_value.ok = False mock_request.return_value.status_code = 429 mock_request.return_value.json.return_value = { @@ -593,7 +593,7 @@ def test_api_rate_limit_exception(self): API_RATE_LIMIT_RETRY_AFTER_HEADER: "10" } with self.assertRaises(RateLimitException) as cm: - auth.do_get(uri="http://test.com", params=False, allow_redirects=None) + auth.do_get(uri="http://test.com", params=False, follow_redirects=None) the_exception = cm.exception self.assertEqual(the_exception.status_code, "E130429") self.assertEqual(the_exception.error_type, ERROR_TYPE_API_RATE_LIMIT) @@ -607,7 +607,7 @@ def test_api_rate_limit_exception(self): ) # Test do_delete - with patch("requests.delete") as mock_request: + with patch("httpx.delete") as mock_request: mock_request.return_value.ok = False mock_request.return_value.status_code = 429 mock_request.return_value.json.return_value = { @@ -633,7 +633,7 @@ def test_api_rate_limit_exception(self): ) # Test do_delete with params and pswd - with patch("requests.delete") as mock_delete: + with patch("httpx.delete") as mock_delete: network_resp = mock.Mock() network_resp.ok = True @@ -647,13 +647,13 @@ def test_api_rate_limit_exception(self): **common.default_headers, "Authorization": f"Bearer {self.dummy_project_id}:{'pswd'}", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) # Test _fetch_public_keys rate limit - with patch("requests.get") as mock_request: + with patch("httpx.get") as mock_request: mock_request.return_value.ok = False mock_request.return_value.status_code = 429 mock_request.return_value.json.return_value = { @@ -680,13 +680,13 @@ def test_api_rate_limit_exception(self): def test_raise_from_response(self): auth = Auth(self.dummy_project_id, self.public_key_dict) - with patch("requests.get") as mock_request: + with patch("httpx.get") as mock_request: mock_request.return_value.ok = False mock_request.return_value.status_code = 400 mock_request.return_value.error_type = ERROR_TYPE_SERVER_ERROR mock_request.return_value.text = """{"errorCode":"E062108","errorDescription":"User not found","errorMessage":"Cannot find user"}""" with self.assertRaises(AuthException) as cm: - auth.do_get(uri="http://test.com", params=False, allow_redirects=None) + auth.do_get(uri="http://test.com", params=False, follow_redirects=None) the_exception = cm.exception self.assertEqual(the_exception.status_code, 400) self.assertEqual(the_exception.error_type, ERROR_TYPE_SERVER_ERROR) diff --git a/tests/test_descope_client.py b/tests/test_descope_client.py index 9aa2bb6e..c480abf7 100644 --- a/tests/test_descope_client.py +++ b/tests/test_descope_client.py @@ -75,12 +75,12 @@ def test_logout(self): self.assertRaises(AuthException, client.logout, None) # Test failed flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, client.logout, dummy_refresh_token) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(client.logout(dummy_refresh_token)) @@ -91,12 +91,12 @@ def test_logout_all(self): self.assertRaises(AuthException, client.logout_all, None) # Test failed flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, client.logout_all, dummy_refresh_token) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(client.logout_all(dummy_refresh_token)) @@ -107,12 +107,12 @@ def test_me(self): self.assertRaises(AuthException, client.me, None) # Test failed flow - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: mock_get.return_value.ok = False self.assertRaises(AuthException, client.me, dummy_refresh_token) # Test success flow - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: my_mock_response = mock.Mock() my_mock_response.ok = True data = json.loads( @@ -129,7 +129,7 @@ def test_me(self): **common.default_headers, "Authorization": f"Bearer {self.dummy_project_id}", }, - allow_redirects=None, + follow_redirects=None, verify=True, params=None, timeout=DEFAULT_TIMEOUT_SECONDS, @@ -146,14 +146,14 @@ def test_my_tenants(self): ) # Test failed flow - with patch("requests.post") as mock_get: + with patch("httpx.post") as mock_get: mock_get.return_value.ok = False self.assertRaises( AuthException, client.my_tenants, dummy_refresh_token, True ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True data = json.loads( @@ -173,7 +173,7 @@ def test_my_tenants(self): "Authorization": f"Bearer {self.dummy_project_id}", }, json={"dct": False, "ids": ["a"]}, - allow_redirects=False, + follow_redirects=False, verify=True, params=None, timeout=DEFAULT_TIMEOUT_SECONDS, @@ -186,12 +186,12 @@ def test_history(self): self.assertRaises(AuthException, client.history, None) # Test failed flow - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: mock_get.return_value.ok = False self.assertRaises(AuthException, client.history, dummy_refresh_token) # Test success flow - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: my_mock_response = mock.Mock() my_mock_response.ok = True data = json.loads( @@ -225,7 +225,7 @@ def test_history(self): **common.default_headers, "Authorization": f"Bearer {self.dummy_project_id}", }, - allow_redirects=None, + follow_redirects=None, verify=True, params=None, timeout=DEFAULT_TIMEOUT_SECONDS, @@ -336,7 +336,7 @@ def test_validate_session_valid_tokens(self): # Test case where key id cannot be found client2 = DescopeClient(self.dummy_project_id, None) - with patch("requests.get") as mock_request: + with patch("httpx.get") as mock_request: fake_key = deepcopy(self.public_key_dict) # overwrite the kid (so it will not be found) fake_key["kid"] = "dummy_kid" @@ -351,7 +351,7 @@ def test_validate_session_valid_tokens(self): # Test case where we failed to load key client3 = DescopeClient(self.dummy_project_id, None) - with patch("requests.get") as mock_request: + with patch("httpx.get") as mock_request: mock_request.return_value.text = """[{"kid": "dummy_kid"}]""" mock_request.return_value.ok = True self.assertRaises( @@ -364,7 +364,7 @@ def test_validate_session_valid_tokens(self): # Test case where header_alg != key[alg] self.public_key_dict["alg"] = "ES521" client4 = DescopeClient(self.dummy_project_id, self.public_key_dict) - with patch("requests.get") as mock_request: + with patch("httpx.get") as mock_request: mock_request.return_value.text = """[{"kid": "dummy_kid"}]""" mock_request.return_value.ok = True self.assertRaises( @@ -386,7 +386,7 @@ def test_validate_session_valid_tokens(self): # expired_jwt_token = "eyJhbGciOiJFUzM4NCIsImtpZCI6IlAyQ3VDOXl2MlVHdEdJMW84NGdDWkViOXFFUVciLCJ0eXAiOiJKV1QifQ.eyJkcm4iOiJEUyIsImV4cCI6MTY1OTY0NDI5OCwiaWF0IjoxNjU5NjQ0Mjk3LCJpc3MiOiJQMkN1Qzl5djJVR3RHSTFvODRnQ1pFYjlxRVFXIiwic3ViIjoiVTJDdUNQdUpnUFdIR0I1UDRHbWZidVBHaEdWbSJ9.wBuOnIQI_z3SXOszqsWCg8ilOPdE5ruWYHA3jkaeQ3uX9hWgCTd69paFajc-xdMYbqlIF7JHji7T9oVmkCUJvDNgRZRZO9boMFANPyXitLOK4aX3VZpMJBpFxdrWV3GE" valid_refresh_token = valid_jwt_token - with patch("requests.get") as mock_request: + with patch("httpx.get") as mock_request: mock_request.return_value.cookies = {SESSION_COOKIE_NAME: expired_jwt_token} mock_request.return_value.ok = True @@ -440,7 +440,7 @@ def test_expired_token(self): ) # Test fail flow - with patch("requests.get") as mock_request: + with patch("httpx.get") as mock_request: mock_request.return_value.ok = False self.assertRaises( AuthException, @@ -448,7 +448,7 @@ def test_expired_token(self): expired_jwt_token, ) - with patch("requests.get") as mock_request: + with patch("httpx.get") as mock_request: mock_request.return_value.cookies = {"aaa": "aaa"} mock_request.return_value.ok = True self.assertRaises( @@ -473,7 +473,7 @@ def test_expired_token(self): new_session_token = "eyJhbGciOiJFUzM4NCIsImtpZCI6IlAyQ3VDOXl2MlVHdEdJMW84NGdDWkViOXFFUVciLCJ0eXAiOiJKV1QifQ.eyJkcm4iOiJEUyIsImV4cCI6MjQ5MzA2MTQxNSwiaWF0IjoxNjU5NjQzMDYxLCJpc3MiOiJQMkN1Qzl5djJVR3RHSTFvODRnQ1pFYjlxRVFXIiwic3ViIjoiVTJDdUNQdUpnUFdIR0I1UDRHbWZidVBHaEdWbSJ9.gMalOv1GhqYVsfITcOc7Jv_fibX1Iof6AFy2KCVmyHmU2KwATT6XYXsHjBFFLq262Pg-LS1IX9f_DV3ppzvb1pSY4ccsP6WDGd1vJpjp3wFBP9Sji6WXL0SCCJUFIyJR" valid_refresh_token = "eyJhbGciOiJFUzM4NCIsImtpZCI6IlAyQ3VDOXl2MlVHdEdJMW84NGdDWkViOXFFUVciLCJ0eXAiOiJKV1QifQ.eyJkcm4iOiJEU1IiLCJleHAiOjIyNjQ0NDMwNjEsImlhdCI6MTY1OTY0MzA2MSwiaXNzIjoiUDJDdUM5eXYyVUd0R0kxbzg0Z0NaRWI5cUVRVyIsInN1YiI6IlUyQ3VDUHVKZ1BXSEdCNVA0R21mYnVQR2hHVm0ifQ.mRo9FihYMR3qnQT06Mj3CJ5X0uTCEcXASZqfLLUv0cPCLBtBqYTbuK-ZRDnV4e4N6zGCNX2a3jjpbyqbViOxICCNSxJsVb-sdsSujtEXwVMsTTLnpWmNsMbOUiKmoME0" expired_token = "eyJhbGciOiJFUzM4NCIsImtpZCI6IlAyQ3VDOXl2MlVHdEdJMW84NGdDWkViOXFFUVciLCJ0eXAiOiJKV1QifQ.eyJkcm4iOiJEUyIsImV4cCI6MTY1OTY0NDI5OCwiaWF0IjoxNjU5NjQ0Mjk3LCJpc3MiOiJQMkN1Qzl5djJVR3RHSTFvODRnQ1pFYjlxRVFXIiwic3ViIjoiVTJDdUNQdUpnUFdIR0I1UDRHbWZidVBHaEdWbSJ9.wBuOnIQI_z3SXOszqsWCg8ilOPdE5ruWYHA3jkaeQ3uX9hWgCTd69paFajc-xdMYbqlIF7JHji7T9oVmkCUJvDNgRZRZO9boMFANPyXitLOK4aX3VZpMJBpFxdrWV3GE" - with patch("requests.post") as mock_request: + with patch("httpx.post") as mock_request: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"sessionJwt": new_session_token} @@ -507,7 +507,7 @@ def test_expired_token(self): new_refreshed_token = ( expired_jwt_token # the refreshed token should be invalid (or expired) ) - with patch("requests.get") as mock_request: + with patch("httpx.get") as mock_request: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"sessionJwt": new_refreshed_token} @@ -742,7 +742,7 @@ def test_exchange_access_key(self): ) dummy_access_key = "dummy access key" valid_jwt_token = "eyJhbGciOiJFUzM4NCIsImtpZCI6IlAyQ3VDOXl2MlVHdEdJMW84NGdDWkViOXFFUVciLCJ0eXAiOiJKV1QifQ.eyJkcm4iOiJEU1IiLCJleHAiOjIyNjQ0NDMwNjEsImlhdCI6MTY1OTY0MzA2MSwiaXNzIjoiUDJDdUM5eXYyVUd0R0kxbzg0Z0NaRWI5cUVRVyIsInN1YiI6IlUyQ3VDUHVKZ1BXSEdCNVA0R21mYnVQR2hHVm0ifQ.mRo9FihYMR3qnQT06Mj3CJ5X0uTCEcXASZqfLLUv0cPCLBtBqYTbuK-ZRDnV4e4N6zGCNX2a3jjpbyqbViOxICCNSxJsVb-sdsSujtEXwVMsTTLnpWmNsMbOUiKmoME0" - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True data = {"sessionJwt": valid_jwt_token} @@ -763,7 +763,7 @@ def test_exchange_access_key(self): }, params=None, json={"loginOptions": {"customClaims": {"k1": "v1"}}}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -810,7 +810,7 @@ def test_select_tenant(self): valid_jwt_token = "eyJhbGciOiJFUzM4NCIsImtpZCI6IlAyQ3VDOXl2MlVHdEdJMW84NGdDWkViOXFFUVciLCJ0eXAiOiJKV1QifQ.eyJkcm4iOiJEU1IiLCJleHAiOjIyNjQ0NDMwNjEsImlhdCI6MTY1OTY0MzA2MSwiaXNzIjoiUDJDdUM5eXYyVUd0R0kxbzg0Z0NaRWI5cUVRVyIsInN1YiI6IlUyQ3VDUHVKZ1BXSEdCNVA0R21mYnVQR2hHVm0ifQ.mRo9FihYMR3qnQT06Mj3CJ5X0uTCEcXASZqfLLUv0cPCLBtBqYTbuK-ZRDnV4e4N6zGCNX2a3jjpbyqbViOxICCNSxJsVb-sdsSujtEXwVMsTTLnpWmNsMbOUiKmoME0" - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True my_mock_response = mock.Mock() my_mock_response.ok = True @@ -831,7 +831,7 @@ def test_select_tenant(self): json={ "tenant": "t1", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) diff --git a/tests/test_enchantedlink.py b/tests/test_enchantedlink.py index 4939feb5..d633cac8 100644 --- a/tests/test_enchantedlink.py +++ b/tests/test_enchantedlink.py @@ -97,7 +97,7 @@ def test_compose_body(self): def test_sign_in(self): enchantedlink = EnchantedLink(Auth(self.dummy_project_id, self.public_key_dict)) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True # Test failed flows @@ -119,7 +119,7 @@ def test_sign_in(self): "URI": "http://test.me", "loginOptions": {}, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -127,7 +127,7 @@ def test_sign_in(self): self.assertEqual(res["linkId"], "24") # Validate refresh token used while provided - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: refresh_token = "dummy refresh token" enchantedlink.sign_in( "dummy@dummy.com", @@ -151,13 +151,13 @@ def test_sign_in(self): "mfa": False, }, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) # With template options - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: refresh_token = "dummy refresh token" enchantedlink.sign_in( "dummy@dummy.com", @@ -182,14 +182,14 @@ def test_sign_in(self): "mfa": False, }, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_sign_in_with_login_options(self): enchantedlink = EnchantedLink(Auth(self.dummy_project_id, self.public_key_dict)) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True data = json.loads("""{"pendingRef": "aaaa", "linkId":"24"}""") @@ -213,14 +213,14 @@ def test_sign_in_with_login_options(self): "mfa": False, }, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) def test_sign_up(self): enchantedlink = EnchantedLink(Auth(self.dummy_project_id, self.public_key_dict)) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True @@ -254,14 +254,14 @@ def test_sign_up(self): "user": {"username": "user1", "email": "dummy@dummy.com"}, "email": "dummy@dummy.com", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) self.assertEqual(res["pendingRef"], "aaaa") # Test user is None so using the login_id as default - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: data = json.loads("""{"pendingRef": "aaaa"}""") my_mock_response.json.return_value = data mock_post.return_value = my_mock_response @@ -283,14 +283,14 @@ def test_sign_up(self): "user": {"email": "dummy@dummy.com"}, "email": "dummy@dummy.com", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) self.assertEqual(res["pendingRef"], "aaaa") # Test success flow with sign up options - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: data = json.loads("""{"pendingRef": "aaaa"}""") my_mock_response.json.return_value = data mock_post.return_value = my_mock_response @@ -314,7 +314,7 @@ def test_sign_up(self): "email": "dummy@dummy.com", "loginOptions": {"templateOptions": {"bla": "blue"}}, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -322,7 +322,7 @@ def test_sign_up(self): def test_sign_up_or_in(self): enchantedlink = EnchantedLink(Auth(self.dummy_project_id, self.public_key_dict)) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True data = json.loads("""{"pendingRef": "aaaa"}""") @@ -344,13 +344,13 @@ def test_sign_up_or_in(self): "URI": "http://test.me", "loginOptions": {}, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) # Test success flow with sign up options - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True data = json.loads("""{"pendingRef": "aaaa"}""") @@ -378,7 +378,7 @@ def test_sign_up_or_in(self): "templateOptions": {"bla": "blue"}, }, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -388,7 +388,7 @@ def test_verify(self): enchantedlink = EnchantedLink(Auth(self.dummy_project_id, self.public_key_dict)) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -398,7 +398,7 @@ def test_verify(self): # Test success flow valid_jwt_token = "eyJhbGciOiJFUzM4NCIsImtpZCI6IlAyQ3R6VWhkcXBJRjJ5czlnZzdtczA2VXZ0QzQiLCJ0eXAiOiJKV1QifQ.eyJkcm4iOiJEU1IiLCJleHAiOjIyNjQ0Mzc1OTYsImlhdCI6MTY1OTYzNzU5NiwiaXNzIjoiUDJDdHpVaGRxcElGMnlzOWdnN21zMDZVdnRDNCIsInN1YiI6IlUyQ3UwajBXUHczWU9pUElTSmI1Mkwwd1VWTWcifQ.WLnlHugvzZtrV9OzBB7SjpCLNRvKF3ImFpVyIN5orkrjO2iyAKg_Rb4XHk9sXGC1aW8puYzLbhE1Jv3kk2hDcKggfE8OaRNRm8byhGFZHnvPJwcP_Ya-aRmfAvCLcKOL" - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {} @@ -413,7 +413,7 @@ def test_get_session(self): enchantedlink = EnchantedLink(Auth(self.dummy_project_id, self.public_key_dict)) valid_jwt_token = "eyJhbGciOiJFUzM4NCIsImtpZCI6IlAyQ3R6VWhkcXBJRjJ5czlnZzdtczA2VXZ0QzQiLCJ0eXAiOiJKV1QifQ.eyJkcm4iOiJEU1IiLCJleHAiOjIyNjQ0Mzc1OTYsImlhdCI6MTY1OTYzNzU5NiwiaXNzIjoiUDJDdHpVaGRxcElGMnlzOWdnN21zMDZVdnRDNCIsInN1YiI6IlUyQ3UwajBXUHczWU9pUElTSmI1Mkwwd1VWTWcifQ.WLnlHugvzZtrV9OzBB7SjpCLNRvKF3ImFpVyIN5orkrjO2iyAKg_Rb4XHk9sXGC1aW8puYzLbhE1Jv3kk2hDcKggfE8OaRNRm8byhGFZHnvPJwcP_Ya-aRmfAvCLcKOL" - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {} @@ -426,7 +426,7 @@ def test_get_session(self): def test_update_user_email(self): enchantedlink = EnchantedLink(Auth(self.dummy_project_id, self.public_key_dict)) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True # Test failed flows @@ -456,14 +456,14 @@ def test_update_user_email(self): "addToLoginIDs": False, "onMergeUseExisting": False, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, params=None, ) # with template options - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True data = json.loads("""{"pendingRef": "aaaa"}""") @@ -489,7 +489,7 @@ def test_update_user_email(self): "onMergeUseExisting": False, "templateOptions": {"bla": "blue"}, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, params=None, diff --git a/tests/test_magiclink.py b/tests/test_magiclink.py index c754072e..e96a7bfa 100644 --- a/tests/test_magiclink.py +++ b/tests/test_magiclink.py @@ -122,7 +122,7 @@ def test_sign_in(self): "http://test.me", ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -133,7 +133,7 @@ def test_sign_in(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedEmail": "t***@example.com"} @@ -156,7 +156,7 @@ def test_sign_in(self): ) # Validate refresh token used while provided - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: refresh_token = "dummy refresh token" magiclink.sign_in( DeliveryMethod.EMAIL, @@ -181,13 +181,13 @@ def test_sign_in(self): "mfa": False, }, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) # With template options - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: refresh_token = "dummy refresh token" magiclink.sign_in( DeliveryMethod.EMAIL, @@ -213,7 +213,7 @@ def test_sign_in(self): "mfa": False, }, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -238,7 +238,7 @@ def test_sign_up(self): signup_user_details, ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -250,7 +250,7 @@ def test_sign_up(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedEmail": "t***@example.com"} @@ -264,7 +264,7 @@ def test_sign_up(self): self.assertEqual("t***@example.com", resp) # Test success flow with sign up options - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedEmail": "t***@example.com"} @@ -296,7 +296,7 @@ def test_sign_up(self): "email": "dummy@dummy.com", "loginOptions": {"templateOptions": {"bla": "blue"}}, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, params=None, @@ -310,7 +310,7 @@ def test_sign_up(self): "email": "dummy@dummy.com", } - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedEmail": "t***@example.com"} @@ -341,14 +341,14 @@ def test_sign_up(self): }, "email": "dummy@dummy.com", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, params=None, ) # Test user is None so using the login_id as default - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedEmail": "t***@example.com"} @@ -374,7 +374,7 @@ def test_sign_up(self): "user": {"email": "dummy@dummy.com"}, "email": "dummy@dummy.com", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, params=None, @@ -385,7 +385,7 @@ def test_sign_up_or_in(self): # Test failed flows - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -396,7 +396,7 @@ def test_sign_up_or_in(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedEmail": "t***@example.com"} @@ -409,7 +409,7 @@ def test_sign_up_or_in(self): ) # Test success flow with sign up options - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedEmail": "t***@example.com"} @@ -439,7 +439,7 @@ def test_sign_up_or_in(self): "templateOptions": {"bla": "blue"}, }, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, params=None, @@ -450,7 +450,7 @@ def test_verify(self): magiclink = MagicLink(Auth(self.dummy_project_id, self.public_key_dict)) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -460,7 +460,7 @@ def test_verify(self): # Test success flow valid_jwt_token = "eyJhbGciOiJFUzM4NCIsImtpZCI6IlAyQ3R6VWhkcXBJRjJ5czlnZzdtczA2VXZ0QzQiLCJ0eXAiOiJKV1QifQ.eyJkcm4iOiJEU1IiLCJleHAiOjIyNjQ0Mzc1OTYsImlhdCI6MTY1OTYzNzU5NiwiaXNzIjoiUDJDdHpVaGRxcElGMnlzOWdnN21zMDZVdnRDNCIsInN1YiI6IlUyQ3UwajBXUHczWU9pUElTSmI1Mkwwd1VWTWcifQ.WLnlHugvzZtrV9OzBB7SjpCLNRvKF3ImFpVyIN5orkrjO2iyAKg_Rb4XHk9sXGC1aW8puYzLbhE1Jv3kk2hDcKggfE8OaRNRm8byhGFZHnvPJwcP_Ya-aRmfAvCLcKOL" - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {} @@ -479,11 +479,11 @@ def test_verify_with_get_keys_mock(self): # Test success flow valid_jwt_token = "eyJhbGciOiJFUzM4NCIsImtpZCI6IlAyQ3R6VWhkcXBJRjJ5czlnZzdtczA2VXZ0QzQiLCJ0eXAiOiJKV1QifQ.eyJkcm4iOiJEU1IiLCJleHAiOjIyNjQ0Mzc1OTYsImlhdCI6MTY1OTYzNzU5NiwiaXNzIjoiUDJDdHpVaGRxcElGMnlzOWdnN21zMDZVdnRDNCIsInN1YiI6IlUyQ3UwajBXUHczWU9pUElTSmI1Mkwwd1VWTWcifQ.WLnlHugvzZtrV9OzBB7SjpCLNRvKF3ImFpVyIN5orkrjO2iyAKg_Rb4XHk9sXGC1aW8puYzLbhE1Jv3kk2hDcKggfE8OaRNRm8byhGFZHnvPJwcP_Ya-aRmfAvCLcKOL" - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: mock_get.return_value.text = json.dumps({"keys": [self.public_key_dict]}) mock_get.return_value.ok = True - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {} @@ -505,7 +505,7 @@ def test_update_user_email(self): "refresh_token1", ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -516,7 +516,7 @@ def test_update_user_email(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedEmail": "t***@example.com"} @@ -537,14 +537,14 @@ def test_update_user_email(self): "addToLoginIDs": False, "onMergeUseExisting": False, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, params=None, ) # Test success flow with template options - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedEmail": "t***@example.com"} @@ -571,7 +571,7 @@ def test_update_user_email(self): "onMergeUseExisting": False, "templateOptions": {"bla": "blue"}, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, params=None, @@ -589,7 +589,7 @@ def test_update_user_phone(self): "refresh_token1", ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -601,7 +601,7 @@ def test_update_user_phone(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedPhone": "*****1111"} @@ -624,14 +624,14 @@ def test_update_user_phone(self): "addToLoginIDs": False, "onMergeUseExisting": False, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, params=None, ) # Test success flow with template options - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedPhone": "*****1111"} @@ -659,7 +659,7 @@ def test_update_user_phone(self): "onMergeUseExisting": False, "templateOptions": {"bla": "blue"}, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, params=None, diff --git a/tests/test_oauth.py b/tests/test_oauth.py index e958b5e5..45363bdf 100644 --- a/tests/test_oauth.py +++ b/tests/test_oauth.py @@ -48,12 +48,12 @@ def test_oauth_start(self): # Test failed flows self.assertRaises(AuthException, oauth.start, "") - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, oauth.start, "google") # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(oauth.start("google")) @@ -65,7 +65,7 @@ def test_oauth_start(self): LoginOptions(mfa=True), ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True oauth.start("facebook") expected_uri = f"{common.DEFAULT_BASE_URL}{EndpointsV1.oauth_start_path}" @@ -77,7 +77,7 @@ def test_oauth_start(self): }, params={"provider": "facebook"}, json={}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -88,16 +88,16 @@ def test_oauth_start_with_login_options(self): # Test failed flows self.assertRaises(AuthException, oauth.start, "") - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, oauth.start, "google") # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(oauth.start("google")) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True lo = LoginOptions(stepup=True, custom_claims={"k1": "v1"}) oauth.start("facebook", login_options=lo, refresh_token="refresh") @@ -110,7 +110,7 @@ def test_oauth_start_with_login_options(self): }, params={"provider": "facebook"}, json={"stepup": True, "customClaims": {"k1": "v1"}, "mfa": False}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -125,12 +125,12 @@ def test_exchange_token(self): self.assertRaises(AuthException, oauth.exchange_token, "") self.assertRaises(AuthException, oauth.exchange_token, None) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, oauth.exchange_token, "c1") # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.cookies = {} @@ -148,7 +148,7 @@ def test_exchange_token(self): }, params=None, json={"code": "c1"}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) diff --git a/tests/test_otp.py b/tests/test_otp.py index 0d0b62da..8aa0d1bf 100644 --- a/tests/test_otp.py +++ b/tests/test_otp.py @@ -182,7 +182,7 @@ def test_sign_up(self): invalid_signup_user_details, ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -193,7 +193,7 @@ def test_sign_up(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedEmail": "t***@example.com"} @@ -213,7 +213,7 @@ def test_sign_up(self): "email": "dummy@dummy.com", } - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedEmail": "t***@example.com"} @@ -241,13 +241,13 @@ def test_sign_up(self): }, "email": "dummy@dummy.com", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) # Test success flow with sign up options - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedEmail": "t***@example.com"} @@ -279,13 +279,13 @@ def test_sign_up(self): "email": "dummy@dummy.com", "loginOptions": {"templateOptions": {"bla": "blue"}}, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) # Test user is None so using the login_id as default - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedEmail": "t***@example.com"} @@ -306,7 +306,7 @@ def test_sign_up(self): "user": {"email": "dummy@dummy.com"}, "email": "dummy@dummy.com", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -324,7 +324,7 @@ def test_sign_in(self): self.assertRaises(AuthException, client.otp.sign_in, DeliveryMethod.EMAIL, "") self.assertRaises(AuthException, client.otp.sign_in, DeliveryMethod.EMAIL, None) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -334,7 +334,7 @@ def test_sign_in(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedEmail": "t***@example.com"} @@ -352,7 +352,7 @@ def test_sign_in(self): ) # Validate refresh token used while provided - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: refresh_token = "dummy refresh token" client.otp.sign_in( DeliveryMethod.EMAIL, @@ -375,13 +375,13 @@ def test_sign_in(self): "mfa": False, }, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) # With template options - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: refresh_token = "dummy refresh token" client.otp.sign_in( DeliveryMethod.EMAIL, @@ -405,7 +405,7 @@ def test_sign_in(self): "mfa": False, }, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -418,7 +418,7 @@ def test_sign_up_or_in(self): AuthException, client.otp.sign_up_or_in, DeliveryMethod.EMAIL, "" ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -428,7 +428,7 @@ def test_sign_up_or_in(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedEmail": "t***@example.com"} @@ -439,7 +439,7 @@ def test_sign_up_or_in(self): ) # Test success flow with sign up options - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedEmail": "t***@example.com"} @@ -467,7 +467,7 @@ def test_sign_up_or_in(self): "templateOptions": {"bla": "blue"}, }, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, params=None, @@ -485,7 +485,7 @@ def test_verify_code(self): AuthException, client.otp.verify_code, DeliveryMethod.EMAIL, None, code ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -497,7 +497,7 @@ def test_verify_code(self): # Test success flow valid_jwt_token = "eyJhbGciOiJFUzM4NCIsImtpZCI6IlAyQ3R6VWhkcXBJRjJ5czlnZzdtczA2VXZ0QzQiLCJ0eXAiOiJKV1QifQ.eyJkcm4iOiJEU1IiLCJleHAiOjIyNjQ0Mzc1OTYsImlhdCI6MTY1OTYzNzU5NiwiaXNzIjoiUDJDdHpVaGRxcElGMnlzOWdnN21zMDZVdnRDNCIsInN1YiI6IlUyQ3UwajBXUHczWU9pUElTSmI1Mkwwd1VWTWcifQ.WLnlHugvzZtrV9OzBB7SjpCLNRvKF3ImFpVyIN5orkrjO2iyAKg_Rb4XHk9sXGC1aW8puYzLbhE1Jv3kk2hDcKggfE8OaRNRm8byhGFZHnvPJwcP_Ya-aRmfAvCLcKOL" - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {} @@ -530,7 +530,7 @@ def test_update_user_email(self): "refresh_token1", ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -541,7 +541,7 @@ def test_update_user_email(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedEmail": "t***@example.com"} @@ -564,14 +564,14 @@ def test_update_user_email(self): "addToLoginIDs": False, "onMergeUseExisting": False, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, params=None, ) # Test success flow with template options - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedEmail": "t***@example.com"} @@ -598,7 +598,7 @@ def test_update_user_email(self): "onMergeUseExisting": False, "templateOptions": {"bla": "blue"}, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, params=None, @@ -633,7 +633,7 @@ def test_update_user_phone(self): "refresh_token1", ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -645,7 +645,7 @@ def test_update_user_phone(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedPhone": "*****111"} @@ -668,13 +668,13 @@ def test_update_user_phone(self): "addToLoginIDs": False, "onMergeUseExisting": False, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, params=None, ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedPhone": "*****111"} @@ -697,13 +697,13 @@ def test_update_user_phone(self): "addToLoginIDs": False, "onMergeUseExisting": False, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, params=None, ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedPhone": "*****111"} @@ -726,14 +726,14 @@ def test_update_user_phone(self): "addToLoginIDs": False, "onMergeUseExisting": False, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, params=None, ) # Test success flow with template options - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = {"maskedPhone": "*****111"} @@ -761,7 +761,7 @@ def test_update_user_phone(self): "onMergeUseExisting": False, "templateOptions": {"bla": "blue"}, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, params=None, diff --git a/tests/test_password.py b/tests/test_password.py index 1d285bde..d6b1d37a 100644 --- a/tests/test_password.py +++ b/tests/test_password.py @@ -67,7 +67,7 @@ def test_sign_up(self): signup_user_details, ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -78,7 +78,7 @@ def test_sign_up(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True my_mock_response = mock.Mock() my_mock_response.ok = True @@ -110,7 +110,7 @@ def test_sign_up(self): "email": "dummy@dummy.com", }, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -147,7 +147,7 @@ def test_sign_in(self): None, ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -157,7 +157,7 @@ def test_sign_in(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True my_mock_response = mock.Mock() my_mock_response.ok = True @@ -181,7 +181,7 @@ def test_sign_in(self): "loginId": "dummy@dummy.com", "password": "123456", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -202,7 +202,7 @@ def test_send_reset(self): None, ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -211,7 +211,7 @@ def test_send_reset(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True my_mock_response = mock.Mock() my_mock_response.ok = True @@ -237,13 +237,13 @@ def test_send_reset(self): "loginId": "dummy@dummy.com", "redirectUrl": "https://redirect.here.com", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) # Test success flow with template options - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True my_mock_response = mock.Mock() my_mock_response.ok = True @@ -274,7 +274,7 @@ def test_send_reset(self): "redirectUrl": "https://redirect.here.com", "templateOptions": {"bla": "blue"}, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -331,7 +331,7 @@ def test_update(self): None, ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -342,7 +342,7 @@ def test_update(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True valid_jwt_token = "eyJhbGciOiJFUzM4NCIsImtpZCI6IjJCdDVXTGNjTFVleTFEcDd1dHB0WmIzRng5SyIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkVGVuYW50cyI6eyIiOm51bGx9LCJjb29raWVEb21haW4iOiIiLCJjb29raWVFeHBpcmF0aW9uIjoxNjYwNjc5MjA4LCJjb29raWVNYXhBZ2UiOjI1OTE5OTksImNvb2tpZU5hbWUiOiJEU1IiLCJjb29raWVQYXRoIjoiLyIsImV4cCI6MjA5MDA4NzIwOCwiaWF0IjoxNjU4MDg3MjA4LCJpc3MiOiIyQnQ1V0xjY0xVZXkxRHA3dXRwdFpiM0Z4OUsiLCJzdWIiOiIyQzU1dnl4dzBzUkw2RmRNNjhxUnNDRGRST1YifQ.cWP5up4R5xeIl2qoG2NtfLH3Q5nRJVKdz-FDoAXctOQW9g3ceZQi6rZQ-TPBaXMKw68bijN3bLJTqxWW5WHzqRUeopfuzTcMYmC0wP2XGJkrdF6A8D5QW6acSGqglFgu" self.assertIsNone( @@ -359,7 +359,7 @@ def test_update(self): "loginId": "dummy@dummy.com", "newPassword": "123456", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -416,7 +416,7 @@ def test_replace(self): None, ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -427,7 +427,7 @@ def test_replace(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True my_mock_response = mock.Mock() my_mock_response.ok = True @@ -454,7 +454,7 @@ def test_replace(self): "oldPassword": "123456", "newPassword": "1234567", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -462,7 +462,7 @@ def test_replace(self): def test_policy(self): password = Password(Auth(self.dummy_project_id, self.public_key_dict)) - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: mock_get.return_value.ok = False self.assertRaises( AuthException, @@ -470,7 +470,7 @@ def test_policy(self): ) # Test success flow - with patch("requests.get") as mock_get: + with patch("httpx.get") as mock_get: mock_get.return_value.ok = True my_mock_response = mock.Mock() my_mock_response.ok = True @@ -486,7 +486,7 @@ def test_policy(self): "Authorization": f"Bearer {self.dummy_project_id}", }, params=None, - allow_redirects=None, + follow_redirects=None, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) diff --git a/tests/test_saml.py b/tests/test_saml.py index c5381cbb..d1927c2e 100644 --- a/tests/test_saml.py +++ b/tests/test_saml.py @@ -40,16 +40,16 @@ def test_saml_start(self): self.assertRaises(AuthException, saml.start, "tenant1", "") self.assertRaises(AuthException, saml.start, "tenant1", None) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, saml.start, "tenant1", "http://dummy.com") # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(saml.start("tenant1", "http://dummy.com")) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True saml.start("tenant1", "http://dummy.com") expected_uri = ( @@ -63,7 +63,7 @@ def test_saml_start(self): }, params={"tenant": "tenant1", "redirectURL": "http://dummy.com"}, json={}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -84,16 +84,16 @@ def test_saml_start_with_login_options(self): self.assertRaises(AuthException, saml.start, "tenant1", "") self.assertRaises(AuthException, saml.start, "tenant1", None) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, saml.start, "tenant1", "http://dummy.com") # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(saml.start("tenant1", "http://dummy.com")) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True lo = LoginOptions(stepup=True, custom_claims={"k1": "v1"}) saml.start("tenant1", "http://dummy.com", lo, "refresh") @@ -108,7 +108,7 @@ def test_saml_start_with_login_options(self): }, params={"tenant": "tenant1", "redirectURL": "http://dummy.com"}, json={"stepup": True, "customClaims": {"k1": "v1"}, "mfa": False}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -123,12 +123,12 @@ def test_exchange_token(self): self.assertRaises(AuthException, saml.exchange_token, "") self.assertRaises(AuthException, saml.exchange_token, None) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, saml.exchange_token, "c1") # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.cookies = {} @@ -146,7 +146,7 @@ def test_exchange_token(self): }, params=None, json={"code": "c1"}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) diff --git a/tests/test_sso.py b/tests/test_sso.py index 74433d9a..aca743dc 100644 --- a/tests/test_sso.py +++ b/tests/test_sso.py @@ -38,16 +38,16 @@ def test_sso_start(self): self.assertRaises(AuthException, sso.start, "", "http://dummy.com") self.assertRaises(AuthException, sso.start, None, "http://dummy.com") - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, sso.start, "tenant1", "http://dummy.com") # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(sso.start("tenant1", "http://dummy.com")) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True sso.start("tenant1", "http://dummy.com") expected_uri = f"{common.DEFAULT_BASE_URL}{EndpointsV1.auth_sso_start_path}" @@ -59,7 +59,7 @@ def test_sso_start(self): }, params={"tenant": "tenant1", "redirectURL": "http://dummy.com"}, json={}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -78,16 +78,16 @@ def test_sso_start_with_login_options(self): self.assertRaises(AuthException, sso.start, "", "http://dummy.com") self.assertRaises(AuthException, sso.start, None, "http://dummy.com") - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, sso.start, "tenant1", "http://dummy.com") # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(sso.start("tenant1", "http://dummy.com")) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True lo = LoginOptions(stepup=True, custom_claims={"k1": "v1"}) sso.start("tenant1", "http://dummy.com", lo, "refresh") @@ -100,7 +100,7 @@ def test_sso_start_with_login_options(self): }, params={"tenant": "tenant1", "redirectURL": "http://dummy.com"}, json={"stepup": True, "customClaims": {"k1": "v1"}, "mfa": False}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -115,12 +115,12 @@ def test_exchange_token(self): self.assertRaises(AuthException, sso.exchange_token, "") self.assertRaises(AuthException, sso.exchange_token, None) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises(AuthException, sso.exchange_token, "c1") # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.cookies = {} @@ -138,7 +138,7 @@ def test_exchange_token(self): }, params=None, json={"code": "c1"}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) diff --git a/tests/test_totp.py b/tests/test_totp.py index ca9f0596..11789910 100644 --- a/tests/test_totp.py +++ b/tests/test_totp.py @@ -49,7 +49,7 @@ def test_sign_up(self): signup_user_details, ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -59,7 +59,7 @@ def test_sign_up(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(totp.sign_up("dummy@dummy.com", signup_user_details)) @@ -72,14 +72,14 @@ def test_sign_in(self): self.assertRaises(AuthException, totp.sign_in_code, "dummy@dummy.com", None) self.assertRaises(AuthException, totp.sign_in_code, "dummy@dummy.com", "") - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, totp.sign_in_code, "dummy@dummy.com", "1234" ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.cookies = {} @@ -98,7 +98,7 @@ def test_sign_in(self): ) # Validate refresh token used while provided - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.cookies = {} @@ -130,7 +130,7 @@ def test_sign_in(self): "mfa": False, }, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -144,7 +144,7 @@ def test_update_user(self): self.assertRaises(AuthException, totp.update_user, "dummy@dummy.com", None) self.assertRaises(AuthException, totp.update_user, "dummy@dummy.com", "") - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -171,7 +171,7 @@ def test_update_user(self): }, params=None, json={"loginId": "dummy@dummy.com"}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) diff --git a/tests/test_webauthn.py b/tests/test_webauthn.py index f750017f..2c2924ec 100644 --- a/tests/test_webauthn.py +++ b/tests/test_webauthn.py @@ -88,7 +88,7 @@ def test_sign_up_start(self): ) self.assertRaises(AuthException, webauthn.sign_up_start, "id1", "") - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, webauthn.sign_up_start, "id1", "https://example.com" @@ -98,11 +98,11 @@ def test_sign_up_start(self): valid_response = json.loads( """{"transactionId": "2COHI3LIixYhf6Q7EECYt20zyMi", "options": "{'publicKey':{'challenge':'5GOywA7BHL1QceQOfxHKDrasuN8SkbbgXmB5ImVZ+QU=','rp':{'name':'comp6','id':'localhost'},'user':{'name”:”dummy@dummy.com','displayName”:”dummy”,”id':'VTJDT0hJNWlWOHJaZ3VURkpKMzV3bjEydHRkTw=='},'pubKeyCredParams':[{'type':'public-key','alg':-7},{'type':'public-key','alg':-35},{'type':'public-key','alg':-36},{'type':'public-key','alg':-257},{'type':'public-key','alg':-258},{'type':'public-key','alg':-259},{'type':'public-key','alg':-37},{'type':'public-key','alg':-38},{'type':'public-key','alg':-39},{'type':'public-key','alg':-8}],'authenticatorSelection':{'userVerification':'preferred'},'timeout':60000,'attestation':'none'}}"}""" ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone(webauthn.sign_up_start("id1", "https://example.com")) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = valid_response @@ -118,7 +118,7 @@ def test_sign_up_start(self): }, params=None, json={"user": {"loginId": "id1"}, "origin": "https://example.com"}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -133,14 +133,14 @@ def test_sign_up_finish(self): self.assertRaises(AuthException, webauthn.sign_up_finish, "t01", "") self.assertRaises(AuthException, webauthn.sign_up_finish, "t01", None) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, webauthn.sign_up_finish, "t01", "response01" ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.cookies = {} @@ -167,7 +167,7 @@ def test_sign_up_finish(self): }, params=None, json={"transactionId": "t01", "response": "response01"}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -182,7 +182,7 @@ def test_sign_in_start(self): ) self.assertRaises(AuthException, webauthn.sign_in_start, "id", "") - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -195,7 +195,7 @@ def test_sign_in_start(self): valid_response = json.loads( """{"transactionId": "2COHI3LIixYhf6Q7EECYt20zyMi", "options": "{'publicKey':{'challenge':'5GOywA7BHL1QceQOfxHKDrasuN8SkbbgXmB5ImVZ+QU=','rp':{'name':'comp6','id':'localhost'},'user':{'name”:”dummy@dummy.com','displayName”:”dummy”,”id':'VTJDT0hJNWlWOHJaZ3VURkpKMzV3bjEydHRkTw=='},'pubKeyCredParams':[{'type':'public-key','alg':-7},{'type':'public-key','alg':-35},{'type':'public-key','alg':-36},{'type':'public-key','alg':-257},{'type':'public-key','alg':-258},{'type':'public-key','alg':-259},{'type':'public-key','alg':-37},{'type':'public-key','alg':-38},{'type':'public-key','alg':-39},{'type':'public-key','alg':-8}],'authenticatorSelection':{'userVerification':'preferred'},'timeout':60000,'attestation':'none'}}"}""" ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone( webauthn.sign_in_start("dummy@dummy.com", "https://example.com") @@ -208,7 +208,7 @@ def test_sign_in_start(self): LoginOptions(mfa=True), ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = valid_response @@ -227,7 +227,7 @@ def test_sign_in_start(self): "origin": "https://example.com", "loginOptions": {}, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -242,7 +242,7 @@ def test_sign_in_start_with_login_options(self): ) self.assertRaises(AuthException, webauthn.sign_in_start, "id", "") - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -255,13 +255,13 @@ def test_sign_in_start_with_login_options(self): valid_response = json.loads( """{"transactionId": "2COHI3LIixYhf6Q7EECYt20zyMi", "options": "{'publicKey':{'challenge':'5GOywA7BHL1QceQOfxHKDrasuN8SkbbgXmB5ImVZ+QU=','rp':{'name':'comp6','id':'localhost'},'user':{'name”:”dummy@dummy.com','displayName”:”dummy”,”id':'VTJDT0hJNWlWOHJaZ3VURkpKMzV3bjEydHRkTw=='},'pubKeyCredParams':[{'type':'public-key','alg':-7},{'type':'public-key','alg':-35},{'type':'public-key','alg':-36},{'type':'public-key','alg':-257},{'type':'public-key','alg':-258},{'type':'public-key','alg':-259},{'type':'public-key','alg':-37},{'type':'public-key','alg':-38},{'type':'public-key','alg':-39},{'type':'public-key','alg':-8}],'authenticatorSelection':{'userVerification':'preferred'},'timeout':60000,'attestation':'none'}}"}""" ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone( webauthn.sign_in_start("dummy@dummy.com", "https://example.com") ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = valid_response @@ -285,7 +285,7 @@ def test_sign_in_start_with_login_options(self): "mfa": False, }, }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -300,14 +300,14 @@ def test_sign_in_finish(self): self.assertRaises(AuthException, webauthn.sign_in_finish, "t01", "") self.assertRaises(AuthException, webauthn.sign_in_finish, "t01", None) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, webauthn.sign_in_finish, "t01", "response01" ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.cookies = {} @@ -328,7 +328,7 @@ def test_sign_in_finish(self): }, params=None, json={"transactionId": "t01", "response": "response01"}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -343,7 +343,7 @@ def test_sign_up_or_in_start(self): ) self.assertRaises(AuthException, webauthn.sign_up_or_in_start, "id", "") - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -356,13 +356,13 @@ def test_sign_up_or_in_start(self): valid_response = json.loads( """{"create": true, "transactionId": "2COHI3LIixYhf6Q7EECYt20zyMi", "options": "{'publicKey':{'challenge':'5GOywA7BHL1QceQOfxHKDrasuN8SkbbgXmB5ImVZ+QU=','rp':{'name':'comp6','id':'localhost'},'user':{'name”:”dummy@dummy.com','displayName”:”dummy”,”id':'VTJDT0hJNWlWOHJaZ3VURkpKMzV3bjEydHRkTw=='},'pubKeyCredParams':[{'type':'public-key','alg':-7},{'type':'public-key','alg':-35},{'type':'public-key','alg':-36},{'type':'public-key','alg':-257},{'type':'public-key','alg':-258},{'type':'public-key','alg':-259},{'type':'public-key','alg':-37},{'type':'public-key','alg':-38},{'type':'public-key','alg':-39},{'type':'public-key','alg':-8}],'authenticatorSelection':{'userVerification':'preferred'},'timeout':60000,'attestation':'none'}}"}""" ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone( webauthn.sign_up_or_in_start("dummy@dummy.com", "https://example.com") ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.json.return_value = valid_response @@ -380,7 +380,7 @@ def test_sign_up_or_in_start(self): "loginId": "id1", "origin": "https://example.com", }, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -412,7 +412,7 @@ def test_update_start(self): "https://example.com", ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, @@ -423,7 +423,7 @@ def test_update_start(self): ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = True self.assertIsNotNone( webauthn.update_start( @@ -431,7 +431,7 @@ def test_update_start(self): ) ) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: valid_response = json.loads("{}") my_mock_response = mock.Mock() my_mock_response.ok = True @@ -449,7 +449,7 @@ def test_update_start(self): }, params=None, json={"loginId": "dummy@dummy.com", "origin": "https://example.com"}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, ) @@ -464,14 +464,14 @@ def test_update_finish(self): self.assertRaises(AuthException, webauthn.update_finish, "t01", "") self.assertRaises(AuthException, webauthn.update_finish, "t01", None) - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: mock_post.return_value.ok = False self.assertRaises( AuthException, webauthn.update_finish, "t01", "response01" ) # Test success flow - with patch("requests.post") as mock_post: + with patch("httpx.post") as mock_post: my_mock_response = mock.Mock() my_mock_response.ok = True my_mock_response.cookies = {} @@ -490,7 +490,7 @@ def test_update_finish(self): }, params=None, json={"transactionId": "t01", "response": "response01"}, - allow_redirects=False, + follow_redirects=False, verify=True, timeout=DEFAULT_TIMEOUT_SECONDS, )