You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace this test with the following code, and it'll fail (a serializer issue)
deftest_success(self):
"""Verify that the view returns the correct response"""self.login_user(self.staff_user)
response=self.client.get(self.url)
self.assertEqual(response.status_code, http_status.HTTP_200_OK)
user_id=15course_id='course-v1:ORG1+5+5'response=self.client.get(self.url, data={'course_ids': course_id, 'user_ids': user_id})
self.assertEqual(response.status_code, http_status.HTTP_200_OK)
self.assertEqual(response.data['count'], 1)
self.assertEqual(response.data['results'][0]['user_id'], user_id)
self.assertEqual(response.data['results'][0]['course_id'], course_id)
In get_learners_enrollments_queryset, make the annotations removable for performance reasons
I found a permission bug in the original get_learners_by_course_queryset function. Same bug in the new get_learners_enrollments_queryset function. We do not want to fix the bug in the original since we're deprecating it soon. Just fix it with the new one. The function does not care about the caller's access. It should receive fx_permission_info and use it to verify that the caller has permission to the selected courses. Create a new function verify_course_access that takes fx_permission_info and course_ids as arguments and do the magic there; raise an FXCodedException if any course is not accessible by the caller.
We also need to verify the access of the requested learners (user_ids). Use get_permitted_learners_queryset to do the verification at the beginning of get_learners_enrollments_queryset
Finally, we have a bug when the caller is not specifying the course_ids. The query will return all courses in the system. It must filter on all accessible courses. fx_permission_info is to be used for that purpose too
The text was updated successfully, but these errors were encountered:
We have several things to fix:
get_learners_enrollments_queryset
, make the annotations removable for performance reasonsget_learners_by_course_queryset
function. Same bug in the newget_learners_enrollments_queryset
function. We do not want to fix the bug in the original since we're deprecating it soon. Just fix it with the new one. The function does not care about the caller's access. It should receivefx_permission_info
and use it to verify that the caller has permission to the selected courses. Create a new functionverify_course_access
that takesfx_permission_info
andcourse_ids
as arguments and do the magic there; raise anFXCodedException
if any course is not accessible by the caller.user_ids
). Useget_permitted_learners_queryset
to do the verification at the beginning ofget_learners_enrollments_queryset
course_ids
. The query will return all courses in the system. It must filter on all accessible courses.fx_permission_info
is to be used for that purpose tooThe text was updated successfully, but these errors were encountered: