Commit 871ad7d6 by David Baumgold

Pass hostname to LTI XModule

Necessary for RFC compliance with oauthlib
parent a1d3899a
...@@ -36,6 +36,7 @@ def test_system(): ...@@ -36,6 +36,7 @@ def test_system():
user=Mock(), user=Mock(),
filestore=fs.osfs.OSFS(os.path.join(TEST_DIR, "test_files")), filestore=fs.osfs.OSFS(os.path.join(TEST_DIR, "test_files")),
debug=True, debug=True,
hostname="edx.org",
xqueue={'interface': xqueue_interface, 'construct_callback': calledback_url, 'default_queuename': 'testqueue', 'waittime': 10}, xqueue={'interface': xqueue_interface, 'construct_callback': calledback_url, 'default_queuename': 'testqueue', 'waittime': 10},
node_path=os.environ.get("NODE_PATH", "/usr/local/lib/node_modules"), node_path=os.environ.get("NODE_PATH", "/usr/local/lib/node_modules"),
anonymous_student_id='student', anonymous_student_id='student',
......
...@@ -6,7 +6,7 @@ http://www.imsglobal.org/LTI/v1p1p1/ltiIMGv1p1p1.html ...@@ -6,7 +6,7 @@ http://www.imsglobal.org/LTI/v1p1p1/ltiIMGv1p1p1.html
""" """
import logging import logging
import oauthlib import oauthlib.oauth1
import urllib import urllib
from xmodule.editing_module import MetadataOnlyEditingDescriptor from xmodule.editing_module import MetadataOnlyEditingDescriptor
...@@ -212,8 +212,11 @@ class LTIModule(LTIFields, XModule): ...@@ -212,8 +212,11 @@ class LTIModule(LTIFields, XModule):
# appending custom parameter for signing # appending custom parameter for signing
body.update(custom_parameters) body.update(custom_parameters)
# This is needed for body encoding: headers = {
headers = {'Content-Type': 'application/x-www-form-urlencoded'} 'Host': self.system.HOSTNAME,
# This is needed for body encoding:
'Content-Type': 'application/x-www-form-urlencoded',
}
__, headers, __ = client.sign( __, headers, __ = client.sign(
unicode(self.launch_url), unicode(self.launch_url),
......
...@@ -62,6 +62,7 @@ def get_test_system(course_id=''): ...@@ -62,6 +62,7 @@ def get_test_system(course_id=''):
user=Mock(is_staff=False), user=Mock(is_staff=False),
filestore=Mock(), filestore=Mock(),
debug=True, debug=True,
hostname="edx.org",
xqueue={'interface': None, 'callback_url': '/', 'default_queuename': 'testqueue', 'waittime': 10, 'construct_callback' : Mock(side_effect="/")}, xqueue={'interface': None, 'callback_url': '/', 'default_queuename': 'testqueue', 'waittime': 10, 'construct_callback' : Mock(side_effect="/")},
node_path=os.environ.get("NODE_PATH", "/usr/local/lib/node_modules"), node_path=os.environ.get("NODE_PATH", "/usr/local/lib/node_modules"),
xblock_field_data=lambda descriptor: descriptor._field_data, xblock_field_data=lambda descriptor: descriptor._field_data,
......
...@@ -833,7 +833,7 @@ class ModuleSystem(Runtime): ...@@ -833,7 +833,7 @@ class ModuleSystem(Runtime):
def __init__( def __init__(
self, ajax_url, track_function, get_module, render_template, self, ajax_url, track_function, get_module, render_template,
replace_urls, xblock_field_data, user=None, filestore=None, replace_urls, xblock_field_data, user=None, filestore=None,
debug=False, xqueue=None, publish=None, node_path="", debug=False, hostname="", xqueue=None, publish=None, node_path="",
anonymous_student_id='', course_id=None, anonymous_student_id='', course_id=None,
open_ended_grading_interface=None, s3_interface=None, open_ended_grading_interface=None, s3_interface=None,
cache=None, can_execute_unsafe_code=None, replace_course_urls=None, cache=None, can_execute_unsafe_code=None, replace_course_urls=None,
...@@ -897,6 +897,7 @@ class ModuleSystem(Runtime): ...@@ -897,6 +897,7 @@ class ModuleSystem(Runtime):
self.get_module = get_module self.get_module = get_module
self.render_template = render_template self.render_template = render_template
self.DEBUG = self.debug = debug self.DEBUG = self.debug = debug
self.HOSTNAME = self.hostname = hostname
self.seed = user.id if user is not None else 0 self.seed = user.id if user is not None else 0
self.replace_urls = replace_urls self.replace_urls = replace_urls
self.node_path = node_path self.node_path = node_path
......
...@@ -347,6 +347,8 @@ def get_module_for_descriptor_internal(user, descriptor, field_data_cache, cours ...@@ -347,6 +347,8 @@ def get_module_for_descriptor_internal(user, descriptor, field_data_cache, cours
filestore=descriptor.system.resources_fs, filestore=descriptor.system.resources_fs,
get_module=inner_get_module, get_module=inner_get_module,
user=user, user=user,
debug=settings.DEBUG,
hostname=settings.SITE_NAME,
# TODO (cpennington): This should be removed when all html from # TODO (cpennington): This should be removed when all html from
# a module is coming through get_html and is therefore covered # a module is coming through get_html and is therefore covered
# by the replace_static_urls code below # by the replace_static_urls code below
...@@ -380,7 +382,6 @@ def get_module_for_descriptor_internal(user, descriptor, field_data_cache, cours ...@@ -380,7 +382,6 @@ def get_module_for_descriptor_internal(user, descriptor, field_data_cache, cours
# pass position specified in URL to module through ModuleSystem # pass position specified in URL to module through ModuleSystem
system.set('position', position) system.set('position', position)
system.set('DEBUG', settings.DEBUG)
if settings.MITX_FEATURES.get('ENABLE_PSYCHOMETRICS'): if settings.MITX_FEATURES.get('ENABLE_PSYCHOMETRICS'):
system.set( system.set(
'psychometrics_handler', # set callback for updating PsychometricsData 'psychometrics_handler', # set callback for updating PsychometricsData
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment