Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 0 additions & 108 deletions lms/djangoapps/lti_provider/migrations/0003_create_lti_user_model.py

This file was deleted.

18 changes: 0 additions & 18 deletions lms/djangoapps/lti_provider/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,3 @@ class Meta(object):
Uniqueness constraints.
"""
unique_together = ('outcome_service', 'lis_result_sourcedid')


class LtiUser(models.Model):
"""
Model mapping the identity of an LTI user to an account on the edX platform.
The LTI user_id field is guaranteed to be unique per LTI consumer (per
to the LTI spec), so we guarantee a unique mapping from LTI to edX account
by using the lti_consumer/lti_user_id tuple.
"""
lti_consumer = models.ForeignKey(LtiConsumer)
lti_user_id = models.CharField(max_length=255)
edx_user = models.ForeignKey(User, unique=True)

class Meta(object):
"""
Uniqueness constraints.
"""
unique_together = ('lti_consumer', 'lti_user_id')
157 changes: 0 additions & 157 deletions lms/djangoapps/lti_provider/tests/test_users.py

This file was deleted.

39 changes: 15 additions & 24 deletions lms/djangoapps/lti_provider/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
'oauth_signature_method': u'HMAC-SHA1',
'oauth_timestamp': u'OAuth Timestamp',
'oauth_nonce': u'OAuth Nonce',
'user_id': u'LTI_User',
}

LTI_OPTIONAL_PARAMS = {
Expand Down Expand Up @@ -90,8 +89,7 @@ class LtiLaunchTest(LtiTestMixin, TestCase):
Tests for the lti_launch view
"""
@patch('lti_provider.views.render_courseware')
@patch('lti_provider.views.authenticate_lti_user')
def test_valid_launch(self, _authenticate, render):
def test_valid_launch(self, render):
"""
Verifies that the LTI launch succeeds when passed a valid request.
"""
Expand All @@ -101,8 +99,7 @@ def test_valid_launch(self, _authenticate, render):

@patch('lti_provider.views.render_courseware')
@patch('lti_provider.views.store_outcome_parameters')
@patch('lti_provider.views.authenticate_lti_user')
def test_outcome_service_registered(self, _authenticate, store_params, _render):
def test_outcome_service_registered(self, store_params, _render):
"""
Verifies that the LTI launch succeeds when passed a valid request.
"""
Expand Down Expand Up @@ -145,8 +142,7 @@ def test_launch_with_disabled_feature_flag(self):
self.assertEqual(response.status_code, 403)

@patch('lti_provider.views.lti_run')
@patch('lti_provider.views.authenticate_lti_user')
def test_session_contents_after_launch(self, _authenticate, _run):
def test_session_contents_after_launch(self, _run):
"""
Verifies that the LTI parameters and the course and usage IDs are
properly stored in the session
Expand All @@ -160,8 +156,7 @@ def test_session_contents_after_launch(self, _authenticate, _run):
self.assertEqual(session[key], request.POST[key], key + ' not set in the session')

@patch('lti_provider.views.lti_run')
@patch('lti_provider.views.authenticate_lti_user')
def test_optional_parameters_in_session(self, _authenticate, _run):
def test_optional_parameters_in_session(self, _run):
"""
Verifies that the outcome-related optional LTI parameters are properly
stored in the session
Expand All @@ -187,6 +182,17 @@ def test_optional_parameters_in_session(self, _authenticate, _run):
'Consumer instance GUID not set in the session'
)

def test_redirect_for_non_authenticated_user(self):
"""
Verifies that if the lti_launch view is called by an unauthenticated
user, the response will redirect to the login page with the correct
URL
"""
request = build_launch_request(False)
response = views.lti_launch(request, unicode(COURSE_KEY), unicode(USAGE_KEY))
self.assertEqual(response.status_code, 302)
self.assertEqual(response['Location'], '/accounts/login?next=/lti_provider/lti_run')

def test_forbidden_if_signature_fails(self):
"""
Verifies that the view returns Forbidden if the LTI OAuth signature is
Expand All @@ -198,21 +204,6 @@ def test_forbidden_if_signature_fails(self):
self.assertEqual(response.status_code, 403)
self.assertEqual(response.status_code, 403)

@patch('lti_provider.views.render_courseware')
@patch('lti_provider.views.authenticate_lti_user')
def test_user_authentication_called(self, authenticate, _render):
"""
Verifies that the view returns Forbidden if the LTI OAuth signature is
incorrect.
"""
request = build_launch_request()
views.lti_launch(
request,
unicode(COURSE_PARAMS['course_key']),
unicode(COURSE_PARAMS['usage_key'])
)
authenticate.assert_called_with(request, u'LTI_User', self.consumer)


class LtiRunTest(LtiTestMixin, TestCase):
"""
Expand Down
Loading