"""Test GET /identity//direct-access/resources/.""" import requests from tests.integration import config, utils def test_vendor_star_user_gets_label_participants(bearer_token_user_with_vendor_star): """Test a vendor * caller getting a user's label participants gets em all.""" # A test user with access to 2 (non-test) label participants test_id = 'f8a3d2e1-9b4c-4a7e-8f1d-3c6e9b2a5d7f' res = requests.get( f'{config.QA_BASE_URL}/identity/{test_id}/direct-access/resources/LabelParticipant', headers={ 'Authorization': f'Bearer {bearer_token_user_with_vendor_star}', 'Orchard-Profile-Type': 'SettingsProfile', 'Orchard-Profile-Id': utils.OWS_ACCOUNT_TEST_USER_SETTINGS_PROFILE_ID, 'Orchard-Identity-Id': utils.OWS_ACCOUNT_TEST_USER_ID, }, ) assert res.status_code == 200 assert len(res.json()['items']) == 2 assert next( item for item in res.json()['items'] if item.get('id') == 190632101 and item['type'] == 'LabelParticipant' ) assert next( item for item in res.json()['items'] if item.get('id') == 950814 and item['type'] == 'LabelParticipant' ) def test_admin_user_gets_one_label_participant(bearer_token_user_without_vendor_star): """Test an admin user getting label participants for a user gets the one it has access to.""" # A test user with access to 2 (non-test) label participants. # Our caller has access to only one of these. test_id = 'f8a3d2e1-9b4c-4a7e-8f1d-3c6e9b2a5d7f' res = requests.get( f'{config.QA_BASE_URL}/identity/{test_id}/direct-access/resources/LabelParticipant', headers={ 'Authorization': f'Bearer {bearer_token_user_without_vendor_star}', 'Orchard-Profile-Type': 'SettingsProfile', 'Orchard-Profile-Id': utils.OWS_PERMISSIONS_TEST_USER_SETTINGS_PROFILE_ID, 'Orchard-Identity-Id': utils.OWS_PERMISSIONS_TEST_USER_ID, }, ) assert res.status_code == 200 assert len(res.json()['items']) == 1 assert next( item for item in res.json()['items'] if item.get('id') == 190632101 and item['type'] == 'LabelParticipant' ) def test_non_admin_user_gets_no_label_participants(bearer_token): """Test a user without any LP access getting LPs for a user gets none.""" # A test user with access to 2 (non-test) label participants. # Our caller doesn't have access to either of them. test_id = 'f8a3d2e1-9b4c-4a7e-8f1d-3c6e9b2a5d7f' res = requests.get( f'{config.QA_BASE_URL}/identity/{test_id}/direct-access/resources/LabelParticipant', headers={ 'Authorization': f'Bearer {bearer_token}', 'Orchard-Profile-Type': 'SettingsProfile', 'Orchard-Profile-Id': utils.PDP_TEST_USER_SETTINGS_PROFILE_ID, 'Orchard-Identity-Id': utils.PDP_TEST_USER_ID, }, ) assert res.status_code == 200 assert len(res.json()['items']) == 0