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';
});
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);
});
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', () => {
}
];
- 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() {