Merge pull request #19693 from edx/mdikan/hackathon-21
Removal of deprecated external auth.
This commit is contained in:
@@ -3,9 +3,7 @@
|
||||
This test file will verify proper password policy enforcement, which is an option feature
|
||||
"""
|
||||
import json
|
||||
from importlib import import_module
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
from django.urls import reverse
|
||||
from django.test import TestCase
|
||||
@@ -13,7 +11,6 @@ from django.test.client import RequestFactory
|
||||
from django.test.utils import override_settings
|
||||
from mock import patch
|
||||
|
||||
from openedx.core.djangoapps.external_auth.models import ExternalAuthMap
|
||||
from openedx.core.djangoapps.site_configuration.tests.factories import SiteFactory
|
||||
from openedx.core.djangoapps.user_authn.views.deprecated import create_account
|
||||
from util.password_policy_validators import create_validator_config
|
||||
@@ -254,31 +251,6 @@ class TestPasswordPolicy(TestCase):
|
||||
obj = json.loads(response.content)
|
||||
self.assertTrue(obj['success'])
|
||||
|
||||
@override_settings(AUTH_PASSWORD_VALIDATORS=[
|
||||
create_validator_config('util.password_policy_validators.MinimumLengthValidator', {'min_length': 6})
|
||||
], SESSION_ENGINE='django.contrib.sessions.backends.cache')
|
||||
def test_ext_auth_password_length_too_short(self):
|
||||
"""
|
||||
Tests that even if password policy is enforced, ext_auth registrations aren't subject to it
|
||||
"""
|
||||
self.url_params['password'] = u'aaa' # shouldn't pass validation
|
||||
request = self.request_factory.post(self.url, self.url_params)
|
||||
request.site = SiteFactory.create()
|
||||
# now indicate we are doing ext_auth by setting 'ExternalAuthMap' in the session.
|
||||
request.session = import_module(settings.SESSION_ENGINE).SessionStore() # empty session
|
||||
extauth = ExternalAuthMap(external_id='withmap@stanford.edu',
|
||||
external_email='withmap@stanford.edu',
|
||||
internal_password=self.url_params['password'],
|
||||
external_domain='shib:https://idp.stanford.edu/')
|
||||
request.session['ExternalAuthMap'] = extauth
|
||||
request.user = AnonymousUser()
|
||||
|
||||
with patch('edxmako.request_context.get_current_request', return_value=request):
|
||||
response = create_account(request)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
obj = json.loads(response.content)
|
||||
self.assertTrue(obj['success'])
|
||||
|
||||
|
||||
class TestUsernamePasswordNonmatch(TestCase):
|
||||
"""
|
||||
|
||||
@@ -134,8 +134,7 @@ def index(request, extra_context=None, user=AnonymousUser()):
|
||||
"""
|
||||
Render the edX main page.
|
||||
|
||||
extra_context is used to allow immediate display of certain modal windows, eg signup,
|
||||
as used by external_auth.
|
||||
extra_context is used to allow immediate display of certain modal windows, eg signup.
|
||||
"""
|
||||
if extra_context is None:
|
||||
extra_context = {}
|
||||
|
||||
@@ -53,8 +53,7 @@ def cache_if_anonymous(*get_parameters):
|
||||
# If that page is cached the authentication doesn't
|
||||
# happen, so we disable the cache when that feature is enabled.
|
||||
if (
|
||||
not request.user.is_authenticated and
|
||||
not settings.FEATURES['AUTH_USE_CERTIFICATES']
|
||||
not request.user.is_authenticated
|
||||
):
|
||||
# Use the cache. The same view accessed through different domain names may
|
||||
# return different things, so include the domain name in the key.
|
||||
|
||||
Reference in New Issue
Block a user