def _enable_third_party_auth(self): """ Enable the use of third_party_auth, which allows users to sign in to edX using other identity providers. For configuration details, see common/djangoapps/third_party_auth/settings.py. """ from common.djangoapps.third_party_auth import settings as auth_settings auth_settings.apply_settings(settings)
def test_apply_settings_avoids_default_username_check(self): # Avoid the default username check where non-ascii characters are not # allowed when unicode username is enabled settings.apply_settings(self.settings) assert self.settings.SOCIAL_AUTH_CLEAN_USERNAMES # verify default behavior with patch.dict('django.conf.settings.FEATURES', {'ENABLE_UNICODE_USERNAME': True}): settings.apply_settings(self.settings) assert not self.settings.SOCIAL_AUTH_CLEAN_USERNAMES
def test_apply_settings_turns_off_redirect_sanitization(self): settings.apply_settings(self.settings) self.assertFalse(self.settings.SOCIAL_AUTH_SANITIZE_REDIRECTS)
def test_apply_settings_turns_off_raising_social_exceptions(self): # Guard against submitting a conf change that's convenient in dev but # bad in prod. settings.apply_settings(self.settings) self.assertFalse(self.settings.SOCIAL_AUTH_RAISE_EXCEPTIONS)
def test_apply_settings_enables_no_providers_by_default(self): # Providers are only enabled via ConfigurationModels in the database settings.apply_settings(self.settings) self.assertEqual([], provider.Registry.enabled())
def test_apply_settings_adds_fields_stored_in_session(self): settings.apply_settings(self.settings) self.assertEqual(['auth_entry', 'next'], self.settings.FIELDS_STORED_IN_SESSION)
def test_apply_settings_adds_exception_middleware(self): settings.apply_settings(self.settings) self.assertIn( 'common.djangoapps.third_party_auth.middleware.ExceptionMiddleware', self.settings.MIDDLEWARE)