From ff8c58f5ee755e6e4f9d59b0a27b346e60835771 Mon Sep 17 00:00:00 2001 From: John Jarvis Date: Fri, 1 Nov 2013 11:49:12 -0400 Subject: [PATCH 1/2] adds a new option to ungenerated_certs to use http in the callback url --- .../management/commands/ungenerated_certs.py | 7 +++++++ lms/djangoapps/certificates/queue.py | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/certificates/management/commands/ungenerated_certs.py b/lms/djangoapps/certificates/management/commands/ungenerated_certs.py index 14895385d6..5fb9c53718 100644 --- a/lms/djangoapps/certificates/management/commands/ungenerated_certs.py +++ b/lms/djangoapps/certificates/management/commands/ungenerated_certs.py @@ -29,6 +29,11 @@ class Command(BaseCommand): dest='noop', default=False, help="Don't add certificate requests to the queue"), + make_option('--insecure', + action='store_true', + dest='insecure', + default=False, + help="Don't use https for the callback url to the LMS, useful in http test environments"), make_option('-c', '--course', metavar='COURSE_ID', dest='course', @@ -83,6 +88,8 @@ class Command(BaseCommand): "groups").order_by('username') xq = XQueueCertInterface() + if options['insecure']: + xq.use_https = False total = enrolled_students.count() count = 0 start = datetime.datetime.now(UTC) diff --git a/lms/djangoapps/certificates/queue.py b/lms/djangoapps/certificates/queue.py index 570067c294..5f63bbf1e2 100644 --- a/lms/djangoapps/certificates/queue.py +++ b/lms/djangoapps/certificates/queue.py @@ -74,6 +74,7 @@ class XQueueCertInterface(object): ) self.whitelist = CertificateWhitelist.objects.all() self.restricted = UserProfile.objects.filter(allow_certificate=False) + self.use_https = True def regen_cert(self, student, course_id, course=None): """(Re-)Make certificate for a particular student in a particular course @@ -216,9 +217,14 @@ class XQueueCertInterface(object): def _send_to_xqueue(self, contents, key): + if self.use_https: + proto = "https" + else: + proto = "http" + xheader = make_xheader( - 'https://{0}/update_certificate?{1}'.format( - settings.SITE_NAME, key), key, settings.CERT_QUEUE) + '{0}://{1}/update_certificate?{2}'.format( + proto, settings.SITE_NAME, key), key, settings.CERT_QUEUE) (error, msg) = self.xqueue_interface.send_to_queue( header=xheader, body=json.dumps(contents)) From f0b074b880f3814b8d1e5d84a07df87fb963d0c3 Mon Sep 17 00:00:00 2001 From: John Jarvis Date: Fri, 1 Nov 2013 12:05:59 -0400 Subject: [PATCH 2/2] also adding insecure option to regenerate_user command --- .../certificates/management/commands/regenerate_user.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lms/djangoapps/certificates/management/commands/regenerate_user.py b/lms/djangoapps/certificates/management/commands/regenerate_user.py index 55f0cc1850..c2b8898498 100644 --- a/lms/djangoapps/certificates/management/commands/regenerate_user.py +++ b/lms/djangoapps/certificates/management/commands/regenerate_user.py @@ -19,6 +19,11 @@ class Command(BaseCommand): dest='noop', default=False, help="Don't grade or add certificate requests to the queue"), + make_option('--insecure', + action='store_true', + dest='insecure', + default=False, + help="Don't use https for the callback url to the LMS, useful in http test environments"), make_option('-c', '--course', metavar='COURSE_ID', dest='course', @@ -52,6 +57,8 @@ class Command(BaseCommand): if not options['noop']: # Add the certificate request to the queue xq = XQueueCertInterface() + if options['insecure']: + xq.use_https = False ret = xq.regen_cert(student, course_id, course=course) print '{0} - {1}'.format(student, ret) else: