Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d80be29

Browse files
committed
Replace callee development dependency
1 parent be89d62 commit d80be29

8 files changed

+31
-108
lines changed

auth0/test/authentication/test_get_token.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import unittest
2+
from fnmatch import fnmatch
23
from unittest import mock
4+
from unittest.mock import ANY
35

4-
from callee.strings import Glob
56
from cryptography.hazmat.primitives import asymmetric, serialization
67

78
from ...authentication.get_token import GetToken
@@ -59,14 +60,16 @@ def test_authorization_code_with_client_assertion(self, mock_post):
5960
kwargs["data"],
6061
{
6162
"client_id": "cid",
62-
"client_assertion": Glob("*.*.*"),
63+
"client_assertion": ANY,
6364
"client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
6465
"code": "cd",
6566
"grant_type": "gt",
6667
"redirect_uri": "idt",
6768
},
6869
)
6970

71+
self.assertTrue(fnmatch(kwargs["data"]["client_assertion"], "*.*.*"))
72+
7073
@mock.patch("auth0.rest.RestClient.post")
7174
def test_authorization_code_pkce(self, mock_post):
7275
g = GetToken("my.domain.com", "cid")
@@ -126,13 +129,15 @@ def test_client_credentials_with_client_assertion(self, mock_post):
126129
kwargs["data"],
127130
{
128131
"client_id": "cid",
129-
"client_assertion": Glob("*.*.*"),
132+
"client_assertion": ANY,
130133
"client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
131134
"audience": "aud",
132135
"grant_type": "gt",
133136
},
134137
)
135138

139+
self.assertTrue(fnmatch(kwargs["data"]["client_assertion"], "*.*.*"))
140+
136141
@mock.patch("auth0.rest.RestClient.post")
137142
def test_login(self, mock_post):
138143
g = GetToken("my.domain.com", "cid", client_secret="clsec")

auth0/test_async/test_async_auth0.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from unittest.mock import ANY, MagicMock
44

55
from aioresponses import CallbackResult, aioresponses
6-
from callee import Attrs
6+
from yarl import URL
77

88
from auth0.management.async_auth0 import AsyncAuth0 as Auth0
99

