Skip to content

Commit

Permalink
feat: moved deleteSubmission and getSubmission into HCMS
Browse files Browse the repository at this point in the history
  • Loading branch information
neatbyte-vnobis committed Nov 8, 2023
1 parent 6e6360c commit f20f406
Show file tree
Hide file tree
Showing 47 changed files with 231 additions and 950 deletions.
16 changes: 2 additions & 14 deletions packages/api-aco/__tests__/folder.flp.crud.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,26 +522,14 @@ describe("Folder Level Permissions", () => {
{
id: folderA.id,
parentId: null,
permissions: [
{
target: "admin:2",
level: "public",
inheritedFrom: "public"
}
],
permissions: [],
hasNonInheritedPermissions: false,
canManagePermissions: false
},
{
id: folderB.id,
parentId: folderA.id,
permissions: [
{
target: "admin:2",
level: "public",
inheritedFrom: `parent:${folderA.id}`
}
],
permissions: [],
hasNonInheritedPermissions: false,
canManagePermissions: false
}
Expand Down
149 changes: 6 additions & 143 deletions packages/api-aco/__tests__/folder.flp.security.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,61 +68,25 @@ describe("Folder Level Permissions - Security Checks", () => {
{
id: createdFolders[0].id,
parentId: null,
permissions: [
{
inheritedFrom: "public",
level: "public",
target: "admin:2"
}
],
canManageStructure: true,
canManagePermissions: false,
hasNonInheritedPermissions: false,
permissions: [],
slug: "folder-1"
},
{
id: createdFolders[1].id,
parentId: null,
permissions: [
{
inheritedFrom: "public",
level: "public",
target: "admin:2"
}
],
canManageStructure: true,
canManagePermissions: false,
hasNonInheritedPermissions: false,
permissions: [],
slug: "folder-2"
},
{
id: createdFolders[2].id,
parentId: null,
permissions: [
{
inheritedFrom: "public",
level: "public",
target: "admin:2"
}
],
canManageStructure: true,
canManagePermissions: false,
hasNonInheritedPermissions: false,
permissions: [],
slug: "folder-3"
},
{
id: createdFolders[3].id,
parentId: null,
permissions: [
{
inheritedFrom: "public",
level: "public",
target: "admin:2"
}
],
canManageStructure: true,
canManagePermissions: false,
hasNonInheritedPermissions: false,
permissions: [],
slug: "folder-4"
}
]);
Expand Down Expand Up @@ -179,11 +143,7 @@ describe("Folder Level Permissions - Security Checks", () => {
acoIdentityB
.updateFolder({
id: folderA.id,
data: {
permissions: [
{ level: "owner", target: `admin:${identityA.id}` } // Include previous permissions.
]
}
data: { permissions: [] }
})
.then(([response]) => {
return response.data.aco.updateFolder.error;
Expand All @@ -195,97 +155,6 @@ describe("Folder Level Permissions - Security Checks", () => {
});
});

it(`should reset folder access level back to "public"`, async () => {
const folderA = await acoIdentityA
.createFolder({
data: {
title: "Folder A",
slug: "folder-a",
type: FOLDER_TYPE
}
})
.then(([response]) => {
return response.data.aco.createFolder.data;
});

await acoIdentityA.updateFolder({
id: folderA.id,
data: {
permissions: [{ level: "owner", target: `admin:${identityB.id}` }]
}
});

// Should be allowed because the user is not loosing access.
await expect(
acoIdentityB
.updateFolder({
id: folderA.id,
data: {
permissions: [
{ level: "owner", target: `admin:${identityB.id}` }, // Include previous permissions.
{ level: "owner", target: `admin:random-id` } // Include new permissions.
]
}
})
.then(([response]) => {
return response.data.aco.updateFolder.data;
})
).resolves.toMatchObject({
canManagePermissions: true,
hasNonInheritedPermissions: true,
id: folderA.id,
parentId: null,
permissions: [
{ inheritedFrom: null, level: "owner", target: "admin:2" },
{ inheritedFrom: null, level: "owner", target: "admin:random-id" }
]
});

await expect(
acoIdentityA
.updateFolder({
id: folderA.id,
data: {
permissions: []
}
})
.then(([response]) => {
return response.data.aco.updateFolder.data;
})
).resolves.toMatchObject({
canManagePermissions: true,
hasNonInheritedPermissions: false,
id: folderA.id,
parentId: null,
permissions: [
{
inheritedFrom: "role:full-access",
level: "owner",
target: "admin:1"
}
]
});

// Should not be allowed because the user is loosing access.
await expect(
acoIdentityB.getFolder({ id: folderA.id }).then(([response]) => {
return response.data.aco.getFolder.data;
})
).resolves.toMatchObject({
canManagePermissions: false,
hasNonInheritedPermissions: false,
id: folderA.id,
parentId: null,
permissions: [
{
inheritedFrom: "public",
level: "public",
target: "admin:2"
}
]
});
});

it("should not allow moving a folder to an inaccessible folder", async () => {
const folderA = await acoIdentityA
.createFolder({
Expand Down Expand Up @@ -457,13 +326,7 @@ describe("Folder Level Permissions - Security Checks", () => {
canManagePermissions: false,
hasNonInheritedPermissions: false,
id: folderC.id,
permissions: [
{
target: "admin:2",
level: "public",
inheritedFrom: "public"
}
]
permissions: []
}
]);
});
Expand Down
1 change: 0 additions & 1 deletion packages/api-aco/__tests__/graphql/folder.gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const DATA_FIELD = /* GraphQL */ `
}
hasNonInheritedPermissions
canManagePermissions
canManageStructure
createdBy {
id
displayName
Expand Down
12 changes: 2 additions & 10 deletions packages/api-aco/src/createAcoContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,8 @@ const setupAcoContext = async (context: AcoContext): Promise<void> => {
});
}

const listAdminUsers = () => {
return security.withoutAuthorization(async () => {
return context.adminUsers.listUsers();
});
};
const listTeams = () => {
return security.withoutAuthorization(async () => {
return context.security.listTeams();
});
};
const listAdminUsers = () => context.adminUsers.listUsers();
const listTeams = () => context.security.listTeams();

context.aco = {
folder: createFolderCrudMethods({
Expand Down
4 changes: 0 additions & 4 deletions packages/api-aco/src/folder/folder.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ const permissionsField = () =>
{
label: "Owner",
value: "owner"
},
{
label: "Public",
value: "public"
}
]
}
Expand Down
Loading

0 comments on commit f20f406

Please sign in to comment.