aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorJérémy Benoist <j0k3r@users.noreply.github.com>2017-06-08 17:24:49 +0200
committerGitHub <noreply@github.com>2017-06-08 17:24:49 +0200
commit3f474025d889c3eff20b481f005f4d292f1ef29d (patch)
treee74288b7df91e226b1d23a4047a3af5cc04a6484 /tests
parent2da8f071cfcc6e50be7be66c037de23f0d073bea (diff)
parenta8d3fe50df52ec486add5691a3b67fe5205a032e (diff)
downloadwallabag-3f474025d889c3eff20b481f005f4d292f1ef29d.tar.gz
wallabag-3f474025d889c3eff20b481f005f4d292f1ef29d.tar.zst
wallabag-3f474025d889c3eff20b481f005f4d292f1ef29d.zip
Merge pull request #3187 from wallabag/api-client-credentials
Create (and return) a client after creating a new user using the API
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php4
-rw-r--r--tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php13
-rw-r--r--tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php2
3 files changed, 15 insertions, 4 deletions
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
85 'text' => 'my annotation', 85 'text' => 'my annotation',
86 'quote' => 'my quote', 86 'quote' => 'my quote',
87 'ranges' => [ 87 'ranges' => [
88 ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31] 88 ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31],
89 ], 89 ],
90 ]); 90 ]);
91 $this->client->request('POST', $prefixUrl.'/'.$entry->getId().'.json', [], [], $headers, $content); 91 $this->client->request('POST', $prefixUrl.'/'.$entry->getId().'.json', [], [], $headers, $content);
@@ -130,7 +130,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
130 'text' => 'my annotation', 130 'text' => 'my annotation',
131 'quote' => $longQuote, 131 'quote' => $longQuote,
132 'ranges' => [ 132 'ranges' => [
133 ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31] 133 ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31],
134 ], 134 ],
135 ]); 135 ]);
136 $this->client->request('POST', $prefixUrl.'/'.$entry->getId().'.json', [], [], $headers, $content); 136 $this->client->request('POST', $prefixUrl.'/'.$entry->getId().'.json', [], [], $headers, $content);
diff --git a/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php
index 5735bc58..4e65f130 100644
--- a/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php
@@ -61,10 +61,16 @@ class UserRestControllerTest extends WallabagApiTestCase
61 $this->assertArrayHasKey('username', $content); 61 $this->assertArrayHasKey('username', $content);
62 $this->assertArrayHasKey('created_at', $content); 62 $this->assertArrayHasKey('created_at', $content);
63 $this->assertArrayHasKey('updated_at', $content); 63 $this->assertArrayHasKey('updated_at', $content);
64 $this->assertArrayHasKey('default_client', $content);
64 65
65 $this->assertEquals('wallabag@google.com', $content['email']); 66 $this->assertEquals('wallabag@google.com', $content['email']);
66 $this->assertEquals('google', $content['username']); 67 $this->assertEquals('google', $content['username']);
67 68
69 $this->assertArrayHasKey('client_secret', $content['default_client']);
70 $this->assertArrayHasKey('client_id', $content['default_client']);
71
72 $this->assertEquals('Default client', $content['default_client']['name']);
73
68 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); 74 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
69 75
70 $this->client->getContainer()->get('craue_config')->set('api_user_registration', 0); 76 $this->client->getContainer()->get('craue_config')->set('api_user_registration', 0);
@@ -79,6 +85,7 @@ class UserRestControllerTest extends WallabagApiTestCase
79 'username' => 'google', 85 'username' => 'google',
80 'password' => 'googlegoogle', 86 'password' => 'googlegoogle',
81 'email' => 'wallabag@google.com', 87 'email' => 'wallabag@google.com',
88 'client_name' => 'My client name !!',
82 ]); 89 ]);
83 90
84 $this->assertEquals(201, $client->getResponse()->getStatusCode()); 91 $this->assertEquals(201, $client->getResponse()->getStatusCode());
@@ -90,10 +97,16 @@ class UserRestControllerTest extends WallabagApiTestCase
90 $this->assertArrayHasKey('username', $content); 97 $this->assertArrayHasKey('username', $content);
91 $this->assertArrayHasKey('created_at', $content); 98 $this->assertArrayHasKey('created_at', $content);
92 $this->assertArrayHasKey('updated_at', $content); 99 $this->assertArrayHasKey('updated_at', $content);
100 $this->assertArrayHasKey('default_client', $content);
93 101
94 $this->assertEquals('wallabag@google.com', $content['email']); 102 $this->assertEquals('wallabag@google.com', $content['email']);
95 $this->assertEquals('google', $content['username']); 103 $this->assertEquals('google', $content['username']);
96 104
105 $this->assertArrayHasKey('client_secret', $content['default_client']);
106 $this->assertArrayHasKey('client_id', $content['default_client']);
107
108 $this->assertEquals('My client name !!', $content['default_client']['name']);
109
97 $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type')); 110 $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type'));
98 111
99 $client->getContainer()->get('craue_config')->set('api_user_registration', 0); 112 $client->getContainer()->get('craue_config')->set('api_user_registration', 0);
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;
4 4
5use Symfony\Bundle\FrameworkBundle\Console\Application; 5use Symfony\Bundle\FrameworkBundle\Console\Application;
6use Symfony\Component\Console\Tester\CommandTester; 6use Symfony\Component\Console\Tester\CommandTester;
7use Wallabag\CoreBundle\Command\CleanDuplicatesCommand;
8use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; 7use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
9use Wallabag\CoreBundle\Command\ShowUserCommand; 8use Wallabag\CoreBundle\Command\ShowUserCommand;
10use Wallabag\CoreBundle\Entity\Entry;
11use Wallabag\UserBundle\Entity\User; 9use Wallabag\UserBundle\Entity\User;
12 10
13class ShowUserCommandTest extends WallabagCoreTestCase 11class ShowUserCommandTest extends WallabagCoreTestCase