function test_checkUser() { appendTestMessage(NEW_LINE_LOG . ">> Test user actions..." . NEW_LINE_LOG); // New user empty appendTestMessage("Test new empty user"); $ret = checkUser("", ""); if (!$ret) { appendTestMessage("- ok"); } else { appendTestMessage("- failed"); return false; } // New user blank appendTestMessage("Test new blank user"); $ret = checkUser(" ", ""); if (!$ret) { appendTestMessage("- ok"); } else { appendTestMessage("- failed"); return false; } // New user format not accepted appendTestMessage("Test new user, format not accepted"); $ret = checkUser("a user", ""); if (!$ret) { appendTestMessage("- ok"); } else { appendTestMessage("- failed"); return false; } // New user, blank password appendTestMessage("Test new user, blank password"); $ret = checkUser("aUser", ""); if ($ret) { appendTestMessage("- ok"); } else { appendTestMessage("- failed"); return false; } // user, wrong password appendTestMessage("user, wrong password"); $ret = checkUser("aUser", "wrong"); if (!$ret) { appendTestMessage("- ok"); } else { appendTestMessage("- failed"); return false; } // user, password appendTestMessage("user, password ok"); $ret = checkUser("aUser", ""); if ($ret) { appendTestMessage("- ok"); } else { appendTestMessage("- failed"); return false; } // user login accepted appendTestMessage("user login accepted"); $ret = isUserAccepted("aUser", ""); if ($ret) { appendTestMessage("- ok"); } else { appendTestMessage("- failed"); return false; } // user login not accepted appendTestMessage("user login not accepted"); $ret = isUserAccepted("aUser", "wrongpassword"); if (!$ret) { appendTestMessage("- ok"); } else { appendTestMessage("- failed"); return false; } // user name login not accepted appendTestMessage("user name for login not accepted"); $ret = isUserAccepted("wronguser", "wrongpassword"); if (!$ret) { appendTestMessage("- ok"); } else { appendTestMessage("- failed"); return false; } // change password wrong password appendTestMessage("Change password but wrong old password"); $ret = changePassword("aUser", "wrong", "xyz"); if (!$ret) { appendTestMessage("- ok"); } else { appendTestMessage("- failed"); return false; } // change password appendTestMessage("Change password"); $ret = changePassword("aUser", "", "newpassword"); if ($ret) { appendTestMessage("- ok"); } else { appendTestMessage("- failed"); return false; } // remove not existing user appendTestMessage("Remove not existing user"); $ret = removeUser("bUser", "p"); if ($ret) { appendTestMessage("- ok"); } else { appendTestMessage("- failed"); return false; } // remove existing user appendTestMessage("Remove existing user"); $ret = removeUser("aUser", "newpassword"); if ($ret) { appendTestMessage("- ok"); } else { appendTestMessage("- failed"); return false; } // Is admin appendTestMessage("Is eUser the admin?"); $ret = isAdmin('eUser'); if (!$ret) { appendTestMessage("- ok"); } else { appendTestMessage("- failed"); return false; } // Is admin appendTestMessage("Is admin the admin?"); $ret = isAdmin('admin'); if ($ret) { appendTestMessage("- ok"); } else { appendTestMessage("- failed"); return false; } // Is admin appendTestMessage("Is AdMin the admin?"); $ret = isAdmin('AdMin'); if ($ret) { appendTestMessage("- ok"); } else { appendTestMessage("- failed"); return false; } return true; }
// 2013-07-19: Checked in at soureforge under . GPLv3 // test from new environment include 'util.php'; header("Access-Control-Allow-Origin: *"); header('Access-Control-Allow-Methods: GET, POST, OPTIONS'); // Every request must have a userAnonym $user = getParam('user'); if (isNullOrEmptyString($user)) { setServerError("GET/POST parameter 'user' is missing."); return; } // New Password $isUserAccepted = getParam('isUserAccepted'); if (!isNullOrEmptyString($isUserAccepted)) { if (!isUserAccepted($user, getParam('pass'))) { setServerError("User not accepted, user {$user}."); return; } setServerResponse("{$user}"); return; } //Accept only user with valid password $pass = getParam('pass'); if (!checkUser($user, $pass)) { setServerError("Format of user name OR password no accepted for user {$user}."); return; } // New Password $passNew = getParam('passNew'); if (!isNullOrEmptyString($passNew)) {