Skip to content

Commit

Permalink
Update tests targeting redirect logic to use relative URLs instead of…
Browse files Browse the repository at this point in the history
  • Loading branch information
itsjeyd committed Mar 15, 2019
1 parent 0a0d5e0 commit 9c3452b
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions django_lti_tool_provider/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_given_incorrect_payload_throws_bad_request(self):
def test_given_correct_requests_sets_session_variable(self):
response = self.send_lti_request(self.get_correct_lti_payload())

self._verify_redirected_to(response, self._url_base + self.DEFAULT_REDIRECT)
self._verify_redirected_to(response, self.DEFAULT_REDIRECT)

self._verify_session_lti_contents(self.client.session, self._data)

Expand Down Expand Up @@ -150,7 +150,7 @@ def test_no_session_correct_payload_processes_lti_request(self, patched_send_lti
# Should have been created.
user = User.objects.all()[0]
self._verify_lti_created(user, self._data)
self._verify_redirected_to(response, self._url_base + self.DEFAULT_REDIRECT)
self._verify_redirected_to(response, self.DEFAULT_REDIRECT)
self._verify_lti_updated_signal_is_sent(patched_send_lti_received, user)

def test_given_session_and_lti_uses_lti(self, patched_send_lti_received):
Expand All @@ -166,7 +166,7 @@ def test_given_session_and_lti_uses_lti(self, patched_send_lti_received):
# Should have been created.
user = User.objects.all()[0]
self._verify_lti_created(user, self._data)
self._verify_redirected_to(response, self._url_base + self.DEFAULT_REDIRECT)
self._verify_redirected_to(response, self.DEFAULT_REDIRECT)
self._verify_lti_updated_signal_is_sent(patched_send_lti_received, user)

def test_force_login_change(self, patched_send_lti_received):
Expand Down Expand Up @@ -200,7 +200,7 @@ def test_force_login_change(self, patched_send_lti_received):

@ddt.ddt
class AuthenticationManagerIntegrationTests(LtiRequestsTestBase):
TEST_URLS = ("/some_url", False), ("/some_other_url", False), ("http://qwe.asd.zxc.com", True)
TEST_URLS = "/some_url", "/some_other_url", "http://qwe.asd.zxc.com"

def setUp(self):
super(AuthenticationManagerIntegrationTests, self).setUp()
Expand Down Expand Up @@ -255,12 +255,10 @@ def test_authentication_hook_passes_optional_lti_data(self):
self.assertEqual(user_data, expected_user_data)

@ddt.data(*TEST_URLS)
@ddt.unpack
def test_anonymous_lti_is_processed_if_hook_does_not_authenticate_user(self, url, absolute):
self.hook_manager.anonymous_redirect_to.return_value = url
def test_anonymous_lti_is_processed_if_hook_does_not_authenticate_user(self, expected_url):
self.hook_manager.anonymous_redirect_to.return_value = expected_url
response = self.send_lti_request(self.get_correct_lti_payload())

expected_url = url if absolute else "{base}{url}".format(base=self._url_base, url=url)
self._verify_redirected_to(response, expected_url)

self._verify_session_lti_contents(self.client.session, self._data)
Expand All @@ -271,13 +269,11 @@ def test_anonymous_lti_is_processed_if_hook_does_not_authenticate_user(self, url
self._verify_lti_data(lti_data, self._data)

@ddt.data(*TEST_URLS)
@ddt.unpack
def test_authenticated_lti_is_processed_if_hook_authenticates_user(self, url, absolute):
def test_authenticated_lti_is_processed_if_hook_authenticates_user(self, expected_url):
self.hook_manager.authentication_hook.side_effect = self._authenticate_user
self.hook_manager.authenticated_redirect_to.return_value = url
self.hook_manager.authenticated_redirect_to.return_value = expected_url
response = self.send_lti_request(self.get_correct_lti_payload())

expected_url = url if absolute else "{base}{url}".format(base=self._url_base, url=url)
self._verify_redirected_to(response, expected_url)

# verifying correct parameters were passed to auth manager hook
Expand Down

0 comments on commit 9c3452b

Please sign in to comment.