2021-06-26 11:23:15 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Permissions;
|
2020-12-18 08:56:00 -05:00
|
|
|
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class ExportPermissionsTest extends TestCase
|
|
|
|
{
|
|
|
|
public function test_page_content_without_view_access_hidden_on_chapter_export()
|
|
|
|
{
|
2022-09-29 12:31:38 -04:00
|
|
|
$chapter = $this->entities->chapter();
|
2020-12-18 08:56:00 -05:00
|
|
|
$page = $chapter->pages()->firstOrFail();
|
|
|
|
$pageContent = Str::random(48);
|
|
|
|
$page->html = '<p>' . $pageContent . '</p>';
|
|
|
|
$page->save();
|
2023-01-21 06:08:34 -05:00
|
|
|
$viewer = $this->users->viewer();
|
2020-12-18 08:56:00 -05:00
|
|
|
$this->actingAs($viewer);
|
|
|
|
$formats = ['html', 'plaintext'];
|
|
|
|
|
|
|
|
foreach ($formats as $format) {
|
|
|
|
$resp = $this->get($chapter->getUrl("export/{$format}"));
|
|
|
|
$resp->assertStatus(200);
|
|
|
|
$resp->assertSee($page->name);
|
|
|
|
$resp->assertSee($pageContent);
|
|
|
|
}
|
|
|
|
|
2023-01-21 06:08:34 -05:00
|
|
|
$this->permissions->setEntityPermissions($page, []);
|
2020-12-18 08:56:00 -05:00
|
|
|
|
|
|
|
foreach ($formats as $format) {
|
|
|
|
$resp = $this->get($chapter->getUrl("export/{$format}"));
|
|
|
|
$resp->assertStatus(200);
|
|
|
|
$resp->assertDontSee($page->name);
|
|
|
|
$resp->assertDontSee($pageContent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function test_page_content_without_view_access_hidden_on_book_export()
|
|
|
|
{
|
2022-09-29 12:31:38 -04:00
|
|
|
$book = $this->entities->book();
|
2020-12-18 08:56:00 -05:00
|
|
|
$page = $book->pages()->firstOrFail();
|
|
|
|
$pageContent = Str::random(48);
|
|
|
|
$page->html = '<p>' . $pageContent . '</p>';
|
|
|
|
$page->save();
|
2023-01-21 06:08:34 -05:00
|
|
|
$viewer = $this->users->viewer();
|
2020-12-18 08:56:00 -05:00
|
|
|
$this->actingAs($viewer);
|
|
|
|
$formats = ['html', 'plaintext'];
|
|
|
|
|
|
|
|
foreach ($formats as $format) {
|
|
|
|
$resp = $this->get($book->getUrl("export/{$format}"));
|
|
|
|
$resp->assertStatus(200);
|
|
|
|
$resp->assertSee($page->name);
|
|
|
|
$resp->assertSee($pageContent);
|
|
|
|
}
|
|
|
|
|
2023-01-21 06:08:34 -05:00
|
|
|
$this->permissions->setEntityPermissions($page, []);
|
2020-12-18 08:56:00 -05:00
|
|
|
|
|
|
|
foreach ($formats as $format) {
|
|
|
|
$resp = $this->get($book->getUrl("export/{$format}"));
|
|
|
|
$resp->assertStatus(200);
|
|
|
|
$resp->assertDontSee($page->name);
|
|
|
|
$resp->assertDontSee($pageContent);
|
|
|
|
}
|
|
|
|
}
|
2021-06-26 11:23:15 -04:00
|
|
|
}
|