Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-openid-auth
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
OpenEdx
django-openid-auth
Commits
7c2abdbd
Commit
7c2abdbd
authored
Jul 18, 2011
by
Michael Nelson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RED: Required fields should be required in SRegRequest.
parent
1bbcbd7b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
12 deletions
+37
-12
django_openid_auth/tests/test_views.py
+32
-11
django_openid_auth/views.py
+5
-1
No files found.
django_openid_auth/tests/test_views.py
View file @
7c2abdbd
...
...
@@ -326,7 +326,7 @@ class RelyingPartyTests(TestCase):
self
.
assertEquals
(
user
.
first_name
,
'Openid'
)
self
.
assertEquals
(
user
.
last_name
,
'User'
)
self
.
assertEquals
(
user
.
email
,
'foo@example.com'
)
def
test_login_follow_rename
(
self
):
settings
.
OPENID_FOLLOW_RENAMES
=
True
settings
.
OPENID_UPDATE_DETAILS_FROM_SREG
=
True
...
...
@@ -344,7 +344,7 @@ class RelyingPartyTests(TestCase):
self
.
_do_user_login
(
openid_req
,
openid_resp
)
response
=
self
.
client
.
get
(
'/getuser/'
)
# If OPENID_FOLLOW_RENAMES, they are logged in as
# If OPENID_FOLLOW_RENAMES, they are logged in as
# someuser (the passed in nickname has changed the username)
self
.
assertEquals
(
response
.
content
,
'someuser'
)
...
...
@@ -353,7 +353,7 @@ class RelyingPartyTests(TestCase):
self
.
assertEquals
(
user
.
first_name
,
'Some'
)
self
.
assertEquals
(
user
.
last_name
,
'User'
)
self
.
assertEquals
(
user
.
email
,
'foo@example.com'
)
def
test_login_follow_rename_conflict
(
self
):
settings
.
OPENID_FOLLOW_RENAMES
=
True
settings
.
OPENID_UPDATE_DETAILS_FROM_SREG
=
True
...
...
@@ -390,7 +390,7 @@ class RelyingPartyTests(TestCase):
self
.
assertEquals
(
user
.
first_name
,
'Rename'
)
self
.
assertEquals
(
user
.
last_name
,
'User'
)
self
.
assertEquals
(
user
.
email
,
'rename@example.com'
)
def
test_login_follow_rename_false_onlyonce
(
self
):
settings
.
OPENID_FOLLOW_RENAMES
=
True
settings
.
OPENID_UPDATE_DETAILS_FROM_SREG
=
True
...
...
@@ -420,8 +420,8 @@ class RelyingPartyTests(TestCase):
# If OPENID_FOLLOW_RENAMES, attempt to change username to 'testuser'
# but since that username is already taken by someone else, we go through
# the process of adding +i to it. Even though it looks like the username
# follows the nickname+i scheme, it has non-numbers in the suffix, so
# it's not an auto-generated one. The regular process of renaming to
# follows the nickname+i scheme, it has non-numbers in the suffix, so
# it's not an auto-generated one. The regular process of renaming to
# 'testuser' has a conflict, so we get +2 at the end.
self
.
assertEquals
(
response
.
content
,
'testuser2'
)
...
...
@@ -430,7 +430,7 @@ class RelyingPartyTests(TestCase):
self
.
assertEquals
(
user
.
first_name
,
'Rename'
)
self
.
assertEquals
(
user
.
last_name
,
'User'
)
self
.
assertEquals
(
user
.
email
,
'rename@example.com'
)
def
test_login_follow_rename_conflict_onlyonce
(
self
):
settings
.
OPENID_FOLLOW_RENAMES
=
True
settings
.
OPENID_UPDATE_DETAILS_FROM_SREG
=
True
...
...
@@ -468,7 +468,7 @@ class RelyingPartyTests(TestCase):
self
.
assertEquals
(
user
.
first_name
,
'Rename'
)
self
.
assertEquals
(
user
.
last_name
,
'User'
)
self
.
assertEquals
(
user
.
email
,
'rename@example.com'
)
def
test_login_follow_rename_false_conflict
(
self
):
settings
.
OPENID_FOLLOW_RENAMES
=
True
settings
.
OPENID_UPDATE_DETAILS_FROM_SREG
=
True
...
...
@@ -498,7 +498,7 @@ class RelyingPartyTests(TestCase):
self
.
assertEquals
(
user
.
first_name
,
'Same'
)
self
.
assertEquals
(
user
.
last_name
,
'User'
)
self
.
assertEquals
(
user
.
email
,
'same@example.com'
)
def
test_strict_username_no_nickname
(
self
):
settings
.
OPENID_CREATE_USERS
=
True
settings
.
OPENID_STRICT_USERNAMES
=
True
...
...
@@ -520,7 +520,7 @@ class RelyingPartyTests(TestCase):
'email'
:
'foo@example.com'
})
openid_response
.
addExtension
(
sreg_response
)
response
=
self
.
complete
(
openid_response
)
# Status code should be 403: Forbidden
self
.
assertEquals
(
403
,
response
.
status_code
)
...
...
@@ -551,7 +551,7 @@ class RelyingPartyTests(TestCase):
'email'
:
'foo@example.com'
})
openid_response
.
addExtension
(
sreg_response
)
response
=
self
.
complete
(
openid_response
)
# Status code should be 403: Forbidden
self
.
assertEquals
(
403
,
response
.
status_code
)
...
...
@@ -599,6 +599,27 @@ class RelyingPartyTests(TestCase):
for
field
in
(
'email'
,
'fullname'
,
'nickname'
,
'language'
):
self
.
assertTrue
(
field
in
sreg_request
)
def
test_login_uses_sreg_required_fields
(
self
):
# The configurable sreg attributes are used in the request.
settings
.
OPENID_SREG_REQUIRED_FIELDS
=
(
'email'
,
'language'
)
user
=
User
.
objects
.
create_user
(
'testuser'
,
'someone@example.com'
)
useropenid
=
UserOpenID
(
user
=
user
,
claimed_id
=
'http://example.com/identity'
,
display_id
=
'http://example.com/identity'
)
useropenid
.
save
()
# Posting in an identity URL begins the authentication request:
response
=
self
.
client
.
post
(
'/openid/login/'
,
{
'openid_identifier'
:
'http://example.com/identity'
,
'next'
:
'/getuser/'
})
openid_request
=
self
.
provider
.
parseFormPost
(
response
.
content
)
sreg_request
=
sreg
.
SRegRequest
.
fromOpenIDRequest
(
openid_request
)
self
.
assertEqual
([
'email'
,
'language'
],
sreg_request
.
required
)
self
.
assertEqual
([
'fullname'
,
'nickname'
],
sreg_request
.
optional
)
def
test_login_attribute_exchange
(
self
):
settings
.
OPENID_UPDATE_DETAILS_FROM_SREG
=
True
user
=
User
.
objects
.
create_user
(
'testuser'
,
'someone@example.com'
)
...
...
django_openid_auth/views.py
View file @
7c2abdbd
...
...
@@ -196,11 +196,15 @@ def login_begin(request, template_name='openid/login.html',
fetch_request
.
add
(
ax
.
AttrInfo
(
attr
,
alias
=
alias
,
required
=
True
))
openid_request
.
addExtension
(
fetch_request
)
else
:
sreg_required_fields
=
[]
sreg_required_fields
.
extend
(
getattr
(
settings
,
'OPENID_SREG_REQUIRED_FIELDS'
,
[]))
sreg_optional_fields
=
[
'email'
,
'fullname'
,
'nickname'
]
extra_fields
=
getattr
(
settings
,
'OPENID_SREG_EXTRA_FIELDS'
,
[])
sreg_optional_fields
.
extend
(
extra_fields
)
openid_request
.
addExtension
(
sreg
.
SRegRequest
(
optional
=
sreg_optional_fields
))
sreg
.
SRegRequest
(
optional
=
sreg_optional_fields
,
required
=
sreg_required_fields
))
# Request team info
teams_mapping_auto
=
getattr
(
settings
,
'OPENID_LAUNCHPAD_TEAMS_MAPPING_AUTO'
,
False
)
...
...
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