Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F10352712
users-who-can.subtest.ts
No One
Temporary
Actions
Download 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.ts
View Options
import
assert
from
"assert"
;
import
{
withRunningApp
}
from
"../../test_utils/with-test-app"
;
import
{
assertThrowsAsync
}
from
"../../test_utils/assert-throws-async"
;
import
axios
from
"axios"
;
import
{
Collection
,
FieldTypes
,
AccessStrategies
,
FieldDefinitionHelper
as
field
,
}
from
"../../main"
;
describe
(
"users-who-can"
,
()
=>
{
it
(
"should deny if the user can't perform the action"
,
async
()
=>
withRunningApp
(
async
({
app
,
base_url
})
=>
{
Collection
.
fromDefinition
(
app
,
{
name
:
"bricks"
,
fields
:
[
field
(
"number"
,
FieldTypes
.
Int
)],
access_strategy
:
{
create
:
AccessStrategies
.
Noone
},
});
Collection
.
fromDefinition
(
app
,
{
name
:
"houses"
,
fields
:
[
field
(
"address"
,
FieldTypes
.
Text
)],
access_strategy
:
{
create
:
new
AccessStrategies
.
UsersWhoCan
([
"create"
,
"bricks"
,
]),
},
});
await
assertThrowsAsync
(
async
()
=>
axios
.
post
(
`
${
base_url
}
/api/v1/collections/houses`
,
{
address
:
"any"
,
})
.
then
(),
(
e
:
any
)
=>
{
assert
.
equal
(
e
.
response
.
status
,
401
);
assert
.
equal
(
e
.
response
.
data
.
message
,
"you can't create bricks - because noone is allowed"
);
}
);
}));
it
(
"should allow if the user can't perform the action"
,
async
()
=>
withRunningApp
(
async
({
app
,
base_url
})
=>
{
Collection
.
fromDefinition
(
app
,
{
name
:
"bricks"
,
fields
:
[
field
(
"number"
,
FieldTypes
.
Int
)],
access_strategy
:
{
create
:
AccessStrategies
.
Public
},
});
Collection
.
fromDefinition
(
app
,
{
name
:
"houses"
,
fields
:
[
field
(
"address"
,
FieldTypes
.
Text
)],
access_strategy
:
{
create
:
new
AccessStrategies
.
UsersWhoCan
([
"create"
,
"bricks"
,
]),
},
});
await
axios
.
post
(
`
${
base_url
}
/api/v1/collections/houses`
,
{
address
:
"any"
,
});
}));
});
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Sun, Nov 2, 18:20 (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1030478
Default Alt Text
users-who-can.subtest.ts (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment