From 40fcf6d119135d08a6d3ecfc40c5d73846bf2205 Mon Sep 17 00:00:00 2001 From: Dawn Pattison Date: Fri, 19 Aug 2022 08:41:25 -0500 Subject: [PATCH] Instead of using a new VerificationCode schema, use the SubjectIdentityVerificationBodyParams that already exists. --- .../ops/api/v1/endpoints/privacy_request_endpoints.py | 6 +++--- src/fidesops/ops/schemas/privacy_request.py | 6 ------ .../api/v1/endpoints/test_privacy_request_endpoints.py | 10 +++++----- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/fidesops/ops/api/v1/endpoints/privacy_request_endpoints.py b/src/fidesops/ops/api/v1/endpoints/privacy_request_endpoints.py index ce907fd76..4836a2503 100644 --- a/src/fidesops/ops/api/v1/endpoints/privacy_request_endpoints.py +++ b/src/fidesops/ops/api/v1/endpoints/privacy_request_endpoints.py @@ -70,6 +70,7 @@ CollectionAddressResponse, DryRunDatasetResponse, ) +from fidesops.ops.schemas.email.email import SubjectIdentityVerificationBodyParams from fidesops.ops.schemas.external_https import PrivacyRequestResumeFormat from fidesops.ops.schemas.privacy_request import ( BulkPostPrivacyRequests, @@ -82,7 +83,6 @@ ReviewPrivacyRequestIds, RowCountRequest, StoppedCollection, - VerificationCode, ) from fidesops.ops.service.privacy_request.request_runner_service import ( queue_privacy_request, @@ -971,7 +971,7 @@ def verify_identification_code( privacy_request_id: str, *, db: Session = Depends(deps.get_db), - provided_code: VerificationCode, + provided_code: SubjectIdentityVerificationBodyParams, ) -> PrivacyRequestResponse: """Verify the supplied identity verification code @@ -983,7 +983,7 @@ def verify_identification_code( db, privacy_request_id ) try: - privacy_request.verify_identity(db, provided_code.code) + privacy_request.verify_identity(db, provided_code.access_code) except IdentityVerificationException as exc: raise HTTPException(status_code=HTTP_400_BAD_REQUEST, detail=exc.message) except PermissionError as exc: diff --git a/src/fidesops/ops/schemas/privacy_request.py b/src/fidesops/ops/schemas/privacy_request.py index 44b6a9d74..56fabfffc 100644 --- a/src/fidesops/ops/schemas/privacy_request.py +++ b/src/fidesops/ops/schemas/privacy_request.py @@ -138,12 +138,6 @@ class StoppedCollectionDetails(StoppedCollection): collection: Optional[str] = None # type: ignore -class VerificationCode(BaseSchema): - """Request Body for the user to supply their identity verification code""" - - code: str - - class PrivacyRequestResponse(BaseSchema): """Schema to check the status of a PrivacyRequest""" diff --git a/tests/ops/api/v1/endpoints/test_privacy_request_endpoints.py b/tests/ops/api/v1/endpoints/test_privacy_request_endpoints.py index f86e908ff..4fc5e3ccf 100644 --- a/tests/ops/api/v1/endpoints/test_privacy_request_endpoints.py +++ b/tests/ops/api/v1/endpoints/test_privacy_request_endpoints.py @@ -2423,7 +2423,7 @@ def url(self, db, privacy_request): ) def test_incorrect_privacy_request_status(self, api_client, url, privacy_request): - request_body = {"code": self.code} + request_body = {"access_code": self.code} resp = api_client.post(url, headers={}, json=request_body) assert resp.status_code == 400 assert ( @@ -2435,7 +2435,7 @@ def test_verification_code_expired(self, db, api_client, url, privacy_request): privacy_request.status = PrivacyRequestStatus.identity_unverified privacy_request.save(db) - request_body = {"code": self.code} + request_body = {"access_code": self.code} resp = api_client.post(url, headers={}, json=request_body) assert resp.status_code == 400 assert ( @@ -2448,7 +2448,7 @@ def test_invalid_code(self, db, api_client, url, privacy_request): privacy_request.save(db) privacy_request.cache_identity_verification_code("999999") - request_body = {"code": self.code} + request_body = {"access_code": self.code} resp = api_client.post(url, headers={}, json=request_body) assert resp.status_code == 403 assert ( @@ -2466,7 +2466,7 @@ def test_verify_identity_no_admin_approval_needed( privacy_request.save(db) privacy_request.cache_identity_verification_code(self.code) - request_body = {"code": self.code} + request_body = {"access_code": self.code} resp = api_client.post(url, headers={}, json=request_body) assert resp.status_code == 200 @@ -2506,7 +2506,7 @@ def test_verify_identity_admin_approval_needed( privacy_request.save(db) privacy_request.cache_identity_verification_code(self.code) - request_body = {"code": self.code} + request_body = {"access_code": self.code} resp = api_client.post(url, headers={}, json=request_body) assert resp.status_code == 200