2018-02-28 03:57:35 +05:30
|
|
|
<?php
|
2019-09-18 04:44:05 +05:30
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace api\tests\functional\dev\applications;
|
2018-02-28 03:57:35 +05:30
|
|
|
|
2019-02-21 01:28:52 +05:30
|
|
|
use api\tests\_pages\OauthRoute;
|
|
|
|
use api\tests\FunctionalTester;
|
2018-02-28 03:57:35 +05:30
|
|
|
|
|
|
|
class ResetClientCest {
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
private OauthRoute $route;
|
2018-02-28 03:57:35 +05:30
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function _before(FunctionalTester $I): void {
|
2018-02-28 03:57:35 +05:30
|
|
|
$this->route = new OauthRoute($I);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function testReset(FunctionalTester $I): void {
|
2018-02-28 03:57:35 +05:30
|
|
|
$I->amAuthenticated('TwoOauthClients');
|
|
|
|
$this->route->resetClient('first-test-oauth-client');
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'success' => true,
|
|
|
|
'data' => [
|
|
|
|
'clientId' => 'first-test-oauth-client',
|
|
|
|
'clientSecret' => 'Zt1kEK7DQLXXYISLDvURVXK32Q58sHWSFKyO71iCIlv4YM2IHlLbhsvYoIJScUzT',
|
|
|
|
'name' => 'First test oauth client',
|
|
|
|
'description' => 'Some description to the first oauth client',
|
|
|
|
'redirectUri' => 'http://some-site-1.com/oauth/ely',
|
|
|
|
'websiteUrl' => '',
|
|
|
|
'countUsers' => 0,
|
|
|
|
'createdAt' => 1519487434,
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function testResetWithSecretChanging(FunctionalTester $I): void {
|
2018-02-28 03:57:35 +05:30
|
|
|
$I->amAuthenticated('TwoOauthClients');
|
|
|
|
$this->route->resetClient('first-test-oauth-client', true);
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'success' => true,
|
|
|
|
'data' => [
|
|
|
|
'clientId' => 'first-test-oauth-client',
|
|
|
|
'name' => 'First test oauth client',
|
|
|
|
'description' => 'Some description to the first oauth client',
|
|
|
|
'redirectUri' => 'http://some-site-1.com/oauth/ely',
|
|
|
|
'websiteUrl' => '',
|
|
|
|
'countUsers' => 0,
|
|
|
|
'createdAt' => 1519487434,
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
$I->canSeeResponseJsonMatchesJsonPath('$.data.clientSecret');
|
|
|
|
$secret = $I->grabDataFromResponseByJsonPath('$.data.clientSecret')[0];
|
|
|
|
$I->assertNotEquals('Zt1kEK7DQLXXYISLDvURVXK32Q58sHWSFKyO71iCIlv4YM2IHlLbhsvYoIJScUzT', $secret);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|