Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Commit 478c011

Browse files
committed
test(server): add regression test for restrict null-safety
1 parent 25b62b5 commit 478c011

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/unit/restrict.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,28 @@ test.serial('throws error on invalid matcher', t => {
8585
error = t.throws(restrict.compileACLs)
8686
t.is(error.message, 'Unrecognized ACL matcher "__proto__"')
8787
})
88+
89+
test.serial('denies no email with all matchers except any', t => {
90+
config.divisionACLs = [{
91+
match: 'domain',
92+
value: 'good-domain.com',
93+
divisions: ['domain']
94+
}, {
95+
match: 'email',
96+
97+
divisions: ['email']
98+
}, {
99+
match: 'regex',
100+
value: '^regex-email(-[a-z]+)[email protected]$',
101+
divisions: ['regex']
102+
}, {
103+
match: 'any',
104+
value: '',
105+
divisions: ['any']
106+
}]
107+
restrict.compileACLs()
108+
t.false(restrict.divisionAllowed(undefined, 'domain'))
109+
t.false(restrict.divisionAllowed(undefined, 'email'))
110+
t.false(restrict.divisionAllowed(undefined, 'regex'))
111+
t.true(restrict.divisionAllowed(undefined, 'any'))
112+
})

0 commit comments

Comments
 (0)