]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: A block-manager can not access the pool page
authorVolker Theile <vtheile@suse.com>
Thu, 29 Aug 2019 11:14:33 +0000 (13:14 +0200)
committerVolker Theile <vtheile@suse.com>
Thu, 29 Aug 2019 13:45:54 +0000 (15:45 +0200)
Fixes: https://tracker.ceph.com/issues/41573
Signed-off-by: Volker Theile <vtheile@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts

index 9097d9dae93b83d834a220513113962d22d9d5b4..50983ab85d5ac61a0c2e2b125e03c9399cea4a4f 100644 (file)
@@ -17,6 +17,7 @@ import { ConfigurationService } from '../../../shared/api/configuration.service'
 import { PoolService } from '../../../shared/api/pool.service';
 import { CriticalConfirmationModalComponent } from '../../../shared/components/critical-confirmation-modal/critical-confirmation-modal.component';
 import { ExecutingTask } from '../../../shared/models/executing-task';
+import { AuthStorageService } from '../../../shared/services/auth-storage.service';
 import { SummaryService } from '../../../shared/services/summary.service';
 import { TaskWrapperService } from '../../../shared/services/task-wrapper.service';
 import { SharedModule } from '../../../shared/shared.module';
@@ -81,9 +82,14 @@ describe('PoolListComponent', () => {
   });
 
   describe('monAllowPoolDelete', () => {
+    let configOptRead: boolean;
     let configurationService: ConfigurationService;
 
     beforeEach(() => {
+      configOptRead = true;
+      spyOn(TestBed.get(AuthStorageService), 'getPermissions').and.callFake(() => ({
+        configOpt: { read: configOptRead }
+      }));
       configurationService = TestBed.get(ConfigurationService);
     });
 
@@ -128,6 +134,13 @@ describe('PoolListComponent', () => {
       component = fixture.componentInstance;
       expect(component.monAllowPoolDelete).toBe(false);
     });
+
+    it('should set value correctly w/o config-opt read privileges', () => {
+      configOptRead = false;
+      fixture = TestBed.createComponent(PoolListComponent);
+      component = fixture.componentInstance;
+      expect(component.monAllowPoolDelete).toBe(false);
+    });
   });
 
   describe('pool deletion', () => {
index a54679ba7503a1fb12f9b5b6791ec2a8f1843483..c73109e8ea52f67ff59cbe405980e61477dbcdee 100644 (file)
@@ -96,14 +96,18 @@ export class PoolListComponent implements OnInit {
       }
     ];
 
-    this.configurationService.get('mon_allow_pool_delete').subscribe((data: any) => {
-      if (_.has(data, 'value')) {
-        const monSection = _.find(data.value, (v) => {
-          return v.section === 'mon';
-        }) || { value: false };
-        this.monAllowPoolDelete = monSection.value === 'true' ? true : false;
-      }
-    });
+    // Note, we need read permissions to get the 'mon_allow_pool_delete'
+    // configuration option.
+    if (this.permissions.configOpt.read) {
+      this.configurationService.get('mon_allow_pool_delete').subscribe((data: any) => {
+        if (_.has(data, 'value')) {
+          const monSection = _.find(data.value, (v) => {
+            return v.section === 'mon';
+          }) || { value: false };
+          this.monAllowPoolDelete = monSection.value === 'true' ? true : false;
+        }
+      });
+    }
   }
 
   ngOnInit() {