Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F1389934
not.test.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
not.test.js
View Options
const
assert
=
require
(
"assert"
);
const
Op
=
require
(
"sequelize"
).
Op
;
const
anyone
=
require
(
"./anyone.js"
);
const
noone
=
require
(
"./noone.js"
);
const
or
=
require
(
"./or.js"
);
const
and
=
require
(
"./and.js"
);
const
not
=
require
(
"./not.js"
);
const
AccessStrategy
=
require
(
"./access-strategy.js"
);
describe
(
"access-strategy"
,
()
=>
{
describe
(
"not"
,
()
=>
{
describe
(
"constructor"
,
()
=>
{
it
(
"should throw an error if constructed without param"
,
()
=>
assert
.
throws
(()
=>
not
()));
it
(
"should throw an error if constructed with param that is not an AccessStrategy"
,
()
=>
assert
.
throws
(()
=>
not
(
"anyone"
)));
});
describe
(
"checkItem"
,
()
=>
{
it
(
"should allow access when given access strategy denies it"
,
async
()
=>
assert
((
await
not
(
noone
).
checkItem
()).
allowed
));
it
(
"should deny access when given access strategy allows it"
,
async
()
=>
assert
((
await
not
(
anyone
).
checkItem
()).
allowed
===
false
));
it
(
"should work with compound access strategies"
,
async
()
=>
assert
(
(
await
not
(
and
(
anyone
,
or
(
noone
,
anyone
))).
checkItem
()).
allowed
===
false
));
});
describe
(
"filterModelQuery"
,
()
=>
{
it
(
"should negate the model query of given access strategy"
,
async
()
=>
assert
.
deepEqual
(
(
await
not
(
noone
).
filterModelQuery
())[
Op
.
not
],
await
AccessStrategy
.
QueryFilters
.
DenyAll
()
));
});
});
});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 27, 19:21 (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
619457
Default Alt Text
not.test.js (1 KB)
Attached To
Mode
rSREWRITE Sealious-rewrite
Attached
Detach File
Event Timeline
Log In to Comment