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
af8a362d
Commit
af8a362d
authored
Apr 07, 2014
by
Nicolas Delaby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reset stored credentials when call client.logout()
parent
115fe048
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
rest_framework/test.py
+4
-0
rest_framework/tests/test_testing.py
+11
-0
No files found.
rest_framework/test.py
View file @
af8a362d
...
@@ -154,6 +154,10 @@ class APIClient(APIRequestFactory, DjangoClient):
...
@@ -154,6 +154,10 @@ class APIClient(APIRequestFactory, DjangoClient):
kwargs
.
update
(
self
.
_credentials
)
kwargs
.
update
(
self
.
_credentials
)
return
super
(
APIClient
,
self
)
.
request
(
**
kwargs
)
return
super
(
APIClient
,
self
)
.
request
(
**
kwargs
)
def
logout
(
self
):
self
.
_credentials
=
{}
return
super
(
APIClient
,
self
)
.
logout
()
class
APITransactionTestCase
(
testcases
.
TransactionTestCase
):
class
APITransactionTestCase
(
testcases
.
TransactionTestCase
):
client_class
=
APIClient
client_class
=
APIClient
...
...
rest_framework/tests/test_testing.py
View file @
af8a362d
...
@@ -99,6 +99,17 @@ class TestAPITestClient(TestCase):
...
@@ -99,6 +99,17 @@ class TestAPITestClient(TestCase):
self
.
assertEqual
(
response
.
status_code
,
403
)
self
.
assertEqual
(
response
.
status_code
,
403
)
self
.
assertEqual
(
response
.
data
,
expected
)
self
.
assertEqual
(
response
.
data
,
expected
)
def
test_can_logout
(
self
):
"""
`logout()` reset stored credentials
"""
self
.
client
.
credentials
(
HTTP_AUTHORIZATION
=
'example'
)
response
=
self
.
client
.
get
(
'/view/'
)
self
.
assertEqual
(
response
.
data
[
'auth'
],
'example'
)
self
.
client
.
logout
()
response
=
self
.
client
.
get
(
'/view/'
)
self
.
assertEqual
(
response
.
data
[
'auth'
],
b
''
)
class
TestAPIRequestFactory
(
TestCase
):
class
TestAPIRequestFactory
(
TestCase
):
def
test_csrf_exempt_by_default
(
self
):
def
test_csrf_exempt_by_default
(
self
):
...
...
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