updating tests to new permissions
Massimo Melina committed
Mar 16, 2023 at 15:44 UTC
0d603f8175a7b3a66eb4b85ff255a75d99bb0151
2 files changed
+28
-24
tests/config.yaml
+15
-13
@@ -24,11 +24,15 @@ vfs:
24
mime: png
25
source: tests/page/gpl.png
26
- name: page
27
- default: index.html
27
source: tests/page
28
+ default: index.html
29
- name: for-admins
30
can_read:
31
- admins
32
+ can_list:
33
+ - admins
34
+ can_see:
35
+ - admins
36
children:
37
- name: upload
38
source: tests
@@ -42,31 +46,29 @@ vfs:
46
rename:
47
alfa.txt: renamed1
48
page/gpl.png: renamed2
45
- - name: cantReadPage
49
+ - name: cantListPage
50
source: tests
51
masks:
52
page:
53
can_see: false
50
- can_read: false
51
- page/*:
52
- can_see: true
53
- can_read: true
54
- - name: cantReadPageAlt
54
+ can_list: false
55
+ - name: cantListPageAlt
56
source: tests
57
masks:
58
page:
58
- can_read: false
59
- masks:
60
- "**/*":
61
- can_read: true
62
- - name: cantReadPageRecursive
59
+ can_see: false
60
+ "**/*":
61
+ can_list: false
62
+ - name: cantReadPage
63
source: tests
64
masks:
65
- page:
65
+ (page|*.ts|*.yaml):
66
can_read: false
67
+ can_list: false
68
- name: cantReadRealFolder
69
source: tests
70
can_read: false
71
+ can_list: false
72
- name: cantSeeThis
73
can_see: "*"
74
children:
tests/test.ts
+13
-11
@@ -27,7 +27,7 @@ describe('basics', () => {
27
it('force slash', req('/f1', 302))
28
it('list', reqList('/f1/', { inList:['f2/', 'page'] }))
29
it('search', reqList('f1', { inList:['f2/'], outList:['page'] }, { search:'2' }))
30
- it('search root', reqList('/', { inList:['cantReadPage/'], outList:['cantReadPage/page/'] }, { search:'page' }))
30
+ it('search root', reqList('/', { inList:['cantListPage/'], outList:['cantListPage/page/'] }, { search:'page' }))
31
it('download', req('/f1/f2/alfa.txt', { re:/abcd/, mime:'text/plain' }))
32
it('download.partial', req('/f1/f2/alfa.txt', /a[^d]+$/, { // only "abc" is expected
33
headers: { Range: 'bytes=0-2' }
@@ -42,16 +42,17 @@ describe('basics', () => {
42
it('missing perm', req('/for-admins/', 401))
43
it('missing perm.file', req('/for-admins/alfa.txt', 401))
44
45
- it('forbidden list', req('/cantReadPage/page/', 403))
46
- it('forbidden list.api', reqList('/cantReadPage/page/', 403))
47
- it('forbidden list.cant see', reqList('/cantReadPage/', { outList:['page/'] }))
48
- it('forbidden list.but readable file', req('/cantReadPage/page/gpl.png', 200))
49
- it('forbidden list.alternative method', reqList('/cantReadPageAlt/page/', 403))
50
- it('forbidden list.alternative method readable file', req('/cantReadPageAlt/page/gpl.png', 200))
51
-
52
- it('cantReadPageRecursive', reqList('/cantReadPageRecursive/page', 403))
53
- it('cantReadPageRecursive.file', req('/cantReadPageRecursive/page/gpl.png', 403))
54
- it('cantReadPageRecursive.parent', reqList('/cantReadPageRecursive', 200))
45
+ it('forbidden list', req('/cantListPage/page/', 403))
46
+ it('forbidden list.api', reqList('/cantListPage/page/', 403))
47
+ it('forbidden list.cant see', reqList('/cantListPage/', { outList:['page/'] }))
48
+ it('forbidden list.but readable file', req('/cantListPage/page/gpl.png', 200))
49
+ it('forbidden list.alternative method', reqList('/cantListPageAlt/page/', 403))
50
+ it('forbidden list.alternative method readable file', req('/cantListPageAlt/page/gpl.png', 200))
51
+
52
+ it('cantReadPage', reqList('/cantReadPage/page', 403))
53
+ it('cantReadPage.zip', req('/cantReadPage/page/?get=zip', 403, { method:'HEAD' }))
54
+ it('cantReadPage.file', req('/cantReadPage/page/gpl.png', 403))
55
+ it('cantReadPage.parent', reqList('/cantReadPage', 200))
56
it('cantReadRealFolder', reqList('/cantReadRealFolder', 403))
57
it('cantReadRealFolder.file', req('/cantReadRealFolder/page/gpl.png', 403))
58
@@ -75,6 +76,7 @@ describe('basics', () => {
76
it('zip.partial.resume', req('/f1/?get=zip', { re:/^C3/, length:zipSize-zipOfs }, { headers: { Range: `bytes=${zipOfs}-` } }) )
77
it('zip.partial.end', req('/f1/f2/?get=zip', { re:/^6/, length:10 }, { headers: { Range: 'bytes=-10' } }) )
78
it('zip.alfa is forbidden', req('/protectFromAbove/child/?get=zip&list=alfa.txt*renamed', { empty: true, length:118 }, { method:'HEAD' }))
79
+ it('zip.cantReadPage', req('/cantReadPage/?get=zip', { length: 120 }, { method:'HEAD' }))
80
it('login', reqApi('login', { username, password }, 406)) // by default, we don't support clear-text login
81
82
it('referer', req('/f1/page/gpl.png', 403, {