Skip to content

Commit

Permalink
Merge pull request #4229 from cloudfoundry/backup-endpoints
Browse files Browse the repository at this point in the history
Backup/Restore endpoints & tokens
  • Loading branch information
richard-cox authored Apr 21, 2020
2 parents e4ab9a9 + efeca9f commit af4dd5c
Show file tree
Hide file tree
Showing 61 changed files with 1,827 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ import { DatePipe } from '@angular/common';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';
import { createEmptyStoreModule } from '@stratos/store/testing';

import { ApplicationService } from '../../../../cloud-foundry/src/features/applications/application.service';
import { CoreModule } from '../../../../core/src/core/core.module';
import { SharedModule } from '../../../../core/src/shared/shared.module';
import { TabNavService } from '../../../../core/tab-nav.service';
import { ApplicationServiceMock } from '../../../../core/test-framework/application-service-helper';
import { createEmptyStoreModule } from '@stratos/store/testing';
import { CfAutoscalerTestingModule } from '../../cf-autoscaler-testing.module';
import { AutoscalerMetricPageComponent } from './autoscaler-metric-page.component';

// TODO: Fix after metrics has been sorted - STRAT-152
xdescribe('AutoscalerMetricPageComponent', () => {
describe('AutoscalerMetricPageComponent', () => {
let component: AutoscalerMetricPageComponent;
let fixture: ComponentFixture<AutoscalerMetricPageComponent>;

Expand Down Expand Up @@ -47,10 +46,5 @@ xdescribe('AutoscalerMetricPageComponent', () => {
expect(component).toBeTruthy();
});

// TODO: Fix after metrics has been sorted - STRAT-152 (cause of `Cannot read property 'getEntityMonitor' of undefined` test failure)
it('Blocked', () => {
fail('Blocked: Requires metrics to be working (specifically metrics entities)');
});

afterAll(() => { });
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ import { DatePipe } from '@angular/common';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';
import { createEmptyStoreModule } from '@stratos/store/testing';

import { ApplicationService } from '../../../../cloud-foundry/src/features/applications/application.service';
import { CoreModule } from '../../../../core/src/core/core.module';
import { SharedModule } from '../../../../core/src/shared/shared.module';
import { TabNavService } from '../../../../core/tab-nav.service';
import { ApplicationServiceMock } from '../../../../core/test-framework/application-service-helper';
import { createEmptyStoreModule } from '@stratos/store/testing';
import { CfAutoscalerTestingModule } from '../../cf-autoscaler-testing.module';
import { AutoscalerScaleHistoryPageComponent } from './autoscaler-scale-history-page.component';

// TODO: Fix after metrics has been sorted - STRAT-152
xdescribe('AutoscalerScaleHistoryPageComponent', () => {
describe('AutoscalerScaleHistoryPageComponent', () => {
let component: AutoscalerScaleHistoryPageComponent;
let fixture: ComponentFixture<AutoscalerScaleHistoryPageComponent>;

Expand Down Expand Up @@ -47,9 +46,5 @@ xdescribe('AutoscalerScaleHistoryPageComponent', () => {
expect(component).toBeTruthy();
});

// TODO: Fix after metrics has been sorted - STRAT-152 (cause of `Cannot read property 'getEntityMonitor' of undefined` test failure)
it('Blocked', () => {
fail('Blocked: Requires metrics to be working (specifically metrics entities)');
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import { SharedModule } from '../../../../../../core/src/shared/shared.module';
import { generateCfStoreModules } from '../../../../../test-framework/cloud-foundry-endpoint-service.helper';
import { ApplicationInstanceChartComponent } from './application-instance-chart.component';

// TODO: Fix after metrics has been sorted - STRAT-152
xdescribe('ApplicationInstanceChartComponent', () => {
describe('ApplicationInstanceChartComponent', () => {
let component: ApplicationInstanceChartComponent;
let fixture: ComponentFixture<ApplicationInstanceChartComponent>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import { applicationEntityType } from '../../../../../../cf-entity-types';
import { ApplicationEnvVarsHelper } from '../build-tab/application-env-vars.service';
import { MetricsTabComponent } from './metrics-tab.component';

// TODO: Fix after metrics has been sorted - STRAT-152
xdescribe('MetricsTabComponent', () => {
describe('MetricsTabComponent', () => {
let component: MetricsTabComponent;
let fixture: ComponentFixture<MetricsTabComponent>;
const appId = '1';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import {
generateCfBaseTestModules,
} from '../../../../../../../test-framework/cloud-foundry-endpoint-service.helper';
import { generateCfBaseTestModules } from '../../../../../../../test-framework/cloud-foundry-endpoint-service.helper';
import { ActiveRouteCfCell } from '../../../../cf-page.types';
import { CloudFoundryCellAppsComponent } from './cloud-foundry-cell-apps.component';

// TODO: Fix after metrics has been sorted - STRAT-152
xdescribe('CloudFoundryCellAppsComponent', () => {
describe('CloudFoundryCellAppsComponent', () => {
let component: CloudFoundryCellAppsComponent;
let fixture: ComponentFixture<CloudFoundryCellAppsComponent>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { TabNavService } from '../../../../../../../../core/tab-nav.service';
import {
generateCfBaseTestModules,
} from '../../../../../../../test-framework/cloud-foundry-endpoint-service.helper';
import { generateCfBaseTestModules } from '../../../../../../../test-framework/cloud-foundry-endpoint-service.helper';
import { CfUserService } from '../../../../../../shared/data-services/cf-user.service';
import { ActiveRouteCfOrgSpace } from '../../../../cf-page.types';
import { CloudFoundryEndpointService } from '../../../../services/cloud-foundry-endpoint.service';
import { CloudFoundryCellService } from '../cloud-foundry-cell.service';
import { CloudFoundryCellBaseComponent } from './cloud-foundry-cell-base.component';

// TODO: Fix after metrics has been sorted - STRAT-152
xdescribe('CloudFoundryCellBaseComponent', () => {
describe('CloudFoundryCellBaseComponent', () => {
let component: CloudFoundryCellBaseComponent;
let fixture: ComponentFixture<CloudFoundryCellBaseComponent>;

Expand All @@ -22,7 +20,8 @@ xdescribe('CloudFoundryCellBaseComponent', () => {
CloudFoundryEndpointService,
CloudFoundryCellService,
ActiveRouteCfOrgSpace,
TabNavService
TabNavService,
CfUserService
]
})
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import {
generateCfBaseTestModules,
} from '../../../../../../../test-framework/cloud-foundry-endpoint-service.helper';
import { generateCfBaseTestModules } from '../../../../../../../test-framework/cloud-foundry-endpoint-service.helper';
import { ActiveRouteCfCell } from '../../../../cf-page.types';
import { CloudFoundryCellService } from '../cloud-foundry-cell.service';
import { CloudFoundryCellChartsComponent } from './cloud-foundry-cell-charts.component';

// TODO: Fix after metrics has been sorted - STRAT-152
xdescribe('CloudFoundryCellChartsComponent', () => {
describe('CloudFoundryCellChartsComponent', () => {
let component: CloudFoundryCellChartsComponent;
let fixture: ComponentFixture<CloudFoundryCellChartsComponent>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ import {
MetricsChartHelpers,
} from '../../../../../../../../core/src/shared/components/metrics-chart/metrics.component.helpers';
import { MetricQueryType } from '../../../../../../../../core/src/shared/services/metrics-range-selector.types';
import {
generateCfBaseTestModules,
} from '../../../../../../../test-framework/cloud-foundry-endpoint-service.helper';
import { MetricQueryConfig } from '../../../../../../../../store/src/actions/metrics.actions';
import { generateCfBaseTestModules } from '../../../../../../../test-framework/cloud-foundry-endpoint-service.helper';
import { FetchCFCellMetricsAction } from '../../../../../../actions/cf-metrics.actions';
import { ActiveRouteCfCell } from '../../../../cf-page.types';
import { CloudFoundryCellService } from '../cloud-foundry-cell.service';
import { CloudFoundryCellSummaryComponent } from './cloud-foundry-cell-summary.component';
import { FetchCFCellMetricsAction } from '../../../../../../actions/cf-metrics.actions';

class MockCloudFoundryCellService {
cfGuid = 'cfGuid';
Expand Down Expand Up @@ -60,8 +58,7 @@ class MockCloudFoundryCellService {

}

// TODO: Fix after metrics has been sorted - STRAT-152
xdescribe('CloudFoundryCellSummaryComponent', () => {
describe('CloudFoundryCellSummaryComponent', () => {
let component: CloudFoundryCellSummaryComponent;
let fixture: ComponentFixture<CloudFoundryCellSummaryComponent>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ import {
import {
TableCellEventTypeComponent,
} from './list/list-types/cf-events/table-cell-event-type/table-cell-event-type.component';
import {
TableCellFeatureFlagDescriptionComponent,
} from './list/list-types/cf-feature-flags/table-cell-feature-flag-description/table-cell-feature-flag-description.component';
import {
TableCellFeatureFlagStateComponent,
} from './list/list-types/cf-feature-flags/table-cell-feature-flag-state/table-cell-feature-flag-state.component';
Expand Down Expand Up @@ -175,7 +178,6 @@ import { SelectServiceComponent } from './select-service/select-service.componen
import { ServiceIconComponent } from './service-icon/service-icon.component';
import { ServicePlanPriceComponent } from './service-plan-price/service-plan-price.component';
import { ServicePlanPublicComponent } from './service-plan-public/service-plan-public.component';
import { TableCellFeatureFlagDescriptionComponent } from './list/list-types/cf-feature-flags/table-cell-feature-flag-description/table-cell-feature-flag-description.component';

// tslint:disable:max-line-length
// tslint:enable:max-line-length
Expand Down Expand Up @@ -219,7 +221,7 @@ const cfListTableCells: Type<TableCellCustom<any>>[] = [
TableCellServiceBindableComponent,
TableCellServiceActiveComponent,
TableCellServiceReferencesComponent,
TableCellServiceInstanceTagsComponent
TableCellServiceInstanceTagsComponent,
];

const cfListCards: Type<CardCell<any>>[] = [
Expand Down
4 changes: 3 additions & 1 deletion src/frontend/packages/core/sass/_all-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
@import '../../cloud-foundry/src/features/cloud-foundry/tabs/cloud-foundry-firehose/cloud-foundry-firehose.component.theme';
@import '../../cloud-foundry/src/features/service-catalog/service-catalog-page/service-catalog-page.component.theme';
@import '../../cloud-foundry/src/features/applications/application-wall/application-wall.component.theme';
@import '../../core/src/features/error-page/error-page/error-page.component.theme.scss';
@import '../../core/src/features/error-page/error-page/error-page.component.theme';
@import '../../core/src/features/endpoints/backup-restore/restore-endpoints/restore-endpoints.component.theme';

// Defaults
$side-nav-light-text: #fff;
Expand Down Expand Up @@ -159,6 +160,7 @@ $side-nav-light-active: #484848;
@include code-block-theme($theme, $app-theme);
@include copy-to-clipboard-theme($theme, $app-theme);
@include app-user-avatar-theme($theme, $app-theme);
@include restore-endpoints-theme($theme, $app-theme)
}

@function app-generate-nav-theme($theme, $nav-theme: null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<mat-checkbox [(ngModel)]="service.state[row.guid][config.type]" [disabled]="disabled()" (change)="validate()">
</mat-checkbox>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { EndpointModel } from '../../../../../../store/src/types/endpoint.types';
import { BaseTestModulesNoShared } from '../../../../../test-framework/core-test.helper';
import { BackupEndpointsService } from '../backup-endpoints.service';
import { BackupEndpointTypes } from '../backup-restore.types';
import { BackupCheckboxCellComponent } from './backup-checkbox-cell.component';

describe('BackupCheckboxCellComponent', () => {
let component: BackupCheckboxCellComponent;
let fixture: ComponentFixture<BackupCheckboxCellComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [BackupCheckboxCellComponent],
imports: [
...BaseTestModulesNoShared
],
providers: [
BackupEndpointsService
]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(BackupCheckboxCellComponent);
component = fixture.componentInstance;
component.config = {
type: BackupEndpointTypes.ENDPOINT
};
component.row = {
guid: 'test',
cnsi_type: 'metrics',
} as EndpointModel;
component.service.initialize([{
guid: 'test'
} as EndpointModel]);
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Component } from '@angular/core';

import { EndpointModel } from '../../../../../../store/src/types/endpoint.types';
import { TableCellCustom } from '../../../../shared/components/list/list.types';
import { BackupEndpointsService } from '../backup-endpoints.service';

@Component({
selector: 'app-backup-checkbox-cell',
templateUrl: './backup-checkbox-cell.component.html',
styleUrls: ['./backup-checkbox-cell.component.scss']
})
export class BackupCheckboxCellComponent extends TableCellCustom<EndpointModel> {

constructor(public service: BackupEndpointsService) {
super();
}

validate() {
this.service.stateUpdated();
}

disabled(): boolean {
return !this.service.canBackupEndpoint(this.row, this.config.type);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<mat-form-field *ngIf="connectable; else unConnectable">
<mat-select [(value)]="service.state[row.guid][backupType.CONNECT]"
[disabled]="!service.state[row.guid][backupType.ENDPOINT]">
<mat-option [value]="connectionTypes.NONE">None</mat-option>
<mat-option [value]="connectionTypes.CURRENT" [disabled]="!!userConnectionWarning"
[matTooltip]="userConnectionWarning">Current User</mat-option>
<mat-option [value]="connectionTypes.ALL">All Users</mat-option>
</mat-select>
</mat-form-field>
<ng-template #unConnectable>N/A</ng-template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { EndpointModel } from '../../../../../../store/src/types/endpoint.types';
import { BaseTestModulesNoShared } from '../../../../../test-framework/core-test.helper';
import { BackupEndpointsService } from '../backup-endpoints.service';
import { BackupConnectionCellComponent } from './backup-connection-cell.component';

describe('BackupConnectionCellComponent', () => {
let component: BackupConnectionCellComponent;
let fixture: ComponentFixture<BackupConnectionCellComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
BackupConnectionCellComponent,
],
imports: [
...BaseTestModulesNoShared
],
providers: [
BackupEndpointsService
]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(BackupConnectionCellComponent);
component = fixture.componentInstance;
component.row = {
guid: 'test',
cnsi_type: 'metrics',
} as EndpointModel;
component.service.initialize([{
guid: 'test'
} as EndpointModel]);
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Component, OnInit } from '@angular/core';

import { entityCatalog } from '../../../../../../store/src/entity-catalog/entity-catalog.service';
import { EndpointModel, SystemSharedUserGuid } from '../../../../../../store/src/types/endpoint.types';
import { TableCellCustom } from '../../../../shared/components/list/list.types';
import { BackupEndpointsService } from '../backup-endpoints.service';
import { BackupEndpointConnectionTypes, BackupEndpointTypes } from '../backup-restore.types';

@Component({
selector: 'app-backup-connection-cell',
templateUrl: './backup-connection-cell.component.html',
styleUrls: ['./backup-connection-cell.component.scss']
})
export class BackupConnectionCellComponent extends TableCellCustom<EndpointModel> implements OnInit {

connectable = false;
backupType = BackupEndpointTypes;
connectionTypes = BackupEndpointConnectionTypes;
selected: BackupEndpointConnectionTypes;
userConnectionWarning: string;

constructor(public service: BackupEndpointsService) {
super();
}

ngOnInit() {
const epType = entityCatalog.getEndpoint(this.row.cnsi_type, this.row.sub_type);
const epEntity = epType.definition;
this.connectable = !epEntity.unConnectable;
if (!this.row.user) {
this.userConnectionWarning = 'User not connected';
} else if (this.row.user.guid === SystemSharedUserGuid) {
this.userConnectionWarning = 'User has shared connection';
}
}
}
Loading

0 comments on commit af4dd5c

Please sign in to comment.