From 4dc67aaa30126a0794d4645d28055174a6e9ad76 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 14 Jun 2024 13:03:14 +0200 Subject: [PATCH] Add tests for method 'Auth#enableTwoFactorViaSms' --- tests/index.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/index.php b/tests/index.php index a710d0a..353c655 100644 --- a/tests/index.php +++ b/tests/index.php @@ -439,6 +439,28 @@ function processRequestData(\Delight\Auth\Auth $auth) { return 'too many requests'; } } + else if ($_POST['action'] === 'enableTwoFactorViaSms') { + try { + $recoveryCodes = $auth->enableTwoFactorViaSms($_POST['otpValue']); + + return \implode(' | ', $recoveryCodes); + } + catch (\Delight\Auth\InvalidOneTimePasswordException $e) { + return 'invalid OTP'; + } + catch (\Delight\Auth\TwoFactorMechanismNotInitializedException $e) { + return 'not initialized'; + } + catch (\Delight\Auth\TwoFactorMechanismAlreadyEnabledException $e) { + return 'already enabled'; + } + catch (\Delight\Auth\NotLoggedInException $e) { + return 'not logged in'; + } + catch (\Delight\Auth\TooManyRequestsException $e) { + return 'too many requests'; + } + } else if ($_POST['action'] === 'reconfirmPassword') { try { return $auth->reconfirmPassword($_POST['password']) ? 'correct' : 'wrong'; @@ -997,6 +1019,12 @@ function showAuthenticatedUserForm(\Delight\Auth\Auth $auth) { echo ''; echo ''; + echo '
'; + echo ''; + echo ' '; + echo ''; + echo '
'; + echo '
'; echo ''; echo '';