share routes refactoring

This commit is contained in:
Čarodej
2022-05-13 11:40:39 +02:00
parent c0e431b384
commit 69a48e8925
35 changed files with 267 additions and 145 deletions

View File

@@ -69,7 +69,7 @@ class HomepageTest extends TestCase
]);
$this
->get("/api/og-site/$share->token")
->get("/api/sharing/og-site/$share->token")
->assertStatus(200)
->assertSee('Folder Title');
}
@@ -100,7 +100,7 @@ class HomepageTest extends TestCase
]);
$this
->get("/api/og-site/$share->token")
->get("/api/sharing/og-site/$share->token")
->assertStatus(200)
->assertSee('Fake Image')
->assertSee('lg-fake-image.jpg');
@@ -132,7 +132,7 @@ class HomepageTest extends TestCase
]);
$this
->get("/api/og-site/$share->token")
->get("/api/sharing/og-site/$share->token")
->assertStatus(200)
->assertSee('This link is protected by password');
}
@@ -153,7 +153,7 @@ class HomepageTest extends TestCase
'email' => 'john@doe.com',
'message' => 'Whaats is up!',
])
->assertStatus(201);
->assertStatus(200);
Mail::assertSent(SendContactMessage::class);
}

View File

@@ -138,7 +138,7 @@ class VisitorAccessToItemsTest extends TestCase
]);
// Get share record
$this->get("/api/browse/file/$share->token")
$this->get("/api/sharing/file/$share->token")
->assertStatus(403);
}

View File

@@ -93,7 +93,7 @@ class VisitorBrowseTest extends TestCase
'password' => bcrypt('secret'),
]);
$this->postJson("/api/browse/authenticate/$share->token", [
$this->postJson("/api/sharing/authenticate/$share->token", [
'password' => 'secret',
])
->assertStatus(200)
@@ -120,7 +120,7 @@ class VisitorBrowseTest extends TestCase
'password' => bcrypt('secret'),
]);
$this->postJson("/api/browse/authenticate/$share->token", [
$this->postJson("/api/sharing/authenticate/$share->token", [
'password' => 'bad-password',
])
->assertStatus(401)
@@ -298,14 +298,14 @@ class VisitorBrowseTest extends TestCase
$this
->withUnencryptedCookies($cookie)
->get("/api/browse/navigation/$share->token")
->get("/api/sharing/navigation/$share->token")
->assertStatus(200)
->assertExactJson($tree);
}
// Check public shared item
if (! $is_protected) {
$this->getJson("/api/browse/navigation/$share->token")
$this->getJson("/api/sharing/navigation/$share->token")
->assertStatus(200)
->assertExactJson($tree);
}
@@ -348,7 +348,7 @@ class VisitorBrowseTest extends TestCase
])];
$this->withUnencryptedCookies($cookie)
->get("/api/search/$share->token?query=doc")
->get("/api/sharing/search/$share->token?query=doc")
->assertStatus(200)
->assertJsonFragment([
'id' => $file->id,
@@ -357,7 +357,7 @@ class VisitorBrowseTest extends TestCase
// Check public shared item
if (! $is_protected) {
$this->getJson("/api/search/$share->token?query=doc")
$this->getJson("/api/sharing/search/$share->token?query=doc")
->assertStatus(200)
->assertJsonFragment([
'id' => $file->id,
@@ -401,14 +401,14 @@ class VisitorBrowseTest extends TestCase
])];
$this->withUnencryptedCookies($cookie)
->get("/api/search/$share->token?query=doc")
->get("/api/sharing/search/$share->token?query=doc")
->assertStatus(200)
->assertJsonFragment([]);
}
// Check public shared item
if (! $is_protected) {
$this->getJson("/api/search/$share->token?query=doc")
$this->getJson("/api/sharing/search/$share->token?query=doc")
->assertStatus(200)
->assertJsonFragment([]);
}
@@ -446,7 +446,7 @@ class VisitorBrowseTest extends TestCase
])];
$this->withUnencryptedCookies($cookie)
->get("/api/browse/file/$share->token")
->get("/api/sharing/file/$share->token")
->assertStatus(200)
->assertJsonFragment([
'name' => 'Document',
@@ -455,7 +455,7 @@ class VisitorBrowseTest extends TestCase
// Check public shared item
if (! $is_protected) {
$this->getJson("/api/browse/file/$share->token")
$this->getJson("/api/sharing/file/$share->token")
->assertStatus(200)
->assertJsonFragment([
'name' => 'Document',

View File

@@ -52,7 +52,7 @@ class VisitorManipulatingTest extends TestCase
$this
->withUnencryptedCookies($cookie)
->patch("/api/editor/rename/{$file->id}/$share->token", [
->patch("/api/sharing/rename/{$file->id}/$share->token", [
'name' => 'Renamed Item',
'type' => 'file',
])
@@ -64,7 +64,7 @@ class VisitorManipulatingTest extends TestCase
// Check public shared item
if (! $is_protected) {
$this->patchJson("/api/editor/rename/{$file->id}/$share->token", [
$this->patchJson("/api/sharing/rename/{$file->id}/$share->token", [
'name' => 'Renamed Item',
'type' => 'file',
])
@@ -122,7 +122,7 @@ class VisitorManipulatingTest extends TestCase
$this
->withUnencryptedCookies($cookie)
->patch("/api/editor/rename/{$children->id}/$share->token", [
->patch("/api/sharing/rename/{$children->id}/$share->token", [
'name' => 'Renamed Folder',
'type' => 'folder',
])
@@ -134,7 +134,7 @@ class VisitorManipulatingTest extends TestCase
// Check public shared item
if (! $is_protected) {
$this->patchJson("/api/editor/rename/{$children->id}/$share->token", [
$this->patchJson("/api/sharing/rename/{$children->id}/$share->token", [
'name' => 'Renamed Folder',
'type' => 'folder',
])
@@ -186,7 +186,7 @@ class VisitorManipulatingTest extends TestCase
$this
->withUnencryptedCookies($cookie)
->post("/api/editor/create-folder/$share->token", [
->post("/api/sharing/create-folder/$share->token", [
'name' => 'Awesome New Folder',
'parent_id' => $folder->id,
])
@@ -198,7 +198,7 @@ class VisitorManipulatingTest extends TestCase
// Check public shared item
if (! $is_protected) {
$this->postJson("/api/editor/create-folder/$share->token", [
$this->postJson("/api/sharing/create-folder/$share->token", [
'name' => 'Awesome New Folder',
'parent_id' => $folder->id,
])
@@ -272,13 +272,13 @@ class VisitorManipulatingTest extends TestCase
$this
->withUnencryptedCookies($cookie)
->post("/api/editor/remove/$share->token", $payload)
->post("/api/sharing/remove/$share->token", $payload)
->assertStatus(204);
}
// Check public shared item
if (! $is_protected) {
$this->postJson("/api/editor/remove/$share->token", $payload)
$this->postJson("/api/sharing/remove/$share->token", $payload)
->assertStatus(204);
}
@@ -329,7 +329,7 @@ class VisitorManipulatingTest extends TestCase
$this
->withUnencryptedCookies($cookie)
->post("/api/editor/upload/chunks/$share->token", [
->post("/api/sharing/upload/chunks/$share->token", [
'name' => $file->name,
'extension' => 'pdf',
'chunk' => $file,
@@ -340,7 +340,7 @@ class VisitorManipulatingTest extends TestCase
// Check public shared item
if (! $is_protected) {
$this->postJson("/api/editor/upload/chunks/$share->token", [
$this->postJson("/api/sharing/upload/chunks/$share->token", [
'name' => $file->name,
'extension' => 'pdf',
'chunk' => $file,
@@ -414,14 +414,14 @@ class VisitorManipulatingTest extends TestCase
$this
->withUnencryptedCookies($cookie)
->post("/api/editor/move/$share->token", $payload)
->assertStatus(204);
->post("/api/sharing/move/$share->token", $payload)
->assertStatus(200);
}
// Check public shared item
if (! $is_protected) {
$this->postJson("/api/editor/move/$share->token", $payload)
->assertStatus(204);
$this->postJson("/api/sharing/move/$share->token", $payload)
->assertStatus(200);
}
$this->assertDatabaseHas('files', [
@@ -487,14 +487,14 @@ class VisitorManipulatingTest extends TestCase
$this
->withUnencryptedCookies($cookie)
->post("/api/editor/move/$share->token", $payload)
->assertStatus(204);
->post("/api/sharing/move/$share->token", $payload)
->assertStatus(200);
}
// Check public shared item
if (! $is_protected) {
$this->postJson("/api/editor/move/$share->token", $payload)
->assertStatus(204);
$this->postJson("/api/sharing/move/$share->token", $payload)
->assertStatus(200);
}
$this->assertDatabaseHas('folders', [

View File

@@ -113,7 +113,7 @@ class TrafficTest extends TestCase
]);
// Check public shared item
$this->postJson("/api/editor/upload/chunks/$share->token", [
$this->postJson("/api/sharing/upload/chunks/$share->token", [
'name' => $this->file->name,
'chunk' => $this->file,
'parent_id' => $folder->id,