- gate implementation

- protected shared view fix
This commit is contained in:
Čarodej
2021-09-24 10:52:19 +02:00
parent d40108f6a9
commit 19cc01131b
84 changed files with 876 additions and 406 deletions

View File

@@ -1,4 +1,5 @@
<?php
namespace Tests\Domain\Sharing;
use Storage;
@@ -53,7 +54,7 @@ class VisitorAccessToItemsTest extends TestCase
->assertStatus(200);
}
if (! $is_protected) {
if (!$is_protected) {
// Get shared file
$this->get("/file/$document->name/$share->token")
->assertStatus(200);
@@ -66,10 +67,21 @@ class VisitorAccessToItemsTest extends TestCase
*/
public function it_try_to_get_protected_file_record()
{
$user = User::factory(User::class)
->create();
$file = File::factory(File::class)
->create([
'user_id' => $user->id,
'name' => 'fake-thumbnail.jpg',
]);
$share = Share::factory(Share::class)
->create([
'type' => 'file',
'is_protected' => true,
'user_id' => $user->id,
'item_id' => $file->id,
]);
// Get share record
@@ -123,7 +135,7 @@ class VisitorAccessToItemsTest extends TestCase
->assertStatus(200);
}
if (! $is_protected) {
if (!$is_protected) {
$this->get("/share/$share->token")
->assertStatus(200);
}
@@ -174,7 +186,7 @@ class VisitorAccessToItemsTest extends TestCase
->assertStatus(200);
}
if (! $is_protected) {
if (!$is_protected) {
$this->get("/thumbnail/$thumbnail->name/$share->token")
->assertStatus(200);
}

View File

@@ -1,5 +1,4 @@
<?php
namespace Tests\Domain\Sharing;
use Tests\TestCase;
@@ -160,7 +159,7 @@ class VisitorBrowseTest extends TestCase
$file = File::factory(File::class)
->create([
'folder_id' => $root->id,
'parent_id' => $root->id,
'name' => 'Document',
'basename' => 'document.pdf',
'mimetype' => 'application/pdf',
@@ -189,7 +188,7 @@ class VisitorBrowseTest extends TestCase
}
// Check public shared item
if (!$is_protected) {
if (! $is_protected) {
$this->getJson("/api/browse/folders/$root->id/$share->token")
->assertStatus(200)
->assertJsonFragment([
@@ -304,7 +303,7 @@ class VisitorBrowseTest extends TestCase
}
// Check public shared item
if (!$is_protected) {
if (! $is_protected) {
$this->getJson("/api/browse/navigation/$share->token")
->assertStatus(200)
->assertExactJson($tree);
@@ -336,7 +335,7 @@ class VisitorBrowseTest extends TestCase
$file = File::factory(File::class)
->create([
'name' => 'Document',
'folder_id' => $folder->id,
'parent_id' => $folder->id,
'user_id' => $folder->user_id,
]);
@@ -356,7 +355,7 @@ class VisitorBrowseTest extends TestCase
}
// Check public shared item
if (!$is_protected) {
if (! $is_protected) {
$this->getJson("/api/browse/search/$share->token?query=doc")
->assertStatus(200)
->assertJsonFragment([
@@ -407,7 +406,7 @@ class VisitorBrowseTest extends TestCase
}
// Check public shared item
if (!$is_protected) {
if (! $is_protected) {
$this->getJson("/api/browse/search/$share->token?query=doc")
->assertStatus(200)
->assertJsonFragment([]);
@@ -454,7 +453,7 @@ class VisitorBrowseTest extends TestCase
}
// Check public shared item
if (!$is_protected) {
if (! $is_protected) {
$this->getJson("/api/browse/file/$share->token")
->assertStatus(200)
->assertJsonFragment([

View File

@@ -29,7 +29,8 @@ class VisitorManipulatingTest extends TestCase
$file = File::factory(File::class)
->create([
'folder_id' => $folder->id,
'parent_id' => $folder->id,
'user_id' => $user->id,
]);
$share = Share::factory(Share::class)
@@ -240,7 +241,8 @@ class VisitorManipulatingTest extends TestCase
$files = File::factory(File::class)
->count(2)
->create([
'folder_id' => $folder->id,
'user_id' => $user->id,
'parent_id' => $folder->id,
]);
$payload = [
@@ -327,7 +329,7 @@ class VisitorManipulatingTest extends TestCase
->post("/api/editor/upload/$share->token", [
'filename' => $file->name,
'file' => $file,
'folder_id' => $folder->id,
'parent_id' => $folder->id,
'is_last' => 'true',
])->assertStatus(201);
}
@@ -337,7 +339,7 @@ class VisitorManipulatingTest extends TestCase
$this->postJson("/api/editor/upload/$share->token", [
'filename' => $file->name,
'file' => $file,
'folder_id' => $folder->id,
'parent_id' => $folder->id,
'is_last' => 'true',
])->assertStatus(201);
}
@@ -378,7 +380,7 @@ class VisitorManipulatingTest extends TestCase
$file = File::factory(File::class)
->create([
'user_id' => $user->id,
'folder_id' => $root->id,
'parent_id' => $root->id,
]);
$share = Share::factory(Share::class)
@@ -421,7 +423,7 @@ class VisitorManipulatingTest extends TestCase
$this->assertDatabaseHas('files', [
'id' => $file->id,
'folder_id' => $children->id,
'parent_id' => $children->id,
]);
});
}