"""Test v2 profile all label access endpoint.""" import pytest import requests from tests.integration import config, utils @pytest.mark.parametrize( ('profile_type', 'profile_id', 'identity_id', 'expected_has_access'), [ pytest.param( 'SettingsProfile', '465788', utils.OWS_ACCOUNT_TEST_USER_ID, True, id='SettingsProfile with vendor star access', ), pytest.param( 'CollaboratorsProfile', '467616', utils.OWS_PERMISSIONS_TEST_USER_ID, False, id='CollaboratorsProfile without vendor star access', ), pytest.param( 'FakeProfile', '999999', utils.OWS_PERMISSIONS_TEST_USER_ID, False, id='Non-existent profile returns false', ), ], ) def test_v2_profile_all_label_access( profile_type: str, profile_id: str, identity_id: str, expected_has_access: bool, ) -> None: """Test GET /v2/profile/self/all-label-access without JWT.""" response = requests.get( f'{config.QA_BASE_URL}/v2/profile/self/all-label-access', headers={ 'Orchard-Profile-Type': profile_type, 'Orchard-Profile-Id': profile_id, 'Orchard-Identity-Id': identity_id, 'Orchard-Requestor-Service': 'graphql-user', }, ) assert response.status_code == 200 assert response.json()['has_access'] is expected_has_access def test_v2_profile_all_label_access_forbidden_context() -> None: """Test GET /v2/profile/self/all-label-access returns 403 for wrong context type.""" response = requests.get( f'{config.QA_BASE_URL}/v2/profile/self/all-label-access', headers={'Orchard-User-Id': 'alw:123', 'Orchard-Requestor-Service': 'ows-account'}, ) assert response.status_code == 403 assert response.json()['code'] == 'authorization_error' assert response.json()['message'] == 'access denied'