Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
9dac2eff
Commit
9dac2eff
authored
Sep 08, 2013
by
Jason Bau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
actually flatten username suggestion to ascii
parent
6a850e27
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
2 deletions
+31
-2
common/djangoapps/external_auth/tests/test_shib.py
+16
-1
common/djangoapps/external_auth/views.py
+11
-1
common/djangoapps/student/views.py
+4
-0
No files found.
common/djangoapps/external_auth/tests/test_shib.py
View file @
9dac2eff
# -*- coding: utf-8 -*-
"""
Tests for Shibboleth Authentication
@jbau
...
...
@@ -7,6 +8,7 @@ from mock import patch
from
django.conf
import
settings
from
django.http
import
HttpResponseRedirect
from
django.test
import
TestCase
from
django.test.client
import
RequestFactory
,
Client
as
DjangoTestClient
from
django.test.utils
import
override_settings
from
django.core.urlresolvers
import
reverse
...
...
@@ -19,7 +21,7 @@ from xmodule.modulestore.inheritance import own_metadata
from
xmodule.modulestore.django
import
editable_modulestore
from
external_auth.models
import
ExternalAuthMap
from
external_auth.views
import
shib_login
,
course_specific_login
,
course_specific_register
from
external_auth.views
import
shib_login
,
course_specific_login
,
course_specific_register
,
_flatten_to_ascii
from
student.views
import
create_account
,
change_enrollment
from
student.models
import
UserProfile
,
Registration
,
CourseEnrollment
...
...
@@ -504,3 +506,16 @@ class ShibSPTest(ModuleStoreTestCase):
self
.
assertEqual
(
response
[
'location'
],
'http://testserver/testredirect'
)
# now there is enrollment
self
.
assertTrue
(
CourseEnrollment
.
is_enrolled
(
student
,
course
.
id
))
class
ShibUtilFnTest
(
TestCase
):
"""
Tests util functions in shib module
"""
def
test__flatten_to_ascii
(
self
):
DIACRITIC
=
u"àèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸåÅçÇ"
# pylint: disable=C0103
FLATTENED
=
u"aeiouAEIOUaeiouyAEIOUYaeiouAEIOUanoANOaeiouyAEIOUYaAcC"
# pylint: disable=C0103
self
.
assertEqual
(
_flatten_to_ascii
(
u'jas
\xf6
n'
),
u'jason'
)
# umlaut
self
.
assertEqual
(
_flatten_to_ascii
(
u'Jason
\u5305
'
),
u'Jason'
)
# mandarin, so it just gets dropped
self
.
assertEqual
(
_flatten_to_ascii
(
u'abc'
),
u'abc'
)
# pass through
self
.
assertEqual
(
_flatten_to_ascii
(
DIACRITIC
),
FLATTENED
)
common/djangoapps/external_auth/views.py
View file @
9dac2eff
...
...
@@ -5,6 +5,7 @@ import random
import
re
import
string
# pylint: disable=W0402
import
fnmatch
import
unicodedata
from
textwrap
import
dedent
from
external_auth.models
import
ExternalAuthMap
...
...
@@ -228,6 +229,15 @@ def _external_login_or_signup(request,
return
retfun
()
def
_flatten_to_ascii
(
txt
):
"""
Flattens possibly unicode txt to ascii (django username limitation)
@param name:
@return:
"""
return
unicodedata
.
normalize
(
'NFKD'
,
txt
)
.
encode
(
'ASCII'
,
'ignore'
)
@ensure_csrf_cookie
@cache_if_anonymous
def
_signup
(
request
,
eamap
):
...
...
@@ -245,7 +255,7 @@ def _signup(request, eamap):
# default conjoin name, no spaces, flattened to ascii b/c django can't handle unicode usernames, sadly
# but this only affects username, not fullname
username
=
eamap
.
external_name
.
replace
(
' '
,
''
)
username
=
_flatten_to_ascii
(
eamap
.
external_name
)
context
=
{
'has_extauth_info'
:
True
,
'show_signup_immediately'
:
True
,
...
...
common/djangoapps/student/views.py
View file @
9dac2eff
...
...
@@ -439,6 +439,10 @@ def _get_course_enrollment_domain(course_id):
@ensure_csrf_cookie
def
accounts_login
(
request
):
"""
This view is mainly used as the redirect from the @login_required decorator. I don't believe that
the login path linked from the homepage uses it.
"""
if
settings
.
MITX_FEATURES
.
get
(
'AUTH_USE_CAS'
):
return
redirect
(
reverse
(
'cas-login'
))
# see if the "next" parameter has been set, whether it has a course context, and if so, whether
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment