]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: RGW User quota validation is not working correctly 29132/head
authorVolker Theile <vtheile@suse.com>
Fri, 19 Jul 2019 12:20:17 +0000 (14:20 +0200)
committerVolker Theile <vtheile@suse.com>
Mon, 22 Jul 2019 10:42:29 +0000 (12:42 +0200)
Fixes: https://tracker.ceph.com/issues/40829
Signed-off-by: Volker Theile <vtheile@suse.com>
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 aa973270a2026b6b70711e22f7622ed9d8c662c3..90fdee5593adb084469c2d202efd044419ed9793 100644 (file)
@@ -257,14 +257,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) {