def initiate_verification(self, verification_details, username): verification_type = verification_details["type"] verification_id = uuid4().hex current_time = datetime.utcnow() logger.info(f"initiate verification for type: {verification_type}") if verification_type == VerificationType.INDIVIDUAL.value: entity_id = username verification = Verification(verification_id, verification_type, entity_id, VerificationStatus.APPROVED.value, username, current_time, current_time) verification_repository.add_verification(verification) elif verification_type == VerificationType.DUNS.value: entity_id = verification_details["entity_id"] logger.info( f"initiate verification for type: {verification_type} entity_id: {entity_id}" ) verification = Verification(verification_id, verification_type, entity_id, VerificationStatus.PENDING.value, username, current_time, current_time) self.initiate_duns_verification(verification) else: raise MethodNotImplemented() return {}
def initiate_verification(self, verification_details, username): verification_type = verification_details["type"] verification_id = uuid4().hex current_time = datetime.utcnow() logger.info(f"initiate verification for type: {verification_type}") if verification_type == VerificationType.JUMIO.value: entity_id = username logger.info( f"initiate verification for type: {verification_type} entity_id: {entity_id}" ) verification = Verification(verification_id, verification_type, entity_id, VerificationStatus.PENDING.value, username, current_time, current_time) if self.is_allowed_bypass_verification(entity_id): return self.initiate_snet_verification(verification) self.terminate_if_not_allowed_to_verify(entity_id, verification_type) return self.initiate_jumio_verification(username, verification) elif verification_type == VerificationType.DUNS.value: entity_id = verification_details["entity_id"] logger.info( f"initiate verification for type: {verification_type} entity_id: {entity_id}" ) verification = Verification(verification_id, verification_type, entity_id, VerificationStatus.PENDING.value, username, current_time, current_time) self.initiate_duns_verification(verification) return {} else: raise MethodNotImplemented()
def verification_entity_from_db(verification_db): return Verification(verification_db.id, verification_db.verification_type, verification_db.entity_id, verification_db.status, verification_db.requestee, verification_db.created_at, verification_db.updated_at, reject_reason=verification_db.reject_reason)
def test_submit(self, mock_boto_utils, mock_jumio_repo, mock_verification_repo): verification_id = uuid4().hex username = "******" user_reference_id = "6a7e9b7d8a9e61566a7bd24345cbebdbea08389f" created_at = datetime.utcnow() mock_verification = Verification(id=verification_id, type="JUMIO", entity_id=username, status=VerificationStatus.PENDING.value, requestee=username, created_at=created_at, updated_at=created_at) mock_verification_repo.get_verification = Mock(return_value=mock_verification) mock_verification_repo.update_status = Mock() mock_jumio_verification = JumioVerification( verification_id=verification_id, username=username, user_reference_id=user_reference_id, created_at=created_at, redirect_url="url", verification_status=JumioVerificationStatus.PENDING.value, transaction_status=JumioTransactionStatus.PENDING.value) mock_jumio_repo.update_transaction_status = Mock(return_value=mock_jumio_verification) response = VerificationManager().submit(verification_id, "SUCCESS") self.assertEqual(response, DAPP_POST_JUMIO_URL)
def test_callback(self, mock_boto_utils, mock_jumio_repo, mock_verification_repo): verification_id = uuid4().hex username = "******" user_reference_id = "6a7e9b7d8a9e61566a7bd24345cbebdbea08389f" created_at = datetime.utcnow() mock_verification = Verification(id=verification_id, type="JUMIO", entity_id=username, status=VerificationStatus.PENDING.value, requestee=username, created_at=created_at, updated_at=created_at) mock_verification_repo.get_verification = Mock(return_value=mock_verification) mock_verification_repo.update_status = Mock() mock_jumio_verification = JumioVerification( verification_id=verification_id, username=username, user_reference_id=user_reference_id, created_at=created_at, redirect_url="url", verification_status=JumioVerificationStatus.APPROVED_VERIFIED.value, transaction_status=JumioTransactionStatus.DONE.value) mock_jumio_repo.update_verification_and_transaction_status = Mock(return_value=mock_jumio_verification) payload = { "callbackDate": "2001-05-02T20:23:10.123Z", "verificationStatus": "APPROVED_VERIFIED" }