diff options
-rw-r--r-- | app/config/security.yml | 1 | ||||
-rw-r--r-- | src/Wallabag/ApiBundle/Controller/WallabagRestController.php | 15 | ||||
-rw-r--r-- | src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php | 11 |
3 files changed, 27 insertions, 0 deletions
diff --git a/app/config/security.yml b/app/config/security.yml index 7f05123a..0748c06c 100644 --- a/app/config/security.yml +++ b/app/config/security.yml | |||
@@ -53,6 +53,7 @@ security: | |||
53 | 53 | ||
54 | access_control: | 54 | access_control: |
55 | - { path: ^/api/doc, roles: IS_AUTHENTICATED_ANONYMOUSLY } | 55 | - { path: ^/api/doc, roles: IS_AUTHENTICATED_ANONYMOUSLY } |
56 | - { path: ^/api/version, roles: IS_AUTHENTICATED_ANONYMOUSLY } | ||
56 | - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } | 57 | - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } |
57 | - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY } | 58 | - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY } |
58 | - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } | 59 | - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } |
diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index 35a90edd..29cab1f4 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php | |||
@@ -340,6 +340,21 @@ class WallabagRestController extends FOSRestController | |||
340 | 340 | ||
341 | return $this->renderJsonResponse($json); | 341 | return $this->renderJsonResponse($json); |
342 | } | 342 | } |
343 | /** | ||
344 | * Retrieve version number. | ||
345 | * | ||
346 | * @ApiDoc() | ||
347 | * | ||
348 | * @return Response | ||
349 | */ | ||
350 | public function getVersionAction() | ||
351 | { | ||
352 | $version = $this->container->getParameter('wallabag_core.version'); | ||
353 | |||
354 | $json = $this->get('serializer')->serialize($version, 'json'); | ||
355 | |||
356 | return $this->renderJsonResponse($json); | ||
357 | } | ||
343 | 358 | ||
344 | /** | 359 | /** |
345 | * Validate that the first id is equal to the second one. | 360 | * Validate that the first id is equal to the second one. |
diff --git a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php index 630b75bf..a705f9de 100644 --- a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php | |||
@@ -336,4 +336,15 @@ class WallabagRestControllerTest extends WallabagApiTestCase | |||
336 | 336 | ||
337 | $this->assertCount(0, $entries); | 337 | $this->assertCount(0, $entries); |
338 | } | 338 | } |
339 | |||
340 | public function testGetVersion() | ||
341 | { | ||
342 | $this->client->request('GET', '/api/version'); | ||
343 | |||
344 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
345 | |||
346 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
347 | |||
348 | $this->assertEquals($this->client->getContainer()->getParameter('wallabag_core.version'), $content); | ||
349 | } | ||
339 | } | 350 | } |