Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing pearson communication code #4765

Merged
merged 9 commits into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,30 +84,6 @@
"ELASTICSEARCH_URL": {
"description": "URL for connecting to Elasticsearch cluster"
},
"EXAMS_AUDIT_NACL_PUBLIC_KEY": {
"description": "NaCl public key for encrypting audit files",
"required": false
},
"EXAMS_SFTP_HOST": {
"description": "Hostname for Pearson SFTP server",
"required": false
},
"EXAMS_SFTP_PORT": {
"description": "Port for Pearson SFTP server",
"required": false
},
"EXAMS_SFTP_USERNAME": {
"description": "Username for Pearson SFTP server authentication",
"required": false
},
"EXAMS_SFTP_PASSWORD": {
"description": "Password for Pearson SFTP server authentication",
"required": false
},
"EXAMS_SFTP_UPLOAD_DIR": {
"description": "Upload directory for files we send to Pearson",
"required": false
},
"FEATURE_OPEN_DISCUSSIONS_USER_SYNC": {
"description": "Enables creation and syncing of open-discussions user data",
"required": false
Expand Down
31 changes: 0 additions & 31 deletions exams/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
API for exams app
"""
import logging
import hashlib

from django.conf import settings
from django.core.exceptions import ImproperlyConfigured

from dashboard.utils import get_mmtrack
from dashboard.api import has_to_pay_for_exam
Expand Down Expand Up @@ -35,33 +31,6 @@
log = logging.getLogger(__name__)


def sso_digest(client_candidate_id, timestamp, session_timeout):
"""
Compute the sso_digest value we need to send to pearson

Args:
client_candidate_id (int|str): id for the user, usually Profile.student_id
timestamp (int): unix timestamp
session_timeout (int): number of seconds the session will last

Returns:
str: the computed digest value
"""
if settings.EXAMS_SSO_PASSPHRASE is None:
raise ImproperlyConfigured("EXAMS_SSO_PASSPHRASE is not configured")
if settings.EXAMS_SSO_CLIENT_CODE is None:
raise ImproperlyConfigured("EXAMS_SSO_CLIENT_CODE is not configured")

data = ''.join([
settings.EXAMS_SSO_PASSPHRASE,
settings.EXAMS_SSO_CLIENT_CODE,
str(timestamp),
str(session_timeout),
str(client_candidate_id),
]).encode('iso-8859-1')
return hashlib.sha256(data).hexdigest()


def authorize_for_exam_run(user, course_run, exam_run):
"""
Authorize user for exam if he has paid for course and passed course.
Expand Down
34 changes: 0 additions & 34 deletions exams/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
from unittest.mock import patch

import ddt
from django.core.exceptions import ImproperlyConfigured
from django.db.models.signals import post_save
from django.test import (
SimpleTestCase,
TestCase,
override_settings,
)
from factory.django import mute_signals

Expand All @@ -23,7 +20,6 @@
from exams.api import (
authorize_for_exam_run,
authorize_for_latest_passed_course,
sso_digest,
MESSAGE_NOT_ELIGIBLE_TEMPLATE,
MESSAGE_NOT_PASSED_OR_EXIST_TEMPLATE,
)
Expand Down Expand Up @@ -53,36 +49,6 @@ def create_order(user, course_run):
).order


class SSODigestTests(SimpleTestCase):
"""
Tests for the sso_digest helper function
"""

@override_settings(
EXAMS_SSO_PASSPHRASE="C is for cookie",
EXAMS_SSO_CLIENT_CODE="and that's good enough for me",
)
def test_that_sso_digest_computes_correctly(self):
"""Verifies sso_digest computes correctly"""

# computed "by hand"
assert sso_digest(123, 1486069731, 1800) == (
'a64ea7218e4a67d863e03ec43ac40240af39f5924af46e02b2199e3f7974b8d3'
)

@override_settings(EXAMS_SSO_PASSPHRASE=None)
def test_that_no_passphrase_raises(self):
"""Verifies that if we don't set the passphrase we raise an exception"""
with self.assertRaises(ImproperlyConfigured):
sso_digest(123, 1486069731, 1800)

@override_settings(EXAMS_SSO_CLIENT_CODE=None)
def test_that_no_client_code_raises(self):
"""Verifies that if we don't set the passphrase we raise an exception"""
with self.assertRaises(ImproperlyConfigured):
sso_digest(123, 1486069731, 1800)


@ddt.ddt
class ExamAuthorizationApiTests(TestCase):
"""Tests for exam api"""
Expand Down
15 changes: 0 additions & 15 deletions exams/conftest.py

This file was deleted.

9 changes: 9 additions & 0 deletions exams/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Pearson-related constants"""

# EXAM constants
EXAM_GRADE_PASS = 'pass'
EXAM_GRADE_FAIL = 'fail'
EXAM_GRADES = (
EXAM_GRADE_PASS,
EXAM_GRADE_FAIL,
)
2 changes: 1 addition & 1 deletion exams/management/commands/import_edx_exam_grades.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from courses.models import Course
from exams.models import ExamRun, ExamAuthorization
from exams.pearson.constants import EXAM_GRADE_PASS
from exams.constants import EXAM_GRADE_PASS
from grades.models import ProctoredExamGrade
from micromasters.utils import now_in_utc

Expand Down
174 changes: 0 additions & 174 deletions exams/management/commands/simulate_sftp_responses.py

This file was deleted.

Loading