deepthisanand2024 / hw10_event_manager

MIT License
0 stars 0 forks source link

Role format mismatch #8

Closed deepthisanand2024 closed 1 month ago

deepthisanand2024 commented 1 month ago

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

deepthisanand2024 commented 1 month ago

Separate branch was not created since this code was merged with the previous fix for test_api