Skip to content

Commit 0b8c698

Browse files
fix
1 parent 26ac23b commit 0b8c698

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

services/web/server/src/simcore_service_webserver/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ClientSessionHeaderParams(RequestParameters):
4848

4949
client_session_id: ClientSessionID | None = Field(
5050
default=None,
51-
alias="x-client-session-id", # X_CLIENT_SESSION_ID_HEADER,
51+
alias="X-Client-Session-Id", # X_CLIENT_SESSION_ID_HEADER,
5252
description="Client session identifier for collaborative features (UUID string)",
5353
)
5454

services/web/server/tests/unit/with_dbs/02/test_projects_crud_handlers__patch.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88

99
import json
10+
import uuid
1011
from http import HTTPStatus
1112

1213
import pytest
@@ -185,3 +186,60 @@ async def test_patch_project(
185186
assert data["ui"] == _patch_ui_2["ui"]
186187
assert data["quality"] == _patch_quality["quality"]
187188
assert data["dev"] == _patch_dev["dev"]
189+
190+
191+
@pytest.mark.parametrize(
192+
"user_role,expected", [(UserRole.USER, status.HTTP_204_NO_CONTENT)]
193+
)
194+
async def test_patch_project_with_client_session_header(
195+
client: TestClient,
196+
logged_user: UserInfoDict,
197+
user_project: ProjectDict,
198+
expected: HTTPStatus,
199+
):
200+
assert client.app
201+
base_url = client.app.router["patch_project"].url_for(
202+
project_id=user_project["uuid"]
203+
)
204+
205+
# Generate a valid UUID for client session ID
206+
client_session_id = str(uuid.uuid4())
207+
208+
# Test patch with X-Client-Session-Id header - should succeed
209+
resp = await client.patch(
210+
f"{base_url}",
211+
data=json.dumps(
212+
{
213+
"name": "testing-name-with-session",
214+
"description": "testing-description-with-session",
215+
}
216+
),
217+
headers={"X-Client-Session-Id": client_session_id},
218+
)
219+
await assert_status(resp, expected)
220+
221+
# Test patch without X-Client-Session-Id header - should also succeed (header is optional)
222+
resp = await client.patch(
223+
f"{base_url}",
224+
data=json.dumps(
225+
{
226+
"name": "testing-name-without-session",
227+
"description": "testing-description-without-session",
228+
}
229+
),
230+
)
231+
await assert_status(resp, expected)
232+
233+
# Test patch with invalid X-Client-Session-Id header - should fail with validation error
234+
resp = await client.patch(
235+
f"{base_url}",
236+
data=json.dumps(
237+
{
238+
"name": "testing-name-invalid-session",
239+
"description": "testing-description-invalid-session",
240+
}
241+
),
242+
headers={"X-Client-Session-Id": "invalid-uuid-format"},
243+
)
244+
# This should fail validation since it's not a proper UUID
245+
await assert_status(resp, status.HTTP_422_UNPROCESSABLE_ENTITY)

0 commit comments

Comments
 (0)