From 3eb619c572c43bb3b1dbb50314a364e310123204 Mon Sep 17 00:00:00 2001 From: dominik003 Date: Tue, 7 Nov 2023 18:04:32 +0100 Subject: [PATCH 1/3] fix(front): Properly validate repository name --- .../create-t4c-model-new-repository.component.html | 9 ++++++--- .../create-t4c-model-new-repository.component.ts | 9 +++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/projects/models/model-source/t4c/create-t4c-model-new-repository/create-t4c-model-new-repository.component.html b/frontend/src/app/projects/models/model-source/t4c/create-t4c-model-new-repository/create-t4c-model-new-repository.component.html index 7249ff4ec..5e03c7df2 100644 --- a/frontend/src/app/projects/models/model-source/t4c/create-t4c-model-new-repository/create-t4c-model-new-repository.component.html +++ b/frontend/src/app/projects/models/model-source/t4c/create-t4c-model-new-repository/create-t4c-model-new-repository.component.html @@ -35,9 +35,12 @@ Repository - Repository already exists + + Repository already exists + + + The following characters are allowed: A-Z, a-z, 0-9, _, - + diff --git a/frontend/src/app/projects/models/model-source/t4c/create-t4c-model-new-repository/create-t4c-model-new-repository.component.ts b/frontend/src/app/projects/models/model-source/t4c/create-t4c-model-new-repository/create-t4c-model-new-repository.component.ts index 30e947c32..83960f487 100644 --- a/frontend/src/app/projects/models/model-source/t4c/create-t4c-model-new-repository/create-t4c-model-new-repository.component.ts +++ b/frontend/src/app/projects/models/model-source/t4c/create-t4c-model-new-repository/create-t4c-model-new-repository.component.ts @@ -43,8 +43,13 @@ export class CreateT4cModelNewRepositoryComponent implements OnInit { t4cInstanceId: new FormControl(null, Validators.required), t4cRepositoryName: new FormControl( { value: null, disabled: true }, - Validators.required, - this.t4cRepoService.asyncNameValidator(), + { + validators: [ + Validators.required, + Validators.pattern(/^[-a-zA-Z0-9_]+$/), + ], + asyncValidators: this.t4cRepoService.asyncNameValidator(), + }, ), t4cProjectName: new FormControl( { value: null, disabled: true }, From 0941162b4af93adc08f9d16832ad0958fa39a5f4 Mon Sep 17 00:00:00 2001 From: dominik003 Date: Tue, 7 Nov 2023 18:10:58 +0100 Subject: [PATCH 2/3] fix(back): Properly validate repository name --- .../settings/modelsources/t4c/repositories/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/capellacollab/settings/modelsources/t4c/repositories/models.py b/backend/capellacollab/settings/modelsources/t4c/repositories/models.py index e15201c16..a4d6a36b1 100644 --- a/backend/capellacollab/settings/modelsources/t4c/repositories/models.py +++ b/backend/capellacollab/settings/modelsources/t4c/repositories/models.py @@ -44,7 +44,7 @@ class DatabaseT4CRepository(database.Base): class CreateT4CRepository(pydantic.BaseModel): - name: str + name: str = pydantic.Field(pattern="^[-a-zA-Z0-9_]+$") class T4CRepositoryStatus(str, enum.Enum): From d5b730c5818bec8ce34debb12eb820953a73ef3c Mon Sep 17 00:00:00 2001 From: MoritzWeber Date: Mon, 13 Nov 2023 11:26:18 +0100 Subject: [PATCH 3/3] docs(backend): Add example for T4C repository name --- .../settings/modelsources/t4c/repositories/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/capellacollab/settings/modelsources/t4c/repositories/models.py b/backend/capellacollab/settings/modelsources/t4c/repositories/models.py index a4d6a36b1..ebe644770 100644 --- a/backend/capellacollab/settings/modelsources/t4c/repositories/models.py +++ b/backend/capellacollab/settings/modelsources/t4c/repositories/models.py @@ -44,7 +44,9 @@ class DatabaseT4CRepository(database.Base): class CreateT4CRepository(pydantic.BaseModel): - name: str = pydantic.Field(pattern="^[-a-zA-Z0-9_]+$") + name: str = pydantic.Field( + pattern="^[-a-zA-Z0-9_]+$", examples=["testrepo"] + ) class T4CRepositoryStatus(str, enum.Enum):