2016-09-01 13:01:43 +05:30
|
|
|
<?php
|
2019-12-04 23:40:15 +05:30
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-02-21 01:28:52 +05:30
|
|
|
namespace api\tests\functional\authserver;
|
2016-09-01 13:01:43 +05:30
|
|
|
|
2019-02-21 01:28:52 +05:30
|
|
|
use api\tests\functional\_steps\AuthserverSteps;
|
2019-12-04 23:40:15 +05:30
|
|
|
use Codeception\Example;
|
2016-09-01 13:01:43 +05:30
|
|
|
|
|
|
|
class SignoutCest {
|
|
|
|
|
|
|
|
/**
|
2019-12-04 23:40:15 +05:30
|
|
|
* @example {"login": "admin", "password": "password_0"}
|
|
|
|
* @example {"login": "admin@ely.by", "password": "password_0"}
|
2016-09-01 13:01:43 +05:30
|
|
|
*/
|
2024-12-02 15:40:55 +05:30
|
|
|
public function signout(AuthserverSteps $I, Example $example): void {
|
2016-09-01 13:01:43 +05:30
|
|
|
$I->wantTo('signout by nickname and password');
|
2019-12-04 23:40:15 +05:30
|
|
|
$I->sendPOST('/api/authserver/authentication/signout', [
|
|
|
|
'username' => $example['login'],
|
|
|
|
'password' => $example['password'],
|
2016-09-01 13:01:43 +05:30
|
|
|
]);
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseEquals('');
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function wrongArguments(AuthserverSteps $I): void {
|
2016-09-01 13:01:43 +05:30
|
|
|
$I->wantTo('get error on wrong amount of arguments');
|
2019-12-04 23:40:15 +05:30
|
|
|
$I->sendPOST('/api/authserver/authentication/signout', [
|
2016-09-01 13:01:43 +05:30
|
|
|
'key' => 'value',
|
|
|
|
]);
|
|
|
|
$I->canSeeResponseCodeIs(400);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'error' => 'IllegalArgumentException',
|
|
|
|
'errorMessage' => 'credentials can not be null.',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function wrongNicknameAndPassword(AuthserverSteps $I): void {
|
2016-09-01 13:01:43 +05:30
|
|
|
$I->wantTo('signout by nickname and password with wrong data');
|
2019-12-04 23:40:15 +05:30
|
|
|
$I->sendPOST('/api/authserver/authentication/signout', [
|
2016-09-01 13:01:43 +05:30
|
|
|
'username' => 'nonexistent_user',
|
|
|
|
'password' => 'nonexistent_password',
|
|
|
|
]);
|
|
|
|
$I->canSeeResponseCodeIs(401);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'error' => 'ForbiddenOperationException',
|
|
|
|
'errorMessage' => 'Invalid credentials. Invalid nickname or password.',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function bannedAccount(AuthserverSteps $I): void {
|
2016-09-01 13:01:43 +05:30
|
|
|
$I->wantTo('signout from banned account');
|
2019-12-04 23:40:15 +05:30
|
|
|
$I->sendPOST('/api/authserver/authentication/signout', [
|
2016-09-01 13:01:43 +05:30
|
|
|
'username' => 'Banned',
|
|
|
|
'password' => 'password_0',
|
|
|
|
]);
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseEquals('');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|