diff --git a/packages/backend-core/src/security/tests/permissions.spec.ts b/packages/backend-core/src/security/tests/permissions.spec.ts deleted file mode 100644 index 292fe4ae56..0000000000 --- a/packages/backend-core/src/security/tests/permissions.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { - doesHaveBasePermission, - getBuiltinPermissionByID, - isPermissionLevelHigherThanRead, - PermissionLevel, - PermissionType, -} from "../permissions" - -xdescribe("getBuiltinPermissionByID", () => { - it("should return the correct permission object", () => { - const id = "123" - const permission = { _id: id, name: "Test Permission" } - expect(getBuiltinPermissionByID(id)).toEqual(permission) - expect(getBuiltinPermissionByID("456")).toBeUndefined() - }) -}) - -xdescribe("doesHaveBasePermission", () => { - it("should return true if base permission has the required level", () => { - const permType = PermissionType.APP - const permLevel = PermissionLevel.READ - const rolesHierarchy = [ - { roleId: "role1", permissionId: "permission1" }, - { roleId: "role2", permissionId: "permission2" }, - ] - expect( - doesHaveBasePermission( - permType, - permLevel, - rolesHierarchy - ) - ).toBeTruthy() - }) - - it("should return false if base permission does not have the required level", () => { - const permType = PermissionType.APP - const permLevel = PermissionLevel.READ - const rolesHierarchy = [ - { roleId: "role1", permissionId: "permission1" }, - { roleId: "role2", permissionId: "permission2" }, - ] - expect( - doesHaveBasePermission( - permType, - permLevel, - rolesHierarchy - ) - ).toBeFalsy() - }) -}) - -xdescribe("isPermissionLevelHigherThanRead", () => { - it("should return true if level is higher than read", () => { - expect(isPermissionLevelHigherThanRead(PermissionLevel.WRITE)).toBeTruthy() - }) - - it("should return false if level is read or lower", () => { - expect(isPermissionLevelHigherThanRead(PermissionLevel.READ)).toBeFalsy() - }) -}) diff --git a/packages/backend-core/src/security/tests/roles.spec.ts b/packages/backend-core/src/security/tests/roles.spec.ts deleted file mode 100644 index 7e233a5cca..0000000000 --- a/packages/backend-core/src/security/tests/roles.spec.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { PermissionLevel } from "../permissions" -import { Role, getBuiltinRoles } from "../roles" - -xdescribe("Role", () => { - describe("constructor", () => { - test("it should initialize _id, name, and permissionId", () => { - const role = new Role("my-role", "My Role", PermissionLevel.READ) - expect(role._id).toEqual("my-role") - expect(role.name).toEqual("My Role") - expect(role.permissionId).toEqual(PermissionLevel.READ) - }) - }) - - describe("addInheritance", () => { - test("it should add the inheritance property to the role", () => { - const role = new Role("my-role", "My Role", PermissionLevel.READ) - const newRole = role.addInheritance("other-role") - expect(newRole).toEqual(role) - expect(role.inherits).toEqual("other-role") - }) - }) - - describe("getBuiltinRoles", () => { - test("it should return an object of builtin roles", () => { - const builtinRoles = getBuiltinRoles() - expect(builtinRoles).toHaveProperty("ADMIN") - expect(builtinRoles).toHaveProperty("POWER") - expect(builtinRoles).toHaveProperty("BASIC") - expect(builtinRoles).toHaveProperty("PUBLIC") - expect(builtinRoles).not.toHaveProperty("BUILDER") - }) - }) -})