test: added a few backend tests
Massimo Melina committed
Jan 16, 2026 at 18:16 UTC
3bb8e3155ab43080503d353dfda60507629c4299
3 files changed
+12
-4
e2e/frontend.spec.ts
-1
@@ -112,7 +112,6 @@ test('around1', async ({ page }) => {
112
await expect(page.getByText('xFolder')).toBeVisible()
113
await page.getByRole('button', { name: 'Close' }).click()
114
await page.getByRole('link', { name: 'home' }).click()
115
- await expect(page.getByText('file, 10 folders, 6 B')).toBeVisible()
115
})
116
117
test('search1', async ({ page }) => {
tests/config.yaml
+5
@@ -70,6 +70,11 @@ vfs:
70
masks:
71
"*":
72
can_list: true
73
+ - name: zipNoList
74
+ source: ../page
75
+ can_see: false
76
+ can_list: false
77
+ can_archive: true
78
- name: cantSearchForMasks
79
source: ..
80
- name: cantReadBut
tests/test.ts
+7
-3
@@ -98,10 +98,12 @@ describe('basics', () => {
98
}))
99
test('file_details.missing', reqApi('get_file_details', { uris: ['/missing'] }, res => res?.details?.[0] === false))
100
test('file_details.hidden', reqApi('get_file_details', { uris: ['/tests/config.yaml'] }, res => res?.details?.[0] === false))
101
- test('file_list.traversal', reqApi('get_file_list', { uri: '/f1/%2e%2e/for-admins' }, 404))
101
+ test('file_details.for-admins', reqApi('get_file_details', { uris: ['/for-admins/alfa.txt'] }, res => res?.details?.[0] === false))
102
test('file_details.traversal', reqApi('get_file_details', { uris: ['/f1/%2e%2e/for-admins/alfa.txt'] }, res => res?.details?.[0] === false))
103
+ test('file_list.traversal', reqApi('get_file_list', { uri: '/f1/%2e%2e/for-admins' }, 404))
104
test('forbidden list', req('/cantListPage/page/', 403))
105
test('forbidden list.api', reqList('/cantListPage/page/', 403))
106
+ test('forbidden list.admin flag', reqApi('get_file_list', { uri: '/for-admins/', admin: true }, 401))
107
test('forbidden list.cant see', reqList('/cantListPage/', { outList:['page/'] }))
108
test('forbidden list.but readable file', req('/cantListPage/page/gpl.png', 200))
109
test('forbidden list.alternative method', reqList('/cantListPageAlt/page/', 403))
@@ -257,6 +259,7 @@ describe('after-login', () => {
259
throwIf(!u?.ip ? 'ip' : u?.username !== username ? 'username' : '')
260
}))
261
test('file_details.non-admin', reqApi('get_file_details', { uris: [UPLOAD_DEST] }, res => res?.details?.[0] === false, { jar: {} }))
262
+ test('zip.no-list but archive', req('/zipNoList/?get=zip', 403, { jar: {} }))
263
test('upload but not delete', async () => {
264
const name = `cant-delete`
265
await mkdir(resolve(ROOT, name), { recursive: true })
@@ -408,9 +411,10 @@ function reqUpload(dest: string, tester: Tester, body?: string | Readable, size?
411
if (resume)
412
dest += (dest.includes('?') ? '&' : '?') + 'resume=' + resume
413
size ??= (body as any)?.length ?? statSync(SAMPLE_FILE_PATH).size // it's ok that Readable.length is undefined
411
- if (tester === 200)
414
+ const status = (tester as any).status || tester
415
+ if (status === 200)
416
tester = {
413
- status: tester,
417
+ status,
418
cb(data) {
419
const fn = ROOT + decodeURI(data.uri).replace(UPLOAD_ROOT, '')
420
const stats = try_(() => statSync(fn))