From: Volker Theile Date: Fri, 19 Jul 2019 12:20:17 +0000 (+0200) Subject: mgr/dashboard: RGW User quota validation is not working correctly X-Git-Tag: v14.2.3~15^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=057d4496b5259e8fa2658475cde8e6a267beda05;p=ceph.git mgr/dashboard: RGW User quota validation is not working correctly Fixes: https://tracker.ceph.com/issues/40829 Signed-off-by: Volker Theile (cherry picked from commit 06b654274dc309109c29f62ffc8df52636f6a146) --- 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 38f74ced342a5..48b459fac7861 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 @@ -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', () => { 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 770bc09854a4f..dc2b5bb49d053 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 @@ -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) {