mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Протестирована логика подписи access_token и refresh_token, добавлены базовые скоупы, подчищен проект
This commit is contained in:
42
tests/codeception/api/functional/_steps/OauthSteps.php
Normal file
42
tests/codeception/api/functional/_steps/OauthSteps.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
namespace tests\codeception\api\functional\_steps;
|
||||
|
||||
use tests\codeception\api\_pages\OauthRoute;
|
||||
|
||||
class OauthSteps extends AccountSteps {
|
||||
|
||||
public function getAuthCode($online = true) {
|
||||
// TODO: по идее можно напрямую сделать зпись в базу, что ускорит процесс тестирования
|
||||
$this->loggedInAsActiveAccount();
|
||||
$route = new OauthRoute($this);
|
||||
$route->complete([
|
||||
'client_id' => 'ely',
|
||||
'redirect_uri' => 'http://ely.by',
|
||||
'response_type' => 'code',
|
||||
'scope' => 'minecraft_server_session' . ($online ? '' : ',offline_access'),
|
||||
], ['accept' => true]);
|
||||
$this->canSeeResponseJsonMatchesJsonPath('$.redirectUri');
|
||||
$response = json_decode($this->grabResponse(), true);
|
||||
preg_match('/code=(\w+)/', $response['redirectUri'], $matches);
|
||||
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
public function getRefreshToken() {
|
||||
// TODO: по идее можно напрямую сделать зпись в базу, что ускорит процесс тестирования
|
||||
$authCode = $this->getAuthCode(false);
|
||||
$route = new OauthRoute($this);
|
||||
$route->issueToken([
|
||||
'code' => $authCode,
|
||||
'client_id' => 'ely',
|
||||
'client_secret' => 'ZuM1vGchJz-9_UZ5HC3H3Z9Hg5PzdbkM',
|
||||
'redirect_uri' => 'http://ely.by',
|
||||
'grant_type' => 'authorization_code',
|
||||
]);
|
||||
|
||||
$response = json_decode($this->grabResponse(), true);
|
||||
|
||||
return $response['refresh_token'];
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user