test(api): upgrade tests to new routes (don't use deprecated routes anymore)
This commit is contained in:
@@ -164,15 +164,15 @@ HTTP 204
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
# Step 7 – Permanently delete file 1 from trash
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
GET {{base_url}}/api/trash
|
||||
GET {{base_url}}/api/trash/resources
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
HTTP 200
|
||||
[Captures]
|
||||
trash_item1_id: jsonpath "$[?(@.original_id == '{{file1_id}}')].id"
|
||||
trash_item1_id: jsonpath "$.items[?(@.resource.id == '{{file1_id}}')].resource.id"
|
||||
[Asserts]
|
||||
jsonpath "$[?(@.original_id == '{{file1_id}}')].id" isString
|
||||
jsonpath "$[?(@.original_id == '{{file1_id}}')].item_type" == "file"
|
||||
jsonpath "$.items[?(@.resource.id == '{{file1_id}}')].resource.id" isString
|
||||
jsonpath "$.items[?(@.resource.id == '{{file1_id}}')].resource_type" == "file"
|
||||
|
||||
|
||||
DELETE {{base_url}}/api/trash/{{trash_item1_id}}
|
||||
@@ -219,15 +219,15 @@ HTTP 204
|
||||
# Step 10 – Permanently delete file 2 from trash
|
||||
# ref_count hits 0 → blob and its disk thumbnail deleted
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
GET {{base_url}}/api/trash
|
||||
GET {{base_url}}/api/trash/resources
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
HTTP 200
|
||||
[Captures]
|
||||
trash_item2_id: jsonpath "$[?(@.original_id == '{{file2_id}}')].id"
|
||||
trash_item2_id: jsonpath "$.items[?(@.resource.id == '{{file2_id}}')].resource.id"
|
||||
[Asserts]
|
||||
jsonpath "$[?(@.original_id == '{{file2_id}}')].id" isString
|
||||
jsonpath "$[?(@.original_id == '{{file2_id}}')].item_type" == "file"
|
||||
jsonpath "$.items[?(@.resource.id == '{{file2_id}}')].resource.id" isString
|
||||
jsonpath "$.items[?(@.resource.id == '{{file2_id}}')].resource_type" == "file"
|
||||
|
||||
|
||||
DELETE {{base_url}}/api/trash/{{trash_item2_id}}
|
||||
@@ -254,15 +254,15 @@ Authorization: Bearer {{token}}
|
||||
HTTP 204
|
||||
|
||||
|
||||
GET {{base_url}}/api/trash
|
||||
GET {{base_url}}/api/trash/resources
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
HTTP 200
|
||||
[Captures]
|
||||
trash_folder_id: jsonpath "$[?(@.original_id == '{{test_folder_id}}')].id"
|
||||
trash_folder_id: jsonpath "$.items[?(@.resource.id == '{{test_folder_id}}')].resource.id"
|
||||
[Asserts]
|
||||
jsonpath "$[?(@.original_id == '{{test_folder_id}}')].id" isString
|
||||
jsonpath "$[?(@.original_id == '{{test_folder_id}}')].item_type" == "folder"
|
||||
jsonpath "$.items[?(@.resource.id == '{{test_folder_id}}')].resource.id" isString
|
||||
jsonpath "$.items[?(@.resource.id == '{{test_folder_id}}')].resource_type" == "folder"
|
||||
|
||||
|
||||
DELETE {{base_url}}/api/trash/{{trash_folder_id}}
|
||||
|
||||
@@ -51,16 +51,16 @@ HTTP 200
|
||||
home_folder_id: jsonpath "$[0].id"
|
||||
|
||||
|
||||
GET {{base_url}}/api/folders/{{home_folder_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{home_folder_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
HTTP 200
|
||||
[Captures]
|
||||
test1_id: jsonpath "$[0].id"
|
||||
test2_id: jsonpath "$[1].id"
|
||||
test1_id: jsonpath "$.items[0].resource.id"
|
||||
test2_id: jsonpath "$.items[1].resource.id"
|
||||
[Asserts]
|
||||
jsonpath "$[0].name" == "test1"
|
||||
jsonpath "$[1].name" == "test2-renamed"
|
||||
jsonpath "$.items[0].resource.name" == "test1"
|
||||
jsonpath "$.items[1].resource.name" == "test2-renamed"
|
||||
|
||||
|
||||
GET {{base_url}}/api/files?folder_id={{test2_id}}
|
||||
|
||||
@@ -47,13 +47,13 @@ jsonpath "$[0].parent_id" == null
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
# Step 3 – Browse the home folder: sub-folders must be empty
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
GET {{base_url}}/api/folders/{{home_folder_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{home_folder_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$" isCollection
|
||||
jsonpath "$" count == 0
|
||||
jsonpath "$.items" isCollection
|
||||
jsonpath "$.items" count == 0
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
@@ -127,28 +127,28 @@ jsonpath "$.parent_id" == {{test1_id}}
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
# Step 8 – Home folder now has exactly one sub-folder (test1)
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
GET {{base_url}}/api/folders/{{home_folder_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{home_folder_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$" count == 1
|
||||
jsonpath "$[0].id" == {{test1_id}}
|
||||
jsonpath "$[0].name" == "test1"
|
||||
jsonpath "$.items" count == 1
|
||||
jsonpath "$.items[0].resource.id" == {{test1_id}}
|
||||
jsonpath "$.items[0].resource.name" == "test1"
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
# Step 9 – test1 has exactly one sub-folder (test2)
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
GET {{base_url}}/api/folders/{{test1_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{test1_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$" count == 1
|
||||
jsonpath "$[0].id" == {{test2_id}}
|
||||
jsonpath "$[0].name" == "test2"
|
||||
jsonpath "$[0].parent_id" == {{test1_id}}
|
||||
jsonpath "$.items" count == 1
|
||||
jsonpath "$.items[0].resource.id" == {{test2_id}}
|
||||
jsonpath "$.items[0].resource.name" == "test2"
|
||||
jsonpath "$.items[0].resource.parent_id" == {{test1_id}}
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
@@ -208,25 +208,25 @@ jsonpath "$.parent_id" == {{home_folder_id}}
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
# Step 13 – test1 is now empty (test2 was its only child)
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
GET {{base_url}}/api/folders/{{test1_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{test1_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$" count == 0
|
||||
jsonpath "$.items" count == 0
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
# Step 14 – Home folder now has two sub-folders: test1 and test2
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
GET {{base_url}}/api/folders/{{home_folder_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{home_folder_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$" count == 2
|
||||
jsonpath "$[*].id" contains {{test1_id}}
|
||||
jsonpath "$[*].id" contains {{test2_id}}
|
||||
jsonpath "$.items" count == 2
|
||||
jsonpath "$.items[*].resource.id" contains {{test1_id}}
|
||||
jsonpath "$.items[*].resource.id" contains {{test2_id}}
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -386,7 +386,7 @@ perm_file_id: jsonpath "$.id"
|
||||
# ════════════════════════════════════════════════════════════════════
|
||||
|
||||
# ── Folder reads ─────────────────────────────────────────────
|
||||
GET {{base_url}}/api/folders/{{perm_folder_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{perm_folder_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{adam_token}}
|
||||
|
||||
HTTP 404
|
||||
@@ -506,13 +506,13 @@ Content-Type: application/json
|
||||
HTTP 201
|
||||
|
||||
# ── Read endpoints now succeed ──────────────────────────────
|
||||
GET {{base_url}}/api/folders/{{perm_folder_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{perm_folder_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{adam_token}}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$" count == 1
|
||||
jsonpath "$[0].id" == "{{perm_child_id}}"
|
||||
jsonpath "$.items" count == 1
|
||||
jsonpath "$.items[0].resource.id" == "{{perm_child_id}}"
|
||||
|
||||
GET {{base_url}}/api/folders/{{perm_folder_id}}/resources
|
||||
Authorization: Bearer {{adam_token}}
|
||||
@@ -557,7 +557,7 @@ HTTP 200
|
||||
header "Content-Type" startsWith "image/"
|
||||
|
||||
# ── Cascading: child folder also readable via parent's grant ─
|
||||
GET {{base_url}}/api/folders/{{perm_child_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{perm_child_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{adam_token}}
|
||||
|
||||
HTTP 200
|
||||
|
||||
@@ -154,7 +154,7 @@ perm_file_id: jsonpath "$.id"
|
||||
# ════════════════════════════════════════════════════════════════════
|
||||
|
||||
# ── Folder reads ─────────────────────────────────────────────
|
||||
GET {{base_url}}/api/folders/{{perm_folder_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{perm_folder_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{henry_token}}
|
||||
|
||||
HTTP 404
|
||||
@@ -288,13 +288,13 @@ jsonpath "$[0].subject.type" == "group"
|
||||
jsonpath "$[0].subject.id" == "{{group_a_id}}"
|
||||
|
||||
# ── Read endpoints now succeed ──────────────────────────────
|
||||
GET {{base_url}}/api/folders/{{perm_folder_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{perm_folder_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{henry_token}}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$" count == 1
|
||||
jsonpath "$[0].id" == "{{perm_child_id}}"
|
||||
jsonpath "$.items" count == 1
|
||||
jsonpath "$.items[0].resource.id" == "{{perm_child_id}}"
|
||||
|
||||
GET {{base_url}}/api/folders/{{perm_folder_id}}/resources
|
||||
Authorization: Bearer {{henry_token}}
|
||||
@@ -339,7 +339,7 @@ HTTP 200
|
||||
header "Content-Type" startsWith "image/"
|
||||
|
||||
# ── Folder cascade through ltree: child also readable. ──────
|
||||
GET {{base_url}}/api/folders/{{perm_child_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{perm_child_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{henry_token}}
|
||||
|
||||
HTTP 200
|
||||
@@ -582,7 +582,7 @@ Authorization: Bearer {{alice_token}}
|
||||
HTTP 204
|
||||
|
||||
# Confirm access is gone.
|
||||
GET {{base_url}}/api/folders/{{perm_folder_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{perm_folder_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{henry_token}}
|
||||
|
||||
HTTP 404
|
||||
@@ -599,7 +599,7 @@ Content-Type: application/json
|
||||
|
||||
HTTP 201
|
||||
|
||||
GET {{base_url}}/api/folders/{{perm_folder_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{perm_folder_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{henry_token}}
|
||||
|
||||
HTTP 200
|
||||
|
||||
+10
-10
@@ -267,14 +267,14 @@ jsonpath "$.error_type" == "Not Found"
|
||||
# Step 15 – Admin's private folder still exists & is untouched.
|
||||
# Bob's attacks must not have polluted admin's tree.
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
GET {{base_url}}/api/folders/{{admin_home_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{admin_home_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{admin_token}}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$[*].id" contains {{admin_private_id}}
|
||||
jsonpath "$[*].name" not contains "bob-attack-1"
|
||||
jsonpath "$[*].name" not contains "bob-attack-2"
|
||||
jsonpath "$.items[*].resource.id" contains {{admin_private_id}}
|
||||
jsonpath "$.items[*].resource.name" not contains "bob-attack-1"
|
||||
jsonpath "$.items[*].resource.name" not contains "bob-attack-2"
|
||||
|
||||
|
||||
# ═════════════════════════════════════════════════════════════
|
||||
@@ -323,22 +323,22 @@ HTTP 201
|
||||
# This proves the path prefix re-rooted the attack
|
||||
# into bob's own namespace.
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
GET {{base_url}}/api/folders/{{bob_home_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{bob_home_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{bob_token}}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$[*].name" contains "bob-webdav-own"
|
||||
jsonpath "$[*].name" contains "My Folder - admin"
|
||||
jsonpath "$.items[*].resource.name" contains "bob-webdav-own"
|
||||
jsonpath "$.items[*].resource.name" contains "My Folder - admin"
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
# Step 19 – Admin's tree is unchanged by bob's WebDAV traffic.
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
GET {{base_url}}/api/folders/{{admin_home_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{admin_home_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{admin_token}}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$[*].name" not contains "bob-webdav-attack"
|
||||
jsonpath "$[*].name" not contains "bob-webdav-own"
|
||||
jsonpath "$.items[*].resource.name" not contains "bob-webdav-attack"
|
||||
jsonpath "$.items[*].resource.name" not contains "bob-webdav-own"
|
||||
|
||||
@@ -39,14 +39,14 @@ HTTP 200
|
||||
home_folder_id: jsonpath "$[0].id"
|
||||
|
||||
|
||||
GET {{base_url}}/api/folders/{{home_folder_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{home_folder_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
HTTP 200
|
||||
[Captures]
|
||||
test2_id: jsonpath "$[1].id"
|
||||
test2_id: jsonpath "$.items[1].resource.id"
|
||||
[Asserts]
|
||||
jsonpath "$[1].name" == "test2-renamed"
|
||||
jsonpath "$.items[1].resource.name" == "test2-renamed"
|
||||
|
||||
|
||||
GET {{base_url}}/api/files?folder_id={{test2_id}}
|
||||
|
||||
@@ -139,7 +139,7 @@ log "Trash emptied."
|
||||
|
||||
# ── 3b. Verify trash is empty according to the API ───────────────────────────
|
||||
|
||||
TRASH_COUNT=$(curl -sf -H "$AUTH" "$base_url/api/trash" | jq 'length')
|
||||
TRASH_COUNT=$(curl -sf -H "$AUTH" "$base_url/api/trash/resources" | jq '.items | length')
|
||||
if [[ "$TRASH_COUNT" -ne 0 ]]; then
|
||||
fail "trash still contains $TRASH_COUNT item(s) after empty"
|
||||
fi
|
||||
|
||||
+25
-20
@@ -29,13 +29,13 @@ jsonpath "$.access_token" isString
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
# Step 2 – Trash is empty at the start
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
GET {{base_url}}/api/trash
|
||||
GET {{base_url}}/api/trash/resources
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$" isCollection
|
||||
jsonpath "$" count == 0
|
||||
jsonpath "$.items" isCollection
|
||||
jsonpath "$.items" count == 0
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
@@ -93,30 +93,35 @@ HTTP 204
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
# Step 7 – Trash contains exactly the "to-delete" folder
|
||||
# Step 7 – Trash contains exactly the "to-delete" folder.
|
||||
# In the soft-delete trash model, the trash entry id
|
||||
# equals the original resource id (see
|
||||
# `storage.trash_items` view + `row_to_trashed_item`),
|
||||
# so `resource.id` is what `POST /api/trash/{id}/restore`
|
||||
# and `DELETE /api/trash/{id}` accept.
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
GET {{base_url}}/api/trash
|
||||
GET {{base_url}}/api/trash/resources
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
HTTP 200
|
||||
[Captures]
|
||||
trash_id: jsonpath "$[0].id"
|
||||
trash_id: jsonpath "$.items[0].resource.id"
|
||||
[Asserts]
|
||||
jsonpath "$" count == 1
|
||||
jsonpath "$[0].item_type" == "folder"
|
||||
jsonpath "$[0].name" == "to-delete"
|
||||
jsonpath "$[0].original_id" == {{to_delete_id}}
|
||||
jsonpath "$.items" count == 1
|
||||
jsonpath "$.items[0].resource_type" == "folder"
|
||||
jsonpath "$.items[0].resource.name" == "to-delete"
|
||||
jsonpath "$.items[0].resource.id" == {{to_delete_id}}
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
# Step 8 – "to-delete" is no longer listed in the home folder
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
GET {{base_url}}/api/folders/{{home_folder_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{home_folder_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$[*].name" not contains "to-delete"
|
||||
jsonpath "$.items[*].resource.name" not contains "to-delete"
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
@@ -133,12 +138,12 @@ jsonpath "$.success" == true
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
# Step 10 – "to-delete" folder is back in the home folder
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
GET {{base_url}}/api/folders/{{home_folder_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{home_folder_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$[*].name" contains "to-delete"
|
||||
jsonpath "$.items[*].resource.name" contains "to-delete"
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
@@ -156,12 +161,12 @@ jsonpath "$[0].name" == "hello.txt"
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
# Step 12 – Trash is empty after restore
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
GET {{base_url}}/api/trash
|
||||
GET {{base_url}}/api/trash/resources
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$" count == 0
|
||||
jsonpath "$.items" count == 0
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
@@ -187,20 +192,20 @@ jsonpath "$.success" == true
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
# Step 15 – Trash is empty after purge
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
GET {{base_url}}/api/trash
|
||||
GET {{base_url}}/api/trash/resources
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$" count == 0
|
||||
jsonpath "$.items" count == 0
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
# Step 16 – "to-delete" folder no longer exists in home folder
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
GET {{base_url}}/api/folders/{{home_folder_id}}/contents
|
||||
GET {{base_url}}/api/folders/{{home_folder_id}}/resources?resource_types=folder
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$[*].name" not contains "to-delete"
|
||||
jsonpath "$.items[*].resource.name" not contains "to-delete"
|
||||
|
||||
Reference in New Issue
Block a user