]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: accept dot(.) in user_id & (alphanumeric chars, _) in tenant in user... 63477/head
authorNaman Munet <naman.munet@ibm.com>
Fri, 16 May 2025 08:29:04 +0000 (13:59 +0530)
committerNaman Munet <naman.munet@ibm.com>
Mon, 26 May 2025 06:12:50 +0000 (11:42 +0530)
fixes: https://tracker.ceph.com/issues/71341

Signed-off-by: Naman Munet <naman.munet@ibm.com>
(cherry picked from commit 083d2a14f5da9df9c9142940f151636c466623ae)

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.ts

index a00d08ad75e1f9697e93e62740281351840dc865..4c9707cad850805b15323902c7c0bfec8f1d79af 100644 (file)
@@ -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');
index ec23ca0f7ba110da5f3b2943dd17be690b51c2eb..6a2804a5492413fe4c4f68c5dd0c05951ddd7177 100644 (file)
@@ -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
           ? []
           : [