feat: pluggable url for idv location (#35494)
* Adds an extension point when generating the url for id verification
This commit is contained in:
@@ -11,6 +11,7 @@ from django.conf import settings
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import gettext as _
|
||||
from openedx_filters.learning.filters import IDVPageURLRequested
|
||||
|
||||
from common.djangoapps.course_modes.models import CourseMode
|
||||
from common.djangoapps.student.models import User
|
||||
@@ -244,7 +245,10 @@ class IDVerificationService:
|
||||
location = f'{settings.ACCOUNT_MICROFRONTEND_URL}/id-verification'
|
||||
if course_id:
|
||||
location += f'?course_id={quote(str(course_id))}'
|
||||
return location
|
||||
|
||||
# .. filter_implemented_name: IDVPageURLRequested
|
||||
# .. filter_type: org.openedx.learning.idv.page.url.requested.v1
|
||||
return IDVPageURLRequested.run_filter(location)
|
||||
|
||||
@classmethod
|
||||
def get_verification_details_by_id(cls, attempt_id):
|
||||
|
||||
@@ -9,10 +9,11 @@ from unittest.mock import patch
|
||||
|
||||
import ddt
|
||||
from django.conf import settings
|
||||
from django.test import TestCase
|
||||
from django.test import TestCase, override_settings
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import gettext as _
|
||||
from freezegun import freeze_time
|
||||
from openedx_filters import PipelineStep
|
||||
from pytz import utc
|
||||
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
@@ -33,6 +34,16 @@ FAKE_SETTINGS = {
|
||||
}
|
||||
|
||||
|
||||
class TestIdvPageUrlRequestedPipelineStep(PipelineStep):
|
||||
""" Utility function to test a configured pipeline step """
|
||||
TEST_URL = 'example.com/verify'
|
||||
|
||||
def run_filter(self, url): # pylint: disable=arguments-differ
|
||||
return {
|
||||
"url": self.TEST_URL
|
||||
}
|
||||
|
||||
|
||||
@patch.dict(settings.VERIFY_STUDENT, FAKE_SETTINGS)
|
||||
@ddt.ddt
|
||||
class TestIDVerificationService(ModuleStoreTestCase):
|
||||
@@ -167,6 +178,26 @@ class TestIDVerificationService(ModuleStoreTestCase):
|
||||
expected_path = f'{settings.ACCOUNT_MICROFRONTEND_URL}/id-verification'
|
||||
assert path == (expected_path + '?course_id=course-v1%3AedX%2BDemoX%2BDemo_Course')
|
||||
|
||||
@override_settings(
|
||||
OPEN_EDX_FILTERS_CONFIG={
|
||||
"org.openedx.learning.idv.page.url.requested.v1": {
|
||||
"pipeline": [
|
||||
"lms.djangoapps.verify_student.tests.test_services.TestIdvPageUrlRequestedPipelineStep",
|
||||
],
|
||||
"fail_silently": False,
|
||||
},
|
||||
},
|
||||
)
|
||||
def test_get_verify_location_with_filter_step(self):
|
||||
"""
|
||||
Test IDV flow location can be customized with an openedx filter
|
||||
"""
|
||||
url = IDVerificationService.get_verify_location()
|
||||
assert url == TestIdvPageUrlRequestedPipelineStep.TEST_URL
|
||||
|
||||
url = IDVerificationService.get_verify_location('course-v1:edX+DemoX+Demo_Course')
|
||||
assert url == TestIdvPageUrlRequestedPipelineStep.TEST_URL
|
||||
|
||||
def test_get_expiration_datetime(self):
|
||||
"""
|
||||
Test that the latest expiration datetime is returned if there are multiple records
|
||||
|
||||
@@ -819,7 +819,7 @@ openedx-events==9.14.0
|
||||
# edx-event-bus-redis
|
||||
# event-tracking
|
||||
# ora2
|
||||
openedx-filters==1.9.0
|
||||
openedx-filters==1.10.0
|
||||
# via
|
||||
# -r requirements/edx/kernel.in
|
||||
# lti-consumer-xblock
|
||||
|
||||
@@ -1367,7 +1367,7 @@ openedx-events==9.14.0
|
||||
# edx-event-bus-redis
|
||||
# event-tracking
|
||||
# ora2
|
||||
openedx-filters==1.9.0
|
||||
openedx-filters==1.10.0
|
||||
# via
|
||||
# -r requirements/edx/doc.txt
|
||||
# -r requirements/edx/testing.txt
|
||||
|
||||
@@ -978,7 +978,7 @@ openedx-events==9.14.0
|
||||
# edx-event-bus-redis
|
||||
# event-tracking
|
||||
# ora2
|
||||
openedx-filters==1.9.0
|
||||
openedx-filters==1.10.0
|
||||
# via
|
||||
# -r requirements/edx/base.txt
|
||||
# lti-consumer-xblock
|
||||
|
||||
@@ -1029,7 +1029,7 @@ openedx-events==9.14.0
|
||||
# edx-event-bus-redis
|
||||
# event-tracking
|
||||
# ora2
|
||||
openedx-filters==1.9.0
|
||||
openedx-filters==1.10.0
|
||||
# via
|
||||
# -r requirements/edx/base.txt
|
||||
# lti-consumer-xblock
|
||||
|
||||
Reference in New Issue
Block a user