Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
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
django-rest-framework
Commits
8bb42753
Commit
8bb42753
authored
Jan 23, 2012
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Docstring tidy up
parent
e362344f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
djangorestframework/tests/authentication.py
+13
-5
No files found.
djangorestframework/tests/authentication.py
View file @
8bb42753
...
@@ -11,7 +11,7 @@ import base64
...
@@ -11,7 +11,7 @@ import base64
class
MockView
(
View
):
class
MockView
(
View
):
permissions
=
(
permissions
.
IsAuthenticated
,
)
permissions
=
(
permissions
.
IsAuthenticated
,
)
def
post
(
self
,
request
):
def
post
(
self
,
request
):
return
{
'a'
:
1
,
'b'
:
2
,
'c'
:
3
}
return
{
'a'
:
1
,
'b'
:
2
,
'c'
:
3
}
...
@@ -74,24 +74,32 @@ class SessionAuthTests(TestCase):
...
@@ -74,24 +74,32 @@ class SessionAuthTests(TestCase):
self
.
csrf_client
.
logout
()
self
.
csrf_client
.
logout
()
def
test_post_form_session_auth_failing_csrf
(
self
):
def
test_post_form_session_auth_failing_csrf
(
self
):
"""Ensure POSTing form over session authentication without CSRF token fails."""
"""
Ensure POSTing form over session authentication without CSRF token fails.
"""
self
.
csrf_client
.
login
(
username
=
self
.
username
,
password
=
self
.
password
)
self
.
csrf_client
.
login
(
username
=
self
.
username
,
password
=
self
.
password
)
response
=
self
.
csrf_client
.
post
(
'/'
,
{
'example'
:
'example'
})
response
=
self
.
csrf_client
.
post
(
'/'
,
{
'example'
:
'example'
})
self
.
assertEqual
(
response
.
status_code
,
403
)
self
.
assertEqual
(
response
.
status_code
,
403
)
def
test_post_form_session_auth_passing
(
self
):
def
test_post_form_session_auth_passing
(
self
):
"""Ensure POSTing form over session authentication with logged in user and CSRF token passes."""
"""
Ensure POSTing form over session authentication with logged in user and CSRF token passes.
"""
self
.
non_csrf_client
.
login
(
username
=
self
.
username
,
password
=
self
.
password
)
self
.
non_csrf_client
.
login
(
username
=
self
.
username
,
password
=
self
.
password
)
response
=
self
.
non_csrf_client
.
post
(
'/'
,
{
'example'
:
'example'
})
response
=
self
.
non_csrf_client
.
post
(
'/'
,
{
'example'
:
'example'
})
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_put_form_session_auth_passing
(
self
):
def
test_put_form_session_auth_passing
(
self
):
"""Ensure PUTting form over session authentication with logged in user and CSRF token passes."""
"""
Ensure PUTting form over session authentication with logged in user and CSRF token passes.
"""
self
.
non_csrf_client
.
login
(
username
=
self
.
username
,
password
=
self
.
password
)
self
.
non_csrf_client
.
login
(
username
=
self
.
username
,
password
=
self
.
password
)
response
=
self
.
non_csrf_client
.
put
(
'/'
,
{
'example'
:
'example'
})
response
=
self
.
non_csrf_client
.
put
(
'/'
,
{
'example'
:
'example'
})
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_post_form_session_auth_failing
(
self
):
def
test_post_form_session_auth_failing
(
self
):
"""Ensure POSTing form over session authentication without logged in user fails."""
"""
Ensure POSTing form over session authentication without logged in user fails.
"""
response
=
self
.
csrf_client
.
post
(
'/'
,
{
'example'
:
'example'
})
response
=
self
.
csrf_client
.
post
(
'/'
,
{
'example'
:
'example'
})
self
.
assertEqual
(
response
.
status_code
,
403
)
self
.
assertEqual
(
response
.
status_code
,
403
)
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