Commit c4bed2c1 by Calen Pennington

Add basic authentication support for requests made to the xqueue server

parent 43745dac
...@@ -94,8 +94,9 @@ JASMINE_TEST_DIRECTORY = PROJECT_ROOT + '/static/coffee' ...@@ -94,8 +94,9 @@ JASMINE_TEST_DIRECTORY = PROJECT_ROOT + '/static/coffee'
#################### CAPA External Code Evaluation ############################# #################### CAPA External Code Evaluation #############################
XQUEUE_INTERFACE = { XQUEUE_INTERFACE = {
'url': 'http://localhost:8888', 'url': 'http://localhost:8888',
'auth': {'username': 'local', 'django_auth': {'username': 'local',
'password': 'local'} 'password': 'local'},
'basic_auth': None,
} }
......
...@@ -60,10 +60,10 @@ class XQueueInterface: ...@@ -60,10 +60,10 @@ class XQueueInterface:
Interface to the external grading system Interface to the external grading system
''' '''
def __init__(self, url, auth): def __init__(self, url, django_auth, basic_auth=None):
self.url = url self.url = url
self.auth = auth self.auth = django_auth
self.session = requests.session() self.session = requests.session(auth=basic_auth)
def send_to_queue(self, header, body, file_to_upload=None): def send_to_queue(self, header, body, file_to_upload=None):
''' '''
......
...@@ -25,7 +25,8 @@ log = logging.getLogger("mitx.courseware") ...@@ -25,7 +25,8 @@ log = logging.getLogger("mitx.courseware")
xqueue_interface = XQueueInterface( xqueue_interface = XQueueInterface(
settings.XQUEUE_INTERFACE['url'], settings.XQUEUE_INTERFACE['url'],
settings.XQUEUE_INTERFACE['auth'] settings.XQUEUE_INTERFACE['django_auth'],
settings.XQUEUE_INTERFACE['basic_auth'],
) )
......
...@@ -55,10 +55,11 @@ CACHES = { ...@@ -55,10 +55,11 @@ CACHES = {
XQUEUE_INTERFACE = { XQUEUE_INTERFACE = {
"url": "http://xqueue.sandbox.edx.org", "url": "http://xqueue.sandbox.edx.org",
"auth": { "django_auth": {
"username": "lms", "username": "lms",
"password": "***REMOVED***" "password": "***REMOVED***"
} },
"basic_auth": ('anant', 'agarwal'),
} }
# Make the keyedcache startup warnings go away # Make the keyedcache startup warnings go away
......
...@@ -52,10 +52,11 @@ GITHUB_REPO_ROOT = ENV_ROOT / "data" ...@@ -52,10 +52,11 @@ GITHUB_REPO_ROOT = ENV_ROOT / "data"
XQUEUE_INTERFACE = { XQUEUE_INTERFACE = {
"url": "http://xqueue.sandbox.edx.org", "url": "http://xqueue.sandbox.edx.org",
"auth": { "django_auth": {
"username": "lms", "username": "lms",
"password": "***REMOVED***" "password": "***REMOVED***"
} },
"basic_auth": ('anant', 'agarwal'),
} }
......
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