]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: Verify the RGW mail reset behavior
authorStephan Müller <smueller@suse.com>
Tue, 6 Nov 2018 12:49:45 +0000 (13:49 +0100)
committerStephan Müller <smueller@suse.com>
Tue, 6 Nov 2018 13:26:01 +0000 (14:26 +0100)
The current behavior when submitting an empty mail field in the RGW user form
that was previously filled was to replace it with "false".

This was a regression introduced through the use of "CdFormGroup" which had
a "_filterValue" method which converted empty strings into false, but it was
removed now.

Fixes: http://tracker.ceph.com/issues/26861
Signed-off-by: Stephan Müller <smueller@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts

index f6025a23e06960f4197a3736163c5c6fe262ac47..af77ad771c28bda93e51978d83ef0714bd8da1c7 100644 (file)
@@ -15,6 +15,8 @@ import { RgwUserFormComponent } from './rgw-user-form.component';
 describe('RgwUserFormComponent', () => {
   let component: RgwUserFormComponent;
   let fixture: ComponentFixture<RgwUserFormComponent>;
+  let rgwUserService: RgwUserService;
+  let formHelper: FormHelper;
 
   configureTestBed({
     declarations: [RgwUserFormComponent],
@@ -26,6 +28,8 @@ describe('RgwUserFormComponent', () => {
     fixture = TestBed.createComponent(RgwUserFormComponent);
     component = fixture.componentInstance;
     fixture.detectChanges();
+    rgwUserService = TestBed.get(RgwUserService);
+    formHelper = new FormHelper(component.userForm);
   });
 
   it('should create', () => {
@@ -33,10 +37,7 @@ describe('RgwUserFormComponent', () => {
   });
 
   describe('s3 key management', () => {
-    let rgwUserService: RgwUserService;
-
     beforeEach(() => {
-      rgwUserService = TestBed.get(RgwUserService);
       spyOn(rgwUserService, 'addS3Key').and.stub();
     });
 
@@ -113,13 +114,8 @@ describe('RgwUserFormComponent', () => {
   });
 
   describe('username validation', () => {
-    let rgwUserService: RgwUserService;
-    let formHelper: FormHelper;
-
     beforeEach(() => {
-      rgwUserService = TestBed.get(RgwUserService);
       spyOn(rgwUserService, 'enumerate').and.returnValue(observableOf(['abc', 'xyz']));
-      formHelper = new FormHelper(component.userForm);
     });
 
     it('should validate that username is required', () => {
@@ -144,4 +140,19 @@ describe('RgwUserFormComponent', () => {
       })
     );
   });
+
+  describe('onSubmit', () => {
+    it('should be able to clear the mail field on update', () => {
+      spyOn(rgwUserService, 'update');
+      component.editing = true;
+      formHelper.setValue('email', '', true);
+      component.onSubmit();
+      expect(rgwUserService.update).toHaveBeenCalledWith(null, {
+        display_name: null,
+        email: '',
+        max_buckets: 1000,
+        suspended: false
+      });
+    });
+  });
 });