From 804141f1d42b6c0db7f7bc59725fbadac8506eaf Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 4 Apr 2024 19:51:18 +0200 Subject: [PATCH] Add tests for method 'Auth#prepareTwoFactorViaSms' --- tests/index.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/index.php b/tests/index.php index 8f203a3..723db3f 100644 --- a/tests/index.php +++ b/tests/index.php @@ -382,6 +382,25 @@ function processRequestData(\Delight\Auth\Auth $auth) { return 'too many requests'; } } + else if ($_POST['action'] === 'prepareTwoFactorViaSms') { + try { + $phoneNumberAndOtpValue = $auth->prepareTwoFactorViaSms($_POST['phoneNumber']); + + return $phoneNumberAndOtpValue[1] . ' -> ' . $phoneNumberAndOtpValue[0]; + } + catch (\Delight\Auth\InvalidPhoneNumberException $e) { + return 'invalid phone number'; + } + 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'] === 'enableTwoFactorViaTotp') { try { $recoveryCodes = $auth->enableTwoFactorViaTotp($_POST['otpValue']); @@ -945,6 +964,12 @@ function showAuthenticatedUserForm(\Delight\Auth\Auth $auth) { echo ''; echo ''; + echo '
'; + echo ''; + echo ' '; + echo ''; + echo '
'; + echo '
'; echo ''; echo ' ';