@@ -316,3 +316,43 @@ async def test_share_project(
316316 },
317317 )
318318 await assert_status (resp , status .HTTP_422_UNPROCESSABLE_ENTITY )
319+
320+
321+ @pytest .mark .parametrize (
322+ "user_role,expected_status" ,
323+ [
324+ (UserRole .ANONYMOUS , status .HTTP_401_UNAUTHORIZED ),
325+ (UserRole .GUEST , status .HTTP_403_FORBIDDEN ),
326+ (UserRole .USER , status .HTTP_202_ACCEPTED ),
327+ (UserRole .TESTER , status .HTTP_202_ACCEPTED ),
328+ (UserRole .ADMIN , status .HTTP_202_ACCEPTED ),
329+ ],
330+ )
331+ async def test_share_project_with_roles (
332+ client : TestClient ,
333+ logged_user : UserInfoDict ,
334+ user_project : ProjectDict ,
335+ mock_catalog_api_get_services_for_user_in_product : MockType ,
336+ mock_project_uses_available_services : MockType ,
337+ user_role : UserRole ,
338+ expected_status : HTTPStatus ,
339+ ):
340+ assert client .app
341+
342+ assert logged_user ["role" ] == user_role
343+
344+ # Attempt to share the project
345+ url = client .app .router ["share_project" ].url_for (
346+ project_id = f"{ user_project ['uuid' ]} "
347+ )
348+ resp = await client .post (
349+ f"{ url } " ,
350+ json = {
351+ "shareeEmail" :
"[email protected] " ,
352+ "sharerMessage" : "Sharing project with role test" ,
353+ "read" : True ,
354+ "write" : False ,
355+ "delete" : False ,
356+ },
357+ )
358+ await assert_status (resp , expected_status )
0 commit comments