1+ import pytest
12from aiohttp .test_utils import TestClient
3+ from common_library .users_enums import UserRole
24from models_library .products import ProductName
5+ from models_library .projects import ProjectID
36from pytest_simcore .helpers .webserver_login import UserInfoDict
47from simcore_service_webserver .projects ._jobs_service import (
58 list_my_projects_marked_as_jobs ,
811from simcore_service_webserver .projects .models import ProjectDict
912
1013
14+ @pytest .fixture
15+ def user_role () -> UserRole :
16+ # for logged_user
17+ return UserRole .USER
18+
19+
1120async def test_list_my_projects_marked_as_jobs_empty (
1221 client : TestClient ,
1322 logged_user : UserInfoDict , # owns `user_project`
@@ -30,14 +39,19 @@ async def test_list_my_projects_marked_as_jobs_with_one_marked(
3039 client : TestClient ,
3140 logged_user : UserInfoDict , # owns `user_project`
3241 user_project : ProjectDict ,
42+ user : UserInfoDict ,
3343 osparc_product_name : ProductName ,
3444):
3545 assert client .app
3646
3747 user_id = logged_user ["id" ]
38- project_uuid = user_project ["uuid" ]
39- job_parent_resource_name = "test/resource"
48+ project_uuid = ProjectID (user_project ["uuid" ])
49+ other_user_id = user ["id" ]
50+
51+ assert user_id != other_user_id
52+ assert user_project ["prjOwner" ] == logged_user ["email" ] # owns `user_project`
4053
54+ job_parent_resource_name = "test/resource"
4155 await set_project_as_job (
4256 app = client .app ,
4357 product_name = osparc_product_name ,
@@ -46,6 +60,7 @@ async def test_list_my_projects_marked_as_jobs_with_one_marked(
4660 job_parent_resource_name = job_parent_resource_name ,
4761 )
4862
63+ # user can see the project
4964 total_count , result = await list_my_projects_marked_as_jobs (
5065 app = client .app ,
5166 product_name = osparc_product_name ,
@@ -58,6 +73,16 @@ async def test_list_my_projects_marked_as_jobs_with_one_marked(
5873 assert project .uuid == project_uuid
5974 assert project .job_parent_resource_name == job_parent_resource_name
6075
76+ # other-user cannot see the project even if it is marked as a job
77+ total_count , result = await list_my_projects_marked_as_jobs (
78+ app = client .app ,
79+ product_name = osparc_product_name ,
80+ user_id = other_user_id ,
81+ )
82+ assert total_count == 0
83+ assert len (result ) == 0
84+
85+ # user can see the project with a filter
6186 total_count , result = await list_my_projects_marked_as_jobs (
6287 app = client .app ,
6388 product_name = osparc_product_name ,
@@ -71,6 +96,7 @@ async def test_list_my_projects_marked_as_jobs_with_one_marked(
7196 assert project .uuid == project_uuid
7297 assert project .job_parent_resource_name == job_parent_resource_name
7398
99+ # user can see the project with a wildcard filter
74100 total_count , result = await list_my_projects_marked_as_jobs (
75101 app = client .app ,
76102 product_name = osparc_product_name ,
@@ -81,9 +107,10 @@ async def test_list_my_projects_marked_as_jobs_with_one_marked(
81107 assert len (result ) == 1
82108
83109 project = result [0 ]
84- assert project .project_uuid == project_uuid
110+ assert project .uuid == project_uuid
85111 assert project .job_parent_resource_name == job_parent_resource_name
86112
113+ # user cannot see the project with another wildcard filter
87114 total_count , result = await list_my_projects_marked_as_jobs (
88115 app = client .app ,
89116 product_name = osparc_product_name ,
0 commit comments