Authentica OTP tests

This commit is contained in:
2026-02-28 17:31:03 +03:00
parent 4253f6f650
commit 828cbcc822
10 changed files with 265 additions and 28 deletions
+12 -1
View File
@@ -154,6 +154,11 @@ class AuthenticaOtpProvider(BaseOtpProvider):
data = {"detail": response.text}
if not response.ok:
if os.getenv("AUTHENTICA_DEBUG") == "1" or os.getenv("AUTHENTICA_E2E") == "1":
raise RuntimeError(
_("Authentica request failed: %(status)s %(body)s")
% {"status": response.status_code, "body": response.text}
)
raise RuntimeError(_("Authentica request failed"))
return data
@@ -166,7 +171,13 @@ class AuthenticaOtpProvider(BaseOtpProvider):
def verify_otp(self, to_number: str, code: str) -> bool:
data = self._post("/api/v2/verify-otp", {"phone": to_number, "otp": code})
return bool(data.get("verified"))
if "verified" in data:
verified = bool(data.get("verified"))
else:
verified = bool(data.get("status")) or data.get("message") == "OTP verified successfully"
if not verified and (os.getenv("AUTHENTICA_DEBUG") == "1" or os.getenv("AUTHENTICA_E2E") == "1"):
raise RuntimeError(_("Authentica verify failed: %(response)s") % {"response": data})
return verified
def send_sms(self, to_number: str, message: str) -> None:
if not self.sender_name: