]> BookStack Code Mirror - bookstack/blobdiff - tests/Api/ApiDocsTest.php
Apply fixes from StyleCI
[bookstack] / tests / Api / ApiDocsTest.php
index 3cbcadfa30759d4197bbc8775370b0b954760590..90d107eb34aa7b170d73fe2999014c7789248176 100644 (file)
@@ -1,5 +1,8 @@
-<?php namespace Tests\Api;
+<?php
 
+namespace Tests\Api;
+
+use BookStack\Auth\User;
 use Tests\TestCase;
 
 class ApiDocsTest extends TestCase
@@ -33,10 +36,25 @@ class ApiDocsTest extends TestCase
         $resp->assertStatus(200);
         $resp->assertHeader('Content-Type', 'application/json');
         $resp->assertJson([
-            'docs' => [ [
+            'docs' => [[
                 'name' => 'docs-display',
-                'uri' => 'api/docs'
-            ] ]
+                'uri'  => 'api/docs',
+            ]],
         ]);
     }
-}
\ No newline at end of file
+
+    public function test_docs_page_visible_by_public_user_if_given_permission()
+    {
+        $this->setSettings(['app-public' => true]);
+        $guest = User::getDefault();
+
+        $this->startSession();
+        $resp = $this->get('/api/docs');
+        $resp->assertStatus(403);
+
+        $this->giveUserPermissions($guest, ['access-api']);
+
+        $resp = $this->get('/api/docs');
+        $resp->assertStatus(200);
+    }
+}