Skip to content

Commit 22cf0e2

Browse files
committed
✨ users: Update account request status handling in API and tests
1 parent 5b0a63e commit 22cf0e2

File tree

4 files changed

+18
-25
lines changed

4 files changed

+18
-25
lines changed

packages/models-library/src/models_library/api_schemas_webserver/users.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -241,24 +241,12 @@ def from_domain_model(cls, data):
241241

242242

243243
class UsersForAdminListFilter(Filters):
244-
# 1. States of an Account Resquest: PENDING, REJECTED, APPROVED
245-
# 2. If APPROVED AND user uses the invitation link, then it can be in any of these states:
246-
# CONFIRMATION_PENDING, ACTIVE, EXPIRED, BANNED, DELETED
244+
# 1. account_request_status: PENDING, REJECTED, APPROVED
245+
# 2. If APPROVED AND user uses the invitation link, then when user is registered,
246+
# it can be in any of these statuses:
247+
# CONFIRMATION_PENDING, ACTIVE, EXPIRED, BANNED, DELETED
247248
#
248-
status: (
249-
Literal[
250-
"PENDING",
251-
# NOTE: future states
252-
# "REJECTED",
253-
# "APPROVED",
254-
# "CONFIRMATION_PENDING",
255-
# "ACTIVE",
256-
# "EXPIRED",
257-
# "BANNED",
258-
# "DELETED",
259-
]
260-
| None
261-
) = None
249+
account_request_status: Literal["PENDING", "REJECETED", "APPROVED"] | None = None
262250

263251

264252
class UsersForAdminListQueryParams(UsersForAdminListFilter, PageQueryParameters): ...

services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,15 +1387,18 @@ paths:
13871387
type: integer
13881388
default: 0
13891389
title: Offset
1390-
- name: status
1390+
- name: account_request_status
13911391
in: query
13921392
required: false
13931393
schema:
13941394
anyOf:
1395-
- const: PENDING
1395+
- enum:
1396+
- PENDING
1397+
- REJECETED
1398+
- APPROVED
13961399
type: string
13971400
- type: 'null'
1398-
title: Status
1401+
title: Account Request Status
13991402
responses:
14001403
'200':
14011404
description: Successful Response

services/web/server/src/simcore_service_webserver/users/_users_rest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ async def list_users_for_admin(request: web.Request) -> web.Response:
183183
request.app,
184184
product_name=req_ctx.product_name,
185185
filter_account_request_status=(
186-
AccountRequestStatus(query_params.status) if query_params.status else None
186+
AccountRequestStatus(query_params.account_request_status)
187+
if query_params.account_request_status
188+
else None
187189
),
188190
pagination_limit=query_params.limit,
189191
pagination_offset=query_params.offset,

services/web/server/tests/unit/with_dbs/03/test_users_rest_registration.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,15 @@ async def test_list_users_for_admin(
267267
assert registered_email not in pending_emails
268268
assert len(pending_emails) >= len(pre_registered_users) - 1
269269

270-
# b. Check ACTIVE filter (should include only the registered user)
270+
# b. Check all users
271271
resp = await client.get(
272-
f"{url}?status=ACTIVE", headers={X_PRODUCT_NAME_HEADER: product_name}
272+
f"{url}?status=APPROVED", headers={X_PRODUCT_NAME_HEADER: product_name}
273273
)
274-
active_data, _ = await assert_status(resp, status.HTTP_200_OK)
274+
approved_data, _ = await assert_status(resp, status.HTTP_200_OK)
275275

276276
# Find the registered user in the active users
277277
active_user = next(
278-
(item for item in active_data if item["email"] == registered_email),
278+
(item for item in approved_data if item["email"] == registered_email),
279279
None,
280280
)
281281
assert active_user is not None

0 commit comments

Comments
 (0)