From: Naman Munet Date: Fri, 16 May 2025 08:29:04 +0000 (+0530) Subject: mgr/dashboard: accept dot(.) in user_id & (alphanumeric chars, _) in tenant in user... X-Git-Tag: v19.2.3~100^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F63477%2Fhead;p=ceph.git mgr/dashboard: accept dot(.) in user_id & (alphanumeric chars, _) in tenant in user form fixes: https://tracker.ceph.com/issues/71341 Signed-off-by: Naman Munet (cherry picked from commit 083d2a14f5da9df9c9142940f151636c466623ae) --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts index a00d08ad75e1f..4c9707cad8508 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts @@ -167,6 +167,13 @@ describe('RgwUserFormComponent', () => { formHelper.expectValid('user_id'); })); + it('should validate that username can contain dot(.)', fakeAsync(() => { + spyOn(rgwUserService, 'get').and.returnValue(throwError('foo')); + formHelper.setValue('user_id', 'user.name', true); + tick(DUE_TIMER); + formHelper.expectValid('user_id'); + })); + it('should validate that username is invalid', fakeAsync(() => { spyOn(rgwUserService, 'get').and.returnValue(observableOf({})); formHelper.setValue('user_id', 'abc', true); @@ -175,6 +182,24 @@ describe('RgwUserFormComponent', () => { })); }); + describe('tenant validation', () => { + it('should validate that tenant is valid', fakeAsync(() => { + spyOn(rgwUserService, 'get').and.returnValue(throwError('foo')); + formHelper.setValue('show_tenant', true, true); + formHelper.setValue('tenant', 'new_tenant123', true); + tick(DUE_TIMER); + formHelper.expectValid('tenant'); + })); + + it('should validate that tenant is invalid', fakeAsync(() => { + spyOn(rgwUserService, 'get').and.returnValue(observableOf({})); + formHelper.setValue('show_tenant', true, true); + formHelper.setValue('tenant', 'new-tenant.dummy', true); + tick(DUE_TIMER); + formHelper.expectError('tenant', 'pattern'); + })); + }); + describe('max buckets', () => { it('disable creation (create)', () => { spyOn(rgwUserService, 'create'); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.ts index ec23ca0f7ba11..6a2804a549241 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.ts @@ -74,7 +74,7 @@ export class RgwUserFormComponent extends CdForm implements OnInit { // General user_id: [ null, - [Validators.required, Validators.pattern(/^[a-zA-Z0-9!@#%^&*()_-]+$/)], + [Validators.required, Validators.pattern(/^[a-zA-Z0-9!@#%^&*()._-]+$/)], this.editing ? [] : [ @@ -86,7 +86,7 @@ export class RgwUserFormComponent extends CdForm implements OnInit { show_tenant: [this.editing], tenant: [ null, - [Validators.pattern(/^[a-zA-Z0-9!@#%^&*()_-]+$/)], + [Validators.pattern(/^[a-zA-Z0-9_]+$/)], this.editing ? [] : [