Skip to content

Commit d25b6f1

Browse files
committed
Merge branch 'is1779/fixes-master' of github.com:pcrespov/osparc-simcore into enh/list-licensed-items
2 parents 6acc12f + 739fad7 commit d25b6f1

File tree

6 files changed

+31
-22
lines changed

6 files changed

+31
-22
lines changed

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
model_validator,
1515
)
1616

17-
from ..basic_types import IDStr
1817
from ..emails import LowerCaseEmailStr
1918
from ..groups import (
2019
AccessRightsDict,
2120
Group,
21+
GroupID,
2222
GroupMember,
2323
StandardGroupCreate,
2424
StandardGroupUpdate,
2525
)
26-
from ..users import UserID
26+
from ..users import UserID, UserNameID
2727
from ..utils.common_validators import create__check_only_one_is_set__root_validator
2828
from ._base import InputSchema, OutputSchema
2929

@@ -55,7 +55,7 @@ class GroupAccessRights(BaseModel):
5555

5656

5757
class GroupGet(OutputSchema):
58-
gid: int = Field(..., description="the group ID")
58+
gid: GroupID = Field(..., description="the group ID")
5959
label: str = Field(..., description="the group name")
6060
description: str = Field(..., description="the group description")
6161
thumbnail: AnyUrl | None = Field(
@@ -228,13 +228,11 @@ class GroupUserGet(BaseModel):
228228
# OutputSchema
229229

230230
# Identifiers
231-
id: Annotated[
232-
str | None, Field(description="the user id", coerce_numbers_to_str=True)
233-
] = None
234-
user_name: Annotated[IDStr, Field(alias="userName")]
231+
id: Annotated[UserID | None, Field(description="the user's id")] = None
232+
user_name: Annotated[UserNameID, Field(alias="userName")]
235233
gid: Annotated[
236-
str | None,
237-
Field(description="the user primary gid", coerce_numbers_to_str=True),
234+
GroupID | None,
235+
Field(description="the user primary gid"),
238236
] = None
239237

240238
# Private Profile
@@ -296,7 +294,7 @@ class GroupUserAdd(InputSchema):
296294
"""
297295

298296
uid: UserID | None = None
299-
user_name: Annotated[IDStr | None, Field(alias="userName")] = None
297+
user_name: Annotated[UserNameID | None, Field(alias="userName")] = None
300298
email: Annotated[
301299
LowerCaseEmailStr | None,
302300
Field(

services/web/server/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.49.0
1+
0.50.0

services/web/server/setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.49.0
2+
current_version = 0.50.0
33
commit = True
44
message = services/webserver api version: {current_version} → {new_version}
55
tag = False

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ openapi: 3.1.0
22
info:
33
title: simcore-service-webserver
44
description: Main service with an interface (http-API & websockets) to the web front-end
5-
version: 0.49.0
5+
version: 0.50.0
66
servers:
77
- url: ''
88
description: webserver
@@ -10033,8 +10033,10 @@ components:
1003310033
properties:
1003410034
gid:
1003510035
type: integer
10036+
exclusiveMinimum: true
1003610037
title: Gid
1003710038
description: the group ID
10039+
minimum: 0
1003810040
label:
1003910041
type: string
1004010042
title: Label
@@ -10116,18 +10118,22 @@ components:
1011610118
properties:
1011710119
id:
1011810120
anyOf:
10119-
- type: string
10121+
- type: integer
10122+
exclusiveMinimum: true
10123+
minimum: 0
1012010124
- type: 'null'
1012110125
title: Id
10122-
description: the user id
10126+
description: the user's id
1012310127
userName:
1012410128
type: string
1012510129
maxLength: 100
1012610130
minLength: 1
1012710131
title: Username
1012810132
gid:
1012910133
anyOf:
10130-
- type: string
10134+
- type: integer
10135+
exclusiveMinimum: true
10136+
minimum: 0
1013110137
- type: 'null'
1013210138
title: Gid
1013310139
description: the user primary gid

services/web/server/src/simcore_service_webserver/groups/_groups_api.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,11 @@ async def add_user_in_group(
258258
)
259259
new_by_user_id = user.id
260260

261-
if not new_by_user_id:
262-
msg = "Missing new user in arguments"
263-
raise GroupsError(msg=msg)
264-
265261
return await _groups_db.add_new_user_in_group(
266262
app,
267263
user_id=user_id,
268264
group_id=group_id,
269265
new_user_id=new_by_user_id,
266+
new_user_name=new_by_user_name,
270267
access_rights=access_rights,
271268
)

services/web/server/tests/unit/with_dbs/01/groups/test_groups_handlers_crud.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,23 @@ async def test_list_user_groups_and_try_modify_organizations(
8585
key=by_gid,
8686
) == sorted(standard_groups, key=by_gid)
8787

88-
for group in standard_groups:
88+
for i, group in enumerate(standard_groups):
8989
# try to delete a group
9090
url = client.app.router["delete_group"].url_for(gid=f"{group['gid']}")
9191
response = await client.delete(f"{url}")
9292
await assert_status(response, status.HTTP_403_FORBIDDEN)
9393

9494
# try to add some user in the group
9595
url = client.app.router["add_group_user"].url_for(gid=f"{group['gid']}")
96-
response = await client.post(f"{url}", json={"uid": logged_user["id"]})
96+
97+
if i % 2 == 0:
98+
# by user-id
99+
params = {"uid": logged_user["id"]}
100+
else:
101+
# by user name
102+
params = {"userName": logged_user["name"]}
103+
104+
response = await client.post(f"{url}", json=params)
97105
await assert_status(response, status.HTTP_403_FORBIDDEN)
98106

99107
# try to modify the user in the group

0 commit comments

Comments
 (0)