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
402ae4d8
Commit
402ae4d8
authored
Jul 23, 2013
by
ihoover
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added csrf tests
parent
4148c00c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
1 deletions
+21
-1
common/djangoapps/student/tests/test_auto_auth.py
+21
-1
No files found.
common/djangoapps/student/tests/test_auto_auth.py
View file @
402ae4d8
...
@@ -3,6 +3,7 @@ from django.test.client import Client
...
@@ -3,6 +3,7 @@ from django.test.client import Client
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
util.testing
import
UrlResetMixin
from
util.testing
import
UrlResetMixin
from
mock
import
patch
from
mock
import
patch
from
django.core.urlresolvers
import
reverse
class
AutoAuthEnabledTestCase
(
UrlResetMixin
,
TestCase
):
class
AutoAuthEnabledTestCase
(
UrlResetMixin
,
TestCase
):
...
@@ -68,8 +69,17 @@ class AutoAuthEnabledTestCase(UrlResetMixin, TestCase):
...
@@ -68,8 +69,17 @@ class AutoAuthEnabledTestCase(UrlResetMixin, TestCase):
# make sure it is the same user
# make sure it is the same user
self
.
assertEqual
(
qset
.
count
(),
1
)
self
.
assertEqual
(
qset
.
count
(),
1
)
def
test_csrf_disabled
(
self
):
"""
test that when load testing, csrf protection is off
"""
self
.
client
=
Client
(
enforce_csrf_checks
=
True
)
csrf_protected_url
=
reverse
(
"signin_user"
)
response
=
self
.
client
.
get
(
csrf_protected_url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
class
AutoAuthDisabledTestCase
(
UrlResetMixin
):
class
AutoAuthDisabledTestCase
(
UrlResetMixin
,
TestCase
):
"""
"""
Test that the page is inaccessible with default settings
Test that the page is inaccessible with default settings
"""
"""
...
@@ -90,3 +100,13 @@ class AutoAuthDisabledTestCase(UrlResetMixin):
...
@@ -90,3 +100,13 @@ class AutoAuthDisabledTestCase(UrlResetMixin):
"""
"""
response
=
self
.
client
.
get
(
self
.
url
)
response
=
self
.
client
.
get
(
self
.
url
)
self
.
assertEqual
(
response
.
status_code
,
404
)
self
.
assertEqual
(
response
.
status_code
,
404
)
def
test_csrf_enabled
(
self
):
"""
test that when not load testing, csrf protection is on
"""
self
.
client
=
Client
(
enforce_csrf_checks
=
True
)
csrf_protected_url
=
reverse
(
"signin_user"
)
response
=
self
.
client
.
post
(
csrf_protected_url
)
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