Revert "Decorated instructor dashboard with sudo_required."

This commit is contained in:
Adam
2015-07-17 12:11:38 -04:00
parent b12d3f6303
commit 2735b2b5bb
88 changed files with 555 additions and 1229 deletions

View File

@@ -283,7 +283,6 @@ class TestInstructorAPIDenyLevels(ModuleStoreTestCase, LoginEnrollmentTestCase):
CourseEnrollment.enroll(staff_member, self.course.id)
CourseFinanceAdminRole(self.course.id).add_users(staff_member)
self.client.login(username=staff_member.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
# Try to promote to forums admin - not working
# update_forum_role(self.course.id, staff_member, FORUM_ROLE_ADMINISTRATOR, 'allow')
@@ -306,23 +305,6 @@ class TestInstructorAPIDenyLevels(ModuleStoreTestCase, LoginEnrollmentTestCase):
"Staff member should not be allowed to access endpoint " + endpoint
)
def test_staff_level_without_sudo_access(self):
"""
Ensure that a staff member redirected to sudo password page without sudo access.
"""
staff_member = StaffFactory(course_key=self.course.id)
CourseEnrollment.enroll(staff_member, self.course.id)
CourseFinanceAdminRole(self.course.id).add_users(staff_member)
self.client.login(username=staff_member.username, password='test')
for endpoint, args in self.staff_level_endpoints:
self._access_endpoint(
endpoint,
args,
401,
""
)
def test_instructor_level(self):
"""
Ensure that an instructor member can access all endpoints.
@@ -332,7 +314,6 @@ class TestInstructorAPIDenyLevels(ModuleStoreTestCase, LoginEnrollmentTestCase):
CourseFinanceAdminRole(self.course.id).add_users(inst)
self.client.login(username=inst.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
for endpoint, args in self.staff_level_endpoints:
# TODO: make these work
@@ -356,31 +337,6 @@ class TestInstructorAPIDenyLevels(ModuleStoreTestCase, LoginEnrollmentTestCase):
"Instructor should be allowed to access endpoint " + endpoint
)
def test_instructor_level_without_sudo_access(self):
"""
Ensure that an instructor member redirected to sudo password page without sudo access.
"""
inst = InstructorFactory(course_key=self.course.id)
CourseEnrollment.enroll(inst, self.course.id)
CourseFinanceAdminRole(self.course.id).add_users(inst)
self.client.login(username=inst.username, password='test')
for endpoint, args in self.staff_level_endpoints:
self._access_endpoint(
endpoint,
args,
401,
""
)
for endpoint, args in self.instructor_level_endpoints:
self._access_endpoint(
endpoint,
args,
401,
""
)
@attr('shard_1')
@patch.dict(settings.FEATURES, {'ALLOW_AUTOMATED_SIGNUPS': True})
@@ -395,7 +351,6 @@ class TestInstructorAPIBulkAccountCreationAndEnrollment(ModuleStoreTestCase, Log
self.course = CourseFactory.create()
self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
self.url = reverse('register_and_enroll_students', kwargs={'course_id': self.course.id.to_deprecated_string()})
self.not_enrolled_student = UserFactory(
@@ -700,7 +655,6 @@ class TestInstructorAPIEnrollment(ModuleStoreTestCase, LoginEnrollmentTestCase):
self.course = CourseFactory.create()
self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
self.enrolled_student = UserFactory(username='EnrolledStudent', first_name='Enrolled', last_name='Student')
CourseEnrollment.enroll(
@@ -1277,7 +1231,6 @@ class TestInstructorAPIEnrollment(ModuleStoreTestCase, LoginEnrollmentTestCase):
manually enrolling the students for the paid courses.
"""
paid_course = self.create_paid_course()
self.grant_sudo_access(unicode(paid_course.id), 'test')
url = reverse('students_update_enrollment', kwargs={'course_id': paid_course.id.to_deprecated_string()})
params = {'identifiers': self.notregistered_email, 'action': 'enroll', 'email_students': False,
'auto_enroll': False}
@@ -1303,7 +1256,6 @@ class TestInstructorAPIEnrollment(ModuleStoreTestCase, LoginEnrollmentTestCase):
test to unenroll allow to enroll user.
"""
paid_course = self.create_paid_course()
self.grant_sudo_access(unicode(paid_course.id), 'test')
url = reverse('students_update_enrollment', kwargs={'course_id': paid_course.id.to_deprecated_string()})
params = {'identifiers': self.notregistered_email, 'action': 'enroll', 'email_students': False,
'auto_enroll': False, 'reason': 'testing..'}
@@ -1354,7 +1306,6 @@ class TestInstructorAPIEnrollment(ModuleStoreTestCase, LoginEnrollmentTestCase):
test unenrolled user already not enrolled in a course.
"""
paid_course = self.create_paid_course()
self.grant_sudo_access(unicode(paid_course.id), 'test')
course_enrollment = CourseEnrollment.objects.filter(
user__email=self.notregistered_email, course_id=paid_course.id
)
@@ -1452,7 +1403,6 @@ class TestInstructorAPIBulkBetaEnrollment(ModuleStoreTestCase, LoginEnrollmentTe
self.course = CourseFactory.create()
self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
self.beta_tester = BetaTesterFactory(course_key=self.course.id)
CourseEnrollment.enroll(
@@ -1781,7 +1731,6 @@ class TestInstructorAPILevelsAccess(ModuleStoreTestCase, LoginEnrollmentTestCase
self.course = CourseFactory.create()
self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
self.other_instructor = InstructorFactory(course_key=self.course.id)
self.other_staff = StaffFactory(course_key=self.course.id)
@@ -2020,7 +1969,6 @@ class TestInstructorAPILevelsDataDump(ModuleStoreTestCase, LoginEnrollmentTestCa
self.course_mode.save()
self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
self.cart = Order.get_cart_for_user(self.instructor)
self.coupon_code = 'abcde'
self.coupon = Coupon(code=self.coupon_code, description='testing code', course_id=self.course.id,
@@ -2448,7 +2396,6 @@ class TestInstructorAPILevelsDataDump(ModuleStoreTestCase, LoginEnrollmentTestCa
UserProfileFactory.create(user=self.students[0], meta='{"company": "asdasda"}')
self.client.login(username=self.instructor.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
url = reverse('get_enrollment_report', kwargs={'course_id': self.course.id.to_deprecated_string()})
response = self.client.get(url, {})
self.assertIn('Your detailed enrollment report is being generated!', response.content)
@@ -2498,7 +2445,6 @@ class TestInstructorAPILevelsDataDump(ModuleStoreTestCase, LoginEnrollmentTestCa
CourseFinanceAdminRole(self.course.id).add_users(self.instructor)
self.client.login(username=self.instructor.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
url = reverse('get_enrollment_report', kwargs={'course_id': self.course.id.to_deprecated_string()})
response = self.client.get(url, {})
@@ -2521,7 +2467,6 @@ class TestInstructorAPILevelsDataDump(ModuleStoreTestCase, LoginEnrollmentTestCa
CourseFinanceAdminRole(self.course.id).add_users(self.instructor)
self.client.login(username=self.instructor.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
url = reverse('get_enrollment_report', kwargs={'course_id': self.course.id.to_deprecated_string()})
response = self.client.get(url, {})
@@ -2547,7 +2492,6 @@ class TestInstructorAPILevelsDataDump(ModuleStoreTestCase, LoginEnrollmentTestCa
CourseFinanceAdminRole(self.course.id).add_users(self.instructor)
self.client.login(username=self.instructor.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
url = reverse('get_enrollment_report', kwargs={'course_id': self.course.id.to_deprecated_string()})
response = self.client.get(url, {})
@@ -2705,7 +2649,6 @@ class TestInstructorAPIRegradeTask(ModuleStoreTestCase, LoginEnrollmentTestCase)
self.course = CourseFactory.create()
self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
self.student = UserFactory()
CourseEnrollment.enroll(self.student, self.course.id)
@@ -2875,8 +2818,6 @@ class TestEntranceExamInstructorAPIRegradeTask(ModuleStoreTestCase, LoginEnrollm
# Add instructor to invalid ee course
CourseInstructorRole(self.course_with_invalid_ee.id).add_users(self.instructor)
self.client.login(username=self.instructor.username, password='test')
self.grant_sudo_access(unicode(self.course_with_invalid_ee.id), 'test')
self.grant_sudo_access(unicode(self.course.id), 'test')
self.student = UserFactory()
CourseEnrollment.enroll(self.student, self.course.id)
@@ -2986,7 +2927,6 @@ class TestEntranceExamInstructorAPIRegradeTask(ModuleStoreTestCase, LoginEnrollm
self.client.logout()
staff_user = StaffFactory(course_key=self.course.id)
self.client.login(username=staff_user.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
url = reverse('reset_student_attempts_for_entrance_exam',
kwargs={'course_id': unicode(self.course.id)})
response = self.client.get(url, {
@@ -3117,7 +3057,6 @@ class TestInstructorSendEmail(ModuleStoreTestCase, LoginEnrollmentTestCase):
self.course = CourseFactory.create()
self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
test_subject = u'\u1234 test subject'
test_message = u'\u6824 test message'
self.full_test_message = {
@@ -3243,7 +3182,6 @@ class TestInstructorAPITaskLists(ModuleStoreTestCase, LoginEnrollmentTestCase):
)
self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
self.student = UserFactory()
CourseEnrollment.enroll(self.student, self.course.id)
@@ -3360,7 +3298,6 @@ class TestInstructorEmailContentList(ModuleStoreTestCase, LoginEnrollmentTestCas
self.course = CourseFactory.create()
self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
self.tasks = {}
self.emails = {}
self.emails_info = {}
@@ -3615,7 +3552,6 @@ class TestDueDateExtensions(ModuleStoreTestCase, LoginEnrollmentTestCase):
self.instructor = InstructorFactory(course_key=course.id)
self.client.login(username=self.instructor.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
def test_change_due_date(self):
url = reverse('change_due_date', kwargs={'course_id': self.course.id.to_deprecated_string()})
@@ -3740,7 +3676,6 @@ class TestCourseRegistrationCodes(ModuleStoreTestCase):
CourseModeFactory.create(course_id=self.course.id, min_price=50)
self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
CourseSalesAdminRole(self.course.id).add_users(self.instructor)
url = reverse('generate_registration_codes',
@@ -4216,7 +4151,6 @@ class TestBulkCohorting(ModuleStoreTestCase):
Verify that we get the error we expect for a given file input.
"""
self.client.login(username=self.staff_user.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
response = self.call_add_users_to_cohorts(file_content, suffix=file_suffix)
self.assertEqual(response.status_code, 400)
result = json.loads(response.content)
@@ -4230,7 +4164,6 @@ class TestBulkCohorting(ModuleStoreTestCase):
"""
mock_store_upload.return_value = (None, 'fake_file_name.csv')
self.client.login(username=self.staff_user.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
response = self.call_add_users_to_cohorts(file_content)
self.assertEqual(response.status_code, 204)
self.assertTrue(mock_store_upload.called)

View File

@@ -33,7 +33,6 @@ class TestInstructorAPIEnrollmentEmailLocalization(ModuleStoreTestCase):
self.instructor = InstructorFactory(course_key=self.course.id)
set_user_preference(self.instructor, LANGUAGE_KEY, 'zh-cn')
self.client.login(username=self.instructor.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
self.student = UserFactory.create()
set_user_preference(self.student, LANGUAGE_KEY, 'fr')

View File

@@ -96,7 +96,6 @@ class CertificatesInstructorDashTest(ModuleStoreTestCase):
def _assert_certificates_visible(self, is_visible):
"""Check that the certificates section is visible on the instructor dash. """
self.grant_sudo_access(unicode(self.course.id), 'test')
response = self.client.get(self.url)
if is_visible:
self.assertContains(response, "Certificates")
@@ -123,7 +122,6 @@ class CertificatesInstructorDashTest(ModuleStoreTestCase):
def _assert_certificate_status(self, cert_name, expected_status):
"""Check the certificate status display on the instructor dash. """
self.grant_sudo_access(unicode(self.course.id), 'test')
response = self.client.get(self.url)
if expected_status == 'started':
@@ -140,7 +138,6 @@ class CertificatesInstructorDashTest(ModuleStoreTestCase):
def _assert_enable_certs_button_is_disabled(self):
"""Check that the "enable student-generated certificates" button is disabled. """
self.grant_sudo_access(unicode(self.course.id), 'test')
response = self.client.get(self.url)
expected_html = '<button class="is-disabled" disabled>Enable Student-Generated Certificates</button>'
self.assertContains(response, expected_html)
@@ -182,13 +179,11 @@ class CertificatesInstructorApiTest(ModuleStoreTestCase):
# Global staff have access
self.client.login(username=self.global_staff.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
response = self.client.post(url)
self.assertEqual(response.status_code, 302)
def test_generate_example_certificates(self):
self.client.login(username=self.global_staff.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
url = reverse(
'generate_example_certificates',
kwargs={'course_id': unicode(self.course.id)}
@@ -207,7 +202,6 @@ class CertificatesInstructorApiTest(ModuleStoreTestCase):
@ddt.data(True, False)
def test_enable_certificate_generation(self, is_enabled):
self.client.login(username=self.global_staff.username, password='test')
self.grant_sudo_access(unicode(self.course.id), 'test')
url = reverse(
'enable_certificate_generation',
kwargs={'course_id': unicode(self.course.id)}

View File

@@ -29,7 +29,6 @@ class TestECommerceDashboardViews(ModuleStoreTestCase):
# Create instructor account
self.instructor = AdminFactory.create()
self.client.login(username=self.instructor.username, password="test")
self.grant_sudo_access(unicode(self.course.id), "test")
mode = CourseMode(
course_id=self.course.id.to_deprecated_string(), mode_slug='honor',
mode_display_name='honor', min_price=10, currency='usd'

View File

@@ -29,7 +29,6 @@ class TestNewInstructorDashboardEmailViewMongoBacked(ModuleStoreTestCase):
# Create instructor account
instructor = AdminFactory.create()
self.client.login(username=instructor.username, password="test")
self.grant_sudo_access(unicode(self.course.id), "test")
# URL for instructor dash
self.url = reverse('instructor_dashboard', kwargs={'course_id': self.course.id.to_deprecated_string()})

View File

@@ -35,8 +35,6 @@ class TestInstructorEnrollsStudent(ModuleStoreTestCase, LoginEnrollmentTestCase)
self.course = CourseFactory.create()
self.grant_sudo_access(unicode(self.course.id), "test")
self.users = [
UserFactory.create(username="student%d" % i, email="student%d@test.com" % i)
for i in xrange(USER_COUNT)
@@ -54,6 +52,7 @@ class TestInstructorEnrollsStudent(ModuleStoreTestCase, LoginEnrollmentTestCase)
"""
course = self.course
# Run the Un-enroll students command
url = reverse('instructor_dashboard_legacy', kwargs={'course_id': course.id.to_deprecated_string()})
response = self.client.post(

View File

@@ -44,7 +44,6 @@ class TestRawGradeCSV(TestSubmittingProblems):
"""
# Answer second problem correctly with 2nd user to expose bug
self.login(self.instructor, self.password)
self.grant_sudo_access(unicode(self.course.id), self.password)
resp = self.submit_question_answer('p2', {'2_1': 'Correct'})
self.assertEqual(resp.status_code, 200)

View File

@@ -52,10 +52,9 @@ class TestXss(ModuleStoreTestCase):
)
req.user = self._instructor
req.session = {}
req.is_sudo = lambda region=None: True
mako_middleware_process_request(req)
resp = legacy.instructor_dashboard(request=req, course_id=self._course.id.to_deprecated_string())
resp = legacy.instructor_dashboard(req, self._course.id.to_deprecated_string())
respUnicode = resp.content.decode(settings.DEFAULT_CHARSET)
self.assertNotIn(self._evil_student.profile.name, respUnicode)
self.assertIn(escape(self._evil_student.profile.name), respUnicode)

View File

@@ -39,7 +39,6 @@ class TestGradebook(ModuleStoreTestCase):
kwargs['grading_policy'] = self.grading_policy
self.course = CourseFactory.create(**kwargs)
self.grant_sudo_access(unicode(self.course.id), 'test')
chapter = ItemFactory.create(
parent_location=self.course.location,
category="sequential",

View File

@@ -43,7 +43,6 @@ class TestInstructorDashboard(ModuleStoreTestCase, LoginEnrollmentTestCase):
# Create instructor account
self.instructor = AdminFactory.create()
self.client.login(username=self.instructor.username, password="test")
self.grant_sudo_access(unicode(self.course.id), 'test')
# URL for instructor dash
self.url = reverse('instructor_dashboard', kwargs={'course_id': self.course.id.to_deprecated_string()})
@@ -203,7 +202,6 @@ class TestInstructorDashboard(ModuleStoreTestCase, LoginEnrollmentTestCase):
student_cart.purchase()
self.client.login(username=self.instructor.username, password="test")
self.grant_sudo_access(unicode(self.course.id), 'test')
CourseFinanceAdminRole(self.course.id).add_users(self.instructor)
single_purchase_total = PaidCourseRegistration.get_total_amount_of_purchased_item(self.course.id)
bulk_purchase_total = CourseRegCodeItem.get_total_amount_of_purchased_item(self.course.id)
@@ -236,13 +234,3 @@ class TestInstructorDashboard(ModuleStoreTestCase, LoginEnrollmentTestCase):
expected_result,
'CCX Coaches are able to create their own Custom Courses based on this course' in response.content
)
def test_sudo_required_on_dashboard(self):
"""
Test that sudo_required redirect user to password page.
"""
# Logout to remove sudo access.
self.client.logout()
self.client.login(username=self.instructor.username, password="test")
response = self.client.get(self.url, content_type='html', HTTP_ACCEPT='html')
self.assertEqual(response.status_code, 302)