1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-20 00:08:02 +01:00

fix: project id should be validated correctly on create

This commit is contained in:
Ivar Conradi Østhus 2021-02-24 13:24:28 +01:00
parent 8d4cdd56c1
commit 55dd2ed72b
No known key found for this signature in database
GPG Key ID: 31AC596886B0BD09
2 changed files with 16 additions and 2 deletions

View File

@ -25,7 +25,7 @@ class ProjectService {
async createProject(newProject, username) {
const data = await schema.validateAsync(newProject);
await this.validateUniqueId(data);
await this.validateUniqueId(data.id);
await this.eventStore.store({
type: eventType.PROJECT_CREATED,
createdBy: username,

View File

@ -101,6 +101,20 @@ test.serial('should validate name, legal', async t => {
t.true(result);
});
test.serial('should not be able to create exiting project', async t => {
const project = {
id: 'test-delete',
name: 'New project',
description: 'Blah',
};
try {
await projectService.createProject(project, 'some-user');
await projectService.createProject(project, 'some-user');
} catch (err) {
t.is(err.message, 'A project with this id already exists.');
}
});
test.serial('should require URL friendly ID', async t => {
try {
await projectService.validateId('new name øæå');
@ -139,7 +153,7 @@ test.serial('should update project', async t => {
t.is(updatedProject.description, readProject.description);
});
test.serial('should give error when getting unkown project', async t => {
test.serial('should give error when getting unknown project', async t => {
try {
await projectService.getProject('unknown');
} catch (err) {