mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Added role permissions for exporting content
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests\Entity;
|
||||
|
||||
use BookStack\Auth\Role;
|
||||
use BookStack\Entities\Models\Book;
|
||||
use BookStack\Entities\Models\Chapter;
|
||||
use BookStack\Entities\Models\Page;
|
||||
@ -340,4 +341,29 @@ class ExportTest extends TestCase
|
||||
$resp->assertSee('# ' . $chapter->name);
|
||||
$resp->assertSee('# ' . $page->name);
|
||||
}
|
||||
|
||||
public function test_export_option_only_visible_and_accessible_with_permission()
|
||||
{
|
||||
$book = Book::query()->whereHas('pages')->whereHas('chapters')->first();
|
||||
$chapter = $book->chapters()->first();
|
||||
$page = $chapter->pages()->first();
|
||||
$entities = [$book, $chapter, $page];
|
||||
$user = $this->getViewer();
|
||||
$this->actingAs($user);
|
||||
|
||||
foreach ($entities as $entity) {
|
||||
$resp = $this->get($entity->getUrl());
|
||||
$resp->assertSee("/export/pdf");
|
||||
}
|
||||
|
||||
/** @var Role $role */
|
||||
$this->removePermissionFromUser($user, 'content-export');
|
||||
|
||||
foreach ($entities as $entity) {
|
||||
$resp = $this->get($entity->getUrl());
|
||||
$resp->assertDontSee("/export/pdf");
|
||||
$resp = $this->get($entity->getUrl("/export/pdf"));
|
||||
$this->assertPermissionError($resp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user