diff --git a/api/modules/oauth/models/OauthClientForm.php b/api/modules/oauth/models/OauthClientForm.php index 8321a22..683e414 100644 --- a/api/modules/oauth/models/OauthClientForm.php +++ b/api/modules/oauth/models/OauthClientForm.php @@ -90,7 +90,10 @@ class OauthClientForm { } protected function isClientExists(string $id): bool { - return OauthClient::find()->andWhere(['id' => $id])->exists(); + return OauthClient::find() + ->includeDeleted() + ->andWhere(['id' => $id]) + ->exists(); } } diff --git a/tests/codeception/api/functional/oauth/CreateClientCest.php b/tests/codeception/api/functional/oauth/CreateClientCest.php index 665367f..ce483d4 100644 --- a/tests/codeception/api/functional/oauth/CreateClientCest.php +++ b/tests/codeception/api/functional/oauth/CreateClientCest.php @@ -88,4 +88,23 @@ class CreateClientCest { $I->canSeeResponseJsonMatchesJsonPath('$.data.createdAt'); } + public function testCreateApplicationWithTheSameNameAsDeletedApp(FunctionalTester $I) { + $I->wantTo('create application with the same name as the recently deleted application'); + $I->amAuthenticated('admin'); + $this->route->createClient('application', [ + 'name' => 'Deleted OAuth Client', + 'description' => '', + 'redirectUri' => 'http://some-site.com/oauth/ely', + 'websiteUrl' => 'http://some-site.com', + ]); + $I->canSeeResponseCodeIs(200); + $I->canSeeResponseIsJson(); + $I->canSeeResponseContainsJson([ + 'success' => true, + 'data' => [ + 'clientId' => 'deleted-oauth-client1', + ], + ]); + } + } diff --git a/tests/codeception/common/fixtures/data/oauth-clients.php b/tests/codeception/common/fixtures/data/oauth-clients.php index df4da2c..02ec7e3 100644 --- a/tests/codeception/common/fixtures/data/oauth-clients.php +++ b/tests/codeception/common/fixtures/data/oauth-clients.php @@ -116,7 +116,7 @@ return [ 'id' => 'deleted-oauth-client', 'secret' => 'YISLDvIHlLbhsvYoIJScUzTURVXK32Q58sHWSFKyO71iCIlv4YM2Zt1kEK7DQLXX', 'type' => 'application', - 'name' => 'I was deleted :(', + 'name' => 'Deleted OAuth Client', 'description' => null, 'redirect_uri' => 'http://not-exists-site.com/oauth/ely', 'website_url' => '',