Restrict grading endpoints in LMS
Cuurently, grading endpoints in capa module are vulnerable as they are not restricted.To avoid it, changes have been made so that they are available only for logged-in users. LEARNER-3761
This commit is contained in:
@@ -906,6 +906,26 @@ class TestHandleXBlockCallback(SharedModuleStoreTestCase, LoginEnrollmentTestCas
|
||||
with self.assertRaises(BlockCompletion.DoesNotExist):
|
||||
BlockCompletion.objects.get(block_key=block.scope_ids.usage_id)
|
||||
|
||||
@XBlock.register_temp_plugin(GradedStatelessXBlock, identifier='stateless_scorer')
|
||||
@patch('lms.djangoapps.courseware.module_render.grades_signals.SCORE_PUBLISHED.send')
|
||||
def test_anonymous_user_not_be_graded(self, mock_score_signal):
|
||||
course = CourseFactory.create()
|
||||
descriptor_kwargs = {
|
||||
'category': 'problem',
|
||||
}
|
||||
request = self.request_factory.get('/')
|
||||
request.user = AnonymousUser()
|
||||
descriptor = ItemFactory.create(**descriptor_kwargs)
|
||||
|
||||
render.handle_xblock_callback(
|
||||
request,
|
||||
text_type(course.id),
|
||||
quote_slashes(text_type(descriptor.location)),
|
||||
'xmodule_handler',
|
||||
'problem_check',
|
||||
)
|
||||
self.assertFalse(mock_score_signal.called)
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_XBLOCK_VIEW_ENDPOINT': True})
|
||||
|
||||
Reference in New Issue
Block a user