예제 #1
0
 def test_valid_launch(self, render):
     """
     Verifies that the view returns OK if called with the correct context
     """
     request = build_run_request()
     views.lti_run(request)
     render.assert_called_with(request, ALL_PARAMS['usage_key'])
예제 #2
0
 def test_lti_consumer_record_supplemented_with_guid(self, _render):
     request = build_run_request()
     request.session[views.LTI_SESSION_KEY]["tool_consumer_instance_guid"] = "instance_guid"
     with self.assertNumQueries(4):
         views.lti_run(request)
     consumer = models.LtiConsumer.objects.get(consumer_key=LTI_DEFAULT_PARAMS["oauth_consumer_key"])
     self.assertEqual(consumer.instance_guid, "instance_guid")
예제 #3
0
 def test_valid_launch(self, render):
     """
     Verifies that the view returns OK if called with the correct context
     """
     request = build_run_request()
     views.lti_run(request)
     render.assert_called_with(request, ALL_PARAMS["usage_key"])
예제 #4
0
 def test_session_cleared_in_view(self, _render):
     """
     Verifies that the LTI parameters are cleaned out of the session after
     launching the view to prevent a launch being replayed.
     """
     request = build_run_request()
     views.lti_run(request)
     self.assertNotIn(views.LTI_SESSION_KEY, request.session)
예제 #5
0
 def test_session_cleared_in_view(self, _render):
     """
     Verifies that the LTI parameters are cleaned out of the session after
     launching the view to prevent a launch being replayed.
     """
     request = build_run_request()
     views.lti_run(request)
     self.assertNotIn(views.LTI_SESSION_KEY, request.session)
예제 #6
0
 def test_lti_consumer_record_supplemented_with_guid(self, _render):
     request = build_run_request()
     request.session[views.LTI_SESSION_KEY][
         'tool_consumer_instance_guid'] = 'instance_guid'
     with self.assertNumQueries(4):
         views.lti_run(request)
     consumer = models.LtiConsumer.objects.get(
         consumer_key=LTI_DEFAULT_PARAMS['oauth_consumer_key'])
     self.assertEqual(consumer.instance_guid, 'instance_guid')
예제 #7
0
 def test_valid_launch(self):
     """
     Verifies that the view returns OK if called with the correct context
     """
     request = self.build_request()
     response = views.lti_run(request)
     self.assertEqual(response.status_code, 200)
예제 #8
0
 def test_valid_launch(self):
     """
     Verifies that the view returns OK if called with the correct context
     """
     request = self.build_request()
     response = views.lti_run(request)
     self.assertEqual(response.status_code, 200)
예제 #9
0
 def test_forbidden_if_session_key_missing(self):
     """
     Verifies that the lti_run view returns a Forbidden status if the session
     doesn't have an entry for the LTI parameters.
     """
     request = build_run_request()
     del request.session[views.LTI_SESSION_KEY]
     response = views.lti_run(request)
     self.assertEqual(response.status_code, 403)
예제 #10
0
 def test_forbidden_if_session_key_missing(self):
     """
     Verifies that the lti_run view returns a Forbidden status if the session
     doesn't have an entry for the LTI parameters.
     """
     request = build_run_request()
     del request.session[views.LTI_SESSION_KEY]
     response = views.lti_run(request)
     self.assertEqual(response.status_code, 403)
예제 #11
0
 def test_forbidden_if_session_incomplete(self):
     """
     Verifies that the lti_run view returns a Forbidden status if the session
     is missing any of the required LTI parameters or course information.
     """
     extra_keys = ["course_key", "usage_key"]
     for key in views.REQUIRED_PARAMETERS + extra_keys:
         request = build_run_request()
         del request.session[views.LTI_SESSION_KEY][key]
         response = views.lti_run(request)
         self.assertEqual(response.status_code, 403, "Expected Forbidden response when session is missing " + key)
예제 #12
0
 def test_forbidden_if_session_incomplete(self):
     """
     Verifies that the lti_run view returns a Forbidden status if the session
     is missing any of the required LTI parameters or course information.
     """
     extra_keys = ['course_key', 'usage_key']
     for key in views.REQUIRED_PARAMETERS + extra_keys:
         request = build_run_request()
         del request.session[views.LTI_SESSION_KEY][key]
         response = views.lti_run(request)
         self.assertEqual(
             response.status_code, 403,
             'Expected Forbidden response when session is missing ' + key)