def test_embargo_restriction(self): """ The view should return HTTP 403 status if the course is embargoed. """ with restrict_course(self.course.id) as redirect_url: response = self._post_to_view() self.assertEqual(403, response.status_code) body = json.loads(response.content) self.assertEqual(get_absolute_url(redirect_url), body['user_message_url'])
def test_embargo_restriction(self): """ The view should return HTTP 403 status if the course is embargoed. """ with restrict_course(self.course.id) as redirect_url: response = self._post_to_view() assert 403 == response.status_code body = json.loads(response.content.decode('utf-8')) assert get_absolute_url(redirect_url) == body['user_message_url']
def test_embargo_restriction(self): """ The view should return HTTP 403 status if the course is embargoed. """ with restrict_course(self.course.id) as redirect_url: response = self._post_to_view() self.assertEqual(403, response.status_code) body = json.loads(response.content) self.assertEqual(get_absolute_url(redirect_url), body['user_message_url'])
def test_embargo_restrict(self): # When accessing the course from an embargoed country, # we should be blocked. with restrict_course(self.course.id) as redirect_url: response = self._change_enrollment('enroll') self.assertEqual(response.status_code, 200) self.assertEqual(response.content, redirect_url) # Verify that we weren't enrolled is_enrolled = CourseEnrollment.is_enrolled(self.user, self.course.id) self.assertFalse(is_enrolled)
def test_embargo_restrict(self): # When accessing the course from an embargoed country, # we should be blocked. with restrict_course(self.course.id) as redirect_url: response = self._change_enrollment('enroll') self.assertEqual(response.status_code, 200) self.assertEqual(response.content, redirect_url) # Verify that we weren't enrolled is_enrolled = CourseEnrollment.is_enrolled(self.user, self.course.id) self.assertFalse(is_enrolled)
def test_embargo_restrict(self): # When accessing the course from an embargoed country, # we should be blocked. with restrict_course(self.course.id) as redirect_url: response = self._change_enrollment('enroll') assert response.status_code == 200 assert response.content.decode('utf-8') == redirect_url # Verify that we weren't enrolled is_enrolled = CourseEnrollment.is_enrolled(self.user, self.course.id) assert not is_enrolled
def test_embargo_restrict(self): with restrict_course(self.course.id) as redirect_url: response = self.client.get(self.url) self.assertRedirects(response, redirect_url)
def test_embargo_restrict(self): with restrict_course(self.course.id) as redirect_url: response = self.client.get(self.url) self.assertRedirects(response, redirect_url)
def test_embargo_change_enrollment_restrict_geoip(self): """ Validates that enrollment changes are blocked if the request originates from an embargoed country. """ # Use the helper to setup the embargo and simulate a request from a blocked IP address. with restrict_course(self.course.id) as redirect_path: self.assert_access_denied(redirect_path)
def test_embargo_change_enrollment_restrict_geoip(self): """ Validates that enrollment changes are blocked if the request originates from an embargoed country. """ # Use the helper to setup the embargo and simulate a request from a blocked IP address. with restrict_course(self.course.id) as redirect_path: self.assert_access_denied(redirect_path)