From 395a065fd4717821b1871b6191c2a64110d1be12 Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 21 Mar 2018 02:28:55 +0100 Subject: [PATCH] Add tests for 'changePasswordForUserByUsername' from 'Administration' --- tests/index.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/index.php b/tests/index.php index 41a8b1c..171f692 100644 --- a/tests/index.php +++ b/tests/index.php @@ -614,6 +614,32 @@ function processRequestData(\Delight\Auth\Auth $auth) { return 'Username required'; } } + else if ($_POST['action'] === 'admin.changePasswordForUser') { + if (isset($_POST['newPassword'])) { + if (isset($_POST['username'])) { + try { + $auth->admin()->changePasswordForUserByUsername($_POST['username'], $_POST['newPassword']); + } + catch (\Delight\Auth\UnknownUsernameException $e) { + return 'unknown username'; + } + catch (\Delight\Auth\AmbiguousUsernameException $e) { + return 'ambiguous username'; + } + catch (\Delight\Auth\InvalidPasswordException $e) { + return 'invalid password'; + } + } + else { + return 'username required'; + } + } + else { + return 'new password required'; + } + + return 'ok'; + } else { throw new Exception('Unexpected action: ' . $_POST['action']); } @@ -944,6 +970,13 @@ function showGuestUserForm() { echo ' '; echo ''; echo ''; + + echo '
'; + echo ''; + echo ' '; + echo ' '; + echo ''; + echo '
'; } function showConfirmEmailForm() {