]> BookStack Code Mirror - bookstack/blobdiff - tests/Api/ApiDocsTest.php
New translations settings.php (Chinese Simplified)
[bookstack] / tests / Api / ApiDocsTest.php
index b240c1672d17fb219f98c4f0c1338aaba5efd544..1687c64a17e10a7a5110166d251be7c2721afcf1 100644 (file)
@@ -1,6 +1,7 @@
-<?php
+<?php namespace Tests\Api;
 
-namespace Tests;
+use BookStack\Auth\User;
+use Tests\TestCase;
 
 class ApiDocsTest extends TestCase
 {
@@ -39,4 +40,19 @@ class ApiDocsTest extends TestCase
             ] ]
         ]);
     }
+
+    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);
+    }
 }
\ No newline at end of file