Fix most tests in user_authn
This commit is contained in:
@@ -8,6 +8,7 @@ from __future__ import absolute_import
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
import six
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth import authenticate
|
from django.contrib.auth import authenticate
|
||||||
from django.contrib.auth import login as django_login
|
from django.contrib.auth import login as django_login
|
||||||
@@ -110,11 +111,11 @@ def _enforce_password_policy_compliance(request, user):
|
|||||||
password_policy_compliance.enforce_compliance_on_login(user, request.POST.get('password'))
|
password_policy_compliance.enforce_compliance_on_login(user, request.POST.get('password'))
|
||||||
except password_policy_compliance.NonCompliantPasswordWarning as e:
|
except password_policy_compliance.NonCompliantPasswordWarning as e:
|
||||||
# Allow login, but warn the user that they will be required to reset their password soon.
|
# Allow login, but warn the user that they will be required to reset their password soon.
|
||||||
PageLevelMessages.register_warning_message(request, e.message)
|
PageLevelMessages.register_warning_message(request, six.text_type(e))
|
||||||
except password_policy_compliance.NonCompliantPasswordException as e:
|
except password_policy_compliance.NonCompliantPasswordException as e:
|
||||||
send_password_reset_email_for_user(user, request)
|
send_password_reset_email_for_user(user, request)
|
||||||
# Prevent the login attempt.
|
# Prevent the login attempt.
|
||||||
raise AuthFailedError(e.message)
|
raise AuthFailedError(six.text_type(e))
|
||||||
|
|
||||||
|
|
||||||
def _generate_not_activated_message(user):
|
def _generate_not_activated_message(user):
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ class LoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMixin, ModuleSto
|
|||||||
visible=True,
|
visible=True,
|
||||||
enabled=True,
|
enabled=True,
|
||||||
icon_class='',
|
icon_class='',
|
||||||
icon_image=SimpleUploadedFile('icon.svg', '<svg><rect width="50" height="100"/></svg>'),
|
icon_image=SimpleUploadedFile('icon.svg', b'<svg><rect width="50" height="100"/></svg>'),
|
||||||
)
|
)
|
||||||
self.hidden_enabled_provider = self.configure_linkedin_provider(
|
self.hidden_enabled_provider = self.configure_linkedin_provider(
|
||||||
visible=False,
|
visible=False,
|
||||||
@@ -606,7 +606,7 @@ class LoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMixin, ModuleSto
|
|||||||
tpa_hint = self.hidden_disabled_provider.provider_id
|
tpa_hint = self.hidden_disabled_provider.provider_id
|
||||||
params = [("next", "/courses/something/?tpa_hint={0}".format(tpa_hint))]
|
params = [("next", "/courses/something/?tpa_hint={0}".format(tpa_hint))]
|
||||||
response = self.client.get(reverse('signin_user'), params, HTTP_ACCEPT="text/html")
|
response = self.client.get(reverse('signin_user'), params, HTTP_ACCEPT="text/html")
|
||||||
self.assertNotIn(response.content, tpa_hint)
|
self.assertNotIn(response.content.decode('utf-8'), tpa_hint)
|
||||||
|
|
||||||
@ddt.data(
|
@ddt.data(
|
||||||
('signin_user', 'login'),
|
('signin_user', 'login'),
|
||||||
@@ -650,7 +650,7 @@ class LoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMixin, ModuleSto
|
|||||||
tpa_hint = self.hidden_disabled_provider.provider_id
|
tpa_hint = self.hidden_disabled_provider.provider_id
|
||||||
params = [("next", "/courses/something/?tpa_hint={0}".format(tpa_hint))]
|
params = [("next", "/courses/something/?tpa_hint={0}".format(tpa_hint))]
|
||||||
response = self.client.get(reverse(url_name), params, HTTP_ACCEPT="text/html")
|
response = self.client.get(reverse(url_name), params, HTTP_ACCEPT="text/html")
|
||||||
self.assertNotIn(response.content, tpa_hint)
|
self.assertNotIn(response.content.decode('utf-8'), tpa_hint)
|
||||||
|
|
||||||
@override_settings(FEATURES=dict(settings.FEATURES, THIRD_PARTY_AUTH_HINT='oa2-google-oauth2'))
|
@override_settings(FEATURES=dict(settings.FEATURES, THIRD_PARTY_AUTH_HINT='oa2-google-oauth2'))
|
||||||
@ddt.data(
|
@ddt.data(
|
||||||
|
|||||||
Reference in New Issue
Block a user