Exemple #1
0
    def test_callback(self, mock_boto):
        test_verification_id = "9f2c90119cb7424b8d69319ce211ddfc"
        verification_type = "DUNS"
        org_uuid = uuid4().hex
        username = "******"
        current_time = datetime.utcnow()
        verification_repository.add_item(
            VerificationModel(id=test_verification_id,
                              verification_type=verification_type,
                              entity_id=org_uuid,
                              status="PENDING",
                              requestee=username,
                              created_at=current_time,
                              updated_at=current_time))

        duns_repository.add_item(
            DUNSVerificationModel(verification_id=test_verification_id,
                                  org_uuid=org_uuid,
                                  comments=[],
                                  status=DUNSVerificationStatus.PENDING.value,
                                  created_at=current_time,
                                  updated_at=current_time))

        event = {
            "requestContext": {
                "authorizer": {
                    "claims": {
                        "email": username
                    }
                }
            },
            "pathParameters": {
                "verification_id": test_verification_id
            },
            "body":
            json.dumps({
                "verificationStatus": "APPROVED",
                "reviewed_by": "*****@*****.**",
                "comment": "looks good"
            })
        }
        callback(event, None)
        verification = verification_repository.session.query(VerificationModel) \
            .filter(VerificationModel.entity_id == org_uuid) \
            .order_by(VerificationModel.created_at.desc()).first()
        if verification is None:
            assert False
        self.assertEqual(VerificationStatus.APPROVED.value,
                         verification.status)
        duns_verification = duns_repository.session.query(DUNSVerificationModel) \
            .filter(DUNSVerificationModel.verification_id == test_verification_id).first()
        if duns_verification is None:
            assert False
        self.assertEqual(DUNSVerificationStatus.APPROVED.value,
                         duns_verification.status)
        self.assertEqual(org_uuid, duns_verification.org_uuid)
        self.assertEqual(1, len(duns_verification.comments))
Exemple #2
0
    def test_jumio_callback_failed_two(self, mock_boto_utils):
        test_verification_id = "9f2c90119cb7424b8d69319ce211ddfc"
        verification_type = "JUMIO"
        username = "******"
        current_time = datetime.utcnow()
        verification_repository.add_item(
            VerificationModel(id=test_verification_id,
                              verification_type=verification_type,
                              entity_id=username,
                              status="PENDING",
                              requestee=username,
                              created_at=current_time,
                              updated_at=current_time))
        jumio_repository.add_item(
            JumioVerificationModel(
                verification_id=test_verification_id,
                username=username,
                jumio_reference_id="123-13-13-134-1234",
                user_reference_id=sha1(username.encode("utf-8")).hexdigest(),
                redirect_url=
                "https://yourcompany.netverify.com/web/v4/app?locale=en-GB&authorizationToken=xxx",
                transaction_status=JumioTransactionStatus.SUCCESS.value,
                verification_status=JumioVerificationStatus.PENDING.value,
                transaction_date=current_time,
                created_at=current_time))
        event = {
            "body":
            urlencode({
                "callBackType":
                "NETVERIFYID",
                "callbackDate":
                "2020-03-06T12:10:50.835Z",
                "clientIp":
                "157.51.114.166",
                "customerId":
                "14bb645983cafeb2bb14bf4df2dff297182aef9f",
                "firstAttemptDate":
                "2020-03-06T12:10:31.339Z",
                "idCheckDataPositions":
                "N/A",
                "idCheckDocumentValidation":
                "N/A",
                "idCheckHologram":
                "N/A",
                "idCheckMRZcode":
                "N/A",
                "idCheckMicroprint":
                "N/A",
                "idCheckSecurityFeatures":
                "N/A",
                "idCheckSignature":
                "N/A",
                "idCountry":
                "IND",
                "idScanImage":
                "https://lon.netverify.com/recognition/v1/idscan/cf657461-bf54-46dd-93e4-2496d6f115b1/front",
                "idScanImageBackside":
                "https://lon.netverify.com/recognition/v1/idscan/cf657461-bf54-46dd-93e4-2496d6f115b1/back",
                "idScanImageFace":
                "https://lon.netverify.com/recognition/v1/idscan/cf657461-bf54-46dd-93e4-2496d6f115b1/face",
                "idScanSource":
                "WEB_UPLOAD",
                "idScanStatus":
                "ERROR",
                "idType":
                "ID_CARD",
                "jumioIdScanReference":
                "cf657461-bf54-46dd-93e4-2496d6f115b1",
                "merchantIdScanReference":
                "52c90d23cf6847edbac663bb770a0f58",
                "rejectReason": {
                    "rejectReasonCode": "201",
                    "rejectReasonDescription": "NO_DOCUMENT",
                    "rejectReasonDetails": []
                },
                "transactionDate":
                "2020-03-06T12:02:56.028Z",
                "verificationStatus":
                JumioVerificationStatus.NO_ID_UPLOADED.value
            }),
            "pathParameters": {
                "verification_id": test_verification_id
            }
        }
        callback(event, None)
        verification = verification_repository.session.query(
            VerificationModel).first()
        if verification is None:
            assert False
        self.assertEqual(verification.entity_id, username)
        self.assertEqual(verification.status, VerificationStatus.FAILED.value)
        self.assertEqual(verification.requestee, username)
        self.assertEqual(verification.verification_type, "JUMIO")
        assert (verification.id is not None or verification.id != ""
                ) and verification.id == test_verification_id

        jumio_verfication = jumio_repository.session.query(
            JumioVerificationModel).first()
        if jumio_verfication is None:
            assert False
        self.assertEqual(jumio_verfication.jumio_reference_id,
                         '123-13-13-134-1234')
        self.assertEqual(jumio_verfication.redirect_url,
                         test_initiate_redirect_url)
        self.assertEqual(jumio_verfication.transaction_status,
                         JumioTransactionStatus.FAILED.value)
        self.assertEqual(jumio_verfication.verification_status,
                         JumioVerificationStatus.NO_ID_UPLOADED.value)
        self.assertEqual(jumio_verfication.username, username)
        self.assertEqual(jumio_verfication.user_reference_id,
                         sha1(username.encode("utf-8")).hexdigest())