mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Rework tests structure. Upgrade codeception to 2.5.3. Merge params configuration into app configuration.
This commit is contained in:
52
api/tests/_pages/AuthenticationRoute.php
Normal file
52
api/tests/_pages/AuthenticationRoute.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace api\tests\_pages;
|
||||
|
||||
class AuthenticationRoute extends BasePage {
|
||||
|
||||
/**
|
||||
* @param string $login
|
||||
* @param string $password
|
||||
* @param string|bool|null $rememberMeOrToken
|
||||
* @param bool $rememberMe
|
||||
*/
|
||||
public function login($login = '', $password = '', $rememberMeOrToken = null, $rememberMe = false) {
|
||||
$params = [
|
||||
'login' => $login,
|
||||
'password' => $password,
|
||||
];
|
||||
|
||||
if ((is_bool($rememberMeOrToken) && $rememberMeOrToken) || $rememberMe) {
|
||||
$params['rememberMe'] = 1;
|
||||
} elseif ($rememberMeOrToken !== null) {
|
||||
$params['totp'] = $rememberMeOrToken;
|
||||
}
|
||||
|
||||
$this->getActor()->sendPOST('/api/authentication/login', $params);
|
||||
}
|
||||
|
||||
public function logout() {
|
||||
$this->getActor()->sendPOST('/api/authentication/logout');
|
||||
}
|
||||
|
||||
public function forgotPassword($login = null, $token = null) {
|
||||
$this->getActor()->sendPOST('/api/authentication/forgot-password', [
|
||||
'login' => $login,
|
||||
'totp' => $token,
|
||||
]);
|
||||
}
|
||||
|
||||
public function recoverPassword($key = null, $newPassword = null, $newRePassword = null) {
|
||||
$this->getActor()->sendPOST('/api/authentication/recover-password', [
|
||||
'key' => $key,
|
||||
'newPassword' => $newPassword,
|
||||
'newRePassword' => $newRePassword,
|
||||
]);
|
||||
}
|
||||
|
||||
public function refreshToken($refreshToken = null) {
|
||||
$this->getActor()->sendPOST('/api/authentication/refresh-token', [
|
||||
'refresh_token' => $refreshToken,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user