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
a1e911ae
Commit
a1e911ae
authored
Aug 29, 2014
by
Waheed Ahmed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed InvalidKeyError in course handler in studio.
LMS-11141
parent
9ca4c566
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
36 deletions
+38
-36
cms/djangoapps/contentstore/tests/test_contentstore.py
+6
-0
cms/djangoapps/contentstore/views/course.py
+25
-22
common/djangoapps/external_auth/tests/test_ssl.py
+7
-14
No files found.
cms/djangoapps/contentstore/tests/test_contentstore.py
View file @
a1e911ae
...
@@ -1488,6 +1488,12 @@ class ContentStoreTest(ContentStoreTestCase):
...
@@ -1488,6 +1488,12 @@ class ContentStoreTest(ContentStoreTestCase):
course_module
=
self
.
store
.
get_course
(
course_key
)
course_module
=
self
.
store
.
get_course
(
course_key
)
self
.
assertEquals
(
course_module
.
wiki_slug
,
'MITx.111.2013_Spring'
)
self
.
assertEquals
(
course_module
.
wiki_slug
,
'MITx.111.2013_Spring'
)
def
test_course_handler_with_invalid_course_key_string
(
self
):
"""Test viewing the course overview page with invalid course id"""
response
=
self
.
client
.
get_html
(
'/course/edX/test'
)
self
.
assertEquals
(
response
.
status_code
,
404
)
class
MetadataSaveTestCase
(
ContentStoreTestCase
):
class
MetadataSaveTestCase
(
ContentStoreTestCase
):
"""Test that metadata is correctly cached and decached."""
"""Test that metadata is correctly cached and decached."""
...
...
cms/djangoapps/contentstore/views/course.py
View file @
a1e911ae
...
@@ -12,7 +12,7 @@ from django.conf import settings
...
@@ -12,7 +12,7 @@ from django.conf import settings
from
django.views.decorators.http
import
require_http_methods
from
django.views.decorators.http
import
require_http_methods
from
django.core.exceptions
import
PermissionDenied
from
django.core.exceptions
import
PermissionDenied
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.http
import
HttpResponseBadRequest
,
HttpResponseNotFound
,
HttpResponse
from
django.http
import
HttpResponseBadRequest
,
HttpResponseNotFound
,
HttpResponse
,
Http404
from
util.json_request
import
JsonResponse
,
JsonResponseBadRequest
from
util.json_request
import
JsonResponse
,
JsonResponseBadRequest
from
util.date_utils
import
get_default_time_display
from
util.date_utils
import
get_default_time_display
from
edxmako.shortcuts
import
render_to_response
from
edxmako.shortcuts
import
render_to_response
...
@@ -208,28 +208,31 @@ def course_handler(request, course_key_string=None):
...
@@ -208,28 +208,31 @@ def course_handler(request, course_key_string=None):
DELETE
DELETE
json: delete this branch from this course (leaving off /branch/draft would imply delete the course)
json: delete this branch from this course (leaving off /branch/draft would imply delete the course)
"""
"""
response_format
=
request
.
REQUEST
.
get
(
'format'
,
'html'
)
try
:
if
response_format
==
'json'
or
'application/json'
in
request
.
META
.
get
(
'HTTP_ACCEPT'
,
'application/json'
):
response_format
=
request
.
REQUEST
.
get
(
'format'
,
'html'
)
if
request
.
method
==
'GET'
:
if
response_format
==
'json'
or
'application/json'
in
request
.
META
.
get
(
'HTTP_ACCEPT'
,
'application/json'
):
course_module
=
_get_course_module
(
CourseKey
.
from_string
(
course_key_string
),
request
.
user
,
depth
=
None
)
if
request
.
method
==
'GET'
:
return
JsonResponse
(
_course_outline_json
(
request
,
course_module
))
course_module
=
_get_course_module
(
CourseKey
.
from_string
(
course_key_string
),
request
.
user
,
depth
=
None
)
elif
request
.
method
==
'POST'
:
# not sure if this is only post. If one will have ids, it goes after access
return
JsonResponse
(
_course_outline_json
(
request
,
course_module
))
return
_create_or_rerun_course
(
request
)
elif
request
.
method
==
'POST'
:
# not sure if this is only post. If one will have ids, it goes after access
elif
not
has_course_access
(
request
.
user
,
CourseKey
.
from_string
(
course_key_string
)):
return
_create_or_rerun_course
(
request
)
raise
PermissionDenied
()
elif
not
has_course_access
(
request
.
user
,
CourseKey
.
from_string
(
course_key_string
)):
elif
request
.
method
==
'PUT'
:
raise
PermissionDenied
()
raise
NotImplementedError
()
elif
request
.
method
==
'PUT'
:
elif
request
.
method
==
'DELETE'
:
raise
NotImplementedError
()
raise
NotImplementedError
()
elif
request
.
method
==
'DELETE'
:
else
:
raise
NotImplementedError
()
return
HttpResponseBadRequest
()
else
:
elif
request
.
method
==
'GET'
:
# assume html
return
HttpResponseBadRequest
()
if
course_key_string
is
None
:
elif
request
.
method
==
'GET'
:
# assume html
return
course_listing
(
request
)
if
course_key_string
is
None
:
return
course_listing
(
request
)
else
:
return
course_index
(
request
,
CourseKey
.
from_string
(
course_key_string
))
else
:
else
:
return
course_index
(
request
,
CourseKey
.
from_string
(
course_key_string
)
)
return
HttpResponseNotFound
(
)
e
lse
:
e
xcept
InvalidKeyError
:
r
eturn
HttpResponseNotFound
()
r
aise
Http404
@login_required
@login_required
...
...
common/djangoapps/external_auth/tests/test_ssl.py
View file @
a1e911ae
...
@@ -200,24 +200,17 @@ class SSLClientTest(ModuleStoreTestCase):
...
@@ -200,24 +200,17 @@ class SSLClientTest(ModuleStoreTestCase):
This tests to make sure when immediate signup is on that
This tests to make sure when immediate signup is on that
the user doesn't get presented with the registration page.
the user doesn't get presented with the registration page.
"""
"""
# Expect an InvalidKeyError from course page as we don't have anything else built
response
=
self
.
client
.
get
(
with
self
.
assertRaisesRegexp
(
reverse
(
'signup'
),
follow
=
True
,
InvalidKeyError
,
SSL_CLIENT_S_DN
=
self
.
AUTH_DN
.
format
(
self
.
USER_NAME
,
self
.
USER_EMAIL
)
"<class 'opaque_keys.edx.keys.CourseKey'>: None"
)
):
self
.
assertEqual
(
response
.
status_code
,
404
)
self
.
client
.
get
(
reverse
(
'signup'
),
follow
=
True
,
SSL_CLIENT_S_DN
=
self
.
AUTH_DN
.
format
(
self
.
USER_NAME
,
self
.
USER_EMAIL
)
)
# assert that we are logged in
# assert that we are logged in
self
.
assertIn
(
SESSION_KEY
,
self
.
client
.
session
)
self
.
assertIn
(
SESSION_KEY
,
self
.
client
.
session
)
# Now that we are logged in, make sure we don't see the registration page
# Now that we are logged in, make sure we don't see the registration page
with
self
.
assertRaisesRegexp
(
response
=
self
.
client
.
get
(
reverse
(
'signup'
),
follow
=
True
)
InvalidKeyError
,
self
.
assertEqual
(
response
.
status_code
,
404
)
"<class 'opaque_keys.edx.keys.CourseKey'>: None"
):
self
.
client
.
get
(
reverse
(
'signup'
),
follow
=
True
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@override_settings
(
FEATURES
=
FEATURES_WITH_SSL_AUTH_IMMEDIATE_SIGNUP
)
@override_settings
(
FEATURES
=
FEATURES_WITH_SSL_AUTH_IMMEDIATE_SIGNUP
)
...
...
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