Exemple #1
0
    def test_launch_custom_landing_page(self):
        with self.settings(
            LTI_TOOL_CONFIGURATION=TEST_LTI_TOOL_CONFIGURATION,
            PYLTI_CONFIG={'consumers': CONSUMERS},
                LTI_EXTRA_PARAMETERS=['lti_version']):
            ctx = LTICourseContextFactory()
            request = generate_lti_request(ctx, 'canvas')

            view = LTIRoutingView()
            view.request = request

            response = view.dispatch(request)
            landing = 'http://testserver/lti/landing/{}/?lti_version=LTI-1p0&'
            self.assertEquals(response.status_code, 302)
            self.assertTrue(
                response.url,
                landing.format(ctx.lms_course_context))

            self.assertIsNotNone(request.session[LTI_SESSION_KEY])
            user = request.user
            self.assertFalse(user.has_usable_password())
            self.assertEquals(user.email, '*****@*****.**')
            self.assertEquals(user.get_full_name(), 'Foo Baz')
            self.assertTrue(user in ctx.group.user_set.all())
            self.assertTrue(user in ctx.faculty_group.user_set.all())
Exemple #2
0
    def test_launch_invalid_user(self):
        request = generate_lti_request()

        response = LTIRoutingView().dispatch(request)
        self.assertEquals(response.status_code, 302)

        self.assertEquals(response.url, reverse('lti-fail-auth'))
        self.assertFalse(request.session.get(LTI_SESSION_KEY, False))
Exemple #3
0
    def test_launch_invalid_course(self):
        with self.settings(
            LTI_TOOL_CONFIGURATION=TEST_LTI_TOOL_CONFIGURATION,
                PYLTI_CONFIG={'consumers': CONSUMERS}):
            request = generate_lti_request()

            response = LTIRoutingView().dispatch(request)
            self.assertEquals(response.status_code, 302)
            self.assertEquals(response.url, reverse('lti-course-config'))
            self.assertTrue(request.session.get(LTI_SESSION_KEY, False))
    def test_lti_session(self):
        with self.settings(PYLTI_CONFIG={'consumers': CONSUMERS}):
            request = generate_lti_request()
            self.assertIsNone(lti_session(request))

            # initialize the session
            lti = LTI('initial', 'any')
            self.assertTrue(lti.verify(request))

            lti = lti_session(request)
            self.assertEqual(lti.user_id(request), 'student')
    def test_verify_any(self):
        lti = LTI('any', 'any')
        request = generate_lti_request()

        with self.settings(PYLTI_CONFIG={'consumers': CONSUMERS}):
            # test_verify_request
            lti.verify(request)
            self.assertTrue(request.session[LTI_SESSION_KEY])

            # test_verify_session
            self.assertTrue(lti.verify(request))
    def test_verify_any(self):
        lti = LTI('any', 'any')
        request = generate_lti_request()

        with self.settings(PYLTI_CONFIG={'consumers': CONSUMERS}):
            # test_verify_request
            lti.verify(request)
            self.assertTrue(request.session[LTI_SESSION_KEY])

            # test_verify_session
            self.assertTrue(lti.verify(request))
    def test_lti_session(self):
        with self.settings(PYLTI_CONFIG={'consumers': CONSUMERS}):
            request = generate_lti_request()
            self.assertIsNone(lti_session(request))

            # initialize the session
            lti = LTI('initial', 'any')
            self.assertTrue(lti.verify(request))

            lti = lti_session(request)
            self.assertEqual(lti.user_id(request), 'student')
Exemple #8
0
    def test_embed(self):
        with self.settings(PYLTI_CONFIG={'consumers': CONSUMERS},
                           LTI_EXTRA_PARAMETERS=['lti_version'],
                           LTI_TOOL_CONFIGURATION=TEST_LTI_TOOL_CONFIGURATION):
            ctx = LTICourseContextFactory()
            request = generate_lti_request(ctx, 'canvas', 'embed')

            view = LTIRoutingView()
            view.request = request

            response = view.dispatch(request)
            self.assertEquals(response.status_code, 302)
            self.assertEquals(
                response.url,
                'http://testserver/asset/embed/?return_url=/asset/'
                '&lti_version=LTI-1p0&')

            self.assertIsNotNone(request.session[LTI_SESSION_KEY])
            user = request.user
            self.assertFalse(user.has_usable_password())
            self.assertEquals(user.email, '*****@*****.**')
            self.assertEquals(user.get_full_name(), 'Foo Baz')
            self.assertTrue(user in ctx.group.user_set.all())
            self.assertTrue(user in ctx.faculty_group.user_set.all())
 def test_verify_request(self):
     with self.settings(PYLTI_CONFIG={'consumers': CONSUMERS}):
         request = generate_lti_request()
         lti = LTI('initial', 'any')
         lti.verify(request)
         self.assertTrue(request.session[LTI_SESSION_KEY])
 def test_verify_request(self):
     with self.settings(PYLTI_CONFIG={'consumers': CONSUMERS}):
         request = generate_lti_request()
         lti = LTI('initial', 'any')
         lti.verify(request)
         self.assertTrue(request.session[LTI_SESSION_KEY])