Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- it("should be able to grant access to a user on a project", async () => {
- const { done } = await service.grantAccess(projectId, {
- assigneeId: "Andrej",
- assigneeType: "user",
- permissions: [Permissions.Access, Permissions.AddComponent, Permissions.AddEnvironment]
- });
- assert.ok(done);
- const accessList = await service.getAccessList(projectId);
- const user = accessList.find(u => u.assigneeId === "Andrej" && u.entityId === projectId);
- assert.ok(user.permissions.includes(Permissions.Access));
- assert.ok(user.permissions.includes(Permissions.AddComponent));
- assert.ok(user.permissions.includes(Permissions.AddEnvironment));
- });
- it("should not be able to grant access to a user on a project", async () => {
- await errorTest(
- assert,
- new ProjectService(serverAddress, auth, {
- userId: "Vlado",
- groupIds: "group1",
- permissions: Permissions.CreateProject,
- projectId
- }).grantAccess(projectId, {
- assigneeId: "Jovan",
- assigneeType: "user",
- permissions: [Permissions.Access, Permissions.GetAccessList]
- }),
- HttpStatus.UNAUTHORIZED,
- "fails because no access to grant access"
- );
- });
- it("should be able to modify access to a user on a project", async () => {
- const { done } = await service.modifyAccess(projectId, "Andrej", [Permissions.Access]);
- assert.ok(done);
- const accessList = await service.getAccessList(projectId);
- const user = accessList.find(u => u.assigneeId === "Andrej" && u.entityId === projectId);
- assert.ok(!user.permissions.includes(Permissions.Access));
- });
- it("should not be able to modify access to a user on a project", async () => {
- await errorTest(
- assert,
- new ProjectService(serverAddress, auth, {
- userId: "Shefot",
- groupIds: "group1",
- permissions: Permissions.CreateProject,
- projectId
- }).modifyAccess(projectId, "Jovan", [Permissions.GetAccessList]),
- HttpStatus.UNAUTHORIZED,
- "fails because no access to grant access"
- );
- });
- it("should not be able to revoke access to a user on a project", async () => {
- await errorTest(
- assert,
- new ProjectService(serverAddress, auth, {
- userId: "Tonka",
- groupIds: "group1",
- permissions: Permissions.CreateProject,
- projectId
- }).revokeAccess(projectId, "Jovan"),
- HttpStatus.UNAUTHORIZED,
- "fails because no access to grant access"
- );
- });
- it("should be able to revoke access to a user on a project", async () => {
- const { done } = await service.revokeAccess(projectId, "Andrej");
- assert.ok(done);
- const accessList = await service.getAccessList(projectId);
- const user = accessList.find(u => u.assigneeId === "Andrej" && u.entityId === projectId);
- assert.ok(!user);
- });
- it("should be able to revoke all access to a user", async () => {
- const result = await service.revokeAccess(projectId, "testUser");
- assert.isTrue(result.done);
- });
- it("should not be able to get an accesslist", async () => {
- await errorTest(
- assert,
- service.getAccessList(projectId),
- 401,
- "should not be able to get an accesslist for the project"
- );
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement