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
7a9991e9
Commit
7a9991e9
authored
Jan 28, 2016
by
Mushtaq Ali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Studio homepage escaping
parent
a26d5764
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
2 deletions
+30
-2
cms/djangoapps/contentstore/tests/test_course_listing.py
+28
-1
cms/djangoapps/contentstore/views/tests/test_programs.py
+2
-1
cms/templates/index.html
+0
-0
No files found.
cms/djangoapps/contentstore/tests/test_course_listing.py
View file @
7a9991e9
...
...
@@ -9,6 +9,9 @@ from mock import patch, Mock
import
ddt
from
django.test
import
RequestFactory
from
django.test.client
import
Client
from
common.test.utils
import
XssTestMixin
from
xmodule.course_module
import
CourseSummary
from
contentstore.views.course
import
(
_accessible_courses_list
,
_accessible_courses_list_from_groups
,
...
...
@@ -30,7 +33,7 @@ USER_COURSES_COUNT = 50
@ddt.ddt
class
TestCourseListing
(
ModuleStoreTestCase
):
class
TestCourseListing
(
ModuleStoreTestCase
,
XssTestMixin
):
"""
Unit tests for getting the list of courses for a logged in user
"""
...
...
@@ -72,6 +75,30 @@ class TestCourseListing(ModuleStoreTestCase):
self
.
client
.
logout
()
ModuleStoreTestCase
.
tearDown
(
self
)
def
test_course_listing_is_escaped
(
self
):
"""
Tests course listing returns escaped data.
"""
escaping_content
=
"<script>alert('ESCAPE')</script>"
# Make user staff to access course listing
self
.
user
.
is_staff
=
True
self
.
user
.
save
()
# pylint: disable=no-member
self
.
client
=
Client
()
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
'test'
)
# Change 'display_coursenumber' field and update the course.
course
=
CourseFactory
.
create
()
course
.
display_coursenumber
=
escaping_content
course
=
self
.
store
.
update_item
(
course
,
self
.
user
.
id
)
# pylint: disable=no-member
self
.
assertEqual
(
course
.
display_coursenumber
,
escaping_content
)
# Check if response is escaped
response
=
self
.
client
.
get
(
'/home'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assert_no_xss
(
response
,
escaping_content
)
def
test_get_course_list
(
self
):
"""
Test getting courses with new access group format e.g. 'instructor_edx.course.run'
...
...
cms/djangoapps/contentstore/views/tests/test_programs.py
View file @
7a9991e9
...
...
@@ -10,6 +10,7 @@ from provider.constants import CONFIDENTIAL
from
openedx.core.djangoapps.programs.models
import
ProgramsApiConfig
from
openedx.core.djangoapps.programs.tests.mixins
import
ProgramsApiConfigMixin
,
ProgramsDataMixin
from
openedx.core.djangolib.markup
import
escape
from
student.tests.factories
import
UserFactory
from
xmodule.modulestore.tests.django_utils
import
SharedModuleStoreTestCase
...
...
@@ -63,7 +64,7 @@ class TestProgramListing(ProgramsApiConfigMixin, ProgramsDataMixin, SharedModule
self
.
mock_programs_api
(
data
=
{
'results'
:
[]})
response
=
self
.
client
.
get
(
self
.
studio_home
)
self
.
assertIn
(
"You haven't created any programs yet."
,
response
.
content
)
self
.
assertIn
(
escape
(
"You haven't created any programs yet."
)
,
response
.
content
)
# When data is provided, expect a program listing.
self
.
mock_programs_api
()
...
...
cms/templates/index.html
View file @
7a9991e9
This diff is collapsed.
Click to expand it.
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