Skip to content

Commit c7b0804

Browse files
committed
drafts tests
1 parent c73f211 commit c7b0804

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

services/web/server/src/simcore_service_webserver/projects/_controller/groups_rest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from models_library.basic_types import IDStr
66
from models_library.groups import GroupID
77
from models_library.projects import ProjectID
8-
from pydantic import BaseModel, ConfigDict, EmailStr
8+
from pydantic import BaseModel, ConfigDict, EmailStr, HttpUrl
99
from servicelib.aiohttp import status
1010
from servicelib.aiohttp.requests_validation import (
1111
parse_request_body_as,
@@ -79,6 +79,8 @@ async def share_project(request: web.Request):
7979
request, code=confirmation_code
8080
)
8181

82+
assert HttpUrl(confirmation_link) # nosec
83+
8284
_logger.debug(
8385
"Send email with confirmation link %s to %s ",
8486
confirmation_link,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def app_environment(
270270
) -> EnvVarsDict:
271271
envs_plugins = setenvs_from_dict(
272272
monkeypatch,
273-
{},
273+
{"WEBSERVER_DEV_FEATURES_ENABLED": "1"},
274274
)
275275
return app_environment | envs_plugins
276276

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

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def mock_project_uses_available_services(mocker: MockerFixture):
3939
"Driving test for https://github.com/ITISFoundation/osparc-issues/issues/1547"
4040
)
4141
@pytest.mark.parametrize("user_role,expected", [(UserRole.USER, status.HTTP_200_OK)])
42-
async def test_projects_groups_full_workflow(
42+
async def test_projects_groups_full_workflow( # noqa: PLR0915
4343
client: TestClient,
4444
logged_user: UserInfoDict,
4545
user_project: ProjectDict,
@@ -251,3 +251,41 @@ async def test_projects_groups_full_workflow(
251251
"delete": True,
252252
},
253253
}
254+
255+
256+
@pytest.mark.parametrize("user_role", [UserRole.USER])
257+
async def test_share_project(
258+
client: TestClient,
259+
logged_user: UserInfoDict,
260+
user_project: ProjectDict,
261+
mock_catalog_api_get_services_for_user_in_product,
262+
mock_project_uses_available_services,
263+
):
264+
assert client.app
265+
266+
# Share the project with a fake email
267+
url = client.app.router["share_project"].url_for(
268+
project_id=f"{user_project['uuid']}"
269+
)
270+
resp = await client.post(
271+
f"{url}",
272+
json={
273+
"shareeEmail": "[email protected]",
274+
"read": True,
275+
"write": False,
276+
"delete": False,
277+
},
278+
)
279+
await assert_status(resp, status.HTTP_204_NO_CONTENT)
280+
281+
# Verify that only logged_user["primary_gid"] has access to the project
282+
url = client.app.router["list_project_groups"].url_for(
283+
project_id=f"{user_project['uuid']}"
284+
)
285+
resp = await client.get(f"{url}")
286+
data, _ = await assert_status(resp, status.HTTP_200_OK)
287+
assert len(data) == 1
288+
assert data[0]["gid"] == logged_user["primary_gid"]
289+
assert data[0]["read"] is True
290+
assert data[0]["write"] is True
291+
assert data[0]["delete"] is True

0 commit comments

Comments
 (0)