Remove django 1.8 shim
This commit is contained in:
@@ -8,7 +8,6 @@ import json
|
||||
import mock
|
||||
|
||||
from contextlib import contextmanager
|
||||
import django
|
||||
from django import test
|
||||
from django.contrib import auth
|
||||
from django.contrib.auth import models as auth_models
|
||||
@@ -23,7 +22,6 @@ from social_django import views as social_views
|
||||
|
||||
from lms.djangoapps.commerce.tests import TEST_API_URL
|
||||
from openedx.core.djangoapps.site_configuration.tests.factories import SiteFactory
|
||||
from openedx.tests.util import expected_redirect_url
|
||||
from student import models as student_models
|
||||
from student import views as student_views
|
||||
from student.tests.factories import UserFactory
|
||||
@@ -68,7 +66,7 @@ class IntegrationTestMixin(object):
|
||||
provider_response = self.do_provider_login(try_login_response['Location'])
|
||||
# We should be redirected to the register screen since this account is not linked to an edX account:
|
||||
self.assertEqual(provider_response.status_code, 302)
|
||||
self.assertEqual(provider_response['Location'], expected_redirect_url(self.register_page_url, hostname=self.hostname))
|
||||
self.assertEqual(provider_response['Location'], self.register_page_url)
|
||||
register_response = self.client.get(self.register_page_url)
|
||||
tpa_context = register_response.context["data"]["third_party_auth"]
|
||||
self.assertEqual(tpa_context["errorMessage"], None)
|
||||
@@ -98,7 +96,7 @@ class IntegrationTestMixin(object):
|
||||
continue_response = self.client.get(tpa_context["finishAuthUrl"])
|
||||
# And we should be redirected to the dashboard:
|
||||
self.assertEqual(continue_response.status_code, 302)
|
||||
self.assertEqual(continue_response['Location'], expected_redirect_url(reverse('dashboard'), hostname=self.hostname))
|
||||
self.assertEqual(continue_response['Location'], reverse('dashboard'))
|
||||
|
||||
# Now check that we can login again, whether or not we have yet verified the account:
|
||||
self.client.logout()
|
||||
@@ -119,7 +117,7 @@ class IntegrationTestMixin(object):
|
||||
complete_response = self.do_provider_login(try_login_response['Location'])
|
||||
# We should be redirected to the login screen since this account is not linked to an edX account:
|
||||
self.assertEqual(complete_response.status_code, 302)
|
||||
self.assertEqual(complete_response['Location'], expected_redirect_url(self.login_page_url, hostname=self.hostname))
|
||||
self.assertEqual(complete_response['Location'], self.login_page_url)
|
||||
login_response = self.client.get(self.login_page_url)
|
||||
tpa_context = login_response.context["data"]["third_party_auth"]
|
||||
self.assertEqual(tpa_context["errorMessage"], None)
|
||||
@@ -136,7 +134,7 @@ class IntegrationTestMixin(object):
|
||||
continue_response = self.client.get(tpa_context["finishAuthUrl"])
|
||||
# And we should be redirected to the dashboard:
|
||||
self.assertEqual(continue_response.status_code, 302)
|
||||
self.assertEqual(continue_response['Location'], expected_redirect_url(reverse('dashboard'), hostname=self.hostname))
|
||||
self.assertEqual(continue_response['Location'], reverse('dashboard'))
|
||||
|
||||
# Now check that we can login again:
|
||||
self.client.logout()
|
||||
@@ -165,12 +163,7 @@ class IntegrationTestMixin(object):
|
||||
# required to set the login cookie (it sticks around if the main session times out):
|
||||
if not previous_session_timed_out:
|
||||
self.assertEqual(login_response.status_code, 302)
|
||||
expected_url = expected_redirect_url(self.complete_url, hostname=self.hostname)
|
||||
# TODO: Remove Django 1.11 upgrade shim
|
||||
# SHIM: Get rid of this logic post-upgrade
|
||||
if django.VERSION >= (1, 9):
|
||||
expected_url = "{}?".format(expected_url)
|
||||
self.assertEqual(login_response['Location'], expected_url)
|
||||
self.assertEqual(login_response['Location'], self.complete_url + "?")
|
||||
# And then we should be redirected to the dashboard:
|
||||
login_response = self.client.get(login_response['Location'])
|
||||
self.assertEqual(login_response.status_code, 302)
|
||||
@@ -178,7 +171,7 @@ class IntegrationTestMixin(object):
|
||||
url_expected = reverse('dashboard')
|
||||
else:
|
||||
url_expected = reverse('third_party_inactive_redirect') + '?next=' + reverse('dashboard')
|
||||
self.assertEqual(login_response['Location'], expected_redirect_url(url_expected, hostname=self.hostname))
|
||||
self.assertEqual(login_response['Location'], url_expected)
|
||||
# Now we are logged in:
|
||||
dashboard_response = self.client.get(reverse('dashboard'))
|
||||
self.assertEqual(dashboard_response.status_code, 200)
|
||||
|
||||
@@ -6,7 +6,6 @@ from django.conf import settings
|
||||
from django.urls import reverse
|
||||
import json
|
||||
from mock import patch
|
||||
from openedx.tests.util import expected_redirect_url
|
||||
from social_core.exceptions import AuthException
|
||||
from student.tests.factories import UserFactory
|
||||
from third_party_auth import pipeline
|
||||
@@ -73,7 +72,7 @@ class GoogleOauth2IntegrationTest(base.Oauth2IntegrationTest):
|
||||
response = self.client.get(complete_url)
|
||||
# This should redirect to the custom login/register form:
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(response['Location'], expected_redirect_url('/auth/custom_auth_entry', hostname='example.none'))
|
||||
self.assertEqual(response['Location'], '/auth/custom_auth_entry')
|
||||
|
||||
response = self.client.get(response['Location'])
|
||||
self.assertEqual(response.status_code, 200)
|
||||
@@ -107,7 +106,7 @@ class GoogleOauth2IntegrationTest(base.Oauth2IntegrationTest):
|
||||
# Now our custom login/registration page must resume the pipeline:
|
||||
response = self.client.get(complete_url)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(response['Location'], expected_redirect_url('/misc/final-destination', hostname='example.none'))
|
||||
self.assertEqual(response['Location'], '/misc/final-destination')
|
||||
|
||||
_, strategy = self.get_request_and_strategy()
|
||||
self.assert_social_auth_exists_for_user(created_user, strategy)
|
||||
@@ -134,4 +133,4 @@ class GoogleOauth2IntegrationTest(base.Oauth2IntegrationTest):
|
||||
response = self.client.get(complete_url)
|
||||
# This should redirect to the custom error URL
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(response['Location'], expected_redirect_url('/misc/my-custom-sso-error-page', hostname='example.none'))
|
||||
self.assertEqual(response['Location'], '/misc/my-custom-sso-error-page')
|
||||
|
||||
@@ -2,12 +2,10 @@
|
||||
Integration tests for third_party_auth LTI auth providers
|
||||
"""
|
||||
import unittest
|
||||
import django
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.urls import reverse
|
||||
from oauthlib.oauth1.rfc5849 import Client, SIGNATURE_TYPE_BODY
|
||||
from openedx.tests.util import expected_redirect_url
|
||||
from third_party_auth.tests import testutil
|
||||
|
||||
FORM_ENCODED = 'application/x-www-form-urlencoded'
|
||||
@@ -94,7 +92,7 @@ class IntegrationTestLTI(testutil.TestCase):
|
||||
self.assertEqual(continue_response.status_code, 302)
|
||||
self.assertEqual(
|
||||
continue_response['Location'],
|
||||
expected_redirect_url('/account/finish_auth/?course_id=my_course_id&enrollment_action=enroll')
|
||||
'/account/finish_auth/?course_id=my_course_id&enrollment_action=enroll'
|
||||
)
|
||||
|
||||
# Now check that we can login again
|
||||
@@ -108,12 +106,7 @@ class IntegrationTestLTI(testutil.TestCase):
|
||||
login_2_response = self.client.post(path=uri, content_type=FORM_ENCODED, data=body)
|
||||
# The user should be redirected to the dashboard
|
||||
self.assertEqual(login_2_response.status_code, 302)
|
||||
expected_url = expected_redirect_url(LTI_TPA_COMPLETE_URL)
|
||||
# TODO: Remove Django 1.11 upgrade shim
|
||||
# SHIM: Get rid of this logic post-upgrade
|
||||
if django.VERSION >= (1, 9):
|
||||
expected_url = "{}?".format(expected_url)
|
||||
self.assertEqual(login_2_response['Location'], expected_url)
|
||||
self.assertEqual(login_2_response['Location'], LTI_TPA_COMPLETE_URL + "?")
|
||||
continue_2_response = self.client.get(login_2_response['Location'])
|
||||
self.assertEqual(continue_2_response.status_code, 302)
|
||||
self.assertTrue(continue_2_response['Location'].endswith(reverse('dashboard')))
|
||||
|
||||
@@ -13,7 +13,6 @@ from social_django.models import UserSocialAuth
|
||||
from testfixtures import LogCapture
|
||||
from unittest import skip
|
||||
|
||||
from openedx.tests.util import expected_redirect_url
|
||||
from third_party_auth.saml import log as saml_log, SapSuccessFactorsIdentityProvider
|
||||
from third_party_auth.tasks import fetch_saml_metadata
|
||||
from third_party_auth.tests import testutil
|
||||
@@ -136,7 +135,7 @@ class TestShibIntegrationTest(SamlIntegrationTestUtilities, IntegrationTestMixin
|
||||
try_login_response = self.client.get(testshib_login_url)
|
||||
# The user should be redirected to back to the login page:
|
||||
self.assertEqual(try_login_response.status_code, 302)
|
||||
self.assertEqual(try_login_response['Location'], expected_redirect_url(self.login_page_url, hostname=self.hostname))
|
||||
self.assertEqual(try_login_response['Location'], self.login_page_url)
|
||||
# When loading the login page, the user will see an error message:
|
||||
response = self.client.get(self.login_page_url)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
Reference in New Issue
Block a user