]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: accept dot(.) in user_id & (alphanumeric chars, _) in tenant in user... 63478/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:22:12 +0000 (11:52 +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 a1d740e6a484141e3abe4508120a02f4e1993453..efdf125ad9ecbf62fb45dee60cf2e9d7ec9adfd1 100644 (file)
@@ -176,6 +176,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);
@@ -184,6 +191,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', () => {
     beforeEach(() => {
       component.loading = LoadingStatus.Ready;
index f0783324c2451d3f642854151d6185e4f0a0398d..fc4f15d2c1e19d6e9820307c308d10bdc935de3c 100644 (file)
@@ -82,7 +82,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
           ? []
           : [
@@ -94,7 +94,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
           ? []
           : [