Merge pull request #13055 from edx/shr/bug/plat-1048-mongo-courses-restriction-split-key
Mongo courses wrong course_key restriction
This commit is contained in:
@@ -1088,6 +1088,11 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo
|
||||
Get the course with the given courseid (org/course/run)
|
||||
"""
|
||||
assert isinstance(course_key, CourseKey)
|
||||
|
||||
if not course_key.deprecated: # split course_key
|
||||
# The supplied CourseKey is of the wrong type, so it can't possibly be stored in this modulestore.
|
||||
raise ItemNotFoundError(course_key)
|
||||
|
||||
course_key = self.fill_in_run(course_key)
|
||||
location = course_key.make_usage_key('course', course_key.run)
|
||||
try:
|
||||
|
||||
@@ -24,6 +24,7 @@ from xblock.runtime import KeyValueStore
|
||||
from xblock.exceptions import InvalidScopeError
|
||||
|
||||
from xmodule.tests import DATA_DIR
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from opaque_keys.edx.locations import Location
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.mongo import MongoKeyValueStore
|
||||
@@ -290,6 +291,15 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
|
||||
assert_false(self.draft_store.has_course(mix_cased))
|
||||
assert_false(self.draft_store.has_course(mix_cased, ignore_case=True))
|
||||
|
||||
def test_get_mongo_course_with_split_course_key(self):
|
||||
"""
|
||||
Test mongo course using split course_key will not able to access it.
|
||||
"""
|
||||
course_key = CourseKey.from_string('course-v1:edX+simple+2012_Fall')
|
||||
|
||||
with self.assertRaises(ItemNotFoundError):
|
||||
self.draft_store.get_course(course_key)
|
||||
|
||||
def test_has_course_with_library(self):
|
||||
"""
|
||||
Test that has_course() returns False when called with a LibraryLocator.
|
||||
|
||||
Reference in New Issue
Block a user