Skip to content

Commit

Permalink
Add action AllowInsertType, object Type, subject guest test
Browse files Browse the repository at this point in the history
  • Loading branch information
FreePhoenix888 committed Dec 14, 2023
1 parent a6d9a5f commit 73a9191
Showing 1 changed file with 89 additions and 0 deletions.
89 changes: 89 additions & 0 deletions tests/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,95 @@ describe('permissions', () => {
expect(da3).to.be.undefined;
expect(e3).to.not.be.undefined;
});
it(`action AllowInsertType, object Type, subject guest`, async () => {
const a1 = await deep.guest({});
const a2 = await deep.guest({});
const a3 = await deep.guest({});
await deep.insert({
type_id: await deep.id('@deep-foundation/core', 'Rule'),
out: { data: [
{
type_id: await deep.id('@deep-foundation/core', 'RuleSubject'),
to: { data: {
type_id: await deep.id('@deep-foundation/core', 'Selector'),
out: { data: [
{
type_id: await deep.id('@deep-foundation/core', 'SelectorInclude'),
to_id: a1.linkId,
out: { data: {
type_id: await deep.id('@deep-foundation/core', 'SelectorTree'),
to_id: await deep.id('@deep-foundation/core', 'containTree'),
} },
},
{
type_id: await deep.id('@deep-foundation/core', 'SelectorInclude'),
to_id: a2.linkId,
out: { data: {
type_id: await deep.id('@deep-foundation/core', 'SelectorTree'),
to_id: await deep.id('@deep-foundation/core', 'containTree'),
} },
},
{
type_id: await deep.id('@deep-foundation/core', 'SelectorExclude'),
to_id: a3.linkId,
out: { data: {
type_id: await deep.id('@deep-foundation/core', 'SelectorTree'),
to_id: await deep.id('@deep-foundation/core', 'containTree'),
} },
},
] }
} }
},
{
type_id: await deep.id('@deep-foundation/core', 'RuleObject'),
to: { data: {
type_id: await deep.id('@deep-foundation/core', 'Selector'),
out: { data: {
type_id: await deep.id('@deep-foundation/core', 'SelectorInclude'),
to_id: await deep.id('@deep-foundation/core', 'Type'),
out: { data: {
type_id: await deep.id('@deep-foundation/core', 'SelectorTree'),
to_id: await deep.id('@deep-foundation/core', 'containTree'),
} },
} }
} }
},
{
type_id: await deep.id('@deep-foundation/core', 'RuleAction'),
to: { data: {
type_id: await deep.id('@deep-foundation/core', 'Selector'),
out: { data: {
type_id: await deep.id('@deep-foundation/core', 'SelectorInclude'),
to_id: await deep.id('@deep-foundation/core', 'AllowInsertType'),
out: { data: {
type_id: await deep.id('@deep-foundation/core', 'SelectorTree'),
to_id: await deep.id('@deep-foundation/core', 'containTree'),
} },
} }
} }
},
] },
});
const d1 = new DeepClient({ deep, ...a1, silent: true });
const { data: da1, error: e1 } = await d1.insert({
type_id: await deep.id('@deep-foundation/core', 'Type'),
});
if (e1) console.log('error', e1);
expect(da1).to.not.be.undefined;
expect(e1).to.be.undefined;
const d2 = new DeepClient({ deep, ...a2, silent: true });
const { data: da2, error: e2 } = await d2.insert({
type_id: await deep.id('@deep-foundation/core', 'Type'),
});
expect(da2).to.not.be.undefined;
expect(e2).to.be.undefined;
const d3 = new DeepClient({ deep, ...a3, silent: true });
const { data: da3, error: e3 } = await d3.insert({
type_id: await deep.id('@deep-foundation/core', 'Type'),
});
expect(da3).to.be.undefined;
expect(e3).to.not.be.undefined;
});
it(`insert permission with SelectorFilter`, async () => {
const a1 = await deep.guest({});
const a2 = await deep.guest({});
Expand Down

0 comments on commit 73a9191

Please sign in to comment.