Skip to content

Commit

Permalink
Merge pull request ceph#30001 from votdev/issue_41573
Browse files Browse the repository at this point in the history
mgr/dashboard: A block-manager can not access the pool page
  • Loading branch information
rjfd authored Aug 30, 2019
2 parents f121081 + 75e9d9a commit 2b6f521
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
});

Expand Down Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 2b6f521

Please sign in to comment.