Testing: Updated tests to account for recent page redirect changes
This commit is contained in:
parent
30bf0ce632
commit
9d6bc1ad4d
|
@ -184,7 +184,7 @@ class EntityPermissionsTest extends TestCase
|
||||||
|
|
||||||
$this->get($bookUrl . '/edit')->assertRedirect('/');
|
$this->get($bookUrl . '/edit')->assertRedirect('/');
|
||||||
$this->get('/')->assertSee('You do not have permission');
|
$this->get('/')->assertSee('You do not have permission');
|
||||||
$this->get($bookPage->getUrl() . '/edit')->assertRedirect('/');
|
$this->get($bookPage->getUrl() . '/edit')->assertRedirect($bookPage->getUrl());
|
||||||
$this->get('/')->assertSee('You do not have permission');
|
$this->get('/')->assertSee('You do not have permission');
|
||||||
$this->get($bookChapter->getUrl() . '/edit')->assertRedirect('/');
|
$this->get($bookChapter->getUrl() . '/edit')->assertRedirect('/');
|
||||||
$this->get('/')->assertSee('You do not have permission');
|
$this->get('/')->assertSee('You do not have permission');
|
||||||
|
@ -282,7 +282,7 @@ class EntityPermissionsTest extends TestCase
|
||||||
|
|
||||||
$this->get($chapterUrl . '/edit')->assertRedirect('/');
|
$this->get($chapterUrl . '/edit')->assertRedirect('/');
|
||||||
$this->get('/')->assertSee('You do not have permission');
|
$this->get('/')->assertSee('You do not have permission');
|
||||||
$this->get($chapterPage->getUrl() . '/edit')->assertRedirect('/');
|
$this->get($chapterPage->getUrl() . '/edit')->assertRedirect($chapterPage->getUrl());
|
||||||
$this->get('/')->assertSee('You do not have permission');
|
$this->get('/')->assertSee('You do not have permission');
|
||||||
|
|
||||||
$this->setRestrictionsForTestRoles($chapter, ['view', 'update']);
|
$this->setRestrictionsForTestRoles($chapter, ['view', 'update']);
|
||||||
|
@ -341,7 +341,7 @@ class EntityPermissionsTest extends TestCase
|
||||||
|
|
||||||
$this->setRestrictionsForTestRoles($page, ['view', 'delete']);
|
$this->setRestrictionsForTestRoles($page, ['view', 'delete']);
|
||||||
|
|
||||||
$this->get($pageUrl . '/edit')->assertRedirect('/');
|
$this->get($pageUrl . '/edit')->assertRedirect($pageUrl);
|
||||||
$this->get('/')->assertSee('You do not have permission');
|
$this->get('/')->assertSee('You do not have permission');
|
||||||
|
|
||||||
$this->setRestrictionsForTestRoles($page, ['view', 'update']);
|
$this->setRestrictionsForTestRoles($page, ['view', 'update']);
|
||||||
|
@ -565,7 +565,7 @@ class EntityPermissionsTest extends TestCase
|
||||||
|
|
||||||
$this->get($bookUrl . '/edit')->assertRedirect('/');
|
$this->get($bookUrl . '/edit')->assertRedirect('/');
|
||||||
$this->get('/')->assertSee('You do not have permission');
|
$this->get('/')->assertSee('You do not have permission');
|
||||||
$this->get($bookPage->getUrl() . '/edit')->assertRedirect('/');
|
$this->get($bookPage->getUrl() . '/edit')->assertRedirect($bookPage->getUrl());
|
||||||
$this->get('/')->assertSee('You do not have permission');
|
$this->get('/')->assertSee('You do not have permission');
|
||||||
$this->get($bookChapter->getUrl() . '/edit')->assertRedirect('/');
|
$this->get($bookChapter->getUrl() . '/edit')->assertRedirect('/');
|
||||||
$this->get('/')->assertSee('You do not have permission');
|
$this->get('/')->assertSee('You do not have permission');
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace Tests\Permissions;
|
namespace Tests\Permissions;
|
||||||
|
|
||||||
use BookStack\Activity\ActivityType;
|
|
||||||
use BookStack\Activity\Models\Comment;
|
use BookStack\Activity\Models\Comment;
|
||||||
use BookStack\Entities\Models\Book;
|
use BookStack\Entities\Models\Book;
|
||||||
use BookStack\Entities\Models\Bookshelf;
|
use BookStack\Entities\Models\Bookshelf;
|
||||||
|
@ -10,7 +9,6 @@ use BookStack\Entities\Models\Chapter;
|
||||||
use BookStack\Entities\Models\Entity;
|
use BookStack\Entities\Models\Entity;
|
||||||
use BookStack\Entities\Models\Page;
|
use BookStack\Entities\Models\Page;
|
||||||
use BookStack\Uploads\Image;
|
use BookStack\Uploads\Image;
|
||||||
use BookStack\Users\Models\Role;
|
|
||||||
use BookStack\Users\Models\User;
|
use BookStack\Users\Models\User;
|
||||||
use Illuminate\Testing\TestResponse;
|
use Illuminate\Testing\TestResponse;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
@ -152,10 +150,14 @@ class RolePermissionsTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* Check a standard entity access permission.
|
* Check a standard entity access permission.
|
||||||
*/
|
*/
|
||||||
private function checkAccessPermission(string $permission, array $accessUrls = [], array $visibles = [])
|
private function checkAccessPermission(
|
||||||
{
|
string $permission,
|
||||||
|
array $accessUrls = [],
|
||||||
|
array $visibles = [],
|
||||||
|
string $expectedRedirectUri = '/',
|
||||||
|
) {
|
||||||
foreach ($accessUrls as $url) {
|
foreach ($accessUrls as $url) {
|
||||||
$this->actingAs($this->user)->get($url)->assertRedirect('/');
|
$this->actingAs($this->user)->get($url)->assertRedirect($expectedRedirectUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($visibles as $url => $text) {
|
foreach ($visibles as $url => $text) {
|
||||||
|
@ -535,11 +537,11 @@ class RolePermissionsTest extends TestCase
|
||||||
$ownPage->getUrl() . '/edit',
|
$ownPage->getUrl() . '/edit',
|
||||||
], [
|
], [
|
||||||
$ownPage->getUrl() => 'Edit',
|
$ownPage->getUrl() => 'Edit',
|
||||||
]);
|
], $ownPage->getUrl());
|
||||||
|
|
||||||
$resp = $this->get($otherPage->getUrl());
|
$resp = $this->get($otherPage->getUrl());
|
||||||
$this->withHtml($resp)->assertElementNotContains('.action-buttons', 'Edit');
|
$this->withHtml($resp)->assertElementNotContains('.action-buttons', 'Edit');
|
||||||
$this->get($otherPage->getUrl() . '/edit')->assertRedirect('/');
|
$this->get($otherPage->getUrl() . '/edit')->assertRedirect($otherPage->getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_page_edit_all_permission()
|
public function test_page_edit_all_permission()
|
||||||
|
@ -550,7 +552,7 @@ class RolePermissionsTest extends TestCase
|
||||||
$otherPage->getUrl('/edit'),
|
$otherPage->getUrl('/edit'),
|
||||||
], [
|
], [
|
||||||
$otherPage->getUrl() => 'Edit',
|
$otherPage->getUrl() => 'Edit',
|
||||||
]);
|
], $otherPage->getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_page_delete_own_permission()
|
public function test_page_delete_own_permission()
|
||||||
|
|
Loading…
Reference in New Issue