"""Tests for the GET /internal/users endpoint.""" import requests from tests.integration import config, constants def test_get_internal_users_without_jwt() -> None: """Test getting internal users without a JWT.""" headers = { 'Content-Type': 'application/json', 'Orchard-Identity-Id': constants.INTEGRATION_TEST_USER_IDENTITY_ID, 'Orchard-Profile-Id': '650536', 'Orchard-Profile-Type': 'SettingsProfile', } res = requests.get( f'{config.QA_BASE_URL}/internal/users?term=test', headers=headers, ) assert res.status_code == 401 assert res.json().get('code') == 'authorization_error' assert res.json().get('message') == 'Request context has no identity uuid.' def test_get_internal_users_without_pp_role(authorized_user_jwt: str) -> None: """Test getting internal users without having the proper role.""" headers = { 'Authorization': f'Bearer {authorized_user_jwt}', 'Content-Type': 'application/json', } res = requests.get( f'{config.QA_BASE_URL}/internal/users?term=test', headers=headers, ) assert res.status_code == 403 def test_get_internal_users(seat_admin_jwt: str) -> None: """Test getting internal users with the seat role.""" headers = { 'Authorization': f'Bearer {seat_admin_jwt}', 'Content-Type': 'application/json', } res = requests.get( f'{config.QA_BASE_URL}/internal/users?term=2dc78f55-4361-4138-959e-35b498274d3e', headers=headers, ) assert res.status_code == 200 # QA test user with their id in their name field assert res.json() == {'users': ['2dc78f55-4361-4138-959e-35b498274d3e']}