"""Tests for the GET /identities//application-access/ endpoint.""" import requests from tests.integration import config, constants def test_get_application_access_with_seat_access( authorized_user_jwt: str, auth0_action_test_machine_jwt: str, ): """Test getting application access for a user with seat access.""" permissionless_user_headers = { 'Authorization': f'Bearer {authorized_user_jwt}', 'Content-Type': 'application/json', } test_machine_headers = { 'Authorization': f'Bearer {auth0_action_test_machine_jwt}', 'Content-Type': 'application/json', } # Call by user who doesn't have permissions to get roles res = requests.get( f'{config.QA_BASE_URL}/identities/{constants.SEAT_ADMIN_IDENTITY_ID}' '/application-access/seat', headers=permissionless_user_headers, ) assert res.status_code == 200 assert res.json() == {'has_access': False} # Call by test machine, who does res = requests.get( f'{config.QA_BASE_URL}/identities/{constants.SEAT_ADMIN_IDENTITY_ID}' '/application-access/seat', headers=test_machine_headers, ) assert res.status_code == 200 assert res.json() == {'has_access': True} def test_get_application_access_without_seat_access( authorized_user_jwt: str, auth0_action_test_machine_jwt: str, ): """Test getting application access for a user without seat access.""" permissionless_user_headers = { 'Authorization': f'Bearer {authorized_user_jwt}', 'Content-Type': 'application/json', } test_machine_headers = { 'Authorization': f'Bearer {auth0_action_test_machine_jwt}', 'Content-Type': 'application/json', } # Call by user who doesn't have permissions to get roles res = requests.get( f'{config.QA_BASE_URL}/identities/{constants.INTEGRATION_TEST_USER_IDENTITY_ID}' '/application-access/seat', headers=permissionless_user_headers, ) assert res.status_code == 200 assert res.json() == {'has_access': False} # Call by test machine, who does res = requests.get( f'{config.QA_BASE_URL}/identities/{constants.INTEGRATION_TEST_USER_IDENTITY_ID}' '/application-access/seat', headers=test_machine_headers, ) assert res.status_code == 200 assert res.json() == {'has_access': False}