Skip to content

Commit 16c9d5a

Browse files
Empty string for user retrieving not allowed
1 parent 3f08f11 commit 16c9d5a

4 files changed

Lines changed: 34 additions & 0 deletions

File tree

src/conductor/asyncio_client/adapters/api/user_resource_api.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from pydantic import StrictStr
2+
13
from conductor.asyncio_client.http.api import UserResourceApi
24

35

@@ -11,3 +13,13 @@ async def get_granted_permissions(
1113
if not user_id:
1214
user_id = None
1315
return await super().get_granted_permissions(user_id=user_id, *args, **kwargs)
16+
17+
async def get_user(
18+
self,
19+
id: StrictStr,
20+
*args,
21+
**kwargs,
22+
) -> object:
23+
if not id:
24+
id = None
25+
return await super().get_user(id=id, *args, **kwargs)

src/conductor/client/adapters/api/user_resource_api_adapter.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ def get_granted_permissions(self, user_id, **kwargs):
66
if not user_id:
77
user_id = None
88
return super().get_granted_permissions(user_id=user_id, **kwargs)
9+
10+
def get_user(self, id, **kwargs):
11+
if not id:
12+
id = None
13+
return super().get_user(id=id, **kwargs)

tests/unit/orkes/test_async_authorization_client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,15 @@ async def test_get_user(mocker, authorization_client, conductor_user_adapter):
263263
assert user.uuid == USER_UUID
264264

265265

266+
@pytest.mark.asyncio
267+
async def test_get_user_with_empty_string(mocker, authorization_client, conductor_user_adapter):
268+
from conductor.asyncio_client.http.api import UserResourceApi
269+
mock = mocker.patch.object(UserResourceApi, "get_user")
270+
mock.return_value = conductor_user_adapter
271+
await authorization_client.get_user("")
272+
mock.assert_called_with(id=None)
273+
274+
266275
@pytest.mark.asyncio
267276
async def test_delete_user(mocker, authorization_client):
268277
mock = mocker.patch.object(UserResourceApiAdapter, "delete_user")

tests/unit/orkes/test_authorization_client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,14 @@ def test_get_user(mocker, authorization_client, conductor_user, roles):
312312
assert user.roles == roles
313313

314314

315+
def test_get_user_with_empty_string(mocker, authorization_client, conductor_user):
316+
from conductor.client.codegen.api.user_resource_api import UserResourceApi
317+
mock = mocker.patch.object(UserResourceApi, "get_user")
318+
mock.return_value = conductor_user.to_dict()
319+
authorization_client.get_user("")
320+
mock.assert_called_with(id=None)
321+
322+
315323
def test_list_users_with_apps(mocker, authorization_client, conductor_user):
316324
mock = mocker.patch.object(UserResourceApi, "list_users")
317325
mock.return_value = [conductor_user]

0 commit comments

Comments
 (0)