mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-30 12:38:12 +08:00
Rolled out new permissions system throughout application
This commit is contained in:
@ -4,12 +4,14 @@ class RestrictionsTest extends TestCase
|
||||
{
|
||||
protected $user;
|
||||
protected $viewer;
|
||||
protected $restrictionService;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->user = $this->getNewUser();
|
||||
$this->viewer = $this->getViewer();
|
||||
$this->restrictionService = $this->app[\BookStack\Services\RestrictionService::class];
|
||||
}
|
||||
|
||||
protected function getViewer()
|
||||
@ -43,6 +45,8 @@ class RestrictionsTest extends TestCase
|
||||
}
|
||||
$entity->save();
|
||||
$entity->load('restrictions');
|
||||
$this->restrictionService->buildEntityPermissionsForEntity($entity);
|
||||
$entity->load('permissions');
|
||||
}
|
||||
|
||||
public function test_book_view_restriction()
|
||||
|
@ -7,7 +7,15 @@ class RolesTest extends TestCase
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->user = $this->getNewBlankUser();
|
||||
$this->user = $this->getViewer();
|
||||
}
|
||||
|
||||
protected function getViewer()
|
||||
{
|
||||
$role = \BookStack\Role::getRole('viewer');
|
||||
$viewer = $this->getNewBlankUser();
|
||||
$viewer->attachRole($role);;
|
||||
return $viewer;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,7 +149,7 @@ class RolesTest extends TestCase
|
||||
|
||||
public function test_restrictions_manage_own_permission()
|
||||
{
|
||||
$otherUsersPage = \BookStack\Page::take(1)->get()->first();
|
||||
$otherUsersPage = \BookStack\Page::first();
|
||||
$content = $this->createEntityChainBelongingToUser($this->user);
|
||||
// Check can't restrict other's content
|
||||
$this->actingAs($this->user)->visit($otherUsersPage->getUrl())
|
||||
|
@ -65,6 +65,8 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
$page = factory(BookStack\Page::class)->create(['created_by' => $creatorUser->id, 'updated_by' => $updaterUser->id, 'book_id' => $book->id]);
|
||||
$book->chapters()->saveMany([$chapter]);
|
||||
$chapter->pages()->saveMany([$page]);
|
||||
$restrictionService = $this->app[\BookStack\Services\RestrictionService::class];
|
||||
$restrictionService->buildEntityPermissionsForEntity($book);
|
||||
return [
|
||||
'book' => $book,
|
||||
'chapter' => $chapter,
|
||||
|
Reference in New Issue
Block a user