From 0c00e5251671c3648eabb8888271c09137ad902d Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 7 Jun 2017 23:23:28 +0200 Subject: Create a client when creating a user using the api MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While creating a new user using the API, we also create a new client for the current user. So the app which just create the user can use its newly created client to configure the app. That new client is only return after creating the user. When calling the endpoint /api/user to get user information, the new client information won’t be return. --- .../Wallabag/ApiBundle/Controller/UserRestControllerTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests') diff --git a/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php index 5735bc58..9f01a976 100644 --- a/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php @@ -61,10 +61,16 @@ class UserRestControllerTest extends WallabagApiTestCase $this->assertArrayHasKey('username', $content); $this->assertArrayHasKey('created_at', $content); $this->assertArrayHasKey('updated_at', $content); + $this->assertArrayHasKey('default_client', $content); $this->assertEquals('wallabag@google.com', $content['email']); $this->assertEquals('google', $content['username']); + $this->assertArrayHasKey('client_secret', $content['default_client']); + $this->assertArrayHasKey('client_id', $content['default_client']); + + $this->assertEquals('Default client', $content['default_client']['name']); + $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); $this->client->getContainer()->get('craue_config')->set('api_user_registration', 0); @@ -90,10 +96,16 @@ class UserRestControllerTest extends WallabagApiTestCase $this->assertArrayHasKey('username', $content); $this->assertArrayHasKey('created_at', $content); $this->assertArrayHasKey('updated_at', $content); + $this->assertArrayHasKey('default_client', $content); $this->assertEquals('wallabag@google.com', $content['email']); $this->assertEquals('google', $content['username']); + $this->assertArrayHasKey('client_secret', $content['default_client']); + $this->assertArrayHasKey('client_id', $content['default_client']); + + $this->assertEquals('Default client', $content['default_client']['name']); + $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type')); $client->getContainer()->get('craue_config')->set('api_user_registration', 0); -- cgit v1.2.3 From eb570e49c8e3ba12638fac600bb5527191c2aaa2 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 7 Jun 2017 23:23:34 +0200 Subject: CS --- .../Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php | 4 ++-- tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php index 8f87ccf3..3c94382c 100644 --- a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php +++ b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php @@ -85,7 +85,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase 'text' => 'my annotation', 'quote' => 'my quote', 'ranges' => [ - ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31] + ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31], ], ]); $this->client->request('POST', $prefixUrl.'/'.$entry->getId().'.json', [], [], $headers, $content); @@ -130,7 +130,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase 'text' => 'my annotation', 'quote' => $longQuote, 'ranges' => [ - ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31] + ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31], ], ]); $this->client->request('POST', $prefixUrl.'/'.$entry->getId().'.json', [], [], $headers, $content); diff --git a/tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php b/tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php index 3b928d1e..c0a4acfa 100644 --- a/tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php @@ -4,10 +4,8 @@ namespace Tests\Wallabag\CoreBundle\Command; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Tester\CommandTester; -use Wallabag\CoreBundle\Command\CleanDuplicatesCommand; use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; use Wallabag\CoreBundle\Command\ShowUserCommand; -use Wallabag\CoreBundle\Entity\Entry; use Wallabag\UserBundle\Entity\User; class ShowUserCommandTest extends WallabagCoreTestCase -- cgit v1.2.3 From a8d3fe50df52ec486add5691a3b67fe5205a032e Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Thu, 8 Jun 2017 14:25:44 +0200 Subject: Add ability to name the client --- tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php index 9f01a976..4e65f130 100644 --- a/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php @@ -85,6 +85,7 @@ class UserRestControllerTest extends WallabagApiTestCase 'username' => 'google', 'password' => 'googlegoogle', 'email' => 'wallabag@google.com', + 'client_name' => 'My client name !!', ]); $this->assertEquals(201, $client->getResponse()->getStatusCode()); @@ -104,7 +105,7 @@ class UserRestControllerTest extends WallabagApiTestCase $this->assertArrayHasKey('client_secret', $content['default_client']); $this->assertArrayHasKey('client_id', $content['default_client']); - $this->assertEquals('Default client', $content['default_client']['name']); + $this->assertEquals('My client name !!', $content['default_client']['name']); $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type')); -- cgit v1.2.3