Skip to content

Commit

Permalink
chore: More minor cleanups of code
Browse files Browse the repository at this point in the history
  • Loading branch information
sighphyre authored and ivarconr committed Jan 11, 2022
1 parent deaf614 commit 21560f2
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/lib/db/access-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import NotFoundError from '../error/notfound-error';
import {
ENVIRONMENT_PERMISSION_TYPE,
ROOT_PERMISSION_TYPE,
} from 'lib/util/constants';
} from '../util/constants';

const T = {
ROLE_USER: 'role_user',
Expand Down
2 changes: 0 additions & 2 deletions src/lib/db/role-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,3 @@ export default class RoleStore implements IRoleStore {

destroy(): void {}
}

module.exports = RoleStore;
1 change: 0 additions & 1 deletion src/lib/error/role-in-use-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ class RoleInUseError extends Error {
}

export default RoleInUseError;
module.exports = RoleInUseError;
6 changes: 1 addition & 5 deletions src/lib/services/project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,7 @@ export default class ProjectService {
}
}

await this.accessService.removeUserFromRole(
userId,
role.id,
projectId,
);
await this.accessService.removeUserFromRole(userId, role.id, projectId);
}

async getMembers(projectId: string): Promise<number> {
Expand Down
32 changes: 3 additions & 29 deletions src/test/e2e/services/access-service.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ const createUserEditorAccess = async (name, email) => {
const createUserViewerAccess = async (name, email) => {
const { userStore } = stores;
const user = await userStore.insert({ name, email });
await accessService.addUserToRole(
user.id,
readRole.id,
ALL_PROJECTS,
);
await accessService.addUserToRole(user.id, readRole.id, ALL_PROJECTS);
return user;
};

Expand Down Expand Up @@ -182,11 +178,7 @@ const createSuperUser = async () => {
name: 'Alice Admin',
email: 'admin@getunleash.io',
});
await accessService.addUserToRole(
user.id,
adminRole.id,
ALL_PROJECTS,
);
await accessService.addUserToRole(user.id, adminRole.id, ALL_PROJECTS);
return user;
};

Expand Down Expand Up @@ -425,11 +417,7 @@ test('should remove user from role', async () => {
expect(userRoles.length).toBe(1);
expect(userRoles[0].name).toBe(RoleName.EDITOR);

await accessService.removeUserFromRole(
user.id,
editorRole.id,
'default',
);
await accessService.removeUserFromRole(user.id, editorRole.id, 'default');
const userRolesAfterRemove = await accessService.getRolesForUser(user.id);
expect(userRolesAfterRemove.length).toBe(0);
});
Expand Down Expand Up @@ -679,17 +667,3 @@ test('Should be denied access to delete a role that is in use', async () => {
);
}
});

test('Should be given full access to project created by user', async () => {
const user = editorUser;
const newProjectName = 'AWholeNewProject';

const project = {
id: newProjectName,
name: newProjectName,
description: 'Blah',
};
await projectService.createProject(project, user.id);

hasFullProjectAccess(user, newProjectName, true);
});

0 comments on commit 21560f2

Please sign in to comment.