示例#1
0
    def test_underage_user_validation_has_email_validated(self, age):
        user = users_factories.UserFactory(isEmailValidated=False)
        fraud_check = fraud_factories.BeneficiaryFraudCheckFactory(
            type=fraud_models.FraudCheckType.EDUCONNECT,
            user=user,
            resultContent=fraud_factories.EduconnectContentFactory(age=age),
        )
        fraud_result = fraud_api.on_identity_fraud_check_result(
            user, fraud_check)

        assert "L'email de l'utilisateur n'est pas validé" in fraud_result.reason
        assert fraud_result.status == fraud_models.FraudStatus.KO
示例#2
0
    def test_ine_whitelisted_fraud_checks_fail(self):
        fraud_factories.IneHashWhitelistFactory(
            ine_hash="identifiantWhitelisté1")
        fraud_check = fraud_factories.BeneficiaryFraudCheckFactory(
            type=fraud_models.FraudCheckType.EDUCONNECT,
            resultContent=fraud_factories.EduconnectContentFactory(
                ine_hash="identifiantWhitelisté2"),
        )
        result = fraud_api.educonnect_fraud_checks(fraud_check)

        duplicate_ine_check = next(
            fraud_check for fraud_check in result if fraud_check.reason_code ==
            fraud_models.FraudReasonCode.INE_NOT_WHITELISTED)
        assert duplicate_ine_check.status == fraud_models.FraudStatus.SUSPICIOUS
示例#3
0
    def test_age_fraud_check_ok(self, age):
        fraud_check = fraud_factories.BeneficiaryFraudCheckFactory(
            type=fraud_models.FraudCheckType.EDUCONNECT,
            resultContent=fraud_factories.EduconnectContentFactory(age=age),
        )
        result = fraud_api.educonnect_fraud_checks(
            beneficiary_fraud_check=fraud_check)

        age_check = next(
            (fraud_check for fraud_check in result if fraud_check.reason_code
             == fraud_models.FraudReasonCode.AGE_NOT_VALID),
            None,
        )
        assert not age_check
示例#4
0
    def test_underage_user_validation_is_beneficiary(self, age):
        user = users_factories.UnderageBeneficiaryFactory()
        fraud_check = fraud_factories.BeneficiaryFraudCheckFactory(
            type=fraud_models.FraudCheckType.EDUCONNECT,
            user=user,
            resultContent=fraud_factories.EduconnectContentFactory(age=age),
        )
        fraud_result = fraud_api.on_identity_fraud_check_result(
            user, fraud_check)

        assert (
            "L’utilisateur est déjà bénéfiaire, avec un portefeuille non expiré. Il ne peut pas prétendre au pass culture 15-17 ans"
            in fraud_result.reason)
        assert fraud_result.status == fraud_models.FraudStatus.KO
示例#5
0
    def test_age_fraud_check_ko(self, age):
        fraud_check = fraud_factories.BeneficiaryFraudCheckFactory(
            type=fraud_models.FraudCheckType.EDUCONNECT,
            resultContent=fraud_factories.EduconnectContentFactory(age=age),
        )
        result = fraud_api.educonnect_fraud_checks(
            beneficiary_fraud_check=fraud_check)

        age_check = next(fraud_check for fraud_check in result
                         if fraud_check.reason_code ==
                         fraud_models.FraudReasonCode.AGE_NOT_VALID)
        assert age_check.status == fraud_models.FraudStatus.KO
        assert (
            age_check.detail ==
            f"L'age de l'utilisateur est invalide ({age} ans). Il devrait être parmi [15, 16, 17]"
        )
示例#6
0
    def test_duplicates_fraud_checks(self):
        already_existing_user = users_factories.UnderageBeneficiaryFactory(
            subscription_age=15)
        fraud_check = fraud_factories.BeneficiaryFraudCheckFactory(
            type=fraud_models.FraudCheckType.EDUCONNECT,
            resultContent=fraud_factories.EduconnectContentFactory(
                first_name=already_existing_user.firstName,
                last_name=already_existing_user.lastName,
                birth_date=already_existing_user.dateOfBirth,
            ),
        )
        result = fraud_api.educonnect_fraud_checks(fraud_check)

        duplicate_check = next(fraud_check for fraud_check in result
                               if fraud_check.reason_code ==
                               fraud_models.FraudReasonCode.DUPLICATE_USER)

        assert duplicate_check.status == fraud_models.FraudStatus.SUSPICIOUS
        assert duplicate_check.detail == f"Duplicat de l'utilisateur {already_existing_user.id}"
示例#7
0
    def test_ine_duplicates_fraud_checks(self):
        fraud_factories.IneHashWhitelistFactory(
            ine_hash="ylwavk71o3jiwyla83fxk5pcmmu0ws01")
        same_ine_user = users_factories.UnderageBeneficiaryFactory(
            ineHash="ylwavk71o3jiwyla83fxk5pcmmu0ws01")
        fraud_check = fraud_factories.BeneficiaryFraudCheckFactory(
            type=fraud_models.FraudCheckType.EDUCONNECT,
            resultContent=fraud_factories.EduconnectContentFactory(
                ine_hash=same_ine_user.ineHash),
        )
        result = fraud_api.educonnect_fraud_checks(fraud_check)

        duplicate_ine_check = next(fraud_check for fraud_check in result
                                   if fraud_check.reason_code ==
                                   fraud_models.FraudReasonCode.DUPLICATE_INE)
        assert duplicate_ine_check.status == fraud_models.FraudStatus.SUSPICIOUS
        assert (
            duplicate_ine_check.detail ==
            f"L'INE ylwavk71o3jiwyla83fxk5pcmmu0ws01 est déjà pris par l'utilisateur {same_ine_user.id}"
        )