@@ -33,7 +33,7 @@ async def test_get(self, mocked):
3333
auth0 = Auth0(domain="example.com", token="jwt")
3434
self.assertEqual(await auth0.clients.all_async(), payload)
3535
mock.assert_called_with(
36-
Attrs(path="/api/v2/clients"),
36+
URL("https://example.com/api/v2/clients?include_fields=true"),
3737
allow_redirects=True,
3838
params={"include_fields": "true"},
3939
headers=ANY,
@@ -53,14 +53,14 @@ async def test_shared_session(self, mocked):
5353
payload,
5454
)
5555
mock.assert_called_with(
56-
Attrs(path="/api/v2/clients"),
56+
URL("https://example.com/api/v2/clients?include_fields=true"),
5757
allow_redirects=True,
5858
params={"include_fields": "true"},
5959
headers=ANY,
6060
timeout=ANY,
6161
)
6262
mock2.assert_called_with(
63-
Attrs(path="/api/v2/guardian/factors/factor-1"),
63+
URL("https://example.com/api/v2/guardian/factors/factor-1"),
6464
allow_redirects=True,
6565
json={"factor": 1},
6666
headers=ANY,

auth0/test_async/test_async_token_verifier.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import jwt
66
from aioresponses import aioresponses
7-
from callee import Attrs
87
from cryptography.hazmat.primitives import serialization
8+
from yarl import URL
99

1010
from .. import TokenValidationError
1111
from ..authentication.async_token_verifier import (
@@ -96,7 +96,7 @@ async def test_async_get_jwks_json_twice_on_cache_expired(
9696
self.assertEqual(expected_key_1_pem, RSA_PUB_KEY_1_PEM)
9797

9898
mock.assert_called_with(
99-
Attrs(path="/.well-known/jwks.json"),
99+
URL("https://example.auth0.com/.well-known/jwks.json"),
100100
allow_redirects=True,
101101
params=None,
102102
headers=ANY,
@@ -112,7 +112,7 @@ async def test_async_get_jwks_json_twice_on_cache_expired(
112112
self.assertEqual(expected_key_1_pem, RSA_PUB_KEY_1_PEM)
113113

114114
mock.assert_called_with(
115-
Attrs(path="/.well-known/jwks.json"),
115+
URL("https://example.auth0.com/.well-known/jwks.json"),
116116
allow_redirects=True,
117117
params=None,
118118
headers=ANY,
@@ -136,7 +136,7 @@ async def test_async_get_jwks_json_once_on_cache_hit(self, mocked):
136136
self.assertEqual(expected_key_2_pem, RSA_PUB_KEY_2_PEM)
137137

138138
mock.assert_called_with(
139-
Attrs(path="/.well-known/jwks.json"),
139+
URL("https://example.auth0.com/.well-known/jwks.json"),
140140
allow_redirects=True,
141141
params=None,
142142
headers=ANY,
@@ -157,7 +157,7 @@ async def test_async_fetches_jwks_json_forced_on_cache_miss(self, mocked):
157157
self.assertEqual(expected_key_1_pem, RSA_PUB_KEY_1_PEM)
158158

159159
mock.assert_called_with(
160-
Attrs(path="/.well-known/jwks.json"),
160+
URL("https://example.auth0.com/.well-known/jwks.json"),
161161
allow_redirects=True,
162162
params=None,
163163
headers=ANY,
@@ -174,7 +174,7 @@ async def test_async_fetches_jwks_json_forced_on_cache_miss(self, mocked):
174174
self.assertEqual(expected_key_2_pem, RSA_PUB_KEY_2_PEM)
175175

176176
mock.assert_called_with(
177-
Attrs(path="/.well-known/jwks.json"),
177+
URL("https://example.auth0.com/.well-known/jwks.json"),
178178
allow_redirects=True,
179179
params=None,
180180
headers=ANY,
@@ -193,7 +193,7 @@ async def test_async_fetches_jwks_json_once_on_cache_miss(self, mocked):
193193
await fetcher.get_key("missing-key")
194194

195195
mock.assert_called_with(
196-
Attrs(path="/.well-known/jwks.json"),
196+
URL("https://example.auth0.com/.well-known/jwks.json"),
197197
allow_redirects=True,
198198
params=None,
199199
headers=ANY,
@@ -216,7 +216,7 @@ async def test_async_fails_to_fetch_jwks_json_after_retrying_twice(self, mocked)
216216
await fetcher.get_key("id1")
217217

218218
mock.assert_called_with(
219-
Attrs(path="/.well-known/jwks.json"),
219+
URL("https://example.auth0.com/.well-known/jwks.json"),
220220
allow_redirects=True,
221221
params=None,
222222
headers=ANY,

auth0/test_async/test_asyncify.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import aiohttp
1111
from aioresponses import CallbackResult, aioresponses
12-
from callee import Attrs
12+
from yarl import URL
1313

1414
from auth0.asyncify import asyncify
1515
from auth0.authentication import GetToken, Users
@@ -65,7 +65,7 @@ async def test_get(self, mocked):
6565
c = asyncify(Clients)(domain="example.com", token="jwt")
6666
self.assertEqual(await c.all_async(), payload)
6767
mock.assert_called_with(
68-
Attrs(path="/api/v2/clients"),
68+
URL("https://example.com/api/v2/clients?include_fields=true"),
6969
allow_redirects=True,
7070
params={"include_fields": "true"},
7171
headers=headers,
@@ -80,7 +80,7 @@ async def test_post(self, mocked):
8080
data = {"client": 1}
8181
self.assertEqual(await c.create_async(data), payload)
8282
mock.assert_called_with(
83-
Attrs(path="/api/v2/clients"),
83+
URL("https://example.com/api/v2/clients"),
8484
allow_redirects=True,
8585
json=data,
8686
headers=headers,
@@ -96,7 +96,7 @@ async def test_post_auth(self, mocked):
9696
await c.login_async(username="usrnm", password="pswd"), payload
9797
)
9898
mock.assert_called_with(
99-
Attrs(path="/oauth/token"),
99+
URL("https://example.com/oauth/token"),
100100
allow_redirects=True,
101101
json={
102102
"client_id": "cid",
@@ -121,7 +121,7 @@ async def test_user_info(self, mocked):
121121
await c.userinfo_async(access_token="access-token-example"), payload
122122
)
123123
mock.assert_called_with(
124-
Attrs(path="/userinfo"),
124+
URL("https://example.com/userinfo"),
125125
headers={**headers, "Authorization": "Bearer access-token-example"},
126126
timeout=ANY,
127127
allow_redirects=True,
@@ -138,7 +138,7 @@ async def test_file_post(self, mocked):
138138
file_port_headers = headers.copy()
139139
file_port_headers.pop("Content-Type")
140140
mock.assert_called_with(
141-
Attrs(path="/api/v2/jobs/users-imports"),
141+
URL("https://example.com/api/v2/jobs/users-imports"),
142142
allow_redirects=True,
143143
data={
144144
"connection_id": "connection-1",
@@ -160,7 +160,7 @@ async def test_patch(self, mocked):
160160
data = {"client": 1}
161161
self.assertEqual(await c.update_async("client-1", data), payload)
162162
mock.assert_called_with(
163-
Attrs(path="/api/v2/clients/client-1"),
163+
URL("https://example.com/api/v2/clients/client-1"),
164164
allow_redirects=True,
165165
json=data,
166166
headers=headers,
@@ -175,7 +175,7 @@ async def test_put(self, mocked):
175175
data = {"factor": 1}
176176
self.assertEqual(await g.update_factor_async("factor-1", data), payload)
177177
mock.assert_called_with(
178-
Attrs(path="/api/v2/guardian/factors/factor-1"),
178+
URL("https://example.com/api/v2/guardian/factors/factor-1"),
179179
allow_redirects=True,
180180
json=data,
181181
headers=headers,
@@ -189,7 +189,7 @@ async def test_delete(self, mocked):
189189
c = asyncify(Clients)(domain="example.com", token="jwt")
190190
self.assertEqual(await c.delete_async("client-1"), payload)
191191
mock.assert_called_with(
192-
Attrs(path="/api/v2/clients/client-1"),
192+
URL("https://example.com/api/v2/clients/client-1"),
193193
allow_redirects=True,
194194
params={},
195195
json=None,
@@ -204,7 +204,7 @@ async def test_shared_session(self, mocked):
204204
async with asyncify(Clients)(domain="example.com", token="jwt") as c:
205205
self.assertEqual(await c.all_async(), payload)
206206
mock.assert_called_with(
207-
Attrs(path="/api/v2/clients"),
207+
URL("https://example.com/api/v2/clients?include_fields=true"),
208208
allow_redirects=True,
209209
params={"include_fields": "true"},
210210
headers=headers,

poetry.lock

Lines changed: 1 addition & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ requests = "^2.31.0"
3535

3636
[tool.poetry.group.dev.dependencies]
3737
aioresponses = "^0.7.4"
38-
callee = "^0.3.1"
3938
mock = "^5.1.0"
4039
pipx = "^1.2.0"
4140
pytest = "^7.4.0"

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ argcomplete==3.1.1 ; python_version >= "3.7" and python_version < "4.0"
55
async-timeout==4.0.3 ; python_version >= "3.7" and python_version < "4.0"
66
asynctest==0.13.0 ; python_version >= "3.7" and python_version < "3.8"
77
attrs==23.1.0 ; python_version >= "3.7" and python_version < "4.0"
8-
callee==0.3.1 ; python_version >= "3.7" and python_version < "4.0"
98
certifi==2023.7.22 ; python_version >= "3.7" and python_version < "4.0"
109
cffi==1.15.1 ; python_version >= "3.7" and python_version < "4.0"
1110
charset-normalizer==3.2.0 ; python_version >= "3.7" and python_version < "4.0"

test-pyproject.toml

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)