mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-19 00:15:43 +01:00
chore: More minor cleanups of code
This commit is contained in:
parent
deaf614dde
commit
21560f2dac
@ -14,7 +14,7 @@ import NotFoundError from '../error/notfound-error';
|
|||||||
import {
|
import {
|
||||||
ENVIRONMENT_PERMISSION_TYPE,
|
ENVIRONMENT_PERMISSION_TYPE,
|
||||||
ROOT_PERMISSION_TYPE,
|
ROOT_PERMISSION_TYPE,
|
||||||
} from 'lib/util/constants';
|
} from '../util/constants';
|
||||||
|
|
||||||
const T = {
|
const T = {
|
||||||
ROLE_USER: 'role_user',
|
ROLE_USER: 'role_user',
|
||||||
|
@ -183,5 +183,3 @@ export default class RoleStore implements IRoleStore {
|
|||||||
|
|
||||||
destroy(): void {}
|
destroy(): void {}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = RoleStore;
|
|
||||||
|
@ -21,4 +21,3 @@ class RoleInUseError extends Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default RoleInUseError;
|
export default RoleInUseError;
|
||||||
module.exports = RoleInUseError;
|
|
||||||
|
@ -324,11 +324,7 @@ export default class ProjectService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.accessService.removeUserFromRole(
|
await this.accessService.removeUserFromRole(userId, role.id, projectId);
|
||||||
userId,
|
|
||||||
role.id,
|
|
||||||
projectId,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getMembers(projectId: string): Promise<number> {
|
async getMembers(projectId: string): Promise<number> {
|
||||||
|
@ -35,11 +35,7 @@ const createUserEditorAccess = async (name, email) => {
|
|||||||
const createUserViewerAccess = async (name, email) => {
|
const createUserViewerAccess = async (name, email) => {
|
||||||
const { userStore } = stores;
|
const { userStore } = stores;
|
||||||
const user = await userStore.insert({ name, email });
|
const user = await userStore.insert({ name, email });
|
||||||
await accessService.addUserToRole(
|
await accessService.addUserToRole(user.id, readRole.id, ALL_PROJECTS);
|
||||||
user.id,
|
|
||||||
readRole.id,
|
|
||||||
ALL_PROJECTS,
|
|
||||||
);
|
|
||||||
return user;
|
return user;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -182,11 +178,7 @@ const createSuperUser = async () => {
|
|||||||
name: 'Alice Admin',
|
name: 'Alice Admin',
|
||||||
email: 'admin@getunleash.io',
|
email: 'admin@getunleash.io',
|
||||||
});
|
});
|
||||||
await accessService.addUserToRole(
|
await accessService.addUserToRole(user.id, adminRole.id, ALL_PROJECTS);
|
||||||
user.id,
|
|
||||||
adminRole.id,
|
|
||||||
ALL_PROJECTS,
|
|
||||||
);
|
|
||||||
return user;
|
return user;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -425,11 +417,7 @@ test('should remove user from role', async () => {
|
|||||||
expect(userRoles.length).toBe(1);
|
expect(userRoles.length).toBe(1);
|
||||||
expect(userRoles[0].name).toBe(RoleName.EDITOR);
|
expect(userRoles[0].name).toBe(RoleName.EDITOR);
|
||||||
|
|
||||||
await accessService.removeUserFromRole(
|
await accessService.removeUserFromRole(user.id, editorRole.id, 'default');
|
||||||
user.id,
|
|
||||||
editorRole.id,
|
|
||||||
'default',
|
|
||||||
);
|
|
||||||
const userRolesAfterRemove = await accessService.getRolesForUser(user.id);
|
const userRolesAfterRemove = await accessService.getRolesForUser(user.id);
|
||||||
expect(userRolesAfterRemove.length).toBe(0);
|
expect(userRolesAfterRemove.length).toBe(0);
|
||||||
});
|
});
|
||||||
@ -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);
|
|
||||||
});
|
|
||||||
|
Loading…
Reference in New Issue
Block a user