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:
parent
8d4cdd56c1
commit
55dd2ed72b
@ -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,
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user