fix unicode strings in openedx/ part 1
This commit is contained in:
committed by
Calen Pennington
parent
4b4957ad9f
commit
f294b1a374
@@ -45,7 +45,7 @@ class DjangoOpenIDStore(OpenIDStore):
|
||||
def storeAssociation(self, server_url, assoc):
|
||||
key = get_url_key(server_url)
|
||||
|
||||
log.info('storeAssociation {0}'.format(key))
|
||||
log.info(u'storeAssociation {0}'.format(key))
|
||||
|
||||
associations = cache.get(key, {})
|
||||
associations[assoc.handle] = assoc
|
||||
@@ -55,7 +55,7 @@ class DjangoOpenIDStore(OpenIDStore):
|
||||
def getAssociation(self, server_url, handle=None):
|
||||
key = get_url_key(server_url)
|
||||
|
||||
log.info('getAssociation {0}'.format(key))
|
||||
log.info(u'getAssociation {0}'.format(key))
|
||||
|
||||
associations = cache.get(key, {})
|
||||
|
||||
@@ -84,7 +84,7 @@ class DjangoOpenIDStore(OpenIDStore):
|
||||
def removeAssociation(self, server_url, handle):
|
||||
key = get_url_key(server_url)
|
||||
|
||||
log.info('removeAssociation {0}'.format(key))
|
||||
log.info(u'removeAssociation {0}'.format(key))
|
||||
|
||||
associations = cache.get(key, {})
|
||||
|
||||
@@ -105,7 +105,7 @@ class DjangoOpenIDStore(OpenIDStore):
|
||||
def useNonce(self, server_url, timestamp, salt):
|
||||
key = get_nonce_key(server_url, timestamp, salt)
|
||||
|
||||
log.info('useNonce {0}'.format(key))
|
||||
log.info(u'useNonce {0}'.format(key))
|
||||
|
||||
if abs(timestamp - time.time()) > nonce.SKEW:
|
||||
return False
|
||||
|
||||
@@ -100,7 +100,7 @@ class OpenIdProviderTest(TestCase):
|
||||
resp = self.client.post(url)
|
||||
code = 200
|
||||
self.assertEqual(resp.status_code, code,
|
||||
"got code {0} for url '{1}'. Expected code {2}"
|
||||
u"got code {0} for url '{1}'. Expected code {2}"
|
||||
.format(resp.status_code, url, code))
|
||||
|
||||
@skipUnless(settings.FEATURES.get('AUTH_USE_OPENID') and
|
||||
@@ -129,7 +129,7 @@ class OpenIdProviderTest(TestCase):
|
||||
resp = self.client.post(url)
|
||||
code = 200
|
||||
self.assertEqual(resp.status_code, code,
|
||||
"got code {0} for url '{1}'. Expected code {2}"
|
||||
u"got code {0} for url '{1}'. Expected code {2}"
|
||||
.format(resp.status_code, url, code))
|
||||
for expected_input in (
|
||||
'<input name="openid.ns" type="hidden" value="http://specs.openid.net/auth/2.0" />',
|
||||
@@ -216,7 +216,7 @@ class OpenIdProviderTest(TestCase):
|
||||
|
||||
code = expected_code
|
||||
self.assertEqual(resp.status_code, code,
|
||||
"got code {0} for url '{1}'. Expected code {2}"
|
||||
u"got code {0} for url '{1}'. Expected code {2}"
|
||||
.format(resp.status_code, url, code))
|
||||
|
||||
@skipUnless(settings.FEATURES.get('AUTH_USE_OPENID') and
|
||||
@@ -454,7 +454,7 @@ class OpenIdProviderLiveServerTest(LiveServerTestCase):
|
||||
resp = self.client.post(url)
|
||||
code = 200
|
||||
self.assertEqual(resp.status_code, code,
|
||||
"got code {0} for url '{1}'. Expected code {2}"
|
||||
u"got code {0} for url '{1}'. Expected code {2}"
|
||||
.format(resp.status_code, url, code))
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -222,7 +222,7 @@ class ShibSPTest(CacheIsolationTestCase):
|
||||
"""
|
||||
inactive_user = UserFactory.create(email='inactive@stanford.edu')
|
||||
if not log_user_string:
|
||||
log_user_string = "user.id: {}".format(inactive_user.id)
|
||||
log_user_string = u"user.id: {}".format(inactive_user.id)
|
||||
inactive_user.is_active = False
|
||||
inactive_user.save()
|
||||
request = self.request_factory.get('/shib-login')
|
||||
|
||||
@@ -45,7 +45,7 @@ class SSLClientTest(ModuleStoreTestCase):
|
||||
Tests SSL Authentication code sections of external_auth
|
||||
"""
|
||||
|
||||
AUTH_DN = '/C=US/ST=Massachusetts/O=Massachusetts Institute of Technology/OU=Client CA v1/CN={0}/emailAddress={1}'
|
||||
AUTH_DN = b'/C=US/ST=Massachusetts/O=Massachusetts Institute of Technology/OU=Client CA v1/CN={0}/emailAddress={1}'
|
||||
USER_NAME = 'test_user_ssl'
|
||||
USER_EMAIL = 'test_user_ssl@EDX.ORG'
|
||||
MOCK_URL = '/'
|
||||
@@ -98,7 +98,7 @@ class SSLClientTest(ModuleStoreTestCase):
|
||||
try:
|
||||
ExternalAuthMap.objects.get(external_id=self.USER_EMAIL)
|
||||
except ExternalAuthMap.DoesNotExist, ex:
|
||||
self.fail('User did not get properly added to external auth map, exception was {0}'.format(str(ex)))
|
||||
self.fail(u'User did not get properly added to external auth map, exception was {0}'.format(str(ex)))
|
||||
|
||||
with self.assertRaises(User.DoesNotExist):
|
||||
User.objects.get(email=self.USER_EMAIL)
|
||||
@@ -117,7 +117,7 @@ class SSLClientTest(ModuleStoreTestCase):
|
||||
try:
|
||||
ExternalAuthMap.objects.get(external_id=self.USER_EMAIL)
|
||||
except ExternalAuthMap.DoesNotExist, ex:
|
||||
self.fail('User did not get properly added to external auth map, exception was {0}'.format(str(ex)))
|
||||
self.fail(u'User did not get properly added to external auth map, exception was {0}'.format(str(ex)))
|
||||
|
||||
with self.assertRaises(User.DoesNotExist):
|
||||
User.objects.get(email=self.USER_EMAIL)
|
||||
@@ -136,11 +136,11 @@ class SSLClientTest(ModuleStoreTestCase):
|
||||
try:
|
||||
ExternalAuthMap.objects.get(external_id=self.USER_EMAIL)
|
||||
except ExternalAuthMap.DoesNotExist, ex:
|
||||
self.fail('User did not get properly added to external auth map, exception was {0}'.format(str(ex)))
|
||||
self.fail(u'User did not get properly added to external auth map, exception was {0}'.format(str(ex)))
|
||||
try:
|
||||
User.objects.get(email=self.USER_EMAIL)
|
||||
except ExternalAuthMap.DoesNotExist, ex:
|
||||
self.fail('User did not get properly added to internal users, exception was {0}'.format(str(ex)))
|
||||
self.fail(u'User did not get properly added to internal users, exception was {0}'.format(str(ex)))
|
||||
|
||||
@skip_unless_cms
|
||||
@override_settings(FEATURES=FEATURES_WITH_SSL_AUTH_IMMEDIATE_SIGNUP)
|
||||
@@ -162,11 +162,11 @@ class SSLClientTest(ModuleStoreTestCase):
|
||||
try:
|
||||
ExternalAuthMap.objects.get(external_id=self.USER_EMAIL)
|
||||
except ExternalAuthMap.DoesNotExist, ex:
|
||||
self.fail('User did not get properly added to external auth map, exception was {0}'.format(str(ex)))
|
||||
self.fail(u'User did not get properly added to external auth map, exception was {0}'.format(str(ex)))
|
||||
try:
|
||||
User.objects.get(email=self.USER_EMAIL)
|
||||
except ExternalAuthMap.DoesNotExist, ex:
|
||||
self.fail('User did not get properly added to internal users, exception was {0}'.format(str(ex)))
|
||||
self.fail(u'User did not get properly added to internal users, exception was {0}'.format(str(ex)))
|
||||
|
||||
@skip_unless_lms
|
||||
@override_settings(FEATURES=FEATURES_WITH_SSL_AUTH_IMMEDIATE_SIGNUP)
|
||||
@@ -323,11 +323,11 @@ class SSLClientTest(ModuleStoreTestCase):
|
||||
try:
|
||||
ExternalAuthMap.objects.get(external_id=self.USER_EMAIL)
|
||||
except ExternalAuthMap.DoesNotExist, ex:
|
||||
self.fail('User did not get properly added to external auth map, exception was {0}'.format(str(ex)))
|
||||
self.fail(u'User did not get properly added to external auth map, exception was {0}'.format(str(ex)))
|
||||
try:
|
||||
User.objects.get(email=self.USER_EMAIL)
|
||||
except ExternalAuthMap.DoesNotExist, ex:
|
||||
self.fail('User did not get properly added to internal users, exception was {0}'.format(str(ex)))
|
||||
self.fail(u'User did not get properly added to internal users, exception was {0}'.format(str(ex)))
|
||||
self.assertEqual(1, len(ExternalAuthMap.objects.all()))
|
||||
|
||||
self.assertTrue(self.mock.called)
|
||||
|
||||
@@ -97,12 +97,12 @@ def openid_login_complete(request,
|
||||
oid_backend = openid_auth.OpenIDBackend()
|
||||
details = oid_backend._extract_user_details(openid_response) # pylint: disable=protected-access
|
||||
|
||||
log.debug('openid success, details=%s', details)
|
||||
log.debug(u'openid success, details=%s', details)
|
||||
|
||||
url = getattr(settings, 'OPENID_SSO_SERVER_URL', None)
|
||||
external_domain = "{0}{1}".format(OPENID_DOMAIN_PREFIX, url)
|
||||
fullname = '%s %s' % (details.get('first_name', ''),
|
||||
details.get('last_name', ''))
|
||||
external_domain = u"{0}{1}".format(OPENID_DOMAIN_PREFIX, url)
|
||||
fullname = u'%s %s' % (details.get('first_name', ''),
|
||||
details.get('last_name', ''))
|
||||
|
||||
return _external_login_or_signup(
|
||||
request,
|
||||
@@ -174,9 +174,9 @@ def _external_login_or_signup(request,
|
||||
# otherwise, there must have been an error, b/c we've already linked a user with these external
|
||||
# creds
|
||||
failure_msg = _(
|
||||
"You have already created an account using "
|
||||
"an external login like WebAuth or Shibboleth. "
|
||||
"Please contact {tech_support_email} for support."
|
||||
u"You have already created an account using "
|
||||
u"an external login like WebAuth or Shibboleth. "
|
||||
"Please contact {tech_support_email} for support." # pylint: disable=unicode-format-string
|
||||
).format(
|
||||
tech_support_email=get_value('email_from_address', settings.TECH_SUPPORT_EMAIL),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user