]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php
Ensure access_token are removed
[github/wallabag/wallabag.git] / tests / Wallabag / ApiBundle / Controller / DeveloperControllerTest.php
similarity index 72%
rename from tests/Wallabag/CoreBundle/Controller/DeveloperControllerTest.php
rename to tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php
index 97ed0d58fa01ce99abfd65bf2f0163344e582a59..95befa9cab2f4fe2502b7776a784c8d022d62905 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-namespace Tests\Wallabag\CoreBundle\Controller;
+namespace Tests\Wallabag\ApiBundle\Controller;
 
 use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
 
@@ -33,6 +33,32 @@ class DeveloperControllerTest extends WallabagCoreTestCase
         $this->assertContains('My app', $alert[0]);
     }
 
+    /**
+     * @depends testCreateClient
+     */
+    public function testCreateToken()
+    {
+        $client = $this->getClient();
+        $em = $client->getContainer()->get('doctrine.orm.entity_manager');
+        $apiClient = $em->getRepository('WallabagApiBundle:Client')->findOneByName('My app');
+
+        $client->request('POST', '/oauth/v2/token', [
+            'grant_type' => 'password',
+            'client_id' => $apiClient->getPublicId(),
+            'client_secret' => $apiClient->getSecret(),
+            'username' => 'admin',
+            'password' => 'mypassword',
+        ]);
+
+        $this->assertEquals(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);
+        $this->assertArrayHasKey('refresh_token', $data);
+    }
+
     public function testListingClient()
     {
         $this->logInAs('admin');