import { CdHelperClass } from '../../src/app/shared/classes/cd-helper.class';
import { Permissions } from '../../src/app/shared/models/permissions';
import { table } from 'table';
+import { LocalStorage } from '~/app/shared/enum/local-storage-enum';
/* tslint:enable*/
let auth: any;
const fillAuth = () => {
- window.localStorage.setItem('dashboard_username', auth.username);
+ window.localStorage.setItem(LocalStorage.DASHBOARD_USRENAME, auth.username);
window.localStorage.setItem('dashboard_permissions', auth.permissions);
window.localStorage.setItem('user_pwd_expiration_date', auth.pwdExpirationDate);
window.localStorage.setItem('user_pwd_update_required', auth.pwdUpdateRequired);
url,
{ args },
({ uname, permissions, pwdExpirationDate, pwdUpdateRequired, sso }: any) => {
- window.localStorage.setItem('dashboard_username', uname);
+ window.localStorage.setItem(LocalStorage.DASHBOARD_USRENAME, uname);
window.localStorage.setItem('dashboard_permissions', permissions);
window.localStorage.setItem('user_pwd_expiration_date', pwdExpirationDate);
window.localStorage.setItem('user_pwd_update_required', pwdUpdateRequired);
import { SharedModule } from '~/app/shared/shared.module';
import { configureTestBed } from '~/testing/unit-test-helper';
import { IscsiTargetDetailsComponent } from './iscsi-target-details.component';
+import { USER } from '~/app/shared/constants/app.constants';
describe('IscsiTargetDetailsComponent', () => {
let component: IscsiTargetDetailsComponent;
);
component.onNodeSelected(node);
expect(component.data).toEqual([
- { current: 'myiscsiusername', default: undefined, displayName: 'user' },
+ { current: 'myiscsiusername', default: undefined, displayName: USER },
{ current: 'myhost', default: undefined, displayName: 'alias' },
{ current: ['192.168.200.1'], default: undefined, displayName: 'ip_address' },
{ current: ['node1'], default: undefined, displayName: 'logged_in' }
import { Node } from 'carbon-components-angular/treeview/tree-node.types';
import _ from 'lodash';
+import { USER } from '~/app/shared/constants/app.constants';
import { TableComponent } from '~/app/shared/datatable/table/table.component';
import { Icons } from '~/app/shared/enum/icons.enum';
});
// Target level authentication was introduced in ceph-iscsi config v11
if (this.cephIscsiConfigVersion > 10) {
- ['user', 'password', 'mutual_user', 'mutual_password'].forEach((key) => {
+ [USER, 'password', 'mutual_user', 'mutual_password'].forEach((key) => {
this.data.push({
displayName: key,
default: null,
import { SharedModule } from '~/app/shared/shared.module';
import { configureTestBed, FormHelper, IscsiHelper } from '~/testing/unit-test-helper';
import { IscsiTargetDiscoveryModalComponent } from './iscsi-target-discovery-modal.component';
+import { USER } from '~/app/shared/constants/app.constants';
describe('IscsiTargetDiscoveryModalComponent', () => {
let component: IscsiTargetDiscoveryModalComponent;
const formHelper = new FormHelper(control);
formHelper.expectValid(control);
- IscsiHelper.validateUser(formHelper, 'user');
+ IscsiHelper.validateUser(formHelper, USER);
IscsiHelper.validatePassword(formHelper, 'password');
IscsiHelper.validateUser(formHelper, 'mutual_user');
IscsiHelper.validatePassword(formHelper, 'mutual_password');
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { IscsiService } from '~/app/shared/api/iscsi.service';
-import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
+import { ActionLabelsI18n, USER } from '~/app/shared/constants/app.constants';
import { NotificationType } from '~/app/shared/enum/notification-type.enum';
import { CdFormGroup } from '~/app/shared/forms/cd-form-group';
import { CdValidators } from '~/app/shared/forms/cd-validators';
});
CdValidators.validateIf(
- this.discoveryForm.get('user'),
+ this.discoveryForm.get(USER),
() =>
this.discoveryForm.getValue('password') ||
this.discoveryForm.getValue('mutual_user') ||
CdValidators.validateIf(
this.discoveryForm.get('password'),
() =>
- this.discoveryForm.getValue('user') ||
+ this.discoveryForm.getValue(USER) ||
this.discoveryForm.getValue('mutual_user') ||
this.discoveryForm.getValue('mutual_password'),
[Validators.required],
[Validators.pattern(this.PASSWORD_REGEX)],
[
- this.discoveryForm.get('user'),
+ this.discoveryForm.get(USER),
this.discoveryForm.get('mutual_user'),
this.discoveryForm.get('mutual_password')
]
[Validators.required],
[Validators.pattern(this.USER_REGEX)],
[
- this.discoveryForm.get('user'),
+ this.discoveryForm.get(USER),
this.discoveryForm.get('password'),
this.discoveryForm.get('mutual_password')
]
[Validators.required],
[Validators.pattern(this.PASSWORD_REGEX)],
[
- this.discoveryForm.get('user'),
+ this.discoveryForm.get(USER),
this.discoveryForm.get('password'),
this.discoveryForm.get('mutual_user')
]
import { RbdService } from '~/app/shared/api/rbd.service';
import { SelectMessages } from '~/app/shared/components/select/select-messages.model';
import { SelectOption } from '~/app/shared/components/select/select-option.model';
-import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
+import { ActionLabelsI18n, USER } from '~/app/shared/constants/app.constants';
import { Icons } from '~/app/shared/enum/icons.enum';
import { CdForm } from '~/app/shared/forms/cd-form';
import { CdFormGroup } from '~/app/shared/forms/cd-form-group';
setAuthValidator(fg: CdFormGroup) {
CdValidators.validateIf(
- fg.get('user'),
+ fg.get(USER),
() => fg.getValue('password') || fg.getValue('mutual_user') || fg.getValue('mutual_password'),
[Validators.required],
[Validators.pattern(this.USER_REGEX)],
CdValidators.validateIf(
fg.get('password'),
- () => fg.getValue('user') || fg.getValue('mutual_user') || fg.getValue('mutual_password'),
+ () => fg.getValue(USER) || fg.getValue('mutual_user') || fg.getValue('mutual_password'),
[Validators.required],
[Validators.pattern(this.PASSWORD_REGEX)],
- [fg.get('user'), fg.get('mutual_user'), fg.get('mutual_password')]
+ [fg.get(USER), fg.get('mutual_user'), fg.get('mutual_password')]
);
CdValidators.validateIf(
() => fg.getValue('mutual_password'),
[Validators.required],
[Validators.pattern(this.USER_REGEX)],
- [fg.get('user'), fg.get('password'), fg.get('mutual_password')]
+ [fg.get(USER), fg.get('password'), fg.get('mutual_password')]
);
CdValidators.validateIf(
() => fg.getValue('mutual_user'),
[Validators.required],
[Validators.pattern(this.PASSWORD_REGEX)],
- [fg.get('user'), fg.get('password'), fg.get('mutual_user')]
+ [fg.get(USER), fg.get('password'), fg.get('mutual_user')]
);
}
// Target level authentication was introduced in ceph-iscsi config v11
if (this.cephIscsiConfigVersion > 10) {
const targetAuth: CdFormGroup = this.targetForm.get('auth') as CdFormGroup;
- if (!targetAuth.getValue('user')) {
- targetAuth.get('user').setValue('');
+ if (!targetAuth.getValue(USER)) {
+ targetAuth.get(USER).setValue('');
}
if (!targetAuth.getValue('password')) {
targetAuth.get('password').setValue('');
}
const acl_enabled = this.targetForm.getValue('acl_enabled');
request['auth'] = {
- user: acl_enabled ? '' : targetAuth.getValue('user'),
+ user: acl_enabled ? '' : targetAuth.getValue(USER),
password: acl_enabled ? '' : targetAuth.getValue('password'),
mutual_user: acl_enabled ? '' : targetAuth.getValue('mutual_user'),
mutual_password: acl_enabled ? '' : targetAuth.getValue('mutual_password')
import { RbdService } from '~/app/shared/api/rbd.service';
import { ComponentsModule } from '~/app/shared/components/components.module';
-import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
+import { ActionLabelsI18n, USER } from '~/app/shared/constants/app.constants';
import { DataTableModule } from '~/app/shared/datatable/datatable.module';
import { TableActionsComponent } from '~/app/shared/datatable/table-actions/table-actions.component';
import { CdTableSelection } from '~/app/shared/models/cd-table-selection';
rbdService = new RbdService(null, null);
notificationService = new NotificationService(null, null, null);
authStorageService = new AuthStorageService();
- authStorageService.set('user', { 'rbd-image': ['create', 'read', 'update', 'delete'] });
+ authStorageService.set(USER, { 'rbd-image': ['create', 'read', 'update', 'delete'] });
component = new RbdSnapshotListComponent(
authStorageService,
null,
import _ from 'lodash';
import { Subscription } from 'rxjs';
import { MultiClusterService } from '~/app/shared/api/multi-cluster.service';
-import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
+import { ActionLabelsI18n, USER } from '~/app/shared/constants/app.constants';
import { NotificationType } from '~/app/shared/enum/notification-type.enum';
import { CdFormGroup } from '~/app/shared/forms/cd-form-group';
import { CdValidators } from '~/app/shared/forms/cd-validators';
[this.clusterAliasNames, this.clusterUrls, this.clusterUsers] = [
'cluster_alias',
'url',
- 'user'
+ USER
].map((prop) => this.clustersData?.map((cluster) => cluster[prop]));
}
import { PrometheusService } from '~/app/shared/api/prometheus.service';
import { CdTableColumn } from '~/app/shared/models/cd-table-column';
import { CellTemplate } from '~/app/shared/enum/cell-template.enum';
+import { VERSION_PREFIX } from '~/app/shared/constants/app.constants';
+
import { Router } from '@angular/router';
import {
}
getVersion(fullVersion: string) {
- const version = fullVersion.replace('ceph version ', '').split(' ');
- return version[0] + ' ' + version.slice(2, version.length).join(' ');
+ const version = fullVersion.replace(`${VERSION_PREFIX} `, '').split(' ');
+ return version[0] + ' ' + version.slice(2).join(' ');
}
generateQueryLabel(query: any, name = false, count = this.COUNT_OF_UTILIZATION_CHARTS) {
import { configureTestBed, FormHelper, Mocks } from '~/testing/unit-test-helper';
import { ServiceFormComponent } from './service-form.component';
import { PoolService } from '~/app/shared/api/pool.service';
+import { USER } from '~/app/shared/constants/app.constants';
// for 'nvmeof' service
const mockPools = [
beforeEach(() => {
formHelper.setValue('service_type', 'iscsi');
formHelper.setValue('pool', 'xyz');
- formHelper.setValue('api_user', 'user');
+ formHelper.setValue('api_user', USER);
formHelper.setValue('api_password', 'password');
formHelper.setValue('ssl', false);
});
placement: {},
unmanaged: false,
pool: 'xyz',
- api_user: 'user',
+ api_user: USER,
api_password: 'password',
api_secure: false
});
placement: {},
unmanaged: false,
pool: 'xyz',
- api_user: 'user',
+ api_user: USER,
api_password: 'password',
api_secure: true,
ssl_cert: '',
placement: {},
unmanaged: false,
pool: 'xyz',
- api_user: 'user',
+ api_user: USER,
api_password: 'password',
api_secure: false,
api_port: 456
import { ToastrModule } from 'ngx-toastr';
import { AuthStorageService } from '~/app/shared/services/auth-storage.service';
import { RouterTestingModule } from '@angular/router/testing';
+import { VERSION_PREFIX } from '~/app/shared/constants/app.constants';
export class SummaryServiceMock {
summaryDataSource = new BehaviorSubject({
version:
- 'ceph version 17.0.0-12222-gcd0cd7cb ' +
+ `${VERSION_PREFIX} 17.0.0-12222-gcd0cd7cb ` +
'(b8193bb4cda16ccc5b028c3e1df62bc72350a15d) quincy (dev)'
});
summaryData$ = this.summaryDataSource.asObservable();
import { ExecutingTask } from '~/app/shared/models/executing-task';
import { Router } from '@angular/router';
import { RefreshIntervalService } from '~/app/shared/services/refresh-interval.service';
+import { VERSION_PREFIX } from '~/app/shared/constants/app.constants';
@Component({
selector: 'cd-upgrade',
this.subs.add(
this.summaryService.subscribe((summary) => {
- const version = summary.version.replace('ceph version ', '').split('-');
+ const version = summary.version.replace(VERSION_PREFIX, '').split('-');
this.version = version[0];
this.executingTasks = summary.executing_tasks.filter((tasks) =>
tasks.name.includes('progress/Upgrade')
import { OrchestratorService } from '~/app/shared/api/orchestrator.service';
import { AlertClass } from '~/app/shared/enum/health-icon.enum';
import { HealthSnapshotMap } from '~/app/shared/models/health.interface';
+import { VERSION_PREFIX } from '~/app/shared/constants/app.constants';
export class SummaryServiceMock {
summaryDataSource = new BehaviorSubject({
version:
- 'ceph version 17.0.0-12222-gcd0cd7cb ' +
+ `${VERSION_PREFIX} 17.0.0-12222-gcd0cd7cb ` +
'(b8193bb4cda16ccc5b028c3e1df62bc72350a15d) quincy (dev)'
});
summaryData$ = this.summaryDataSource.asObservable();
IscsiMap,
PgStateCount
} from '~/app/shared/models/health.interface';
+import { VERSION_PREFIX } from '~/app/shared/constants/app.constants';
@Component({
selector: 'cd-dashboard-v3',
});
this.subs.add(
this.summaryService.subscribe((summary) => {
- const version = summary.version.replace('ceph version ', '').split(' ');
+ const version = summary.version.replace(`${VERSION_PREFIX} `, '').split(' ');
this.detailsCardData.cephVersion =
version[0] + ' ' + version.slice(2, version.length).join(' ');
})
import { RgwDaemonDetailsComponent } from '../rgw-daemon-details/rgw-daemon-details.component';
import { RgwDaemonListComponent } from './rgw-daemon-list.component';
import { TableComponent } from '~/app/shared/datatable/table/table.component';
+import { VERSION_PREFIX } from '~/app/shared/constants/app.constants';
describe('RgwDaemonListComponent', () => {
let component: RgwDaemonListComponent;
const daemon: RgwDaemon = {
id: '8000',
service_map_id: '4803',
- version: 'ceph version',
+ version: VERSION_PREFIX,
server_hostname: 'ceph',
realm_name: 'realm1',
zonegroup_name: 'zg1-realm1',
import { of } from 'rxjs';
import { RgwMultisiteService } from '~/app/shared/api/rgw-multisite.service';
import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
+import { USER } from '~/app/shared/constants/app.constants';
class MultisiteServiceMock {
createEditSyncPipe = jest.fn().mockReturnValue(of(null));
id: 'pipi1',
params: {
dest: {},
- mode: 'user',
+ mode: USER,
priority: 0,
source: { filter: { tags: [] } },
user: 'dashboard'
expect(putDataSpy).toHaveBeenCalled();
expect(putDataSpy).toHaveBeenCalledWith({
...component.pipeForm.getRawValue(),
- mode: 'user',
+ mode: USER,
user: 'dashboard'
});
});
import { ToastrModule } from 'ngx-toastr';
import { CommonModule } from '@angular/common';
import { ActivatedRoute } from '@angular/router';
+import { VERSION_PREFIX } from '~/app/shared/constants/app.constants';
describe('RgwOverviewDashboardComponent', () => {
let component: RgwOverviewDashboardComponent;
const daemon: RgwDaemon = {
id: '8000',
service_map_id: '4803',
- version: 'ceph version',
+ version: VERSION_PREFIX,
server_hostname: 'ceph',
realm_name: 'realm1',
zonegroup_name: 'zg1-realm1',
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { configureTestBed } from '~/testing/unit-test-helper';
+import { USER } from '~/app/shared/constants/app.constants';
describe('RgwRateLimitDetailsComponent', () => {
let component: RgwRateLimitDetailsComponent;
beforeEach(() => {
fixture = TestBed.createComponent(RgwRateLimitDetailsComponent);
component = fixture.componentInstance;
- component.type = 'user';
+ component.type = USER;
component.rateLimitConfig = {
enabled: true,
max_read_bytes: 987648,
import _ from 'lodash';
import { NotificationService } from '~/app/shared/services/notification.service';
import { NotificationType } from '~/app/shared/enum/notification-type.enum';
+import { USER } from '~/app/shared/constants/app.constants';
@Component({
selector: 'cd-rgw-rate-limit',
ngOnInit(): void {
// get the global rate Limit
- if (this.type === 'user') {
+ if (this.type === USER) {
this.rgwUserService.getGlobalUserRateLimit().subscribe(
(data: GlobalRateLimitConfig) => {
if (data && data.user_ratelimit !== undefined) {
* on load for user and bucket
*/
private getRateLimitFormValues() {
- if (this.type === 'user') {
+ if (this.type === USER) {
this.rgwUserService.getUserRateLimit(this.id).subscribe(
(resp: GlobalRateLimitConfig) => {
this.populateFormValues(resp.user_ratelimit);
import { Permissions } from '~/app/shared/models/permissions';
import { RgwRateLimitConfig } from '../models/rgw-rate-limit';
import { ModalCdsService } from '~/app/shared/services/modal-cds.service';
+import { USER } from '~/app/shared/constants/app.constants';
@Component({
selector: 'cd-rgw-user-details',
});
}
- this.keys = _.sortBy(this.keys, 'user');
+ this.keys = _.sortBy(this.keys, USER);
}
}
import { By } from '@angular/platform-browser';
import { CheckboxModule, NumberModule, SelectModule } from 'carbon-components-angular';
import { LoadingStatus } from '~/app/shared/forms/cd-form';
+import { USER } from '~/app/shared/constants/app.constants';
describe('RgwUserFormComponent', () => {
let component: RgwUserFormComponent;
// Assertions
expect(result).toEqual({
- quota_type: 'user',
+ quota_type: USER,
enabled: true,
max_size_kb: -1,
max_objects: -1
const result = component._getUserQuotaArgs();
expect(toBytesSpy).toHaveBeenCalledWith(2048);
expect(result).toEqual({
- quota_type: 'user',
+ quota_type: USER,
enabled: true,
max_size_kb: '2048', // Expect the converted KB value
max_objects: -1
const result = component._getUserQuotaArgs();
expect(result).toEqual({
- quota_type: 'user',
+ quota_type: USER,
enabled: true,
max_size_kb: -1,
max_objects: 1000
import { concat as observableConcat, forkJoin as observableForkJoin, Observable } from 'rxjs';
import { RgwUserService } from '~/app/shared/api/rgw-user.service';
-import { ActionLabelsI18n, URLVerbs } from '~/app/shared/constants/app.constants';
+import { ActionLabelsI18n, URLVerbs, USER } from '~/app/shared/constants/app.constants';
import { Icons } from '~/app/shared/enum/icons.enum';
import { NotificationType } from '~/app/shared/enum/notification-type.enum';
import { CdForm } from '~/app/shared/forms/cd-form';
break;
}
// Map the quota values.
- ['user', 'bucket'].forEach((type) => {
+ [USER, 'bucket'].forEach((type) => {
const quota = resp[1][type + '_quota'];
value[type + '_quota_enabled'] = quota.enabled;
if (quota.max_size < 0) {
*/
_getUserQuotaArgs(): Record<string, any> {
const result = {
- quota_type: 'user',
+ quota_type: USER,
enabled: this.userForm.getValue('user_quota_enabled'),
max_size_kb: -1,
max_objects: -1
import { FOO_USERSGROUPS } from '../smb-usersgroups-form/smb-usersgroups-form.component.spec';
import { of } from 'rxjs';
import { By } from '@angular/platform-browser';
+import { USER } from '~/app/shared/constants/app.constants';
describe('SmbClusterFormComponent', () => {
let component: SmbClusterFormComponent;
it('should change the form when authmode is changed', () => {
const authModeControl = component.smbForm.get('auth_mode');
- authModeControl?.setValue('user');
+ authModeControl?.setValue(USER);
component.onAuthModeChange();
fixture.detectChanges();
const joinSourcesControl = component.smbForm.get('joinSources') as FormArray;
import { SmbService } from '~/app/shared/api/smb.service';
import { JOIN_AUTH_RESOURCE } from '../smb.model';
import { of } from 'rxjs';
+import { USER } from '~/app/shared/constants/app.constants';
export const FOO_JOIN_AUTH = {
auth_id: 'foo',
auth: {
- username: 'user',
+ username: USER,
password: 'pass'
},
resource_type: JOIN_AUTH_RESOURCE
it('should submit the form', () => {
component.form.controls['authId'].setValue('foo');
- component.form.controls['username'].setValue('user');
+ component.form.controls['username'].setValue(USER);
component.form.controls['password'].setValue('pass');
component.form.controls['linkedToCluster'].setValue(undefined);
expect(getJoinAuth).toHaveBeenCalled();
expect(component.form.getRawValue()).toEqual({
authId: 'foo',
- username: 'user',
+ username: USER,
password: 'pass',
linkedToCluster: undefined
});
import { SmbService } from '~/app/shared/api/smb.service';
import { USERSGROUPS_RESOURCE } from '../smb.model';
import { of } from 'rxjs';
+import { USER } from '~/app/shared/constants/app.constants';
export const FOO_USERSGROUPS = {
users_groups_id: 'foo',
values: {
users: [
{
- name: 'user',
+ name: USER,
password: 'pass'
}
],
const user = component.users.controls[0] as FormGroup;
component.form.controls['usersGroupsId'].setValue('foo');
component.form.controls['linkedToCluster'].setValue(undefined);
- user.controls['name'].setValue('user');
+ user.controls['name'].setValue(USER);
user.controls['password'].setValue('pass');
component.addGroup();
const group = component.groups.controls[0] as FormGroup;
usersGroupsId: 'foo',
users: [
{
- name: 'user',
+ name: USER,
password: 'pass'
}
],
import { CephServicePlacement } from '~/app/shared/models/service.interface';
+import { USER } from '~/app/shared/constants/app.constants';
export interface SMBCluster {
resource_type: typeof CLUSTER_RESOURCE;
interface SMBShareLoginControl {
name: string;
access: 'read' | 'read-write' | 'none' | 'admin';
- category?: 'user' | 'group';
+ category?: typeof USER | 'group';
}
export interface Filesystem {
};
export const AUTHMODE = {
- User: 'user',
+ User: USER,
ActiveDirectory: 'active-directory'
};
interface SMBShareLoginControl {
name: string;
access: 'read' | 'read-write' | 'none' | 'admin';
- category?: 'user' | 'group';
+ category?: typeof USER | 'group';
}
export interface SMBJoinAuth {
import { configureTestBed, FormHelper } from '~/testing/unit-test-helper';
import { RoleFormComponent } from './role-form.component';
import { RoleFormModel } from './role-form.model';
+import { USER } from '~/app/shared/constants/app.constants';
describe('RoleFormComponent', () => {
let component: RoleFormComponent;
description: 'Role 1',
scopes_permissions: { osd: ['read', 'create'] }
};
- const scopes = ['osd', 'user'];
+ const scopes = ['osd', USER];
beforeEach(() => {
formHelper = new FormHelper(form);
spyOn(roleService, 'get').and.callFake(() => of(role));
import { UserService } from '~/app/shared/api/user.service';
import { ConfirmationModalComponent } from '~/app/shared/components/confirmation-modal/confirmation-modal.component';
import { SelectMessages } from '~/app/shared/components/select/select-messages.model';
-import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
+import { ActionLabelsI18n, USER } from '~/app/shared/constants/app.constants';
import { Icons } from '~/app/shared/enum/icons.enum';
import { NotificationType } from '~/app/shared/enum/notification-type.enum';
import { CdForm } from '~/app/shared/forms/cd-form';
private hasUserReadUpdatePermissions(roles: Array<string> = []) {
for (const role of this.allRoles) {
- if (roles.indexOf(role.name) !== -1 && role.scopes_permissions['user']) {
- const userPermissions = role.scopes_permissions['user'];
+ if (roles.indexOf(role.name) !== -1 && role.scopes_permissions[USER]) {
+ const userPermissions = role.scopes_permissions[USER];
return ['read', 'update'].every((permission) => {
return userPermissions.indexOf(permission) !== -1;
});
import { SettingsService } from '~/app/shared/api/settings.service';
import { UserService } from '~/app/shared/api/user.service';
import { DeleteConfirmationModalComponent } from '~/app/shared/components/delete-confirmation-modal/delete-confirmation-modal.component';
-import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
+import { ActionLabelsI18n, USER } from '~/app/shared/constants/app.constants';
import { CellTemplate } from '~/app/shared/enum/cell-template.enum';
import { DeletionImpact } from '~/app/shared/enum/delete-confirmation-modal-impact.enum';
import { Icons } from '~/app/shared/enum/icons.enum';
this.modalRef = this.modalService.show(DeleteConfirmationModalComponent, {
impact: DeletionImpact.high,
- itemDescription: 'User',
+ itemDescription: USER,
itemNames: [username],
submitAction: () => this.deleteUser(username)
});
import { environment } from '~/environments/environment';
import { configureTestBed } from '~/testing/unit-test-helper';
import { AboutComponent } from './about.component';
+import { VERSION_PREFIX } from '~/app/shared/constants/app.constants';
export class SummaryServiceMock {
summaryDataSource = new BehaviorSubject({
version:
- 'ceph version 14.0.0-855-gb8193bb4cd ' +
+ `${VERSION_PREFIX} 14.0.0-855-gb8193bb4cd ` +
'(b8193bb4cda16ccc5b028c3e1df62bc72350a15d) nautilus (dev)',
mgr_host: 'http://localhost:11000/'
});
import { NotificationService } from '~/app/shared/services/notification.service';
import { PrometheusAlertService } from '~/app/shared/services/prometheus-alert.service';
import { SummaryService } from '~/app/shared/services/summary.service';
+import { USER } from '~/app/shared/constants/app.constants';
@Component({
selector: 'cd-navigation',
Object.keys(clustersConfig).forEach((clusterKey: string) => {
const clusterDetailsList = clustersConfig[clusterKey];
clusterDetailsList.forEach((clusterDetails: MultiCluster) => {
- const clusterUser = clusterDetails['user'];
+ const clusterUser = clusterDetails[USER];
const clusterUrl = clusterDetails['url'];
const clusterUniqueKey = `${clusterUrl}-${clusterUser}`;
this.clustersMap.set(clusterUniqueKey, clusterDetails);
if (value['cluster_alias'] === 'local-cluster') {
localStorage.setItem('cluster_api_url', '');
} else {
- localStorage.setItem('current_cluster_name', `${value['name']}-${value['user']}`);
+ localStorage.setItem('current_cluster_name', `${value['name']}-${value[USER]}`);
localStorage.setItem('cluster_api_url', value['url']);
}
- this.selectedCluster = this.clustersMap.get(`${value['url']}-${value['user']}`) || {};
+ this.selectedCluster = this.clustersMap.get(`${value['url']}-${value[USER]}`) || {};
const clustersConfig = resp['config'];
if (clustersConfig && typeof clustersConfig === 'object') {
Object.keys(clustersConfig).forEach((clusterKey: string) => {
clusterDetailsList.forEach((clusterDetails: any) => {
const clusterName = clusterDetails['name'];
const clusterToken = clusterDetails['token'];
- const clusterUser = clusterDetails['user'];
+ const clusterUser = clusterDetails[USER];
if (
- clusterName === this.selectedCluster['name'] &&
- clusterUser === this.selectedCluster['user'] &&
+ clusterName === this.selectedCluster[USER] &&
+ clusterUser === this.selectedCluster[USER] &&
clusterDetails['cluster_alias'] !== 'local-cluster'
) {
this.cookieService.setToken(`${clusterName}-${clusterUser}`, clusterToken);
import { configureTestBed } from '~/testing/unit-test-helper';
import { AuthStorageService } from '../services/auth-storage.service';
import { AuthService } from './auth.service';
+import { LocalStorage } from '~/app/shared/enum/local-storage-enum';
describe('AuthService', () => {
let service: AuthService;
expect(req.request.body).toEqual(fakeCredentials);
req.flush(fakeResponse);
tick();
- expect(localStorage.getItem('dashboard_username')).toBe('foo');
+ expect(localStorage.getItem(LocalStorage.DASHBOARD_USRENAME)).toBe('foo');
}));
it('should logout and remove the user', () => {
const req = httpTesting.expectOne('api/auth/logout');
expect(req.request.method).toBe('POST');
req.flush({ redirect_url: '#/login' });
- expect(localStorage.getItem('dashboard_username')).toBe(null);
+ expect(localStorage.getItem(LocalStorage.DASHBOARD_USRENAME)).toBe(null);
expect(router.navigate).toBeCalledTimes(1);
});
});
import { Observable } from 'rxjs';
import { RgwRealm, RgwZone, RgwZonegroup } from '~/app/ceph/rgw/models/rgw-multisite';
import { Icons } from '../enum/icons.enum';
+import { USER } from '~/app/shared/constants/app.constants';
@Injectable({
providedIn: 'root'
const secret_key = zoneInfo[0].system_key['secret_key'];
nodes['access_key'] = access_key ? access_key : '';
nodes['secret_key'] = secret_key ? secret_key : '';
- nodes['user'] = access_key && access_key !== '' ? true : false;
+ nodes[USER] = access_key && access_key !== '' ? true : false;
}
if (nodes['access_key'] === '' || nodes['access_key'] === 'null') {
nodes['show_warning'] = true;
import { ToastrModule } from 'ngx-toastr';
import { NotificationType } from '../enum/notification-type.enum';
import { SharedModule } from '../shared.module';
+import { USER } from '~/app/shared/constants/app.constants';
describe('SmbService', () => {
let service: SmbService;
resource_type: JOIN_AUTH_RESOURCE,
auth_id: 'foo',
auth: {
- username: 'user',
+ username: USER,
password: 'pass'
},
linked_to_cluster: ''
values: {
users: [
{
- name: 'user',
+ name: USER,
password: 'pass'
}
],
import { TestBed } from '@angular/core/testing';
import { SummaryService } from '../services/summary.service';
import { BehaviorSubject } from 'rxjs';
+import { VERSION_PREFIX } from '~/app/shared/constants/app.constants';
export class SummaryServiceMock {
summaryDataSource = new BehaviorSubject({
version:
- 'ceph version 18.1.3-12222-gcd0cd7cb ' +
+ `${VERSION_PREFIX} 18.1.3-12222-gcd0cd7cb ` +
'(b8193bb4cda16ccc5b028c3e1df62bc72350a15d) reef (dev)'
});
summaryData$ = this.summaryDataSource.asObservable();
import { UpgradeStartModalComponent } from '~/app/ceph/cluster/upgrade/upgrade-form/upgrade-start-modal.component';
import { ModalService } from '../services/modal.service';
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
+import { VERSION_PREFIX } from '~/app/shared/constants/app.constants';
const CACHE_SIZE = 1;
versionAvailableForUpgrades(upgradeInfo: UpgradeInfoInterface): UpgradeInfoInterface {
let version = '';
this.summaryService.subscribe((summary) => {
- version = summary.version.replace('ceph version ', '').split('-')[0];
+ version = summary.version.replace(`${VERSION_PREFIX}`, '').split('-')[0];
});
const upgradableVersions = upgradeInfo.versions.filter((targetVersion) => {
import { CephReleaseNamePipe } from './ceph-release-name.pipe';
+import { VERSION_PREFIX } from '~/app/shared/constants/app.constants';
describe('CephReleaseNamePipe', () => {
const pipe = new CephReleaseNamePipe();
});
it('recognizes a stable release', () => {
- const value =
- 'ceph version 13.2.1 \
- (5533ecdc0fda920179d7ad84e0aa65a127b20d77) mimic (stable)';
+ const value = `${VERSION_PREFIX} 13.2.1 \
+ (5533ecdc0fda920179d7ad84e0aa65a127b20d77) mimic (stable)`;
expect(pipe.transform(value)).toBe('mimic');
});
it('recognizes a development release as the main branch', () => {
- const value =
- 'ceph version 13.1.0-534-g23d3751b89 \
- (23d3751b897b31d2bda57aeaf01acb5ff3c4a9cd) nautilus (dev)';
+ const value = `${VERSION_PREFIX} 13.1.0-534-g23d3751b89 \
+ (23d3751b897b31d2bda57aeaf01acb5ff3c4a9cd) nautilus (dev)`;
expect(pipe.transform(value)).toBe('main');
});
import { Pipe, PipeTransform } from '@angular/core';
+import { VERSION_PREFIX } from '~/app/shared/constants/app.constants';
@Pipe({
name: 'cephReleaseName'
transform(value: any): any {
// Expect "ceph version 13.1.0-419-g251e2515b5
// (251e2515b563856349498c6caf34e7a282f62937) nautilus (dev)"
- const result = /ceph version\s+[^ ]+\s+\(.+\)\s+(.+)\s+\((.+)\)/.exec(value);
+ const result = new RegExp(`${VERSION_PREFIX}\\s+[^ ]+\\s+\\(.+\\)\\s+(.+)\\s+\\((.+)\\)`).exec(
+ value
+ );
if (result) {
if (result[2] === 'dev') {
// Assume this is actually main
import { CephShortVersionPipe } from './ceph-short-version.pipe';
+import { VERSION_PREFIX } from '~/app/shared/constants/app.constants';
describe('CephShortVersionPipe', () => {
const pipe = new CephShortVersionPipe();
});
it('transforms with correct version format', () => {
- const value =
- 'ceph version 13.1.0-534-g23d3751b89 \
- (23d3751b897b31d2bda57aeaf01acb5ff3c4a9cd) nautilus (dev)';
+ const value = `${VERSION_PREFIX} 13.1.0-534-g23d3751b89 \
+ (23d3751b897b31d2bda57aeaf01acb5ff3c4a9cd) nautilus (dev)`;
expect(pipe.transform(value)).toBe('13.1.0-534-g23d3751b89');
});
import { Pipe, PipeTransform } from '@angular/core';
+import { VERSION_PREFIX } from '~/app/shared/constants/app.constants';
@Pipe({
name: 'cephShortVersion'
export class CephShortVersionPipe implements PipeTransform {
transform(value: any): any {
// Expect "ceph version 1.2.3-g9asdasd (as98d7a0s8d7)"
- const result = /ceph version\s+([^ ]+)\s+\(.+\)/.exec(value);
+ const result = new RegExp(`${VERSION_PREFIX}\\s+([^ ]+)\\s+\\(.+\\)`).exec(value);
if (result) {
// Return the "1.2.3-g9asdasd" part
return result[1];
import { AuthStorageService } from './auth-storage.service';
+import { LocalStorage } from '~/app/shared/enum/local-storage-enum';
describe('AuthStorageService', () => {
let service: AuthStorageService;
it('should store username', () => {
service.set(username, '');
- expect(localStorage.getItem('dashboard_username')).toBe(username);
+ expect(localStorage.getItem(LocalStorage.DASHBOARD_USRENAME)).toBe(username);
});
it('should remove username', () => {
service.set(username, '');
service.remove();
- expect(localStorage.getItem('dashboard_username')).toBe(null);
+ expect(localStorage.getItem(LocalStorage.DASHBOARD_USRENAME)).toBe(null);
});
it('should be loggedIn', () => {
import { Injectable } from '@angular/core';
-
import { BehaviorSubject } from 'rxjs';
-
import { Permissions } from '../models/permissions';
-
+import { LocalStorage } from '~/app/shared/enum/local-storage-enum';
@Injectable({
providedIn: 'root'
})
pwdExpirationDate: number = null,
pwdUpdateRequired: boolean = false
) {
- localStorage.setItem('dashboard_username', username);
+ localStorage.setItem(LocalStorage.DASHBOARD_USRENAME, username);
localStorage.setItem('dashboard_permissions', JSON.stringify(new Permissions(permissions)));
localStorage.setItem('user_pwd_expiration_date', String(pwdExpirationDate));
localStorage.setItem('user_pwd_update_required', String(pwdUpdateRequired));
}
remove() {
- localStorage.removeItem('dashboard_username');
+ localStorage.removeItem(LocalStorage.DASHBOARD_USRENAME);
localStorage.removeItem('user_pwd_expiration_data');
localStorage.removeItem('user_pwd_update_required');
}
isLoggedIn() {
- return localStorage.getItem('dashboard_username') !== null;
+ return localStorage.getItem(LocalStorage.DASHBOARD_USRENAME) !== null;
}
getUsername() {
- return localStorage.getItem('dashboard_username');
+ return localStorage.getItem(LocalStorage.DASHBOARD_USRENAME);
}
getPermissions(): Permissions {