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
dffcb13c
Commit
dffcb13c
authored
Apr 25, 2017
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate that the language cookie is preserved during logout
parent
f8b050a5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
openedx/core/djangoapps/lang_pref/tests/test_middleware.py
+18
-0
No files found.
openedx/core/djangoapps/lang_pref/tests/test_middleware.py
View file @
dffcb13c
...
@@ -8,6 +8,7 @@ import mock
...
@@ -8,6 +8,7 @@ import mock
import
ddt
import
ddt
from
django.conf
import
settings
from
django.conf
import
settings
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.core.urlresolvers
import
reverse
from
django.test.client
import
RequestFactory
from
django.test.client
import
RequestFactory
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
django.contrib.sessions.middleware
import
SessionMiddleware
from
django.contrib.sessions.middleware
import
SessionMiddleware
...
@@ -144,6 +145,23 @@ class TestUserPreferenceMiddleware(TestCase):
...
@@ -144,6 +145,23 @@ class TestUserPreferenceMiddleware(TestCase):
self
.
assertEquals
(
self
.
request
.
session
.
get
(
LANGUAGE_SESSION_KEY
),
lang_session
)
self
.
assertEquals
(
self
.
request
.
session
.
get
(
LANGUAGE_SESSION_KEY
),
lang_session
)
@ddt.data
(
None
,
'es'
,
'en'
)
def
test_logout_preserves_cookie
(
self
,
lang_cookie
):
if
lang_cookie
:
self
.
client
.
cookies
[
settings
.
LANGUAGE_COOKIE
]
=
lang_cookie
elif
settings
.
LANGUAGE_COOKIE
in
self
.
client
.
cookies
:
del
self
.
client
.
cookies
[
settings
.
LANGUAGE_COOKIE
]
# Use an actual call to the logout endpoint, because the logout function
# explicitly clears all cookies
self
.
client
.
get
(
reverse
(
'logout'
))
if
lang_cookie
:
self
.
assertEqual
(
self
.
client
.
cookies
[
settings
.
LANGUAGE_COOKIE
]
.
value
,
lang_cookie
)
else
:
self
.
assertNotIn
(
settings
.
LANGUAGE_COOKIE
,
self
.
client
.
cookies
)
def
test_process_response_no_user_noop
(
self
):
def
test_process_response_no_user_noop
(
self
):
del
self
.
request
.
user
del
self
.
request
.
user
response
=
mock
.
Mock
(
spec
=
HttpResponse
)
response
=
mock
.
Mock
(
spec
=
HttpResponse
)
...
...
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