From: Jeremy Benoist Date: Sat, 8 Jul 2017 17:28:12 +0000 (+0200) Subject: Revert client_credentials grant types X-Git-Tag: 2.3.0~31^2~42^2 X-Git-Url: https://git.immae.eu/?p=github%2Fwallabag%2Fwallabag.git;a=commitdiff_plain;h=2e5b2fa808ca2793705069e56a3cc7e6631f9d9d Revert client_credentials grant types --- diff --git a/src/Wallabag/ApiBundle/Controller/DeveloperController.php b/src/Wallabag/ApiBundle/Controller/DeveloperController.php index c8a1c635..c7178017 100644 --- a/src/Wallabag/ApiBundle/Controller/DeveloperController.php +++ b/src/Wallabag/ApiBundle/Controller/DeveloperController.php @@ -43,7 +43,7 @@ class DeveloperController extends Controller $clientForm->handleRequest($request); if ($clientForm->isSubmitted() && $clientForm->isValid()) { - $client->setAllowedGrantTypes(['client_credentials', 'token', 'authorization_code', 'password', 'refresh_token']); + $client->setAllowedGrantTypes(['token', 'authorization_code', 'password', 'refresh_token']); $em->persist($client); $em->flush(); diff --git a/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php b/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php index 2caeccf5..e9e5ee3b 100644 --- a/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php @@ -34,7 +34,7 @@ class DeveloperControllerTest extends WallabagCoreTestCase $this->assertContains('My app', $alert[0]); } - public function testCreateTokenFromPasswords() + public function testCreateToken() { $client = $this->getClient(); $apiClient = $this->createApiClientForUser('admin'); @@ -56,26 +56,6 @@ class DeveloperControllerTest extends WallabagCoreTestCase $this->assertArrayHasKey('refresh_token', $data); } - public function testCreateTokenFromClientCredentialsOnly() - { - $client = $this->getClient(); - $apiClient = $this->createApiClientForUser('admin', ['client_credentials']); - - $client->request('POST', '/oauth/v2/token', [ - 'grant_type' => 'client_credentials', - 'client_id' => $apiClient->getPublicId(), - 'client_secret' => $apiClient->getSecret(), - ]); - - $this->assertSame(200, $client->getResponse()->getStatusCode()); - - $data = json_decode($client->getResponse()->getContent(), true); - $this->assertArrayHasKey('access_token', $data); - $this->assertArrayHasKey('expires_in', $data); - $this->assertArrayHasKey('token_type', $data); - // Client Credentials created-clients have no refresh tokens - } - public function testListingClient() { $this->logInAs('admin');