diff --git a/src/app/components/preferences/common/symbols/symbols.component.ts b/src/app/components/preferences/common/symbols/symbols.component.ts index e7a13d95..965cc9a2 100644 --- a/src/app/components/preferences/common/symbols/symbols.component.ts +++ b/src/app/components/preferences/common/symbols/symbols.component.ts @@ -1,4 +1,5 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { environment } from 'environments/environment'; import { Server } from '../../../../models/server'; import { Symbol } from '../../../../models/symbol'; import { SymbolService } from '../../../../services/symbol.service'; @@ -77,6 +78,6 @@ export class SymbolsComponent implements OnInit { } getImageSourceForTemplate(symbol: string) { - return `${this.server.protocol}//${this.server.host}:${this.server.port}/v3/symbols/${symbol}/raw`; + return `${this.server.protocol}//${this.server.host}:${this.server.port}/${environment.current_version}/symbols/${symbol}/raw`; } } diff --git a/src/app/components/project-map/import-appliance/import-appliance.component.ts b/src/app/components/project-map/import-appliance/import-appliance.component.ts index 1cee4164..95f04332 100644 --- a/src/app/components/project-map/import-appliance/import-appliance.component.ts +++ b/src/app/components/project-map/import-appliance/import-appliance.component.ts @@ -1,4 +1,5 @@ import { Component, Input, OnInit } from '@angular/core'; +import { environment } from 'environments/environment'; import { FileItem, FileUploader, ParsedResponseHeaders } from 'ng2-file-upload'; import { Project } from '../../../models/project'; import { Server } from '../../../models/server'; @@ -149,6 +150,6 @@ export class ImportApplianceComponent implements OnInit { } private getUploadPath(server: Server, emulator: string, filename: string) { - return `${server.protocol}//${server.host}:${server.port}/v3/${emulator}/images/${filename}`; + return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/${emulator}/images/${filename}`; } } diff --git a/src/app/components/project-map/new-template-dialog/new-template-dialog.component.ts b/src/app/components/project-map/new-template-dialog/new-template-dialog.component.ts index 18714865..35d0d631 100644 --- a/src/app/components/project-map/new-template-dialog/new-template-dialog.component.ts +++ b/src/app/components/project-map/new-template-dialog/new-template-dialog.component.ts @@ -32,6 +32,7 @@ import { ToasterService } from '../../../services/toaster.service'; import { ApplianceInfoDialogComponent } from './appliance-info-dialog/appliance-info-dialog.component'; import { TemplateNameDialogComponent } from './template-name-dialog/template-name-dialog.component'; import { UploadServiceService } from '../../../common/uploading-processbar/upload-service.service'; +import { environment } from 'environments/environment'; @Component({ selector: 'app-new-template-dialog', @@ -246,7 +247,7 @@ export class NewTemplateDialogComponent implements OnInit { } getAppliance(url: string) { - let str = url.split('/v3'); + let str = url.split(`/${environment.current_version}`); let appliancePath = str[str.length - 1]; this.applianceService.getAppliance(this.server, appliancePath).subscribe((appliance: Appliance) => { this.applianceToInstall = appliance; diff --git a/src/app/components/project-map/project-map.component.ts b/src/app/components/project-map/project-map.component.ts index ad4bf0e0..df7936f1 100644 --- a/src/app/components/project-map/project-map.component.ts +++ b/src/app/components/project-map/project-map.component.ts @@ -3,6 +3,7 @@ import { MatBottomSheet } from '@angular/material/bottom-sheet'; import { MatDialog } from '@angular/material/dialog'; import { Title } from '@angular/platform-browser'; import { ActivatedRoute, ParamMap, Router } from '@angular/router'; +import { environment } from 'environments/environment'; import * as Mousetrap from 'mousetrap'; import { from, Observable, Subscription } from 'rxjs'; import { map, mergeMap, takeUntil } from 'rxjs/operators'; @@ -260,7 +261,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { this.nodesDataSource.changes.subscribe((nodes: Node[]) => { if (!this.server) return; nodes.forEach(async (node: Node) => { - node.symbol_url = `${this.server.protocol}//${this.server.host}:${this.server.port}/v3/symbols/${node.symbol}/raw`; + node.symbol_url = `${this.server.protocol}//${this.server.host}:${this.server.port}/${environment.current_version}/symbols/${node.symbol}/raw`; if (node.width == 0 && node.height == 0) { let symbolDimensions = await this.symbolService.getDimensions(this.server, node.symbol).toPromise(); diff --git a/src/app/components/projects/import-project-dialog/import-project-dialog.component.spec.ts b/src/app/components/projects/import-project-dialog/import-project-dialog.component.spec.ts index 10321ff5..883d8fa6 100644 --- a/src/app/components/projects/import-project-dialog/import-project-dialog.component.spec.ts +++ b/src/app/components/projects/import-project-dialog/import-project-dialog.component.spec.ts @@ -11,6 +11,7 @@ import { MatTooltipModule } from '@angular/material/tooltip'; import { By } from '@angular/platform-browser'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; +import { environment } from 'environments/environment'; import { FileItem, FileSelectDirective, FileUploadModule } from 'ng2-file-upload'; import { of } from 'rxjs/internal/observable/of'; import { Project } from '../../../models/project'; @@ -47,11 +48,11 @@ export class MockedProjectService { } getUploadPath(server: Server, uuid: string, project_name: string) { - return `http://${server.host}:${server.port}/v3/projects/${uuid}/import?name=${project_name}`; + return `http://${server.host}:${server.port}/${environment.current_version}/projects/${uuid}/import?name=${project_name}`; } getExportPath(server: Server, project: Project) { - return `http://${server.host}:${server.port}/v3/projects/${project.project_id}/export`; + return `http://${server.host}:${server.port}/${environment.current_version}/projects/${project.project_id}/export`; } } diff --git a/src/app/filters/authImageFilter.ts b/src/app/filters/authImageFilter.ts index 070b286b..72f6cbe8 100644 --- a/src/app/filters/authImageFilter.ts +++ b/src/app/filters/authImageFilter.ts @@ -3,19 +3,20 @@ import { Console } from 'console'; import { Server } from '../models/server'; import { HttpServer } from '../services/http-server.service'; import { DomSanitizer } from '@angular/platform-browser'; +import { environment } from 'environments/environment'; @Pipe({ name: 'authImage' }) export class AuthImageFilter implements PipeTransform { - + constructor( private httpServer: HttpServer, private domSanitizer: DomSanitizer - ) {} - + ) { } + async transform(src: string, server: Server) { - let url = src.split('v3')[1]; + let url = src.split(`${environment.current_version}`)[1]; const imageBlob: Blob = await this.httpServer.getBlob(server, url).toPromise(); const reader = new FileReader(); return new Promise((resolve, reject) => { diff --git a/src/app/services/built-in-templates.service.spec.ts b/src/app/services/built-in-templates.service.spec.ts index eee94c8d..86cd0938 100644 --- a/src/app/services/built-in-templates.service.spec.ts +++ b/src/app/services/built-in-templates.service.spec.ts @@ -1,6 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { inject, TestBed } from '@angular/core/testing'; +import { environment } from 'environments/environment'; import { Server } from '../models/server'; import { CloudTemplate } from '../models/templates/cloud-template'; import { EthernetHubTemplate } from '../models/templates/ethernet-hub-template'; @@ -51,7 +52,7 @@ describe('BuiltInTemplatesService', () => { service.saveTemplate(server, cloudtemplate).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/templates/1'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates/1`); expect(req.request.method).toEqual('PUT'); expect(req.request.body).toEqual(cloudtemplate); })); @@ -71,7 +72,7 @@ describe('BuiltInTemplatesService', () => { service.saveTemplate(server, ethernethubtemplate).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/templates/2'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates/2`); expect(req.request.method).toEqual('PUT'); expect(req.request.body).toEqual(ethernethubtemplate); })); @@ -91,7 +92,7 @@ describe('BuiltInTemplatesService', () => { service.saveTemplate(server, ethernetswitchtemplate).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/templates/3'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates/3`); expect(req.request.method).toEqual('PUT'); expect(req.request.body).toEqual(ethernetswitchtemplate); })); @@ -112,7 +113,7 @@ describe('BuiltInTemplatesService', () => { service.addTemplate(server, cloudtemplate).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/templates'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates`) expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual(cloudtemplate); })); @@ -132,7 +133,7 @@ describe('BuiltInTemplatesService', () => { service.addTemplate(server, ethernethubtemplate).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/templates'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates`) expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual(ethernethubtemplate); })); @@ -152,7 +153,7 @@ describe('BuiltInTemplatesService', () => { service.addTemplate(server, ethernetswitchtemplate).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/templates'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates`) expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual(ethernetswitchtemplate); })); diff --git a/src/app/services/compute.service.ts b/src/app/services/compute.service.ts index 36e83e7a..b8234b6d 100644 --- a/src/app/services/compute.service.ts +++ b/src/app/services/compute.service.ts @@ -1,4 +1,5 @@ import { Injectable } from '@angular/core'; +import { environment } from 'environments/environment'; import { Observable } from 'rxjs'; import { Compute } from '../models/compute'; import { ComputeStatistics } from '../models/computeStatistics'; @@ -14,7 +15,7 @@ export class ComputeService { } getUploadPath(server: Server, emulator: string, filename: string) { - return `${server.protocol}//${server.host}:${server.port}/v3/${emulator}/images/${filename}`; + return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/${emulator}/images/${filename}`; } getStatistics(server: Server): Observable { diff --git a/src/app/services/drawing.service.spec.ts b/src/app/services/drawing.service.spec.ts index 3307f869..d470a6a4 100644 --- a/src/app/services/drawing.service.spec.ts +++ b/src/app/services/drawing.service.spec.ts @@ -1,6 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { inject, TestBed } from '@angular/core/testing'; +import { environment } from 'environments/environment'; import { SvgToDrawingConverter } from '../cartography/helpers/svg-to-drawing-converter'; import { Drawing } from '../cartography/models/drawing'; import { Project } from '../models/project'; @@ -44,7 +45,7 @@ describe('DrawingService', () => { service.updatePosition(server, project, drawing, 10, 20).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/drawings/id'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/drawings/id`); expect(req.request.method).toEqual('PUT'); expect(req.request.body).toEqual({ x: 10, @@ -59,7 +60,7 @@ describe('DrawingService', () => { service.updatePosition(server, project, drawing, 10.1, 20.6).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/drawings/id'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/drawings/id`); expect(req.request.method).toEqual('PUT'); expect(req.request.body).toEqual({ x: 10, @@ -75,7 +76,7 @@ describe('DrawingService', () => { service.updateSizeAndPosition(server, drawing, 100, 100, svgSample).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/drawings/id'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/drawings/id`); expect(req.request.method).toEqual('PUT'); expect(req.request.body).toEqual({ x: 100, @@ -94,7 +95,7 @@ describe('DrawingService', () => { service.updateSizeAndPosition(server, drawing, 100.1, 100.6, svgSample).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/drawings/id'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/drawings/id`); expect(req.request.method).toEqual('PUT'); expect(req.request.body).toEqual({ x: 100, @@ -117,7 +118,7 @@ describe('DrawingService', () => { service.update(server, drawing).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/drawings/id'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/drawings/id`); expect(req.request.method).toEqual('PUT'); expect(req.request.body).toEqual({ x: 10, @@ -136,7 +137,7 @@ describe('DrawingService', () => { service.delete(server, drawing).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/drawings/id'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/drawings/id`); expect(req.request.method).toEqual('DELETE'); })); @@ -153,7 +154,7 @@ describe('DrawingService', () => { service.duplicate(server, drawing.project_id, drawing).subscribe(); - const req = httpTestingController.expectOne(`http://127.0.0.1:3080/v3/projects/${drawing.project_id}/drawings`); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/${drawing.project_id}/drawings`); expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual({ svg: drawing.svg, diff --git a/src/app/services/http-server.service.spec.ts b/src/app/services/http-server.service.spec.ts index 47c19c77..12d17859 100644 --- a/src/app/services/http-server.service.spec.ts +++ b/src/app/services/http-server.service.spec.ts @@ -1,6 +1,7 @@ import { HttpClient, HttpErrorResponse } from '@angular/common/http'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { TestBed } from '@angular/core/testing'; +import { environment } from 'environments/environment'; import { Server } from '../models/server'; import { AppTestingModule } from '../testing/app-testing/app-testing.module'; import { HttpServer, ServerError, ServerErrorHandler } from './http-server.service'; @@ -76,7 +77,7 @@ describe('HttpServer', () => { it('should make GET query for get method', () => { service.get(server, '/test').subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/test'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/test`); expect(req.request.method).toEqual('GET'); expect(req.request.responseType).toEqual('json'); }); @@ -89,7 +90,7 @@ describe('HttpServer', () => { expect(data).toEqual(testData); }); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/test'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/test`); expect(req.request.method).toEqual('GET'); expect(req.request.responseType).toEqual('json'); @@ -115,7 +116,7 @@ describe('HttpServer', () => { it('should make GET query for getText method', () => { service.getText(server, '/test').subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/test'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/test`); expect(req.request.method).toEqual('GET'); expect(req.request.responseType).toEqual('text'); }); @@ -130,7 +131,7 @@ describe('HttpServer', () => { }) .subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/test'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/test`); expect(req.request.method).toEqual('GET'); expect(req.request.responseType).toEqual('text'); }); @@ -138,7 +139,7 @@ describe('HttpServer', () => { it('should make POST query for post method', () => { service.post(server, '/test', { test: '1' }).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/test'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/test`); expect(req.request.method).toEqual('POST'); expect(req.request.responseType).toEqual('json'); }); @@ -146,7 +147,7 @@ describe('HttpServer', () => { it('should make PUT query for put method', () => { service.put(server, '/test', { test: '1' }).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/test'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/test`); expect(req.request.method).toEqual('PUT'); expect(req.request.responseType).toEqual('json'); }); @@ -154,7 +155,7 @@ describe('HttpServer', () => { it('should make DELETE query for delete method', () => { service.delete(server, '/test').subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/test'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/test`); expect(req.request.method).toEqual('DELETE'); expect(req.request.responseType).toEqual('json'); }); @@ -162,7 +163,7 @@ describe('HttpServer', () => { it('should make PATCH query for patch method', () => { service.patch(server, '/test', { test: '1' }).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/test'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/test`); expect(req.request.method).toEqual('PATCH'); expect(req.request.responseType).toEqual('json'); }); @@ -170,7 +171,7 @@ describe('HttpServer', () => { it('should make HEAD query for head method', () => { service.head(server, '/test').subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/test'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/test`); expect(req.request.method).toEqual('HEAD'); expect(req.request.responseType).toEqual('json'); }); @@ -178,7 +179,7 @@ describe('HttpServer', () => { it('should make OPTIONS query for options method', () => { service.options(server, '/test').subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/test'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/test`); expect(req.request.method).toEqual('OPTIONS'); expect(req.request.responseType).toEqual('json'); }); @@ -195,7 +196,7 @@ describe('HttpServer', () => { }) .subscribe(); - const req = httpTestingController.expectOne('/v3/test'); - expect(req.request.url).toBe('/v3/test'); + const req = httpTestingController.expectOne(`/${environment.current_version}/test`); + expect(req.request.url).toBe(`/${environment.current_version}/test`); }); }); diff --git a/src/app/services/http-server.service.ts b/src/app/services/http-server.service.ts index f46b97fe..5668c286 100644 --- a/src/app/services/http-server.service.ts +++ b/src/app/services/http-server.service.ts @@ -1,5 +1,6 @@ import { HttpClient, HttpErrorResponse, HttpHeaders, HttpParams } from '@angular/common/http'; import { EventEmitter, Injectable } from '@angular/core'; +import { environment } from 'environments/environment'; import { Observable, throwError } from 'rxjs'; import { catchError } from 'rxjs/operators'; import { Server, ServerProtocol } from '../models/server'; @@ -218,9 +219,9 @@ export class HttpServer { if (!server.protocol) { server.protocol = location.protocol as ServerProtocol; } - url = `${server.protocol}//${server.host}:${server.port}/v3${url}`; + url = `${server.protocol}//${server.host}:${server.port}/${environment.current_version}${url}`; } else { - url = `/v3${url}`; + url = `/${environment.current_version}${url}`; } if (!options.headers) { diff --git a/src/app/services/image-manager.service.ts b/src/app/services/image-manager.service.ts index 67df46b0..9c210b6f 100644 --- a/src/app/services/image-manager.service.ts +++ b/src/app/services/image-manager.service.ts @@ -3,6 +3,7 @@ import { Server } from '../models/server'; import { HttpServer } from './http-server.service'; import { Observable } from 'rxjs'; import { Image } from "../models/images"; +import { environment } from 'environments/environment'; @Injectable({ providedIn: 'root' @@ -16,11 +17,11 @@ export class ImageManagerService { } getImagePath(server:Server, install_appliance, image_path){ - return `${server.protocol}//${server.host}:${server.port}/v3/images/upload/${image_path}?install_appliances=${install_appliance}`; + return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/images/upload/${image_path}?install_appliances=${install_appliance}`; } getUploadPath(server: Server, emulator: string, filename: string) { - return `${server.protocol}//${server.host}:${server.port}/v3/images/upload/${filename}`; + return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/images/upload/${filename}`; } uploadedImage(server:Server, install_appliance, image_path, flie){ diff --git a/src/app/services/link.service.spec.ts b/src/app/services/link.service.spec.ts index 18ba9c31..a4cc5e8d 100644 --- a/src/app/services/link.service.spec.ts +++ b/src/app/services/link.service.spec.ts @@ -1,6 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { inject, TestBed } from '@angular/core/testing'; +import { environment } from 'environments/environment'; import { Node } from '../cartography/models/node'; import { Port } from '../models/port'; import { Server } from '../models/server'; @@ -53,7 +54,7 @@ describe('LinkService', () => { service.createLink(server, sourceNode, sourcePort, targetNode, targetPort, 0, 0, 10, 10).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/links'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/links`); expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual({ nodes: [ diff --git a/src/app/services/node.service.spec.ts b/src/app/services/node.service.spec.ts index 4b16e450..7760fc7b 100644 --- a/src/app/services/node.service.spec.ts +++ b/src/app/services/node.service.spec.ts @@ -1,6 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { inject, TestBed } from '@angular/core/testing'; +import { environment } from 'environments/environment'; import { Label } from '../cartography/models/label'; import { Node } from '../cartography/models/node'; import { Project } from '../models/project'; @@ -49,7 +50,7 @@ describe('NodeService', () => { service.start(server, node).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/nodes/id/start'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/nodes/id/start`); expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual({}); })); @@ -61,7 +62,7 @@ describe('NodeService', () => { service.stop(server, node).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/nodes/id/stop'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/nodes/id/stop`); expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual({}); })); @@ -73,7 +74,7 @@ describe('NodeService', () => { service.suspend(server, node).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/nodes/id/suspend'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/nodes/id/suspend`); expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual({}); })); @@ -85,7 +86,7 @@ describe('NodeService', () => { service.reload(server, node).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/nodes/id/reload'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/nodes/id/reload`); expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual({}); })); @@ -97,7 +98,7 @@ describe('NodeService', () => { service.startAll(server, project).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/1/nodes/start'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/1/nodes/start`); expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual({}); })); @@ -109,7 +110,7 @@ describe('NodeService', () => { service.stopAll(server, project).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/1/nodes/stop'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/1/nodes/stop`); expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual({}); })); @@ -121,7 +122,7 @@ describe('NodeService', () => { service.suspendAll(server, project).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/1/nodes/suspend'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/1/nodes/suspend`); expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual({}); })); @@ -133,7 +134,7 @@ describe('NodeService', () => { service.reloadAll(server, project).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/1/nodes/reload'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/1/nodes/reload`); expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual({}); })); @@ -146,7 +147,7 @@ describe('NodeService', () => { service.createFromTemplate(server, project, template, 10, 20, 'compute').subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/templates/mytemplate'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/templates/mytemplate`); expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual({ x: 10, @@ -165,7 +166,7 @@ describe('NodeService', () => { service.updatePosition(server, project, node, 10, 20).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/nodes/id'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/nodes/id`); expect(req.request.method).toEqual('PUT'); expect(req.request.body).toEqual({ x: 10, @@ -183,7 +184,7 @@ describe('NodeService', () => { service.updatePosition(server, project, node, 10.1, 20.6).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/nodes/id'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/nodes/id`); expect(req.request.method).toEqual('PUT'); expect(req.request.body).toEqual({ x: 10, @@ -205,7 +206,7 @@ describe('NodeService', () => { service.updateLabel(server, node, label).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/nodes/id'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/nodes/id`); expect(req.request.method).toEqual('PUT'); expect(req.request.body).toEqual({ label: { @@ -228,7 +229,7 @@ describe('NodeService', () => { service.update(server, node).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/nodes/id'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/nodes/id`); expect(req.request.method).toEqual('PUT'); expect(req.request.body).toEqual({ x: 10, @@ -244,7 +245,7 @@ describe('NodeService', () => { service.delete(server, node).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/nodes/id'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/nodes/id`); expect(req.request.method).toEqual('DELETE'); })); @@ -256,7 +257,7 @@ describe('NodeService', () => { service.duplicate(server, node).subscribe(); const req = httpTestingController.expectOne( - `http://127.0.0.1:3080/v3/projects/${node.project_id}/nodes/${node.node_id}/duplicate` + `http://127.0.0.1:3080/${environment.current_version}/projects/${node.project_id}/nodes/${node.node_id}/duplicate` ); expect(req.request.method).toEqual('POST'); })); diff --git a/src/app/services/nodeConsole.service.ts b/src/app/services/nodeConsole.service.ts index 7a97788d..e38e4617 100644 --- a/src/app/services/nodeConsole.service.ts +++ b/src/app/services/nodeConsole.service.ts @@ -6,6 +6,7 @@ import { Router } from '@angular/router'; import { ToasterService } from './toaster.service'; import { MapSettingsService } from './mapsettings.service'; import { node } from 'prop-types'; +import { environment } from 'environments/environment'; @Injectable() export class NodeConsoleService { @@ -71,7 +72,7 @@ export class NodeConsoleService { protocol = "wss" } - return `${protocol}://${server.host}:${server.port}/v3/projects/${node.project_id}/nodes/${node.node_id}/console/ws` + return `${protocol}://${server.host}:${server.port}/${environment.current_version}/projects/${node.project_id}/nodes/${node.node_id}/console/ws` } openConsolesForAllNodesInWidget(nodes: Node[]) { diff --git a/src/app/services/notification.service.ts b/src/app/services/notification.service.ts index 46cb69e5..c159a83a 100644 --- a/src/app/services/notification.service.ts +++ b/src/app/services/notification.service.ts @@ -1,4 +1,5 @@ import { Injectable } from '@angular/core'; +import { environment } from 'environments/environment'; import { Server } from '../models/server'; @Injectable() @@ -9,7 +10,7 @@ export class NotificationService { protocol = "wss" } - return `${protocol}://${server.host}:${server.port}/v3/notifications/ws?token=${server.authToken}`; + return `${protocol}://${server.host}:${server.port}/${environment.current_version}/notifications/ws?token=${server.authToken}`; } @@ -19,6 +20,6 @@ export class NotificationService { protocol = "wss" } - return `${protocol}://${server.host}:${server.port}/v3/projects/${project_id}/notifications/ws?token=${server.authToken}`; + return `${protocol}://${server.host}:${server.port}/${environment.current_version}/projects/${project_id}/notifications/ws?token=${server.authToken}`; } } diff --git a/src/app/services/project.service.spec.ts b/src/app/services/project.service.spec.ts index f4acb932..41071e7a 100644 --- a/src/app/services/project.service.spec.ts +++ b/src/app/services/project.service.spec.ts @@ -1,6 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { TestBed } from '@angular/core/testing'; +import { environment } from 'environments/environment'; import { of } from 'rxjs'; import { Project } from '../models/project'; import { Server } from '../models/server'; @@ -89,14 +90,14 @@ describe('ProjectService', () => { it('should get the project', () => { service.get(server, 'myproject').subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject`); expect(req.request.method).toEqual('GET'); }); it('should open the project', () => { service.open(server, 'myproject').subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/open'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/open`); expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual({}); }); @@ -104,7 +105,7 @@ describe('ProjectService', () => { it('should close the project', () => { service.close(server, 'myproject').subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/close'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/close`); expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual({}); }); @@ -112,42 +113,42 @@ describe('ProjectService', () => { it('should list projects', () => { service.list(server).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects`); expect(req.request.method).toEqual('GET'); }); it('should get nodes of project', () => { service.nodes(server, 'myproject').subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/nodes'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/nodes`); expect(req.request.method).toEqual('GET'); }); it('should get links of project', () => { service.links(server, 'myproject').subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/links'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/links`); expect(req.request.method).toEqual('GET'); }); it('should get drawings of project', () => { service.drawings(server, 'myproject').subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/drawings'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/drawings`); expect(req.request.method).toEqual('GET'); }); it('should delete the project', () => { service.delete(server, 'myproject').subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject`); expect(req.request.method).toEqual('DELETE'); }); it('should duplicate the project', () => { service.duplicate(server, 'projectId', 'projectName').subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/projectId/duplicate'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/projectId/duplicate`); expect(req.request.method).toEqual('POST'); }); diff --git a/src/app/services/project.service.ts b/src/app/services/project.service.ts index 5ec97122..3367adba 100644 --- a/src/app/services/project.service.ts +++ b/src/app/services/project.service.ts @@ -1,4 +1,5 @@ import { Injectable } from '@angular/core'; +import { environment } from 'environments/environment'; import { Observable, Subject } from 'rxjs'; import { Drawing } from '../cartography/models/drawing'; import { Node } from '../cartography/models/node'; @@ -83,11 +84,11 @@ export class ProjectService { } getUploadPath(server: Server, uuid: string, project_name: string) { - return `${server.protocol}//${server.host}:${server.port}/v3/projects/${uuid}/import?name=${project_name}`; + return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/projects/${uuid}/import?name=${project_name}`; } getExportPath(server: Server, project: Project) { - return `${server.protocol}//${server.host}:${server.port}/v3/projects/${project.project_id}/export`; + return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/projects/${project.project_id}/export`; } export(server: Server, project_id: string): Observable { diff --git a/src/app/services/qemu.service.spec.ts b/src/app/services/qemu.service.spec.ts index b3e64552..b2c80f11 100644 --- a/src/app/services/qemu.service.spec.ts +++ b/src/app/services/qemu.service.spec.ts @@ -1,6 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { inject, TestBed } from '@angular/core/testing'; +import { environment } from 'environments/environment'; import { Server } from '../models/server'; import { QemuTemplate } from '../models/templates/qemu-template'; import { AppTestingModule } from '../testing/app-testing/app-testing.module'; @@ -81,7 +82,7 @@ describe('QemuService', () => { service.saveTemplate(server, template).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/templates/1'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates/1`); expect(req.request.method).toEqual('PUT'); expect(req.request.body).toEqual(template); })); @@ -133,7 +134,7 @@ describe('QemuService', () => { service.addTemplate(server, template).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/templates'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates`); expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual(template); })); diff --git a/src/app/services/snapshot.service.spec.ts b/src/app/services/snapshot.service.spec.ts index 9df90aa9..2c677c0b 100644 --- a/src/app/services/snapshot.service.spec.ts +++ b/src/app/services/snapshot.service.spec.ts @@ -1,6 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { inject, TestBed } from '@angular/core/testing'; +import { environment } from 'environments/environment'; import { Server } from '../models/server'; import { Snapshot } from '../models/snapshot'; import { AppTestingModule } from '../testing/app-testing/app-testing.module'; @@ -40,7 +41,7 @@ describe('SnapshotService', () => { const snapshot = new Snapshot(); service.create(server, 'myproject', snapshot).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/snapshots'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/snapshots`); expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual(snapshot); })); @@ -48,7 +49,7 @@ describe('SnapshotService', () => { it('should list snapshots', inject([SnapshotService], (service: SnapshotService) => { service.list(server, 'myproject').subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/projects/myproject/snapshots'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/projects/myproject/snapshots`); expect(req.request.method).toEqual('GET'); })); }); diff --git a/src/app/services/symbol.service.spec.ts b/src/app/services/symbol.service.spec.ts index 1fce0b1e..153aaee4 100644 --- a/src/app/services/symbol.service.spec.ts +++ b/src/app/services/symbol.service.spec.ts @@ -1,6 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { inject, TestBed } from '@angular/core/testing'; +import { environment } from 'environments/environment'; import { of } from 'rxjs'; import { Server } from '../models/server'; import { Symbol } from '../models/symbol'; @@ -38,14 +39,14 @@ describe('SymbolService', () => { it('should list symbols', inject([SymbolService], (service: SymbolService) => { service.list(server).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/symbols'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/symbols`); expect(req.request.method).toEqual('GET'); })); it('should get raw symbol', inject([SymbolService], (service: SymbolService) => { service.raw(server, ':my/tested.png').subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/symbols/:my/tested.png/raw'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/symbols/:my/tested.png/raw`); expect(req.request.method).toEqual('GET'); })); }); diff --git a/src/app/services/symbol.service.ts b/src/app/services/symbol.service.ts index 97706022..bf7eeb05 100644 --- a/src/app/services/symbol.service.ts +++ b/src/app/services/symbol.service.ts @@ -6,6 +6,7 @@ import { Node } from '../cartography/models/node'; import { Server } from '../models/server'; import { Symbol } from '../models/symbol'; import { HttpServer } from './http-server.service'; +import { environment } from 'environments/environment'; const CACHE_SIZE = 1; @@ -65,7 +66,7 @@ export class SymbolService { } getSymbolFromTemplate(server: Server, template: Template) { - return `${server.protocol}//${server.host}:${server.port}/v3/symbols/${template.symbol}/raw`; + return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/symbols/${template.symbol}/raw`; } } diff --git a/src/app/services/template.service.spec.ts b/src/app/services/template.service.spec.ts index c7f02ce5..82cb9b64 100644 --- a/src/app/services/template.service.spec.ts +++ b/src/app/services/template.service.spec.ts @@ -1,6 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { TestBed } from '@angular/core/testing'; +import { environment } from 'environments/environment'; import { Server } from '../models/server'; import { AppTestingModule } from '../testing/app-testing/app-testing.module'; import { HttpServer } from './http-server.service'; @@ -33,7 +34,7 @@ describe('TemplateService', () => { service.list(server).subscribe(() => {}); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/templates'); - expect(req.request.url).toBe('http://127.0.0.1:3080/v3/templates'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates`); + expect(req.request.url).toBe(`http://127.0.0.1:3080/${environment.current_version}/templates`); }); }); diff --git a/src/app/services/version.service.spec.ts b/src/app/services/version.service.spec.ts index e541c367..6d8bad0e 100644 --- a/src/app/services/version.service.spec.ts +++ b/src/app/services/version.service.spec.ts @@ -1,6 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { inject, TestBed } from '@angular/core/testing'; +import { environment } from 'environments/environment'; import { Observable } from 'rxjs/Rx'; import { Server } from '../models/server'; import { AppTestingModule } from '../testing/app-testing/app-testing.module'; @@ -47,7 +48,7 @@ describe('VersionService', () => { it('should get version', inject([VersionService], (service: VersionService) => { service.get(server).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/version'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/version`); expect(req.request.method).toEqual('GET'); })); }); diff --git a/src/app/services/virtual-box.service.spec.ts b/src/app/services/virtual-box.service.spec.ts index fae3f8b0..edcee5cf 100644 --- a/src/app/services/virtual-box.service.spec.ts +++ b/src/app/services/virtual-box.service.spec.ts @@ -1,6 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { inject, TestBed } from '@angular/core/testing'; +import { environment } from 'environments/environment'; import { Server } from '../models/server'; import { VirtualBoxTemplate } from '../models/templates/virtualbox-template'; import { AppTestingModule } from '../testing/app-testing/app-testing.module'; @@ -63,7 +64,7 @@ describe('VirtualBoxService', () => { service.saveTemplate(server, template).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/templates/1'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates/1`); expect(req.request.method).toEqual('PUT'); expect(req.request.body).toEqual(template); })); @@ -97,7 +98,7 @@ describe('VirtualBoxService', () => { service.addTemplate(server, template).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/templates'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates`); expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual(template); })); @@ -105,7 +106,7 @@ describe('VirtualBoxService', () => { it('should get available virtual machines', inject([VirtualBoxService], (service: VirtualBoxService) => { service.getVirtualMachines(server).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/compute/virtualbox/vms'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/compute/virtualbox/vms`); expect(req.request.method).toEqual('GET'); })); }); diff --git a/src/app/services/vmware.service.spec.ts b/src/app/services/vmware.service.spec.ts index 759c8ae1..172ae2a1 100644 --- a/src/app/services/vmware.service.spec.ts +++ b/src/app/services/vmware.service.spec.ts @@ -1,6 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { inject, TestBed } from '@angular/core/testing'; +import { environment } from 'environments/environment'; import { Server } from '../models/server'; import { VmwareTemplate } from '../models/templates/vmware-template'; import { AppTestingModule } from '../testing/app-testing/app-testing.module'; @@ -62,7 +63,7 @@ describe('VmwareService', () => { service.saveTemplate(server, template).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/templates/1'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates/1`); expect(req.request.method).toEqual('PUT'); expect(req.request.body).toEqual(template); })); @@ -95,7 +96,7 @@ describe('VmwareService', () => { service.addTemplate(server, template).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/templates'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates`); expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual(template); })); @@ -103,7 +104,7 @@ describe('VmwareService', () => { it('should get available virtual machines', inject([VmwareService], (service: VmwareService) => { service.getVirtualMachines(server).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/compute/vmware/vms'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/compute/vmware/vms`); expect(req.request.method).toEqual('GET'); })); }); diff --git a/src/app/services/vpcs.service.spec.ts b/src/app/services/vpcs.service.spec.ts index c98318bf..d3c351f0 100644 --- a/src/app/services/vpcs.service.spec.ts +++ b/src/app/services/vpcs.service.spec.ts @@ -1,6 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { inject, TestBed } from '@angular/core/testing'; +import { environment } from 'environments/environment'; import { Server } from '../models/server'; import { VpcsTemplate } from '../models/templates/vpcs-template'; import { AppTestingModule } from '../testing/app-testing/app-testing.module'; @@ -51,7 +52,7 @@ describe('VpcsService', () => { service.saveTemplate(server, template).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/templates/1'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates/1`); expect(req.request.method).toEqual('PUT'); expect(req.request.body).toEqual(template); })); @@ -73,7 +74,7 @@ describe('VpcsService', () => { service.addTemplate(server, template).subscribe(); - const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/templates'); + const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/templates`); expect(req.request.method).toEqual('POST'); expect(req.request.body).toEqual(template); }));