X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FApiBundle%2FController%2FDeveloperControllerTest.php;h=e1a0ac7e49d2d1ee92405e7f3c3ab03a86e6edc2;hb=3a2d4cf9fda87760c86320a7f8a5041d1d4256c6;hp=2caeccf5f0fc8bc9275fa79e972c0a4ca7f3e6d2;hpb=71e1cbc8eb5928d393b0772055d6b711e90a09b3;p=github%2Fwallabag%2Fwallabag.git diff --git a/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php b/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php index 2caeccf5..e1a0ac7e 100644 --- a/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php @@ -17,7 +17,7 @@ class DeveloperControllerTest extends WallabagCoreTestCase $crawler = $client->request('GET', '/developer/client/create'); $this->assertSame(200, $client->getResponse()->getStatusCode()); - $form = $crawler->filter('button[type=submit]')->form(); + $form = $crawler->filter('button[id=client_save]')->form(); $data = [ 'client[name]' => 'My app', @@ -28,13 +28,13 @@ class DeveloperControllerTest extends WallabagCoreTestCase $this->assertSame(200, $client->getResponse()->getStatusCode()); $newNbClients = $em->getRepository('WallabagApiBundle:Client')->findAll(); - $this->assertGreaterThan(count($nbClients), count($newNbClients)); + $this->assertGreaterThan(\count($nbClients), \count($newNbClients)); $this->assertGreaterThan(1, $alert = $crawler->filter('.settings ul li strong')->extract(['_text'])); $this->assertContains('My app', $alert[0]); } - public function testCreateTokenFromPasswords() + public function testCreateToken() { $client = $this->getClient(); $apiClient = $this->createApiClientForUser('admin'); @@ -56,24 +56,18 @@ class DeveloperControllerTest extends WallabagCoreTestCase $this->assertArrayHasKey('refresh_token', $data); } - public function testCreateTokenFromClientCredentialsOnly() + public function testCreateTokenWithBadClientId() { $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(), + 'grant_type' => 'password', + 'client_id' => '$WALLABAG_CLIENT_ID', + 'client_secret' => 'secret', + 'username' => 'admin', + 'password' => 'mypassword', ]); - $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 + $this->assertSame(400, $client->getResponse()->getStatusCode()); } public function testListingClient() @@ -85,7 +79,7 @@ class DeveloperControllerTest extends WallabagCoreTestCase $crawler = $client->request('GET', '/developer'); $this->assertSame(200, $client->getResponse()->getStatusCode()); - $this->assertSame(count($nbClients), $crawler->filter('ul[class=collapsible] li')->count()); + $this->assertSame(\count($nbClients), $crawler->filter('ul[class=collapsible] li')->count()); } public function testDeveloperHowto()