]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: RGW User quota validation is not working correctly 29650/head
authorVolker Theile <vtheile@suse.com>
Fri, 19 Jul 2019 12:20:17 +0000 (14:20 +0200)
committerPrashant D <pdhange@redhat.com>
Wed, 14 Aug 2019 00:24:36 +0000 (20:24 -0400)
Fixes: https://tracker.ceph.com/issues/40829
Signed-off-by: Volker Theile <vtheile@suse.com>
(cherry picked from commit 06b654274dc309109c29f62ffc8df52636f6a146)

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 38f74ced342a5505848128da730db036bd52bba2..48b459fac7861796abf305d9674e0681076f7817 100644 (file)
@@ -87,40 +87,50 @@ describe('RgwUserFormComponent', () => {
   });
 
   describe('quotaMaxSizeValidator', () => {
-    it('should validate max size (1/7)', () => {
+    it('should validate max size (1)', () => {
       const resp = component.quotaMaxSizeValidator(new FormControl(''));
       expect(resp).toBe(null);
     });
 
-    it('should validate max size (2/7)', () => {
+    it('should validate max size (2)', () => {
       const resp = component.quotaMaxSizeValidator(new FormControl('xxxx'));
       expect(resp.quotaMaxSize).toBeTruthy();
     });
 
-    it('should validate max size (3/7)', () => {
+    it('should validate max size (3)', () => {
       const resp = component.quotaMaxSizeValidator(new FormControl('1023'));
       expect(resp.quotaMaxSize).toBeTruthy();
     });
 
-    it('should validate max size (4/7)', () => {
+    it('should validate max size (4)', () => {
       const resp = component.quotaMaxSizeValidator(new FormControl('1024'));
       expect(resp).toBe(null);
     });
 
-    it('should validate max size (5/7)', () => {
+    it('should validate max size (5)', () => {
       const resp = component.quotaMaxSizeValidator(new FormControl('1M'));
       expect(resp).toBe(null);
     });
 
-    it('should validate max size (6/7)', () => {
+    it('should validate max size (6)', () => {
       const resp = component.quotaMaxSizeValidator(new FormControl('1024 gib'));
       expect(resp).toBe(null);
     });
 
-    it('should validate max size (7/7)', () => {
+    it('should validate max size (7)', () => {
       const resp = component.quotaMaxSizeValidator(new FormControl('10 X'));
       expect(resp.quotaMaxSize).toBeTruthy();
     });
+
+    it('should validate max size (8)', () => {
+      const resp = component.quotaMaxSizeValidator(new FormControl('1.085 GiB'));
+      expect(resp).toBe(null);
+    });
+
+    it('should validate max size (9)', () => {
+      const resp = component.quotaMaxSizeValidator(new FormControl('1,085 GiB'));
+      expect(resp.quotaMaxSize).toBeTruthy();
+    });
   });
 
   describe('username validation', () => {
index 770bc09854a4f2e57cad665e8bf1b075fea5da16..dc2b5bb49d053551c5e02cbf2786e6c2fea3d4bc 100644 (file)
@@ -252,14 +252,13 @@ export class RgwUserFormComponent implements OnInit {
   }
 
   /**
-   * Validate the quota maximum size, e.g. 1096, 1K, 30M. Only integer numbers are valid,
-   * something like 1.9M is not recognized as valid.
+   * Validate the quota maximum size, e.g. 1096, 1K, 30M or 1.9MiB.
    */
   quotaMaxSizeValidator(control: AbstractControl): ValidationErrors | null {
     if (isEmptyInputValue(control.value)) {
       return null;
     }
-    const m = RegExp('^(\\d+)\\s*(B|K(B|iB)?|M(B|iB)?|G(B|iB)?|T(B|iB)?)?$', 'i').exec(
+    const m = RegExp('^(\\d+(\\.\\d+)?)\\s*(B|K(B|iB)?|M(B|iB)?|G(B|iB)?|T(B|iB)?)?$', 'i').exec(
       control.value
     );
     if (m === null) {