]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Fix permission to settings page
authorJeremy Benoist <jeremy.benoist@gmail.com>
Fri, 22 Jan 2016 17:48:04 +0000 (18:48 +0100)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Sun, 31 Jan 2016 13:48:26 +0000 (14:48 +0100)
app/config/security.yml
src/Wallabag/CoreBundle/Tests/Controller/SettingsControllerTest.php [new file with mode: 0644]

index 6f20490b8e4d4a31f2a05ffd33d8a3ff7254f3de..7c10889ff3669d33a6b2bd794f2d39c4c56f6cc4 100644 (file)
@@ -57,5 +57,5 @@ security:
         - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
         - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
         - { path: /(unread|starred|archive).xml$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
-        - { path: ^/, roles: ROLE_USER }
         - { path: ^/settings, roles: ROLE_SUPER_ADMIN }
+        - { path: ^/, roles: ROLE_USER }
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/SettingsControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/SettingsControllerTest.php
new file mode 100644 (file)
index 0000000..354aedb
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+
+namespace Wallabag\CoreBundle\Tests\Controller;
+
+use Wallabag\CoreBundle\Tests\WallabagCoreTestCase;
+
+/**
+ * The controller `SettingsController` does not exist.
+ * This test cover security against the internal settings page managed by CraueConfigBundle
+ */
+class SettingsControllerTest extends WallabagCoreTestCase
+{
+    public function testSettingsWithAdmin()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $crawler = $client->request('GET', '/settings');
+
+        $this->assertEquals(200, $client->getResponse()->getStatusCode());
+    }
+
+    public function testSettingsWithNormalUser()
+    {
+        $this->logInAs('bob');
+        $client = $this->getClient();
+
+        $crawler = $client->request('GET', '/settings');
+
+        $this->assertEquals(403, $client->getResponse()->getStatusCode());
+    }
+}