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/Wallabag/ApiBundle/Controller/UserRestControllerTest.php') 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 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/Wallabag/ApiBundle/Controller/UserRestControllerTest.php') 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