Cause: The test_retrieve_user_access_allowed test is failing because the API returns a 403 Forbidden status code instead of the expected 200 OK. This indicates an issue with the permission or authentication logic in your application.Role Format Mismatch: The role in the token is USERROLE.ADMIN, which includes a prefix USERROLE. that might not match the expected ADMIN role in your authorization checks.
Resolution: if 'role' in to_encode:
to_encode['role'] = str(to_encode['role']).split('.')[-1].upper()
This code was added to jwt_service.py to get only ADMIN as the user role.
Issue: FAILED tests/test_api/test_users_api.py::test_list_users_as_manager - assert 403 == 200
Cause: The test_retrieve_user_access_allowed test is failing because the API returns a 403 Forbidden status code instead of the expected 200 OK. This indicates an issue with the permission or authentication logic in your application.Role Format Mismatch: The role in the token is USERROLE.ADMIN, which includes a prefix USERROLE. that might not match the expected ADMIN role in your authorization checks.
Resolution: if 'role' in to_encode: to_encode['role'] = str(to_encode['role']).split('.')[-1].upper() This code was added to jwt_service.py to get only ADMIN as the user role.
Files changed: jwt_service.py, test_users_api.py, dependencies.py