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
f1260f38
Commit
f1260f38
authored
Jan 21, 2010
by
stuart.langridge@canonical.com
Committed by
Tarmac
Jan 21, 2010
Browse files
Options
Browse Files
Download
Plain Diff
Add a test for the sanitise_redirect_url function
parents
389bec33
8e99c2a8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
django_openid_auth/tests/test_views.py
+24
-0
No files found.
django_openid_auth/tests/test_views.py
View file @
f1260f38
...
...
@@ -43,6 +43,7 @@ from openid.store.memstore import MemoryStore
from
django_openid_auth
import
teams
from
django_openid_auth.models
import
UserOpenID
from
django_openid_auth.views
import
sanitise_redirect_url
ET
=
importElementTree
()
...
...
@@ -362,5 +363,28 @@ class RelyingPartyTests(TestCase):
self
.
assertEqual
(
group2
in
user
.
groups
.
all
(),
False
)
self
.
assertTrue
(
group3
not
in
user
.
groups
.
all
())
class
HelperFunctionsTest
(
TestCase
):
def
test_sanitise_redirect_url
(
self
):
settings
.
ALLOWED_EXTERNAL_OPENID_REDIRECT_DOMAINS
=
[
"example.com"
,
"example.org"
]
# list of URLs and whether they should be passed or not
urls
=
[
(
"http://example.com"
,
True
),
(
"http://example.org/"
,
True
),
(
"http://example.org/foo/bar"
,
True
),
(
"http://example.org/foo/bar?baz=quux"
,
True
),
(
"http://example.org:9999/foo/bar?baz=quux"
,
True
),
(
"http://www.example.org/"
,
False
),
(
"http://example.net/foo/bar?baz=quux"
,
False
),
(
"/somewhere/local"
,
True
),
(
"/somewhere/local?url=http://fail.com/bar"
,
True
),
]
for
url
,
returns_self
in
urls
:
sanitised
=
sanitise_redirect_url
(
url
)
if
returns_self
:
self
.
assertEqual
(
url
,
sanitised
)
else
:
self
.
assertEqual
(
settings
.
LOGIN_REDIRECT_URL
,
sanitised
)
def
suite
():
return
unittest
.
TestLoader
()
.
loadTestsFromName
(
__name__
)
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