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
65f04205
Commit
65f04205
authored
Dec 18, 2016
by
Douglas Hall
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow for SiteConfiguration override of SESSION_COOKIE_DOMAIN setting in Studio
parent
6de2535e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
2 deletions
+35
-2
cms/envs/common.py
+3
-0
openedx/core/djangoapps/site_configuration/tests/test_middleware.py
+32
-2
No files found.
cms/envs/common.py
View file @
65f04205
...
...
@@ -389,6 +389,9 @@ MIDDLEWARE_CLASSES = (
# use Django built in clickjacking protection
'django.middleware.clickjacking.XFrameOptionsMiddleware'
,
# This must be last so that it runs first in the process_response chain
'openedx.core.djangoapps.site_configuration.middleware.SessionCookieDomainOverrideMiddleware'
,
)
# Clickjacking protection can be enabled by setting this to 'DENY'
...
...
openedx/core/djangoapps/site_configuration/tests/test_middleware.py
View file @
65f04205
...
...
@@ -7,6 +7,7 @@ import unittest
from
mock
import
patch
from
django.conf
import
settings
from
django.test
import
TestCase
from
django.test.client
import
Client
from
django.test.utils
import
override_settings
...
...
@@ -29,13 +30,13 @@ from openedx.core.djangoapps.site_configuration.tests.factories import SiteConfi
@ddt.ddt
@override_settings
(
SESSION_SAVE_EVERY_REQUEST
=
True
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
class
SessionCookieDomainOverrideTests
(
DatabaseMicrositeTestCase
):
class
SessionCookieDomain
Microsite
OverrideTests
(
DatabaseMicrositeTestCase
):
"""
Tests regarding the session cookie management in the middlware for Microsites
"""
def
setUp
(
self
):
super
(
SessionCookieDomainOverrideTests
,
self
)
.
setUp
()
super
(
SessionCookieDomain
Microsite
OverrideTests
,
self
)
.
setUp
()
# Create a test client, and log it in so that it will save some session
# data.
self
.
user
=
UserFactory
.
create
()
...
...
@@ -91,6 +92,35 @@ class SessionCookieDomainOverrideTests(DatabaseMicrositeTestCase):
self
.
assertNotIn
(
'test_site.localhost'
,
str
(
response
.
cookies
[
'sessionid'
]))
self
.
assertNotIn
(
'Domain'
,
str
(
response
.
cookies
[
'sessionid'
]))
# NOTE: We set SESSION_SAVE_EVERY_REQUEST to True in order to make sure
# Sessions are always started on every request
# pylint: disable=no-member, protected-access
@override_settings
(
SESSION_SAVE_EVERY_REQUEST
=
True
)
class
SessionCookieDomainSiteConfigurationOverrideTests
(
TestCase
):
"""
Tests regarding the session cookie management in the middlware for Microsites
"""
def
setUp
(
self
):
super
(
SessionCookieDomainSiteConfigurationOverrideTests
,
self
)
.
setUp
()
# Create a test client, and log it in so that it will save some session data.
self
.
user
=
UserFactory
.
create
()
self
.
user
.
set_password
(
'password'
)
self
.
user
.
save
()
self
.
site
=
SiteFactory
.
create
(
domain
=
'testserver.fake'
,
name
=
'testserver.fake'
)
self
.
site_configuration
=
SiteConfigurationFactory
.
create
(
site
=
self
.
site
,
values
=
{
"SESSION_COOKIE_DOMAIN"
:
self
.
site
.
domain
,
}
)
self
.
client
=
Client
()
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
"password"
)
def
test_session_cookie_domain_with_site_configuration_override
(
self
):
"""
Makes sure that the cookie being set is for the overridden domain
...
...
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