From: Jeremy Benoist Date: Wed, 9 Jan 2019 22:29:30 +0000 (+0100) Subject: Cast client id to avoid PG error X-Git-Tag: 2.3.6~3^2 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=3a2d4cf9fda87760c86320a7f8a5041d1d4256c6;p=github%2Fwallabag%2Fwallabag.git Cast client id to avoid PG error If someone send a malformated client_id when trying to authenticate using the API we got a 500 if wallabag use postgres because the request send a string instead of an integer. --- diff --git a/src/Wallabag/ApiBundle/Entity/Client.php b/src/Wallabag/ApiBundle/Entity/Client.php index e6f98f98..78349820 100644 --- a/src/Wallabag/ApiBundle/Entity/Client.php +++ b/src/Wallabag/ApiBundle/Entity/Client.php @@ -11,7 +11,7 @@ use Wallabag\UserBundle\Entity\User; /** * @ORM\Table("oauth2_clients") - * @ORM\Entity + * @ORM\Entity(repositoryClass="Wallabag\ApiBundle\Repository\ClientRepository") */ class Client extends BaseClient { diff --git a/src/Wallabag/ApiBundle/Repository/ClientRepository.php b/src/Wallabag/ApiBundle/Repository/ClientRepository.php new file mode 100644 index 00000000..fc14262e --- /dev/null +++ b/src/Wallabag/ApiBundle/Repository/ClientRepository.php @@ -0,0 +1,19 @@ +assertArrayHasKey('refresh_token', $data); } + public function testCreateTokenWithBadClientId() + { + $client = $this->getClient(); + $client->request('POST', '/oauth/v2/token', [ + 'grant_type' => 'password', + 'client_id' => '$WALLABAG_CLIENT_ID', + 'client_secret' => 'secret', + 'username' => 'admin', + 'password' => 'mypassword', + ]); + + $this->assertSame(400, $client->getResponse()->getStatusCode()); + } + public function testListingClient() { $this->logInAs('admin');