Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F7317037
users-who-can.subtest.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
users-who-can.subtest.js
View Options
const
locreq
=
require
(
"locreq"
)(
__dirname
);
const
assert
=
require
(
"assert"
);
const
{
with_running_app
}
=
locreq
(
"test_utils/with-test-app.js"
);
const
assert_throws_async
=
locreq
(
"test_utils/assert_throws_async.js"
);
const
axios
=
require
(
"axios"
);
describe
(
"users-who-can"
,
()
=>
{
it
(
"should deny if the user can't perform the action"
,
async
()
=>
with_running_app
(
async
({
app
,
base_url
})
=>
{
const
bricks
=
app
.
createChip
(
Sealious
.
Collection
,
{
name
:
"bricks"
,
fields
:
[{
name
:
"number"
,
type
:
"int"
}],
access_strategy
:
{
create
:
"noone"
},
});
app
.
createChip
(
Sealious
.
Collection
,
{
name
:
"houses"
,
fields
:
[{
name
:
"address"
,
type
:
"text"
}],
access_strategy
:
{
create
:
[
"users-who-can"
,
[
"create"
,
bricks
]],
},
});
await
assert_throws_async
(
async
()
=>
axios
.
post
(
`
${
base_url
}
/api/v1/collections/houses`
,
{
address
:
"any"
,
}),
e
=>
{
assert
.
equal
(
e
.
response
.
status
,
401
);
assert
.
equal
(
e
.
response
.
data
.
message
,
"You can't perform this action beacuse you can't create bricks"
);
}
);
}));
it
(
"should allow if the user can't perform the action"
,
async
()
=>
with_running_app
(
async
({
app
,
base_url
})
=>
{
const
bricks
=
app
.
createChip
(
Sealious
.
Collection
,
{
name
:
"bricks"
,
fields
:
[{
name
:
"number"
,
type
:
"int"
}],
access_strategy
:
{
create
:
"public"
},
});
app
.
createChip
(
Sealious
.
Collection
,
{
name
:
"houses"
,
fields
:
[{
name
:
"address"
,
type
:
"text"
}],
access_strategy
:
{
create
:
[
"users-who-can"
,
[
"create"
,
bricks
]],
},
});
await
axios
.
post
(
`
${
base_url
}
/api/v1/collections/houses`
,
{
address
:
"any"
,
});
}));
});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jul 13, 04:21 (16 h, 29 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
814197
Default Alt Text
users-who-can.subtest.js (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment