Always check group access when masquerading.
TNL-6050
This commit is contained in:
@@ -6,7 +6,6 @@ import django.test
|
||||
from mock import patch
|
||||
from nose.plugins.attrib import attr
|
||||
|
||||
from courseware.masquerade import handle_ajax, setup_masquerade
|
||||
from courseware.tests.test_masquerade import StaffMasqueradeTestCase
|
||||
from student.tests.factories import UserFactory
|
||||
from xmodule.partitions.partitions import Group, UserPartition, UserPartitionError
|
||||
@@ -341,30 +340,17 @@ class TestMasqueradedGroup(StaffMasqueradeTestCase):
|
||||
scheme_id='cohort'
|
||||
)
|
||||
self.course.user_partitions.append(self.user_partition)
|
||||
self.session = {}
|
||||
modulestore().update_item(self.course, self.test_user.id)
|
||||
|
||||
def _verify_masquerade_for_group(self, group):
|
||||
"""
|
||||
Verify that the masquerade works for the specified group id.
|
||||
"""
|
||||
# Send the request to set the masquerade
|
||||
request_json = {
|
||||
"role": "student",
|
||||
"user_partition_id": self.user_partition.id,
|
||||
"group_id": group.id if group is not None else None
|
||||
}
|
||||
request = self._create_mock_json_request(
|
||||
self.test_user,
|
||||
data=request_json,
|
||||
session=self.session
|
||||
self.ensure_masquerade_as_group_member( # pylint: disable=no-member
|
||||
self.user_partition.id,
|
||||
group.id if group is not None else None
|
||||
)
|
||||
response = handle_ajax(request, unicode(self.course.id))
|
||||
# pylint has issues analyzing this class (maybe due to circular imports?)
|
||||
self.assertEquals(response.status_code, 200) # pylint: disable=no-member
|
||||
|
||||
# Now setup the masquerade for the test user
|
||||
setup_masquerade(request, self.course.id, True)
|
||||
scheme = self.user_partition.scheme
|
||||
self.assertEqual(
|
||||
scheme.get_group_for_user(self.course.id, self.test_user, self.user_partition),
|
||||
|
||||
Reference in New Issue
Block a user