Shahar Mizrahi
10/19/2025, 12:25 PM@pytest.fixture(scope="session")
def testing_user(descope_client: DescopeClient) -> Generator[str, None, None]:
login_id = f"{uuid.uuid4()}@test-user.com"
descope_client.mgmt.user.create_test_user(
login_id=login_id,
email=login_id,
display_name="John Doe",
role_names=DESCOPE_TEST_USER_ROLES,
user_tenants=[DESCOPE_TEST_TENANT],
verified_email=True,
)
yield login_id
descope_client.mgmt.user.delete(login_id=login_id)
I dont have permissions to delete a specific user (provided management key with insufficient permissions [required permissions: project-asset-mgmt-read-write]") but do have permissions to delete_all_test_users
using delete_all_test_users is not feasible because multiple tests may run at the same time, I can run a background task that periodically delete tests user
but I believe that if I have permissions to delete all tests users, I should have an option to delete a specific test user
BTW, a simple expiration date for the user will work even better