From 01a431dd0bd579a14e26ebad388a382f37b78e59 Mon Sep 17 00:00:00 2001 From: Dan Nguyen <186835528+dnguyen1-pass@users.noreply.github.com> Date: Mon, 20 Jan 2025 18:38:18 +0100 Subject: [PATCH] (PC-34065)[API] fix: mark declined ubble checks as ko Our Ubble v1 flow marked declined checks as suspicious instead of ko. This used to work because we always create a new identity verification at every Ubble v1 attempt. However, we reuse existing Ubble v2 identity verifications if they are marked as suspicious. If the id verification is declined, Ubble v2 returns a 409 error. Therefore, we should not reuse declined Ubble v2 checks by marking them as KO instead of suspicious. --- api/src/pcapi/core/fraud/ubble/api.py | 8 ++++---- api/tests/core/subscription/ubble/test_api.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/src/pcapi/core/fraud/ubble/api.py b/api/src/pcapi/core/fraud/ubble/api.py index 04bf4cf8de2..5206e6d9230 100644 --- a/api/src/pcapi/core/fraud/ubble/api.py +++ b/api/src/pcapi/core/fraud/ubble/api.py @@ -40,11 +40,11 @@ def _ubble_result_fraud_item_using_status( if id_provider_detected_eligibility: return fraud_models.FraudItem(status=fraud_models.FraudStatus.OK, detail=detail, reason_codes=[]) return _ubble_not_eligible_fraud_item(user, content) - case ( - ubble_serializers.UbbleIdentificationStatus.RETRY_REQUIRED - | ubble_serializers.UbbleIdentificationStatus.DECLINED - ): + case ubble_serializers.UbbleIdentificationStatus.RETRY_REQUIRED: status = fraud_models.FraudStatus.SUSPICIOUS + case ubble_serializers.UbbleIdentificationStatus.DECLINED: + status = fraud_models.FraudStatus.KO + case _: raise ValueError(f"unhandled Ubble status {content.status} for identification {content.identification_id}") diff --git a/api/tests/core/subscription/ubble/test_api.py b/api/tests/core/subscription/ubble/test_api.py index e9bafcd0221..ed389d93154 100644 --- a/api/tests/core/subscription/ubble/test_api.py +++ b/api/tests/core/subscription/ubble/test_api.py @@ -295,7 +295,7 @@ def test_ubble_identification_declined(self, requests_mock): ubble_content = fraud_check.resultContent assert ubble_content["status"] == ubble_serializers.UbbleIdentificationStatus.DECLINED.value - assert fraud_check.status == fraud_models.FraudCheckStatus.SUSPICIOUS + assert fraud_check.status == fraud_models.FraudCheckStatus.KO assert fraud_check.reasonCodes == [fraud_models.FraudReasonCode.ID_CHECK_DATA_MATCH] assert "Ubble DECLINED" in fraud_check.reason