mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-29 21:54:13 +01:00
Merge pull request #10826 from AllForNothing/api-level
Upgrade api level to v2
This commit is contained in:
commit
d3b3f6abab
@ -1,6 +1,7 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
import { Express } from 'express';
|
import { Express } from 'express';
|
||||||
import * as Controllers from '../controllers';
|
import * as Controllers from '../controllers';
|
||||||
|
import { CURRENT_BASE_HREF } from "../../src/lib/utils/utils";
|
||||||
|
|
||||||
|
|
||||||
const mockApi: Express = express();
|
const mockApi: Express = express();
|
||||||
@ -9,7 +10,7 @@ mockApi.get('/', (req, res) => {
|
|||||||
res.send('Hello World!');
|
res.send('Hello World!');
|
||||||
});
|
});
|
||||||
|
|
||||||
mockApi.get('/api/scanners', Controllers.getScanner);
|
mockApi.get(CURRENT_BASE_HREF + '/scanners', Controllers.getScanner);
|
||||||
|
|
||||||
mockApi.listen(3000, () => {
|
mockApi.listen(3000, () => {
|
||||||
console.log('Api server listening on port 3000!');
|
console.log('Api server listening on port 3000!');
|
||||||
|
@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { catchError, map } from 'rxjs/operators';
|
import { catchError, map } from 'rxjs/operators';
|
||||||
import { throwError as observableThrowError, Observable } from 'rxjs';
|
import { throwError as observableThrowError, Observable } from 'rxjs';
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../lib/utils/utils";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ export class AccountSettingsModalService {
|
|||||||
|
|
||||||
constructor(private http: HttpClient) { }
|
constructor(private http: HttpClient) { }
|
||||||
saveNewCli(userId, secretObj): Observable<any> {
|
saveNewCli(userId, secretObj): Observable<any> {
|
||||||
return this.http.put(`/api/users/${userId}/cli_secret`, secretObj).pipe( map(response => response)
|
return this.http.put(`${ CURRENT_BASE_HREF }/users/${userId}/cli_secret`, secretObj).pipe( map(response => response)
|
||||||
, catchError(error => observableThrowError(error)));
|
, catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { TestBed, inject, getTestBed } from '@angular/core/testing';
|
import { TestBed, inject, getTestBed } from '@angular/core/testing';
|
||||||
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
|
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
|
||||||
import { PasswordSettingService } from './password-setting.service';
|
import { PasswordSettingService } from './password-setting.service';
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../lib/utils/utils";
|
||||||
|
|
||||||
describe('PasswordSettingService', () => {
|
describe('PasswordSettingService', () => {
|
||||||
let injector: TestBed;
|
let injector: TestBed;
|
||||||
@ -32,7 +33,7 @@ describe('PasswordSettingService', () => {
|
|||||||
expect(res).toEqual(null);
|
expect(res).toEqual(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
const req = httpMock.expectOne('/api/users/1/password');
|
const req = httpMock.expectOne(CURRENT_BASE_HREF + '/users/1/password');
|
||||||
expect(req.request.method).toBe('PUT');
|
expect(req.request.method).toBe('PUT');
|
||||||
req.flush(null);
|
req.flush(null);
|
||||||
});
|
});
|
||||||
|
@ -16,9 +16,9 @@ import { HttpClient, HttpParams } from '@angular/common/http';
|
|||||||
import { map, catchError } from "rxjs/operators";
|
import { map, catchError } from "rxjs/operators";
|
||||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||||
import { PasswordSetting } from './password-setting';
|
import { PasswordSetting } from './password-setting';
|
||||||
import { HTTP_FORM_OPTIONS, HTTP_GET_OPTIONS, HTTP_JSON_OPTIONS } from "../../../lib/utils/utils";
|
import { CURRENT_BASE_HREF, HTTP_FORM_OPTIONS, HTTP_GET_OPTIONS, HTTP_JSON_OPTIONS } from "../../../lib/utils/utils";
|
||||||
|
|
||||||
const passwordChangeEndpoint = "/api/users/:user_id/password";
|
const passwordChangeEndpoint = CURRENT_BASE_HREF + "/users/:user_id/password";
|
||||||
const sendEmailEndpoint = "/c/sendEmail";
|
const sendEmailEndpoint = "/c/sendEmail";
|
||||||
const resetPasswordEndpoint = "/c/reset";
|
const resetPasswordEndpoint = "/c/reset";
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import { CookieService } from 'ngx-cookie';
|
|||||||
import { AppConfigService } from './app-config.service';
|
import { AppConfigService } from './app-config.service';
|
||||||
import { AppConfig } from './app-config';
|
import { AppConfig } from './app-config';
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
|
import { CURRENT_BASE_HREF } from "../lib/utils/utils";
|
||||||
|
|
||||||
describe('AppConfigService', () => {
|
describe('AppConfigService', () => {
|
||||||
let injector: TestBed;
|
let injector: TestBed;
|
||||||
@ -35,7 +36,7 @@ describe('AppConfigService', () => {
|
|||||||
expect(res).toEqual(systeminfo);
|
expect(res).toEqual(systeminfo);
|
||||||
});
|
});
|
||||||
|
|
||||||
const req = httpMock.expectOne('/api/systeminfo');
|
const req = httpMock.expectOne(CURRENT_BASE_HREF + '/systeminfo');
|
||||||
expect(req.request.method).toBe('GET');
|
expect(req.request.method).toBe('GET');
|
||||||
req.flush(systeminfo);
|
req.flush(systeminfo);
|
||||||
expect(service.getConfig()).toEqual(systeminfo);
|
expect(service.getConfig()).toEqual(systeminfo);
|
||||||
|
@ -19,9 +19,9 @@ import { CookieKeyOfAdmiral, HarborQueryParamKey } from './shared/shared.const';
|
|||||||
import { maintainUrlQueryParmas } from './shared/shared.utils';
|
import { maintainUrlQueryParmas } from './shared/shared.utils';
|
||||||
import { map, catchError } from "rxjs/operators";
|
import { map, catchError } from "rxjs/operators";
|
||||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||||
import { HTTP_GET_OPTIONS } from "../lib/utils/utils";
|
import { CURRENT_BASE_HREF, HTTP_GET_OPTIONS } from "../lib/utils/utils";
|
||||||
import { CONFIG_AUTH_MODE } from "../lib/entities/shared.const";
|
import { CONFIG_AUTH_MODE } from "../lib/entities/shared.const";
|
||||||
export const systemInfoEndpoint = "/api/systeminfo";
|
export const systemInfoEndpoint = CURRENT_BASE_HREF + "/systeminfo";
|
||||||
/**
|
/**
|
||||||
* Declare service to handle the bootstrap options
|
* Declare service to handle the bootstrap options
|
||||||
*
|
*
|
||||||
|
@ -45,7 +45,6 @@ import { LabelsComponent } from './labels/labels.component';
|
|||||||
import { ProjectQuotasComponent } from './project-quotas/project-quotas.component';
|
import { ProjectQuotasComponent } from './project-quotas/project-quotas.component';
|
||||||
import { HarborLibraryModule } from "../lib/harbor-library.module";
|
import { HarborLibraryModule } from "../lib/harbor-library.module";
|
||||||
import { HTTP_INTERCEPTORS } from '@angular/common/http';
|
import { HTTP_INTERCEPTORS } from '@angular/common/http';
|
||||||
import { BaseHrefInterceptService } from "./base-href-intercept.service";
|
|
||||||
|
|
||||||
registerLocaleData(zh, 'zh-cn');
|
registerLocaleData(zh, 'zh-cn');
|
||||||
registerLocaleData(es, 'es-es');
|
registerLocaleData(es, 'es-es');
|
||||||
@ -99,7 +98,6 @@ export function getCurrentLanguage(translateService: TranslateService) {
|
|||||||
multi: true
|
multi: true
|
||||||
},
|
},
|
||||||
{ provide: LOCALE_ID, useValue: "en-US" },
|
{ provide: LOCALE_ID, useValue: "en-US" },
|
||||||
{ provide: HTTP_INTERCEPTORS, useClass: BaseHrefInterceptService, multi: true },
|
|
||||||
{ provide: HTTP_INTERCEPTORS, useClass: InterceptHttpService, multi: true }
|
{ provide: HTTP_INTERCEPTORS, useClass: InterceptHttpService, multi: true }
|
||||||
|
|
||||||
],
|
],
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
import { TestBed } from '@angular/core/testing';
|
|
||||||
import { BaseHrefInterceptService } from "./base-href-intercept.service";
|
|
||||||
|
|
||||||
|
|
||||||
describe('BaseHrefSwitchService', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
providers: [
|
|
||||||
BaseHrefInterceptService
|
|
||||||
]
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
const service: BaseHrefInterceptService = TestBed.get(BaseHrefInterceptService);
|
|
||||||
expect(service).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,22 +0,0 @@
|
|||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http';
|
|
||||||
import { Observable } from "rxjs";
|
|
||||||
|
|
||||||
const BASE_HREF = '/api';
|
|
||||||
enum APILevels {
|
|
||||||
'V1.0' = '',
|
|
||||||
'V2.0' = '/v2.0'
|
|
||||||
}
|
|
||||||
@Injectable()
|
|
||||||
export class BaseHrefInterceptService implements HttpInterceptor {
|
|
||||||
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<any> {
|
|
||||||
let url: string = req.url;
|
|
||||||
// use API level v2.0
|
|
||||||
if (url && url.indexOf(BASE_HREF) !== -1 && url.indexOf(BASE_HREF + APILevels["V2.0"]) === -1) {
|
|
||||||
url = BASE_HREF + APILevels["V2.0"] + url.split(BASE_HREF)[1];
|
|
||||||
}
|
|
||||||
const apiReq = req.clone({url});
|
|
||||||
return next.handle(apiReq);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { HttpClientTestingModule, HttpTestingController } from '@angular/common/
|
|||||||
import { GlobalSearchService } from './global-search.service';
|
import { GlobalSearchService } from './global-search.service';
|
||||||
import { Injector } from '@angular/core';
|
import { Injector } from '@angular/core';
|
||||||
import { SearchResults } from './search-results';
|
import { SearchResults } from './search-results';
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../lib/utils/utils";
|
||||||
|
|
||||||
describe('GlobalSearchService', () => {
|
describe('GlobalSearchService', () => {
|
||||||
let injector: TestBed;
|
let injector: TestBed;
|
||||||
@ -31,7 +32,7 @@ describe('GlobalSearchService', () => {
|
|||||||
expect(res).toEqual(new SearchResults());
|
expect(res).toEqual(new SearchResults());
|
||||||
});
|
});
|
||||||
|
|
||||||
const req = httpMock.expectOne('/api/search?q=library');
|
const req = httpMock.expectOne(CURRENT_BASE_HREF + '/search?q=library');
|
||||||
expect(req.request.method).toBe('GET');
|
expect(req.request.method).toBe('GET');
|
||||||
req.flush(new SearchResults());
|
req.flush(new SearchResults());
|
||||||
});
|
});
|
||||||
|
@ -16,9 +16,9 @@ import { HttpClient } from '@angular/common/http';
|
|||||||
import { map, catchError } from "rxjs/operators";
|
import { map, catchError } from "rxjs/operators";
|
||||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||||
import { SearchResults } from './search-results';
|
import { SearchResults } from './search-results';
|
||||||
import { HTTP_GET_OPTIONS } from "../../../lib/utils/utils";
|
import { CURRENT_BASE_HREF, HTTP_GET_OPTIONS } from "../../../lib/utils/utils";
|
||||||
|
|
||||||
const searchEndpoint = "/api/search";
|
const searchEndpoint = CURRENT_BASE_HREF + "/search";
|
||||||
/**
|
/**
|
||||||
* Declare service to handle the global search
|
* Declare service to handle the global search
|
||||||
*
|
*
|
||||||
|
@ -16,12 +16,12 @@ import { HttpClient } from '@angular/common/http';
|
|||||||
import { map, catchError } from "rxjs/operators";
|
import { map, catchError } from "rxjs/operators";
|
||||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||||
import { Configuration } from "../../lib/components/config/config";
|
import { Configuration } from "../../lib/components/config/config";
|
||||||
import { HTTP_GET_OPTIONS, HTTP_JSON_OPTIONS } from "../../lib/utils/utils";
|
import { CURRENT_BASE_HREF, HTTP_GET_OPTIONS, HTTP_JSON_OPTIONS } from "../../lib/utils/utils";
|
||||||
|
|
||||||
const configEndpoint = "/api/configurations";
|
const configEndpoint = CURRENT_BASE_HREF + "/configurations";
|
||||||
const emailEndpoint = "/api/email/ping";
|
const emailEndpoint = CURRENT_BASE_HREF + "/email/ping";
|
||||||
const ldapEndpoint = "/api/ldap/ping";
|
const ldapEndpoint = CURRENT_BASE_HREF + "/ldap/ping";
|
||||||
const oidcEndpoint = "/api/system/oidc/ping";
|
const oidcEndpoint = CURRENT_BASE_HREF + "/system/oidc/ping";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ConfigurationService {
|
export class ConfigurationService {
|
||||||
|
@ -4,6 +4,7 @@ import { forkJoin, Observable, throwError as observableThrowError } from "rxjs";
|
|||||||
import { catchError, map } from "rxjs/operators";
|
import { catchError, map } from "rxjs/operators";
|
||||||
import { HttpClient } from "@angular/common/http";
|
import { HttpClient } from "@angular/common/http";
|
||||||
import { ScannerMetadata } from "./scanner-metadata";
|
import { ScannerMetadata } from "./scanner-metadata";
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../lib/utils/utils";
|
||||||
|
|
||||||
export const SCANNERS_DOC: string = "https://github.com/goharbor/harbor/blob/master/docs/harbor_compatibility_list.md";
|
export const SCANNERS_DOC: string = "https://github.com/goharbor/harbor/blob/master/docs/harbor_compatibility_list.md";
|
||||||
|
|
||||||
@ -13,35 +14,35 @@ export class ConfigScannerService {
|
|||||||
constructor( private http: HttpClient) {}
|
constructor( private http: HttpClient) {}
|
||||||
getScannersByName(name: string): Observable<Scanner[]> {
|
getScannersByName(name: string): Observable<Scanner[]> {
|
||||||
name = encodeURIComponent(name);
|
name = encodeURIComponent(name);
|
||||||
return this.http.get(`/api/scanners?ex_name=${name}`)
|
return this.http.get(`${ CURRENT_BASE_HREF }/scanners?ex_name=${name}`)
|
||||||
.pipe(catchError(error => observableThrowError(error)))
|
.pipe(catchError(error => observableThrowError(error)))
|
||||||
.pipe(map(response => response as Scanner[]));
|
.pipe(map(response => response as Scanner[]));
|
||||||
}
|
}
|
||||||
getScannersByEndpointUrl(endpointUrl: string): Observable<Scanner[]> {
|
getScannersByEndpointUrl(endpointUrl: string): Observable<Scanner[]> {
|
||||||
endpointUrl = encodeURIComponent(endpointUrl);
|
endpointUrl = encodeURIComponent(endpointUrl);
|
||||||
return this.http.get(`/api/scanners?ex_url=${endpointUrl}`)
|
return this.http.get(`${ CURRENT_BASE_HREF }/scanners?ex_url=${endpointUrl}`)
|
||||||
.pipe(catchError(error => observableThrowError(error)))
|
.pipe(catchError(error => observableThrowError(error)))
|
||||||
.pipe(map(response => response as Scanner[]));
|
.pipe(map(response => response as Scanner[]));
|
||||||
}
|
}
|
||||||
testEndpointUrl(testValue: any): Observable<any> {
|
testEndpointUrl(testValue: any): Observable<any> {
|
||||||
return this.http.post(`/api/scanners/ping`, testValue)
|
return this.http.post(`${ CURRENT_BASE_HREF }/scanners/ping`, testValue)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
addScanner(scanner: Scanner): Observable<any> {
|
addScanner(scanner: Scanner): Observable<any> {
|
||||||
return this.http.post('/api/scanners', scanner )
|
return this.http.post(CURRENT_BASE_HREF + '/scanners', scanner )
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
getScanners(): Observable<Scanner[]> {
|
getScanners(): Observable<Scanner[]> {
|
||||||
return this.http.get('/api/scanners')
|
return this.http.get(CURRENT_BASE_HREF + '/scanners')
|
||||||
.pipe(map(response => response as Scanner[]))
|
.pipe(map(response => response as Scanner[]))
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
updateScanner(scanner: Scanner): Observable<any> {
|
updateScanner(scanner: Scanner): Observable<any> {
|
||||||
return this.http.put(`/api/scanners/${scanner.uuid}`, scanner )
|
return this.http.put(`${ CURRENT_BASE_HREF }/scanners/${scanner.uuid}`, scanner )
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
deleteScanner(scanner: Scanner): Observable<any> {
|
deleteScanner(scanner: Scanner): Observable<any> {
|
||||||
return this.http.delete(`/api/scanners/${scanner.uuid}`)
|
return this.http.delete(`${ CURRENT_BASE_HREF }/scanners/${scanner.uuid}`)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
deleteScanners(scanners: Scanner[]): Observable<any> {
|
deleteScanners(scanners: Scanner[]): Observable<any> {
|
||||||
@ -54,25 +55,25 @@ export class ConfigScannerService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
getProjectScanner(projectId: number): Observable<Scanner> {
|
getProjectScanner(projectId: number): Observable<Scanner> {
|
||||||
return this.http.get(`/api/projects/${projectId}/scanner`)
|
return this.http.get(`${ CURRENT_BASE_HREF }/projects/${projectId}/scanner`)
|
||||||
.pipe(map(response => response as Scanner))
|
.pipe(map(response => response as Scanner))
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
updateProjectScanner(projectId: number , uid: string): Observable<any> {
|
updateProjectScanner(projectId: number , uid: string): Observable<any> {
|
||||||
return this.http.put(`/api/projects/${projectId}/scanner` , {uuid: uid})
|
return this.http.put(`${ CURRENT_BASE_HREF }/projects/${projectId}/scanner` , {uuid: uid})
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
getScannerMetadata(uid: string): Observable<ScannerMetadata> {
|
getScannerMetadata(uid: string): Observable<ScannerMetadata> {
|
||||||
return this.http.get(`/api/scanners/${uid}/metadata`)
|
return this.http.get(`${ CURRENT_BASE_HREF }/scanners/${uid}/metadata`)
|
||||||
.pipe(map(response => response as ScannerMetadata))
|
.pipe(map(response => response as ScannerMetadata))
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
setAsDefault(uid: string): Observable<any> {
|
setAsDefault(uid: string): Observable<any> {
|
||||||
return this.http.patch(`/api/scanners/${uid}`, {is_default: true} )
|
return this.http.patch(`${ CURRENT_BASE_HREF }/scanners/${uid}`, {is_default: true} )
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
getProjectScanners(projectId: number) {
|
getProjectScanners(projectId: number) {
|
||||||
return this.http.get(`/api/projects/${projectId}/scanner/candidates`)
|
return this.http.get(`${ CURRENT_BASE_HREF }/projects/${projectId}/scanner/candidates`)
|
||||||
.pipe(map(response => response as Scanner[]))
|
.pipe(map(response => response as Scanner[]))
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,10 @@ import {catchError, map} from 'rxjs/operators';
|
|||||||
import { Injectable } from "@angular/core";
|
import { Injectable } from "@angular/core";
|
||||||
import { HttpClient } from "@angular/common/http";
|
import { HttpClient } from "@angular/common/http";
|
||||||
import { UserGroup } from "./group";
|
import { UserGroup } from "./group";
|
||||||
import { HTTP_GET_OPTIONS, HTTP_JSON_OPTIONS } from "../../lib/utils/utils";
|
import { CURRENT_BASE_HREF, HTTP_GET_OPTIONS, HTTP_JSON_OPTIONS } from "../../lib/utils/utils";
|
||||||
|
|
||||||
const userGroupEndpoint = "/api/usergroups";
|
const userGroupEndpoint = CURRENT_BASE_HREF + "/usergroups";
|
||||||
const ldapGroupSearchEndpoint = "/api/ldap/groups/search?groupname=";
|
const ldapGroupSearchEndpoint = CURRENT_BASE_HREF + "/ldap/groups/search?groupname=";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class GroupService {
|
export class GroupService {
|
||||||
|
@ -18,10 +18,14 @@ import {map, catchError} from 'rxjs/operators';
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http';
|
import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http';
|
||||||
import { AuditLog } from './audit-log';
|
import { AuditLog } from './audit-log';
|
||||||
import { buildHttpRequestOptions, buildHttpRequestOptionsWithObserveResponse } from "../../lib/utils/utils";
|
import {
|
||||||
|
buildHttpRequestOptions,
|
||||||
|
buildHttpRequestOptionsWithObserveResponse,
|
||||||
|
CURRENT_BASE_HREF
|
||||||
|
} from "../../lib/utils/utils";
|
||||||
import { RequestQueryParams } from "../../lib/services";
|
import { RequestQueryParams } from "../../lib/services";
|
||||||
|
|
||||||
export const logEndpoint = '/api/logs';
|
export const logEndpoint = CURRENT_BASE_HREF + '/logs';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AuditLogService {
|
export class AuditLogService {
|
||||||
@ -46,7 +50,7 @@ export class AuditLogService {
|
|||||||
params = params.set('page_size', <string>queryParam.page_size);
|
params = params.set('page_size', <string>queryParam.page_size);
|
||||||
}
|
}
|
||||||
return this.http
|
return this.http
|
||||||
.get<HttpResponse<AuditLog[]>>(`/api/projects/${queryParam.project_id}/logs`
|
.get<HttpResponse<AuditLog[]>>(`${ CURRENT_BASE_HREF }/projects/${queryParam.project_id}/logs`
|
||||||
, buildHttpRequestOptionsWithObserveResponse(params)).pipe(
|
, buildHttpRequestOptionsWithObserveResponse(params)).pipe(
|
||||||
catchError(error => observableThrowError(error)), );
|
catchError(error => observableThrowError(error)), );
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import { User } from '../../user/user';
|
|||||||
import { Member } from './member';
|
import { Member } from './member';
|
||||||
import {throwError as observableThrowError, Observable } from "rxjs";
|
import {throwError as observableThrowError, Observable } from "rxjs";
|
||||||
import {map, catchError} from 'rxjs/operators';
|
import {map, catchError} from 'rxjs/operators';
|
||||||
import { HTTP_GET_OPTIONS, HTTP_JSON_OPTIONS } from "../../../lib/utils/utils";
|
import { CURRENT_BASE_HREF, HTTP_GET_OPTIONS, HTTP_JSON_OPTIONS } from "../../../lib/utils/utils";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MemberService {
|
export class MemberService {
|
||||||
@ -26,7 +26,7 @@ export class MemberService {
|
|||||||
|
|
||||||
listMembers(projectId: number, entity_name: string): Observable<Member[]> {
|
listMembers(projectId: number, entity_name: string): Observable<Member[]> {
|
||||||
return this.http
|
return this.http
|
||||||
.get(`/api/projects/${projectId}/members?entityname=${entity_name}`, HTTP_GET_OPTIONS).pipe(
|
.get(`${ CURRENT_BASE_HREF }/projects/${projectId}/members?entityname=${entity_name}`, HTTP_GET_OPTIONS).pipe(
|
||||||
map(response => response as Member[]),
|
map(response => response as Member[]),
|
||||||
catchError(error => observableThrowError(error)), );
|
catchError(error => observableThrowError(error)), );
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ export class MemberService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return this.http.post(
|
return this.http.post(
|
||||||
`/api/projects/${projectId}/members`,
|
`${ CURRENT_BASE_HREF }/projects/${projectId}/members`,
|
||||||
{
|
{
|
||||||
role_id: roleId,
|
role_id: roleId,
|
||||||
member_user: member_user
|
member_user: member_user
|
||||||
@ -52,7 +52,7 @@ export class MemberService {
|
|||||||
|
|
||||||
addGroupMember(projectId: number, group: any, roleId: number): Observable<any> {
|
addGroupMember(projectId: number, group: any, roleId: number): Observable<any> {
|
||||||
return this.http
|
return this.http
|
||||||
.post(`/api/projects/${projectId}/members`,
|
.post(`${ CURRENT_BASE_HREF }/projects/${projectId}/members`,
|
||||||
{ role_id: roleId, member_group: group},
|
{ role_id: roleId, member_group: group},
|
||||||
HTTP_JSON_OPTIONS).pipe(
|
HTTP_JSON_OPTIONS).pipe(
|
||||||
catchError(error => observableThrowError(error)), );
|
catchError(error => observableThrowError(error)), );
|
||||||
@ -60,13 +60,13 @@ export class MemberService {
|
|||||||
|
|
||||||
changeMemberRole(projectId: number, userId: number, roleId: number): Observable<any> {
|
changeMemberRole(projectId: number, userId: number, roleId: number): Observable<any> {
|
||||||
return this.http
|
return this.http
|
||||||
.put(`/api/projects/${projectId}/members/${userId}`, { role_id: roleId }, HTTP_JSON_OPTIONS)
|
.put(`${ CURRENT_BASE_HREF }/projects/${projectId}/members/${userId}`, { role_id: roleId }, HTTP_JSON_OPTIONS)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteMember(projectId: number, memberId: number): Observable<any> {
|
deleteMember(projectId: number, memberId: number): Observable<any> {
|
||||||
return this.http
|
return this.http
|
||||||
.delete(`/api/projects/${projectId}/members/${memberId}`)
|
.delete(`${ CURRENT_BASE_HREF }/projects/${projectId}/members/${memberId}`)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import { AppConfigService } from "../../../app-config.service";
|
|||||||
import { ArtifactService } from "../../../../../ng-swagger-gen/services/artifact.service";
|
import { ArtifactService } from "../../../../../ng-swagger-gen/services/artifact.service";
|
||||||
import { ArtifactDefaultService } from "../artifact/artifact.service";
|
import { ArtifactDefaultService } from "../artifact/artifact.service";
|
||||||
import { IServiceConfig, SERVICE_CONFIG } from "../../../../lib/entities/service.config";
|
import { IServiceConfig, SERVICE_CONFIG } from "../../../../lib/entities/service.config";
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../../lib/utils/utils";
|
||||||
|
|
||||||
describe('ArtifactListPageComponent', () => {
|
describe('ArtifactListPageComponent', () => {
|
||||||
let component: ArtifactListPageComponent;
|
let component: ArtifactListPageComponent;
|
||||||
@ -70,7 +71,7 @@ describe('ArtifactListPageComponent', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const config: IServiceConfig = {
|
const config: IServiceConfig = {
|
||||||
repositoryBaseEndpoint: "/api/repositories/testing"
|
repositoryBaseEndpoint: CURRENT_BASE_HREF + "/repositories/testing"
|
||||||
};
|
};
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
|
@ -3,17 +3,18 @@ import { ArtifactAdditionsComponent } from './artifact-additions.component';
|
|||||||
import { AdditionLinks } from "../../../../../../ng-swagger-gen/models/addition-links";
|
import { AdditionLinks } from "../../../../../../ng-swagger-gen/models/addition-links";
|
||||||
import { IServiceConfig, SERVICE_CONFIG } from "../../../../../lib/entities/service.config";
|
import { IServiceConfig, SERVICE_CONFIG } from "../../../../../lib/entities/service.config";
|
||||||
import { ProjectModule } from "../../../project.module";
|
import { ProjectModule } from "../../../project.module";
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../../../lib/utils/utils";
|
||||||
|
|
||||||
|
|
||||||
describe('ArtifactAdditionsComponent', () => {
|
describe('ArtifactAdditionsComponent', () => {
|
||||||
const mockedAdditionLinks: AdditionLinks = {
|
const mockedAdditionLinks: AdditionLinks = {
|
||||||
vulnerabilities: {
|
vulnerabilities: {
|
||||||
absolute: false,
|
absolute: false,
|
||||||
href: "api/v2/test"
|
href: CURRENT_BASE_HREF + "/test"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const config: IServiceConfig = {
|
const config: IServiceConfig = {
|
||||||
baseEndpoint: "/api/v2"
|
baseEndpoint: CURRENT_BASE_HREF
|
||||||
};
|
};
|
||||||
let component: ArtifactAdditionsComponent;
|
let component: ArtifactAdditionsComponent;
|
||||||
let fixture: ComponentFixture<ArtifactAdditionsComponent>;
|
let fixture: ComponentFixture<ArtifactAdditionsComponent>;
|
||||||
|
@ -7,6 +7,7 @@ import { ArtifactDependency } from "../models";
|
|||||||
import { AdditionLink } from "../../../../../../../ng-swagger-gen/models/addition-link";
|
import { AdditionLink } from "../../../../../../../ng-swagger-gen/models/addition-link";
|
||||||
import { IServiceConfig, SERVICE_CONFIG } from "../../../../../../lib/entities/service.config";
|
import { IServiceConfig, SERVICE_CONFIG } from "../../../../../../lib/entities/service.config";
|
||||||
import { ErrorHandler } from "../../../../../../lib/utils/error-handler";
|
import { ErrorHandler } from "../../../../../../lib/utils/error-handler";
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../../../../lib/utils/utils";
|
||||||
|
|
||||||
|
|
||||||
describe('DependenciesComponent', () => {
|
describe('DependenciesComponent', () => {
|
||||||
@ -35,7 +36,7 @@ describe('DependenciesComponent', () => {
|
|||||||
href: '/test'
|
href: '/test'
|
||||||
};
|
};
|
||||||
const config: IServiceConfig = {
|
const config: IServiceConfig = {
|
||||||
repositoryBaseEndpoint: "/api/repositories/testing"
|
repositoryBaseEndpoint: CURRENT_BASE_HREF + "/repositories/testing"
|
||||||
};
|
};
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
|
@ -7,6 +7,7 @@ import { AdditionLink } from "../../../../../../../ng-swagger-gen/models/additio
|
|||||||
import { IServiceConfig, SERVICE_CONFIG } from "../../../../../../lib/entities/service.config";
|
import { IServiceConfig, SERVICE_CONFIG } from "../../../../../../lib/entities/service.config";
|
||||||
import { ErrorHandler } from "../../../../../../lib/utils/error-handler";
|
import { ErrorHandler } from "../../../../../../lib/utils/error-handler";
|
||||||
import { ProjectModule } from "../../../../project.module";
|
import { ProjectModule } from "../../../../project.module";
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../../../../lib/utils/utils";
|
||||||
|
|
||||||
describe('SummaryComponent', () => {
|
describe('SummaryComponent', () => {
|
||||||
let component: SummaryComponent;
|
let component: SummaryComponent;
|
||||||
@ -160,7 +161,7 @@ describe('SummaryComponent', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const config: IServiceConfig = {
|
const config: IServiceConfig = {
|
||||||
repositoryBaseEndpoint: "/api/repositories/testing"
|
repositoryBaseEndpoint: CURRENT_BASE_HREF + "/repositories/testing"
|
||||||
};
|
};
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
|
@ -9,6 +9,7 @@ import { SharedModule } from "../../../../../lib/utils/shared/shared.module";
|
|||||||
import { ErrorHandler } from "../../../../../lib/utils/error-handler";
|
import { ErrorHandler } from "../../../../../lib/utils/error-handler";
|
||||||
import { TagService } from "../../../../../lib/services";
|
import { TagService } from "../../../../../lib/services";
|
||||||
import { OperationService } from "../../../../../lib/components/operation/operation.service";
|
import { OperationService } from "../../../../../lib/components/operation/operation.service";
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../../../lib/utils/utils";
|
||||||
|
|
||||||
|
|
||||||
describe('ArtifactTagComponent', () => {
|
describe('ArtifactTagComponent', () => {
|
||||||
@ -22,7 +23,7 @@ describe('ArtifactTagComponent', () => {
|
|||||||
deleteTag: () => of(null),
|
deleteTag: () => of(null),
|
||||||
};
|
};
|
||||||
const config: IServiceConfig = {
|
const config: IServiceConfig = {
|
||||||
repositoryBaseEndpoint: "/api/repositories/testing"
|
repositoryBaseEndpoint: CURRENT_BASE_HREF + "/repositories/testing"
|
||||||
};
|
};
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
|
@ -2,11 +2,12 @@ import { TestBed, inject } from '@angular/core/testing';
|
|||||||
import { IServiceConfig, SERVICE_CONFIG } from "../../../../lib/entities/service.config";
|
import { IServiceConfig, SERVICE_CONFIG } from "../../../../lib/entities/service.config";
|
||||||
import { SharedModule } from "../../../../lib/utils/shared/shared.module";
|
import { SharedModule } from "../../../../lib/utils/shared/shared.module";
|
||||||
import { TagDefaultService, TagService } from "../../../../lib/services";
|
import { TagDefaultService, TagService } from "../../../../lib/services";
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../../lib/utils/utils";
|
||||||
|
|
||||||
describe('TagService', () => {
|
describe('TagService', () => {
|
||||||
|
|
||||||
const mockConfig: IServiceConfig = {
|
const mockConfig: IServiceConfig = {
|
||||||
repositoryBaseEndpoint: "/api/repositories/testing"
|
repositoryBaseEndpoint: CURRENT_BASE_HREF + "/repositories/testing"
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -5,7 +5,7 @@ import { Observable, throwError as observableThrowError, Subject } from "rxjs";
|
|||||||
import { Manifest, RequestQueryParams } from "../../../../lib/services";
|
import { Manifest, RequestQueryParams } from "../../../../lib/services";
|
||||||
import { IServiceConfig, SERVICE_CONFIG } from "../../../../lib/entities/service.config";
|
import { IServiceConfig, SERVICE_CONFIG } from "../../../../lib/entities/service.config";
|
||||||
import {
|
import {
|
||||||
buildHttpRequestOptionsWithObserveResponse,
|
buildHttpRequestOptionsWithObserveResponse, CURRENT_BASE_HREF,
|
||||||
HTTP_GET_OPTIONS,
|
HTTP_GET_OPTIONS,
|
||||||
HTTP_JSON_OPTIONS
|
HTTP_JSON_OPTIONS
|
||||||
} from "../../../../lib/utils/utils";
|
} from "../../../../lib/utils/utils";
|
||||||
@ -122,10 +122,10 @@ export class ArtifactDefaultService extends ArtifactService {
|
|||||||
super();
|
super();
|
||||||
this._baseUrl = this.config.repositoryBaseEndpoint
|
this._baseUrl = this.config.repositoryBaseEndpoint
|
||||||
? this.config.repositoryBaseEndpoint
|
? this.config.repositoryBaseEndpoint
|
||||||
: "/api/repositories";
|
: CURRENT_BASE_HREF + "/repositories";
|
||||||
this._labelUrl = this.config.labelEndpoint
|
this._labelUrl = this.config.labelEndpoint
|
||||||
? this.config.labelEndpoint
|
? this.config.labelEndpoint
|
||||||
: "/api/labels";
|
: CURRENT_BASE_HREF + "/labels";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ export class ArtifactDefaultService extends ArtifactService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// queryParams = queryParams.set("detail", "true");
|
// queryParams = queryParams.set("detail", "true");
|
||||||
let url: string = `/api/v2.0/projects/${project_id}/repositories/${repositoryName}/artifacts`;
|
let url: string = `${ CURRENT_BASE_HREF }/projects/${project_id}/repositories/${repositoryName}/artifacts`;
|
||||||
// /api/v2/projects/{project_id}/repositories/{repositoryName}/artifacts
|
// /api/v2/projects/{project_id}/repositories/{repositoryName}/artifacts
|
||||||
return this.http
|
return this.http
|
||||||
.get<HttpResponse<Artifact[]>>(url, buildHttpRequestOptionsWithObserveResponse(queryParams))
|
.get<HttpResponse<Artifact[]>>(url, buildHttpRequestOptionsWithObserveResponse(queryParams))
|
||||||
@ -164,7 +164,7 @@ export class ArtifactDefaultService extends ArtifactService {
|
|||||||
if (!artifactDigest) {
|
if (!artifactDigest) {
|
||||||
return observableThrowError("Bad argument");
|
return observableThrowError("Bad argument");
|
||||||
}
|
}
|
||||||
let url = `/api/v2.0/projects/${projectName}/repositories/${repositoryName}/artifacts/${artifactDigest}`;
|
let url = `${ CURRENT_BASE_HREF }/projects/${projectName}/repositories/${repositoryName}/artifacts/${artifactDigest}`;
|
||||||
return this.http.get(url).pipe(catchError(error => observableThrowError(error))) as Observable<Artifact>;
|
return this.http.get(url).pipe(catchError(error => observableThrowError(error))) as Observable<Artifact>;
|
||||||
}
|
}
|
||||||
public deleteArtifact(
|
public deleteArtifact(
|
||||||
@ -176,7 +176,7 @@ export class ArtifactDefaultService extends ArtifactService {
|
|||||||
return observableThrowError("Bad argument");
|
return observableThrowError("Bad argument");
|
||||||
}
|
}
|
||||||
|
|
||||||
let url: string = `/api/v2.0/projects/${projectName}/repositories/${repositoryName}/artifacts/${digest}`;
|
let url: string = `${ CURRENT_BASE_HREF }/projects/${projectName}/repositories/${repositoryName}/artifacts/${digest}`;
|
||||||
return this.http
|
return this.http
|
||||||
.delete(url, HTTP_JSON_OPTIONS)
|
.delete(url, HTTP_JSON_OPTIONS)
|
||||||
.pipe(map(response => response)
|
.pipe(map(response => response)
|
||||||
@ -195,7 +195,7 @@ export class ArtifactDefaultService extends ArtifactService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let _addLabelToImageUrl = `
|
let _addLabelToImageUrl = `
|
||||||
/api/v2.0/projects/${projectName}/repositories/${repoName}/artifacts/${digest}/labels`;
|
${ CURRENT_BASE_HREF }/projects/${projectName}/repositories/${repoName}/artifacts/${digest}/labels`;
|
||||||
return this.http
|
return this.http
|
||||||
.post(_addLabelToImageUrl, { id: labelId }, HTTP_JSON_OPTIONS)
|
.post(_addLabelToImageUrl, { id: labelId }, HTTP_JSON_OPTIONS)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
@ -212,7 +212,7 @@ export class ArtifactDefaultService extends ArtifactService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let _addLabelToImageUrl = `
|
let _addLabelToImageUrl = `
|
||||||
/api/v2.0/projects/${projectName}/repositories/${repoName}/artifacts/${digest}/labels/${labelId}`;
|
${ CURRENT_BASE_HREF }/projects/${projectName}/repositories/${repoName}/artifacts/${digest}/labels/${labelId}`;
|
||||||
return this.http
|
return this.http
|
||||||
.delete(_addLabelToImageUrl)
|
.delete(_addLabelToImageUrl)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
|
@ -25,6 +25,7 @@ import { ProjectModule } from "../project.module";
|
|||||||
import { ActivatedRoute } from "@angular/router";
|
import { ActivatedRoute } from "@angular/router";
|
||||||
import { Repository as NewRepository } from "../../../../ng-swagger-gen/models/repository";
|
import { Repository as NewRepository } from "../../../../ng-swagger-gen/models/repository";
|
||||||
import { StrictHttpResponse as __StrictHttpResponse } from '../../../../ng-swagger-gen/strict-http-response';
|
import { StrictHttpResponse as __StrictHttpResponse } from '../../../../ng-swagger-gen/strict-http-response';
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../lib/utils/utils";
|
||||||
|
|
||||||
describe('RepositoryComponentGridview (inline template)', () => {
|
describe('RepositoryComponentGridview (inline template)', () => {
|
||||||
|
|
||||||
@ -73,9 +74,9 @@ describe('RepositoryComponentGridview (inline template)', () => {
|
|||||||
let mockRepo: NewRepository[] = mockRepoData;
|
let mockRepo: NewRepository[] = mockRepoData;
|
||||||
let mockNginxRepo: NewRepository[] = mockRepoNginxData;
|
let mockNginxRepo: NewRepository[] = mockRepoNginxData;
|
||||||
let config: IServiceConfig = {
|
let config: IServiceConfig = {
|
||||||
repositoryBaseEndpoint: '/api/repository/testing',
|
repositoryBaseEndpoint: CURRENT_BASE_HREF + '/repository/testing',
|
||||||
systemInfoEndpoint: '/api/systeminfo/testing',
|
systemInfoEndpoint: CURRENT_BASE_HREF + '/systeminfo/testing',
|
||||||
targetBaseEndpoint: '/api/tag/testing'
|
targetBaseEndpoint: CURRENT_BASE_HREF + '/tag/testing'
|
||||||
};
|
};
|
||||||
const fakedErrorHandler = {
|
const fakedErrorHandler = {
|
||||||
error() {
|
error() {
|
||||||
|
@ -3,11 +3,12 @@ import { TestBed, inject } from '@angular/core/testing';
|
|||||||
import { RepositoryService, RepositoryDefaultService } from './repository.service';
|
import { RepositoryService, RepositoryDefaultService } from './repository.service';
|
||||||
import { IServiceConfig, SERVICE_CONFIG } from "../../../lib/entities/service.config";
|
import { IServiceConfig, SERVICE_CONFIG } from "../../../lib/entities/service.config";
|
||||||
import { SharedModule } from "../../../lib/utils/shared/shared.module";
|
import { SharedModule } from "../../../lib/utils/shared/shared.module";
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../lib/utils/utils";
|
||||||
|
|
||||||
|
|
||||||
describe('RepositoryService', () => {
|
describe('RepositoryService', () => {
|
||||||
const mockConfig: IServiceConfig = {
|
const mockConfig: IServiceConfig = {
|
||||||
repositoryBaseEndpoint: "/api/repositories/testing"
|
repositoryBaseEndpoint: CURRENT_BASE_HREF + "/repositories/testing"
|
||||||
};
|
};
|
||||||
|
|
||||||
let config: IServiceConfig;
|
let config: IServiceConfig;
|
||||||
@ -37,7 +38,7 @@ describe('RepositoryService', () => {
|
|||||||
|
|
||||||
it('should inject the right config', () => {
|
it('should inject the right config', () => {
|
||||||
expect(config).toBeTruthy();
|
expect(config).toBeTruthy();
|
||||||
expect(config.repositoryBaseEndpoint).toEqual("/api/repositories/testing");
|
expect(config.repositoryBaseEndpoint).toEqual(CURRENT_BASE_HREF + "/repositories/testing");
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -4,7 +4,11 @@ import { map, catchError } from "rxjs/operators";
|
|||||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||||
import { Repository, RepositoryItem, RequestQueryParams } from "../../../lib/services";
|
import { Repository, RepositoryItem, RequestQueryParams } from "../../../lib/services";
|
||||||
import { IServiceConfig, SERVICE_CONFIG } from "../../../lib/entities/service.config";
|
import { IServiceConfig, SERVICE_CONFIG } from "../../../lib/entities/service.config";
|
||||||
import { buildHttpRequestOptionsWithObserveResponse, HTTP_JSON_OPTIONS } from "../../../lib/utils/utils";
|
import {
|
||||||
|
buildHttpRequestOptionsWithObserveResponse,
|
||||||
|
CURRENT_BASE_HREF,
|
||||||
|
HTTP_JSON_OPTIONS
|
||||||
|
} from "../../../lib/utils/utils";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define service methods for handling the repository related things.
|
* Define service methods for handling the repository related things.
|
||||||
@ -86,7 +90,7 @@ export class RepositoryDefaultService extends RepositoryService {
|
|||||||
if (repositoryName && repositoryName.trim() !== '') {
|
if (repositoryName && repositoryName.trim() !== '') {
|
||||||
queryParams = queryParams.set('q', repositoryName);
|
queryParams = queryParams.set('q', repositoryName);
|
||||||
}
|
}
|
||||||
let url: string = this.config.repositoryBaseEndpoint ? this.config.repositoryBaseEndpoint : '/api/repositories';
|
let url: string = this.config.repositoryBaseEndpoint ? this.config.repositoryBaseEndpoint : CURRENT_BASE_HREF + '/repositories';
|
||||||
return this.http.get<HttpResponse<RepositoryItem[]>>(url, buildHttpRequestOptionsWithObserveResponse(queryParams))
|
return this.http.get<HttpResponse<RepositoryItem[]>>(url, buildHttpRequestOptionsWithObserveResponse(queryParams))
|
||||||
.pipe(map(response => {
|
.pipe(map(response => {
|
||||||
let result: Repository = {
|
let result: Repository = {
|
||||||
@ -123,7 +127,7 @@ export class RepositoryDefaultService extends RepositoryService {
|
|||||||
queryParams = new RequestQueryParams();
|
queryParams = new RequestQueryParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
let baseUrl: string = this.config.repositoryBaseEndpoint ? this.config.repositoryBaseEndpoint : '/api/repositories';
|
let baseUrl: string = this.config.repositoryBaseEndpoint ? this.config.repositoryBaseEndpoint : CURRENT_BASE_HREF + '/repositories';
|
||||||
let url = `${baseUrl}/${repositoryName}`;
|
let url = `${baseUrl}/${repositoryName}`;
|
||||||
return this.http.put(url, { 'description': description }, HTTP_JSON_OPTIONS)
|
return this.http.put(url, { 'description': description }, HTTP_JSON_OPTIONS)
|
||||||
.pipe(map(response => response)
|
.pipe(map(response => response)
|
||||||
@ -134,7 +138,7 @@ export class RepositoryDefaultService extends RepositoryService {
|
|||||||
if (!repositoryName) {
|
if (!repositoryName) {
|
||||||
return observableThrowError('Bad argument');
|
return observableThrowError('Bad argument');
|
||||||
}
|
}
|
||||||
let url: string = this.config.repositoryBaseEndpoint ? this.config.repositoryBaseEndpoint : '/api/repositories';
|
let url: string = this.config.repositoryBaseEndpoint ? this.config.repositoryBaseEndpoint : CURRENT_BASE_HREF + '/repositories';
|
||||||
url = `${url}/${repositoryName}`;
|
url = `${url}/${repositoryName}`;
|
||||||
|
|
||||||
return this.http.delete(url, HTTP_JSON_OPTIONS)
|
return this.http.delete(url, HTTP_JSON_OPTIONS)
|
||||||
|
@ -11,7 +11,7 @@ import {
|
|||||||
ScanningResultService,
|
ScanningResultService,
|
||||||
VulnerabilitySummary
|
VulnerabilitySummary
|
||||||
} from "../../../../lib/services";
|
} from "../../../../lib/services";
|
||||||
import { VULNERABILITY_SCAN_STATUS } from "../../../../lib/utils/utils";
|
import { CURRENT_BASE_HREF, VULNERABILITY_SCAN_STATUS } from "../../../../lib/utils/utils";
|
||||||
import { SharedModule } from "../../../../lib/utils/shared/shared.module";
|
import { SharedModule } from "../../../../lib/utils/shared/shared.module";
|
||||||
import { ErrorHandler } from "../../../../lib/utils/error-handler";
|
import { ErrorHandler } from "../../../../lib/utils/error-handler";
|
||||||
import { ChannelService } from "../../../../lib/services/channel.service";
|
import { ChannelService } from "../../../../lib/services/channel.service";
|
||||||
@ -22,7 +22,7 @@ describe('ResultBarChartComponent (inline template)', () => {
|
|||||||
let fixture: ComponentFixture<ResultBarChartComponent>;
|
let fixture: ComponentFixture<ResultBarChartComponent>;
|
||||||
let serviceConfig: IServiceConfig;
|
let serviceConfig: IServiceConfig;
|
||||||
let testConfig: IServiceConfig = {
|
let testConfig: IServiceConfig = {
|
||||||
vulnerabilityScanningBaseEndpoint: "/api/vulnerability/testing"
|
vulnerabilityScanningBaseEndpoint: CURRENT_BASE_HREF + "/vulnerability/testing"
|
||||||
};
|
};
|
||||||
let mockData: VulnerabilitySummary = {
|
let mockData: VulnerabilitySummary = {
|
||||||
scan_status: VULNERABILITY_SCAN_STATUS.SUCCESS,
|
scan_status: VULNERABILITY_SCAN_STATUS.SUCCESS,
|
||||||
@ -75,7 +75,7 @@ describe('ResultBarChartComponent (inline template)', () => {
|
|||||||
it('should be created', () => {
|
it('should be created', () => {
|
||||||
expect(component).toBeTruthy();
|
expect(component).toBeTruthy();
|
||||||
expect(serviceConfig).toBeTruthy();
|
expect(serviceConfig).toBeTruthy();
|
||||||
expect(serviceConfig.vulnerabilityScanningBaseEndpoint).toEqual("/api/vulnerability/testing");
|
expect(serviceConfig.vulnerabilityScanningBaseEndpoint).toEqual(CURRENT_BASE_HREF + "/vulnerability/testing");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show "not scanned" if status is STOPPED', () => {
|
it('should show "not scanned" if status is STOPPED', () => {
|
||||||
|
@ -11,7 +11,12 @@ import { ScannerVo, ScanningResultService, VulnerabilitySummary } from "../../..
|
|||||||
import { ArtifactDefaultService } from "../artifact/artifact.service";
|
import { ArtifactDefaultService } from "../artifact/artifact.service";
|
||||||
import { ErrorHandler } from "../../../../lib/utils/error-handler";
|
import { ErrorHandler } from "../../../../lib/utils/error-handler";
|
||||||
import { ChannelService } from "../../../../lib/services/channel.service";
|
import { ChannelService } from "../../../../lib/services/channel.service";
|
||||||
import { clone, DEFAULT_SUPPORTED_MIME_TYPE, VULNERABILITY_SCAN_STATUS } from "../../../../lib/utils/utils";
|
import {
|
||||||
|
clone,
|
||||||
|
CURRENT_BASE_HREF,
|
||||||
|
DEFAULT_SUPPORTED_MIME_TYPE,
|
||||||
|
VULNERABILITY_SCAN_STATUS
|
||||||
|
} from "../../../../lib/utils/utils";
|
||||||
import { Artifact } from "../artifact/artifact";
|
import { Artifact } from "../artifact/artifact";
|
||||||
|
|
||||||
|
|
||||||
@ -200,7 +205,7 @@ export class ResultBarChartComponent implements OnInit, OnDestroy {
|
|||||||
}, duration);
|
}, duration);
|
||||||
}
|
}
|
||||||
viewLog(): string {
|
viewLog(): string {
|
||||||
return `/api/v2.0/projects/${this.projectName}/repositories/${this.repoName}
|
return `${ CURRENT_BASE_HREF }/projects/${this.projectName}/repositories/${this.repoName}
|
||||||
/artifacts/${this.artifactId}/scan/${this.summary.report_id}/log`;
|
/artifacts/${this.artifactId}/scan/${this.summary.report_id}/log`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import { SharedModule } from "../../../../lib/utils/shared/shared.module";
|
|||||||
import { FilterComponent } from "../../../../lib/components/filter/filter.component";
|
import { FilterComponent } from "../../../../lib/components/filter/filter.component";
|
||||||
import { ChannelService } from "../../../../lib/services/channel.service";
|
import { ChannelService } from "../../../../lib/services/channel.service";
|
||||||
import { ErrorHandler } from "../../../../lib/utils/error-handler";
|
import { ErrorHandler } from "../../../../lib/utils/error-handler";
|
||||||
import { DEFAULT_SUPPORTED_MIME_TYPE, VULNERABILITY_SEVERITY } from "../../../../lib/utils/utils";
|
import { CURRENT_BASE_HREF, DEFAULT_SUPPORTED_MIME_TYPE, VULNERABILITY_SEVERITY } from "../../../../lib/utils/utils";
|
||||||
describe('ResultGridComponent (inline template)', () => {
|
describe('ResultGridComponent (inline template)', () => {
|
||||||
let component: ResultGridComponent;
|
let component: ResultGridComponent;
|
||||||
let fixture: ComponentFixture<ResultGridComponent>;
|
let fixture: ComponentFixture<ResultGridComponent>;
|
||||||
@ -23,7 +23,7 @@ describe('ResultGridComponent (inline template)', () => {
|
|||||||
let spy: jasmine.Spy;
|
let spy: jasmine.Spy;
|
||||||
let mockHasScanImagePermission: boolean = true;
|
let mockHasScanImagePermission: boolean = true;
|
||||||
let testConfig: IServiceConfig = {
|
let testConfig: IServiceConfig = {
|
||||||
vulnerabilityScanningBaseEndpoint: "/api/vulnerability/testing"
|
vulnerabilityScanningBaseEndpoint: CURRENT_BASE_HREF + "/vulnerability/testing"
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
@ -90,7 +90,7 @@ describe('ResultGridComponent (inline template)', () => {
|
|||||||
|
|
||||||
it('should inject the SERVICE_CONFIG', () => {
|
it('should inject the SERVICE_CONFIG', () => {
|
||||||
expect(serviceConfig).toBeTruthy();
|
expect(serviceConfig).toBeTruthy();
|
||||||
expect(serviceConfig.vulnerabilityScanningBaseEndpoint).toEqual("/api/vulnerability/testing");
|
expect(serviceConfig.vulnerabilityScanningBaseEndpoint).toEqual(CURRENT_BASE_HREF + "/vulnerability/testing");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should inject and call the ScanningResultService', () => {
|
it('should inject and call the ScanningResultService', () => {
|
||||||
|
@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|||||||
import { ResultTipComponent } from './result-tip.component';
|
import { ResultTipComponent } from './result-tip.component';
|
||||||
import { IServiceConfig, SERVICE_CONFIG } from "../../../../lib/entities/service.config";
|
import { IServiceConfig, SERVICE_CONFIG } from "../../../../lib/entities/service.config";
|
||||||
import { UserPermissionDefaultService, UserPermissionService, VulnerabilitySummary } from "../../../../lib/services";
|
import { UserPermissionDefaultService, UserPermissionService, VulnerabilitySummary } from "../../../../lib/services";
|
||||||
import { VULNERABILITY_SCAN_STATUS } from "../../../../lib/utils/utils";
|
import { CURRENT_BASE_HREF, VULNERABILITY_SCAN_STATUS } from "../../../../lib/utils/utils";
|
||||||
import { SharedModule } from "../../../../lib/utils/shared/shared.module";
|
import { SharedModule } from "../../../../lib/utils/shared/shared.module";
|
||||||
|
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ describe('ResultTipComponent (inline template)', () => {
|
|||||||
let component: ResultTipComponent;
|
let component: ResultTipComponent;
|
||||||
let fixture: ComponentFixture<ResultTipComponent>;
|
let fixture: ComponentFixture<ResultTipComponent>;
|
||||||
let testConfig: IServiceConfig = {
|
let testConfig: IServiceConfig = {
|
||||||
vulnerabilityScanningBaseEndpoint: "/api/vulnerability/testing"
|
vulnerabilityScanningBaseEndpoint: CURRENT_BASE_HREF + "/vulnerability/testing"
|
||||||
};
|
};
|
||||||
let mockData: VulnerabilitySummary = {
|
let mockData: VulnerabilitySummary = {
|
||||||
scan_status: VULNERABILITY_SCAN_STATUS.SUCCESS,
|
scan_status: VULNERABILITY_SCAN_STATUS.SUCCESS,
|
||||||
|
@ -3,6 +3,7 @@ import { HttpClient } from "@angular/common/http";
|
|||||||
import { throwError as observableThrowError, Observable, pipe } from "rxjs";
|
import { throwError as observableThrowError, Observable, pipe } from "rxjs";
|
||||||
import { catchError, map } from "rxjs/operators";
|
import { catchError, map } from "rxjs/operators";
|
||||||
import { Robot } from './robot';
|
import { Robot } from './robot';
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../lib/utils/utils";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RobotApiRepository {
|
export class RobotApiRepository {
|
||||||
@ -10,33 +11,33 @@ export class RobotApiRepository {
|
|||||||
|
|
||||||
public postRobot(projectId, param): Observable<any> {
|
public postRobot(projectId, param): Observable<any> {
|
||||||
return this.http
|
return this.http
|
||||||
.post(`/api/projects/${projectId}/robots`, param)
|
.post(`${ CURRENT_BASE_HREF }/projects/${projectId}/robots`, param)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public deleteRobot(projectId, id): Observable<any> {
|
public deleteRobot(projectId, id): Observable<any> {
|
||||||
return this.http
|
return this.http
|
||||||
.delete(`/api/projects/${projectId}/robots/${id}`)
|
.delete(`${ CURRENT_BASE_HREF }/projects/${projectId}/robots/${id}`)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public listRobot(projectId): Observable<Robot[]> {
|
public listRobot(projectId): Observable<Robot[]> {
|
||||||
return this.http
|
return this.http
|
||||||
.get(`/api/projects/${projectId}/robots`)
|
.get(`${ CURRENT_BASE_HREF }/projects/${projectId}/robots`)
|
||||||
.pipe(map(response => response as Robot[]))
|
.pipe(map(response => response as Robot[]))
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public getRobot(projectId, id): Observable<Robot[]> {
|
public getRobot(projectId, id): Observable<Robot[]> {
|
||||||
return this.http
|
return this.http
|
||||||
.get(`/api/projects/${projectId}/robots/${id}`)
|
.get(`${ CURRENT_BASE_HREF }/projects/${projectId}/robots/${id}`)
|
||||||
.pipe(map(response => response as Robot[]))
|
.pipe(map(response => response as Robot[]))
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public toggleDisabledAccount(projectId, id, data): Observable<any> {
|
public toggleDisabledAccount(projectId, id, data): Observable<any> {
|
||||||
return this.http
|
return this.http
|
||||||
.put(`/api/projects/${projectId}/robots/${id}`, data)
|
.put(`${ CURRENT_BASE_HREF }/projects/${projectId}/robots/${id}`, data)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import { ImmutableRetentionRule, RuleMetadate } from "../tag-retention/retention
|
|||||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||||
import { map, catchError } from "rxjs/operators";
|
import { map, catchError } from "rxjs/operators";
|
||||||
import { Project } from "../../project";
|
import { Project } from "../../project";
|
||||||
import { HTTP_JSON_OPTIONS } from "../../../../lib/utils/utils";
|
import { CURRENT_BASE_HREF, HTTP_JSON_OPTIONS } from "../../../../lib/utils/utils";
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -33,34 +33,34 @@ export class ImmutableTagService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getRetentionMetadata(): Observable<RuleMetadate> {
|
getRetentionMetadata(): Observable<RuleMetadate> {
|
||||||
return this.http.get(`/api/retentions/metadatas`)
|
return this.http.get(`${ CURRENT_BASE_HREF }/retentions/metadatas`)
|
||||||
.pipe(map(response => response as RuleMetadate))
|
.pipe(map(response => response as RuleMetadate))
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
getRules(projectId): Observable<ImmutableRetentionRule[]> {
|
getRules(projectId): Observable<ImmutableRetentionRule[]> {
|
||||||
return this.http.get(`/api/projects/${projectId}/immutabletagrules`)
|
return this.http.get(`${ CURRENT_BASE_HREF }/projects/${projectId}/immutabletagrules`)
|
||||||
.pipe(map(response => response as ImmutableRetentionRule[]))
|
.pipe(map(response => response as ImmutableRetentionRule[]))
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
createRule(projectId: number, retention: ImmutableRetentionRule) {
|
createRule(projectId: number, retention: ImmutableRetentionRule) {
|
||||||
return this.http.post(`/api/projects/${projectId}/immutabletagrules`, retention)
|
return this.http.post(`${ CURRENT_BASE_HREF }/projects/${projectId}/immutabletagrules`, retention)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateRule(projectId, immutabletagrule: ImmutableRetentionRule) {
|
updateRule(projectId, immutabletagrule: ImmutableRetentionRule) {
|
||||||
return this.http.put(`/api/projects/${projectId}/immutabletagrules/${immutabletagrule.id}`, immutabletagrule)
|
return this.http.put(`${ CURRENT_BASE_HREF }/projects/${projectId}/immutabletagrules/${immutabletagrule.id}`, immutabletagrule)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
deleteRule(projectId, ruleId) {
|
deleteRule(projectId, ruleId) {
|
||||||
|
|
||||||
return this.http.delete(`/api/projects/${projectId}/immutabletagrules/${ruleId}`, HTTP_JSON_OPTIONS)
|
return this.http.delete(`${ CURRENT_BASE_HREF }/projects/${projectId}/immutabletagrules/${ruleId}`, HTTP_JSON_OPTIONS)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
getProjectInfo(projectId) {
|
getProjectInfo(projectId) {
|
||||||
return this.http.get(`/api/projects/${projectId}`)
|
return this.http.get(`${ CURRENT_BASE_HREF }/projects/${projectId}`)
|
||||||
.pipe(map(response => response as Project))
|
.pipe(map(response => response as Project))
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import { Retention, RuleMetadate } from "./retention";
|
|||||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||||
import { map, catchError } from "rxjs/operators";
|
import { map, catchError } from "rxjs/operators";
|
||||||
import { Project } from "../../project";
|
import { Project } from "../../project";
|
||||||
import { buildHttpRequestOptionsWithObserveResponse } from "../../../../lib/utils/utils";
|
import { buildHttpRequestOptionsWithObserveResponse, CURRENT_BASE_HREF } from "../../../../lib/utils/utils";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TagRetentionService {
|
export class TagRetentionService {
|
||||||
@ -65,45 +65,45 @@ export class TagRetentionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getRetentionMetadata(): Observable<RuleMetadate> {
|
getRetentionMetadata(): Observable<RuleMetadate> {
|
||||||
return this.http.get(`/api/retentions/metadatas`)
|
return this.http.get(`${ CURRENT_BASE_HREF }/retentions/metadatas`)
|
||||||
.pipe(map(response => response as RuleMetadate))
|
.pipe(map(response => response as RuleMetadate))
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
getRetention(retentionId): Observable<Retention> {
|
getRetention(retentionId): Observable<Retention> {
|
||||||
return this.http.get(`/api/retentions/${retentionId}`)
|
return this.http.get(`${ CURRENT_BASE_HREF }/retentions/${retentionId}`)
|
||||||
.pipe(map(response => response as Retention))
|
.pipe(map(response => response as Retention))
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
createRetention(retention: Retention) {
|
createRetention(retention: Retention) {
|
||||||
return this.http.post(`/api/retentions`, retention)
|
return this.http.post(`${ CURRENT_BASE_HREF }/retentions`, retention)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateRetention(retentionId, retention: Retention) {
|
updateRetention(retentionId, retention: Retention) {
|
||||||
return this.http.put(`/api/retentions/${retentionId}`, retention)
|
return this.http.put(`${ CURRENT_BASE_HREF }/retentions/${retentionId}`, retention)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
getProjectInfo(projectId) {
|
getProjectInfo(projectId) {
|
||||||
return this.http.get(`/api/projects/${projectId}`)
|
return this.http.get(`${ CURRENT_BASE_HREF }/projects/${projectId}`)
|
||||||
.pipe(map(response => response as Project))
|
.pipe(map(response => response as Project))
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
runNowTrigger(retentionId) {
|
runNowTrigger(retentionId) {
|
||||||
return this.http.post(`/api/retentions/${retentionId}/executions`, {dry_run: false})
|
return this.http.post(`${ CURRENT_BASE_HREF }/retentions/${retentionId}/executions`, {dry_run: false})
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
whatIfRunTrigger(retentionId) {
|
whatIfRunTrigger(retentionId) {
|
||||||
return this.http.post(`/api/retentions/${retentionId}/executions`, {dry_run: true})
|
return this.http.post(`${ CURRENT_BASE_HREF }/retentions/${retentionId}/executions`, {dry_run: true})
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
AbortRun(retentionId, executionId) {
|
AbortRun(retentionId, executionId) {
|
||||||
return this.http.patch(`/api/retentions/${retentionId}/executions/${executionId}`, {action: 'stop'})
|
return this.http.patch(`${ CURRENT_BASE_HREF }/retentions/${retentionId}/executions/${executionId}`, {action: 'stop'})
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +113,8 @@ export class TagRetentionService {
|
|||||||
params = params.set('page', page + '').set('page_size', pageSize + '');
|
params = params.set('page', page + '').set('page_size', pageSize + '');
|
||||||
}
|
}
|
||||||
return this.http
|
return this.http
|
||||||
.get<HttpResponse<Array<any>>>(`/api/retentions/${retentionId}/executions`, buildHttpRequestOptionsWithObserveResponse(params))
|
.get<HttpResponse<Array<any>>>(`${ CURRENT_BASE_HREF }/retentions/${retentionId}/executions`,
|
||||||
|
buildHttpRequestOptionsWithObserveResponse(params))
|
||||||
.pipe(catchError(error => observableThrowError(error)), );
|
.pipe(catchError(error => observableThrowError(error)), );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,12 +123,12 @@ export class TagRetentionService {
|
|||||||
if (page && pageSize) {
|
if (page && pageSize) {
|
||||||
params = params.set('page', page + '').set('page_size', pageSize + '');
|
params = params.set('page', page + '').set('page_size', pageSize + '');
|
||||||
}
|
}
|
||||||
return this.http.get<HttpResponse<Array<any>>>(`/api/retentions/${retentionId}/executions/${executionId}/tasks`,
|
return this.http.get<HttpResponse<Array<any>>>(`${ CURRENT_BASE_HREF }/retentions/${retentionId}/executions/${executionId}/tasks`,
|
||||||
buildHttpRequestOptionsWithObserveResponse(params))
|
buildHttpRequestOptionsWithObserveResponse(params))
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
seeLog(retentionId, executionId, taskId) {
|
seeLog(retentionId, executionId, taskId) {
|
||||||
window.open(`api/retentions/${retentionId}/executions/${executionId}/tasks/${taskId}`, '_blank');
|
window.open(`${ CURRENT_BASE_HREF }/retentions/${retentionId}/executions/${executionId}/tasks/${taskId}`, '_blank');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import { map, catchError } from "rxjs/operators";
|
|||||||
import { Injectable } from "@angular/core";
|
import { Injectable } from "@angular/core";
|
||||||
import { HttpClient } from "@angular/common/http";
|
import { HttpClient } from "@angular/common/http";
|
||||||
import { Webhook, LastTrigger } from "./webhook";
|
import { Webhook, LastTrigger } from "./webhook";
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../lib/utils/utils";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class WebhookService {
|
export class WebhookService {
|
||||||
@ -23,34 +24,34 @@ export class WebhookService {
|
|||||||
|
|
||||||
public listWebhook(projectId: number): Observable<Webhook[]> {
|
public listWebhook(projectId: number): Observable<Webhook[]> {
|
||||||
return this.http
|
return this.http
|
||||||
.get(`/api/projects/${projectId}/webhook/policies`)
|
.get(`${ CURRENT_BASE_HREF }/projects/${projectId}/webhook/policies`)
|
||||||
.pipe(map(response => response as Webhook[]))
|
.pipe(map(response => response as Webhook[]))
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public listLastTrigger(projectId: number): Observable<LastTrigger[]> {
|
public listLastTrigger(projectId: number): Observable<LastTrigger[]> {
|
||||||
return this.http
|
return this.http
|
||||||
.get(`/api/projects/${projectId}/webhook/lasttrigger`)
|
.get(`${ CURRENT_BASE_HREF }/projects/${projectId}/webhook/lasttrigger`)
|
||||||
.pipe(map(response => response as LastTrigger[]))
|
.pipe(map(response => response as LastTrigger[]))
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public editWebhook(projectId: number, policyId: number, data: any): Observable<any> {
|
public editWebhook(projectId: number, policyId: number, data: any): Observable<any> {
|
||||||
return this.http
|
return this.http
|
||||||
.put(`/api/projects/${projectId}/webhook/policies/${policyId}`, data)
|
.put(`${ CURRENT_BASE_HREF }/projects/${projectId}/webhook/policies/${policyId}`, data)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public createWebhook(projectId: number, data: any): Observable<any> {
|
public createWebhook(projectId: number, data: any): Observable<any> {
|
||||||
return this.http
|
return this.http
|
||||||
.post(`/api/projects/${projectId}/webhook/policies`, data)
|
.post(`${ CURRENT_BASE_HREF }/projects/${projectId}/webhook/policies`, data)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public testEndpoint(projectId: number, param): Observable<any> {
|
public testEndpoint(projectId: number, param): Observable<any> {
|
||||||
return this.http
|
return this.http
|
||||||
.post(`/api/projects/${projectId}/webhook/policies/test`, param)
|
.post(`${ CURRENT_BASE_HREF }/projects/${projectId}/webhook/policies/test`, param)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,16 +20,22 @@ import { Member } from '../project/member/member';
|
|||||||
import { SignInCredential } from './sign-in-credential';
|
import { SignInCredential } from './sign-in-credential';
|
||||||
import { enLang } from './shared.const';
|
import { enLang } from './shared.const';
|
||||||
import { SessionViewmodelFactory } from './session.viewmodel.factory';
|
import { SessionViewmodelFactory } from './session.viewmodel.factory';
|
||||||
import { HTTP_FORM_OPTIONS, HTTP_GET_OPTIONS, HTTP_JSON_OPTIONS, clone } from "../../lib/utils/utils";
|
import {
|
||||||
|
HTTP_FORM_OPTIONS,
|
||||||
|
HTTP_GET_OPTIONS,
|
||||||
|
HTTP_JSON_OPTIONS,
|
||||||
|
clone,
|
||||||
|
CURRENT_BASE_HREF
|
||||||
|
} from "../../lib/utils/utils";
|
||||||
import { FlushAll } from "../../lib/utils/cache-util";
|
import { FlushAll } from "../../lib/utils/cache-util";
|
||||||
|
|
||||||
const signInUrl = '/c/login';
|
const signInUrl = '/c/login';
|
||||||
const currentUserEndpoint = "/api/users/current";
|
const currentUserEndpoint = CURRENT_BASE_HREF + "/users/current";
|
||||||
const signOffEndpoint = "/c/log_out";
|
const signOffEndpoint = "/c/log_out";
|
||||||
const accountEndpoint = "/api/users/:id";
|
const accountEndpoint = CURRENT_BASE_HREF + "/users/:id";
|
||||||
const langEndpoint = "/language";
|
const langEndpoint = "/language";
|
||||||
const userExistsEndpoint = "/c/userExists";
|
const userExistsEndpoint = "/c/userExists";
|
||||||
const renameAdminEndpoint = '/api/internal/renameadmin';
|
const renameAdminEndpoint = CURRENT_BASE_HREF + '/internal/renameadmin';
|
||||||
const langMap = {
|
const langMap = {
|
||||||
"zh": "zh-CN",
|
"zh": "zh-CN",
|
||||||
"en": "en-US"
|
"en": "en-US"
|
||||||
|
@ -46,6 +46,7 @@ import { ListChartVersionRoComponent } from "./list-chart-version-ro/list-chart-
|
|||||||
import { IServiceConfig, SERVICE_CONFIG } from "../../lib/entities/service.config";
|
import { IServiceConfig, SERVICE_CONFIG } from "../../lib/entities/service.config";
|
||||||
import { ErrorHandler } from "../../lib/utils/error-handler";
|
import { ErrorHandler } from "../../lib/utils/error-handler";
|
||||||
import { HarborLibraryModule } from "../../lib/harbor-library.module";
|
import { HarborLibraryModule } from "../../lib/harbor-library.module";
|
||||||
|
import { CURRENT_BASE_HREF } from "../../lib/utils/utils";
|
||||||
|
|
||||||
const uiLibConfig: IServiceConfig = {
|
const uiLibConfig: IServiceConfig = {
|
||||||
enablei18Support: true,
|
enablei18Support: true,
|
||||||
@ -53,24 +54,24 @@ const uiLibConfig: IServiceConfig = {
|
|||||||
langMessageLoader: "http",
|
langMessageLoader: "http",
|
||||||
langMessagePathForHttpLoader: "i18n/lang/",
|
langMessagePathForHttpLoader: "i18n/lang/",
|
||||||
langMessageFileSuffixForHttpLoader: "-lang.json",
|
langMessageFileSuffixForHttpLoader: "-lang.json",
|
||||||
systemInfoEndpoint: "/api/systeminfo",
|
systemInfoEndpoint: CURRENT_BASE_HREF + "/systeminfo",
|
||||||
repositoryBaseEndpoint: "/api/repositories",
|
repositoryBaseEndpoint: CURRENT_BASE_HREF + "/repositories",
|
||||||
logBaseEndpoint: "/api/logs",
|
logBaseEndpoint: CURRENT_BASE_HREF + "/logs",
|
||||||
targetBaseEndpoint: "/api/registries",
|
targetBaseEndpoint: CURRENT_BASE_HREF + "/registries",
|
||||||
replicationBaseEndpoint: "/api/replication",
|
replicationBaseEndpoint: CURRENT_BASE_HREF + "/replication",
|
||||||
replicationRuleEndpoint: "/api/replication/policies",
|
replicationRuleEndpoint: CURRENT_BASE_HREF + "/replication/policies",
|
||||||
vulnerabilityScanningBaseEndpoint: "/api/repositories",
|
vulnerabilityScanningBaseEndpoint: CURRENT_BASE_HREF + "/repositories",
|
||||||
projectPolicyEndpoint: "/api/projects/configs",
|
projectPolicyEndpoint: CURRENT_BASE_HREF + "/projects/configs",
|
||||||
projectBaseEndpoint: "/api/projects",
|
projectBaseEndpoint: CURRENT_BASE_HREF + "/projects",
|
||||||
localI18nMessageVariableMap: {},
|
localI18nMessageVariableMap: {},
|
||||||
configurationEndpoint: "/api/configurations",
|
configurationEndpoint: CURRENT_BASE_HREF + "/configurations",
|
||||||
scanJobEndpoint: "/api/jobs/scan",
|
scanJobEndpoint: CURRENT_BASE_HREF + "/jobs/scan",
|
||||||
labelEndpoint: "/api/labels",
|
labelEndpoint: CURRENT_BASE_HREF + "/labels",
|
||||||
helmChartEndpoint: "/api/chartrepo",
|
helmChartEndpoint: CURRENT_BASE_HREF + "/chartrepo",
|
||||||
downloadChartEndpoint: "/chartrepo",
|
downloadChartEndpoint: "/chartrepo",
|
||||||
gcEndpoint: "/api/system/gc",
|
gcEndpoint: CURRENT_BASE_HREF + "/system/gc",
|
||||||
ScanAllEndpoint: "/api/system/scanAll",
|
ScanAllEndpoint: CURRENT_BASE_HREF + "/system/scanAll",
|
||||||
quotaUrl: "/api/quotas"
|
quotaUrl: CURRENT_BASE_HREF + "/quotas"
|
||||||
};
|
};
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@ -17,11 +17,11 @@ import { map, catchError } from "rxjs/operators";
|
|||||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||||
import { Statistics } from './statistics';
|
import { Statistics } from './statistics';
|
||||||
import { Volumes } from './volumes';
|
import { Volumes } from './volumes';
|
||||||
import { HTTP_GET_OPTIONS } from "../../../lib/utils/utils";
|
import { CURRENT_BASE_HREF, HTTP_GET_OPTIONS } from "../../../lib/utils/utils";
|
||||||
|
|
||||||
|
|
||||||
const statisticsEndpoint = "/api/statistics";
|
const statisticsEndpoint = CURRENT_BASE_HREF + "/statistics";
|
||||||
const volumesEndpoint = "/api/systeminfo/volumes";
|
const volumesEndpoint = CURRENT_BASE_HREF + "/systeminfo/volumes";
|
||||||
/**
|
/**
|
||||||
* Declare service to handle the top repositories
|
* Declare service to handle the top repositories
|
||||||
*
|
*
|
||||||
|
@ -16,9 +16,9 @@ import { HttpClient } from '@angular/common/http';
|
|||||||
import { map, catchError } from "rxjs/operators";
|
import { map, catchError } from "rxjs/operators";
|
||||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||||
import { Repository } from "../../../lib/services";
|
import { Repository } from "../../../lib/services";
|
||||||
import { HTTP_GET_OPTIONS } from "../../../lib/utils/utils";
|
import { CURRENT_BASE_HREF, HTTP_GET_OPTIONS } from "../../../lib/utils/utils";
|
||||||
|
|
||||||
export const topRepoEndpoint = "/api/repositories/top";
|
export const topRepoEndpoint = CURRENT_BASE_HREF + "/repositories/top";
|
||||||
/**
|
/**
|
||||||
* Declare service to handle the top repositories
|
* Declare service to handle the top repositories
|
||||||
*
|
*
|
||||||
|
@ -17,12 +17,17 @@ import { map, catchError } from "rxjs/operators";
|
|||||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||||
import { User, LDAPUser } from './user';
|
import { User, LDAPUser } from './user';
|
||||||
import LDAPUsertoUser from './user';
|
import LDAPUsertoUser from './user';
|
||||||
import { buildHttpRequestOptionsWithObserveResponse, HTTP_GET_OPTIONS, HTTP_JSON_OPTIONS } from "../../lib/utils/utils";
|
import {
|
||||||
|
buildHttpRequestOptionsWithObserveResponse,
|
||||||
|
CURRENT_BASE_HREF,
|
||||||
|
HTTP_GET_OPTIONS,
|
||||||
|
HTTP_JSON_OPTIONS
|
||||||
|
} from "../../lib/utils/utils";
|
||||||
|
|
||||||
|
|
||||||
const userMgmtEndpoint = '/api/users';
|
const userMgmtEndpoint = CURRENT_BASE_HREF + '/users';
|
||||||
const userListSearch = '/api/users/search?';
|
const userListSearch = CURRENT_BASE_HREF + '/users/search?';
|
||||||
const ldapUserEndpoint = '/api/ldap/users';
|
const ldapUserEndpoint = CURRENT_BASE_HREF + '/ldap/users';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define related methods to handle account and session corresponding things
|
* Define related methods to handle account and session corresponding things
|
||||||
|
@ -10,13 +10,14 @@ import { CronScheduleComponent } from '../../cron-schedule/cron-schedule.compone
|
|||||||
import { CronTooltipComponent } from "../../cron-schedule/cron-tooltip/cron-tooltip.component";
|
import { CronTooltipComponent } from "../../cron-schedule/cron-tooltip/cron-tooltip.component";
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { GcJobData } from './gcLog';
|
import { GcJobData } from './gcLog';
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../utils/utils";
|
||||||
|
|
||||||
describe('GcComponent', () => {
|
describe('GcComponent', () => {
|
||||||
let component: GcComponent;
|
let component: GcComponent;
|
||||||
let fixture: ComponentFixture<GcComponent>;
|
let fixture: ComponentFixture<GcComponent>;
|
||||||
let gcRepoService: GcRepoService;
|
let gcRepoService: GcRepoService;
|
||||||
let config: IServiceConfig = {
|
let config: IServiceConfig = {
|
||||||
systemInfoEndpoint: "/api/system/gc"
|
systemInfoEndpoint: CURRENT_BASE_HREF + "/system/gc"
|
||||||
};
|
};
|
||||||
let mockSchedule = [];
|
let mockSchedule = [];
|
||||||
let mockJobs: GcJobData[] = [
|
let mockJobs: GcJobData[] = [
|
||||||
|
@ -4,12 +4,13 @@ import { SERVICE_CONFIG, IServiceConfig } from '../../../../entities/service.con
|
|||||||
import { EditQuotaQuotaInterface } from '../../../../services';
|
import { EditQuotaQuotaInterface } from '../../../../services';
|
||||||
import { HarborLibraryModule } from '../../../../harbor-library.module';
|
import { HarborLibraryModule } from '../../../../harbor-library.module';
|
||||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../../utils/utils";
|
||||||
|
|
||||||
describe('EditProjectQuotasComponent', () => {
|
describe('EditProjectQuotasComponent', () => {
|
||||||
let component: EditProjectQuotasComponent;
|
let component: EditProjectQuotasComponent;
|
||||||
let fixture: ComponentFixture<EditProjectQuotasComponent>;
|
let fixture: ComponentFixture<EditProjectQuotasComponent>;
|
||||||
let config: IServiceConfig = {
|
let config: IServiceConfig = {
|
||||||
quotaUrl: "/api/quotas/testing"
|
quotaUrl: CURRENT_BASE_HREF + "/quotas/testing"
|
||||||
};
|
};
|
||||||
const mockedEditQuota: EditQuotaQuotaInterface = {
|
const mockedEditQuota: EditQuotaQuotaInterface = {
|
||||||
editQuota: "Edit Default Project Quotas",
|
editQuota: "Edit Default Project Quotas",
|
||||||
|
@ -12,6 +12,7 @@ import { delay } from 'rxjs/operators';
|
|||||||
import {APP_BASE_HREF} from '@angular/common';
|
import {APP_BASE_HREF} from '@angular/common';
|
||||||
import { HarborLibraryModule } from '../../../harbor-library.module';
|
import { HarborLibraryModule } from '../../../harbor-library.module';
|
||||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../utils/utils";
|
||||||
describe('ProjectQuotasComponent', () => {
|
describe('ProjectQuotasComponent', () => {
|
||||||
let spy: jasmine.Spy;
|
let spy: jasmine.Spy;
|
||||||
let spyUpdate: jasmine.Spy;
|
let spyUpdate: jasmine.Spy;
|
||||||
@ -22,7 +23,7 @@ describe('ProjectQuotasComponent', () => {
|
|||||||
let fixture: ComponentFixture<ProjectQuotasComponent>;
|
let fixture: ComponentFixture<ProjectQuotasComponent>;
|
||||||
|
|
||||||
let config: IServiceConfig = {
|
let config: IServiceConfig = {
|
||||||
quotaUrl: "/api/quotas/testing"
|
quotaUrl: CURRENT_BASE_HREF + "/quotas/testing"
|
||||||
};
|
};
|
||||||
let mockQuotaList: Quota[] = [{
|
let mockQuotaList: Quota[] = [{
|
||||||
id: 1111,
|
id: 1111,
|
||||||
|
@ -23,6 +23,7 @@ import {
|
|||||||
} from '../../services';
|
} from '../../services';
|
||||||
import { Configuration } from './config';
|
import { Configuration } from './config';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
|
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||||
|
|
||||||
describe('RegistryConfigComponent (inline template)', () => {
|
describe('RegistryConfigComponent (inline template)', () => {
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ describe('RegistryConfigComponent (inline template)', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let config: IServiceConfig = {
|
let config: IServiceConfig = {
|
||||||
configurationEndpoint: '/api/configurations/testing'
|
configurationEndpoint: CURRENT_BASE_HREF + '/configurations/testing'
|
||||||
};
|
};
|
||||||
let mockSystemInfo: SystemInfo = {
|
let mockSystemInfo: SystemInfo = {
|
||||||
"with_notary": true,
|
"with_notary": true,
|
||||||
|
@ -3,11 +3,12 @@ import { ReplicationConfigComponent } from "./replication-config.component";
|
|||||||
import { HarborLibraryModule } from "../../../harbor-library.module";
|
import { HarborLibraryModule } from "../../../harbor-library.module";
|
||||||
import { IServiceConfig, SERVICE_CONFIG } from "../../../entities/service.config";
|
import { IServiceConfig, SERVICE_CONFIG } from "../../../entities/service.config";
|
||||||
import { Configuration } from "../config";
|
import { Configuration } from "../config";
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../utils/utils";
|
||||||
describe('ReplicationConfigComponent', () => {
|
describe('ReplicationConfigComponent', () => {
|
||||||
let component: ReplicationConfigComponent;
|
let component: ReplicationConfigComponent;
|
||||||
let fixture: ComponentFixture<ReplicationConfigComponent>;
|
let fixture: ComponentFixture<ReplicationConfigComponent>;
|
||||||
const config: IServiceConfig = {
|
const config: IServiceConfig = {
|
||||||
baseEndpoint: "/api/testing"
|
baseEndpoint: CURRENT_BASE_HREF + "/testing"
|
||||||
};
|
};
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
|
@ -7,11 +7,12 @@ import { ErrorHandler } from "../../../utils/error-handler";
|
|||||||
import { of } from "rxjs";
|
import { of } from "rxjs";
|
||||||
import { StringValueItem } from "../config";
|
import { StringValueItem } from "../config";
|
||||||
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
|
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../utils/utils";
|
||||||
describe('SystemSettingsComponent', () => {
|
describe('SystemSettingsComponent', () => {
|
||||||
let component: SystemSettingsComponent;
|
let component: SystemSettingsComponent;
|
||||||
let fixture: ComponentFixture<SystemSettingsComponent>;
|
let fixture: ComponentFixture<SystemSettingsComponent>;
|
||||||
const config: IServiceConfig = {
|
const config: IServiceConfig = {
|
||||||
baseEndpoint: "/api/testing"
|
baseEndpoint: CURRENT_BASE_HREF + "/testing"
|
||||||
};
|
};
|
||||||
const mockedWhitelist = {
|
const mockedWhitelist = {
|
||||||
id: 1,
|
id: 1,
|
||||||
|
@ -5,6 +5,7 @@ import { ErrorHandler } from '../../../utils/error-handler';
|
|||||||
import {HttpClient} from "@angular/common/http";
|
import {HttpClient} from "@angular/common/http";
|
||||||
import {ScanningMetrics} from "../config";
|
import {ScanningMetrics} from "../config";
|
||||||
import {catchError, map} from "rxjs/operators";
|
import {catchError, map} from "rxjs/operators";
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../utils/utils";
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -51,21 +52,21 @@ export class ScanAllRepoService {
|
|||||||
return this.scanApiRepository.putSchedule(param);
|
return this.scanApiRepository.putSchedule(param);
|
||||||
}
|
}
|
||||||
getScheduleMetrics(): Observable<ScanningMetrics> {
|
getScheduleMetrics(): Observable<ScanningMetrics> {
|
||||||
return this.http.get('/api/scans/schedule/metrics')
|
return this.http.get(CURRENT_BASE_HREF + '/scans/schedule/metrics')
|
||||||
.pipe(catchError(error => observableThrowError(error)))
|
.pipe(catchError(error => observableThrowError(error)))
|
||||||
.pipe(map(response => response as ScanningMetrics));
|
.pipe(map(response => response as ScanningMetrics));
|
||||||
}
|
}
|
||||||
getManualMetrics(): Observable<ScanningMetrics> {
|
getManualMetrics(): Observable<ScanningMetrics> {
|
||||||
return this.http.get('/api/scans/all/metrics')
|
return this.http.get(CURRENT_BASE_HREF + '/scans/all/metrics')
|
||||||
.pipe(catchError(error => observableThrowError(error)))
|
.pipe(catchError(error => observableThrowError(error)))
|
||||||
.pipe(map(response => response as ScanningMetrics));
|
.pipe(map(response => response as ScanningMetrics));
|
||||||
}
|
}
|
||||||
getScanners(): Observable<any> {
|
getScanners(): Observable<any> {
|
||||||
return this.http.get('/api/scanners')
|
return this.http.get(CURRENT_BASE_HREF + '/scanners')
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
getScannerMetadata(uid: string): Observable<any> {
|
getScannerMetadata(uid: string): Observable<any> {
|
||||||
return this.http.get(`/api/scanners/${uid}/metadata`)
|
return this.http.get(`${ CURRENT_BASE_HREF }/scanners/${uid}/metadata`)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,12 @@ import { IServiceConfig, SERVICE_CONFIG } from "../../../entities/service.config
|
|||||||
import { ScanningMetrics } from "../config";
|
import { ScanningMetrics } from "../config";
|
||||||
import { SharedModule } from "../../../utils/shared/shared.module";
|
import { SharedModule } from "../../../utils/shared/shared.module";
|
||||||
import { ErrorHandler } from "../../../utils/error-handler";
|
import { ErrorHandler } from "../../../utils/error-handler";
|
||||||
|
import { CURRENT_BASE_HREF } from "../../../utils/utils";
|
||||||
|
|
||||||
let component: VulnerabilityConfigComponent;
|
let component: VulnerabilityConfigComponent;
|
||||||
let fixture: ComponentFixture<VulnerabilityConfigComponent>;
|
let fixture: ComponentFixture<VulnerabilityConfigComponent>;
|
||||||
let config: IServiceConfig = {
|
let config: IServiceConfig = {
|
||||||
configurationEndpoint: '/api/configurations/testing'
|
configurationEndpoint: CURRENT_BASE_HREF + '/configurations/testing'
|
||||||
};
|
};
|
||||||
let mockedSchedule = {"schedule": null};
|
let mockedSchedule = {"schedule": null};
|
||||||
let mockedScheduledMetrics: ScanningMetrics = {
|
let mockedScheduledMetrics: ScanningMetrics = {
|
||||||
|
@ -6,6 +6,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|||||||
import { ConfirmationTargets } from '../../entities/shared.const';
|
import { ConfirmationTargets } from '../../entities/shared.const';
|
||||||
import { ConfirmationMessage } from './confirmation-message';
|
import { ConfirmationMessage } from './confirmation-message';
|
||||||
import { BatchInfo } from './confirmation-batch-message';
|
import { BatchInfo } from './confirmation-batch-message';
|
||||||
|
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||||
|
|
||||||
|
|
||||||
describe('ConfirmationDialogComponent', () => {
|
describe('ConfirmationDialogComponent', () => {
|
||||||
@ -13,7 +14,7 @@ describe('ConfirmationDialogComponent', () => {
|
|||||||
let comp: ConfirmationDialogComponent;
|
let comp: ConfirmationDialogComponent;
|
||||||
let fixture: ComponentFixture<ConfirmationDialogComponent>;
|
let fixture: ComponentFixture<ConfirmationDialogComponent>;
|
||||||
let config: IServiceConfig = {
|
let config: IServiceConfig = {
|
||||||
configurationEndpoint: '/api/configurations/testing'
|
configurationEndpoint: CURRENT_BASE_HREF + '/configurations/testing'
|
||||||
};
|
};
|
||||||
const deletionMessage: ConfirmationMessage = new ConfirmationMessage(
|
const deletionMessage: ConfirmationMessage = new ConfirmationMessage(
|
||||||
"MEMBER.DELETION_TITLE",
|
"MEMBER.DELETION_TITLE",
|
||||||
|
@ -21,6 +21,7 @@ import { IServiceConfig, SERVICE_CONFIG } from "../../entities/service.config";
|
|||||||
import { of } from "rxjs";
|
import { of } from "rxjs";
|
||||||
import { HttpClient } from "@angular/common/http";
|
import { HttpClient } from "@angular/common/http";
|
||||||
import { HttpClientTestingModule } from "@angular/common/http/testing";
|
import { HttpClientTestingModule } from "@angular/common/http/testing";
|
||||||
|
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||||
|
|
||||||
describe("CreateEditEndpointComponent (inline template)", () => {
|
describe("CreateEditEndpointComponent (inline template)", () => {
|
||||||
let mockData: Endpoint = {
|
let mockData: Endpoint = {
|
||||||
@ -254,7 +255,7 @@ describe("CreateEditEndpointComponent (inline template)", () => {
|
|||||||
let fixture: ComponentFixture<CreateEditEndpointComponent>;
|
let fixture: ComponentFixture<CreateEditEndpointComponent>;
|
||||||
|
|
||||||
let config: IServiceConfig = {
|
let config: IServiceConfig = {
|
||||||
systemInfoEndpoint: "/api/endpoints/testing"
|
systemInfoEndpoint: CURRENT_BASE_HREF + "/endpoints/testing"
|
||||||
};
|
};
|
||||||
|
|
||||||
let endpointService: EndpointService;
|
let endpointService: EndpointService;
|
||||||
@ -326,6 +327,6 @@ describe("CreateEditEndpointComponent (inline template)", () => {
|
|||||||
|
|
||||||
it("should endpoint be initialized", () => {
|
it("should endpoint be initialized", () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(config.systemInfoEndpoint).toEqual("/api/endpoints/testing");
|
expect(config.systemInfoEndpoint).toEqual(CURRENT_BASE_HREF + "/endpoints/testing");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -29,13 +29,13 @@ import { EndpointService } from "../../services/endpoint.service";
|
|||||||
import { ErrorHandler } from "../../utils/error-handler";
|
import { ErrorHandler } from "../../utils/error-handler";
|
||||||
import { InlineAlertComponent } from "../inline-alert/inline-alert.component";
|
import { InlineAlertComponent } from "../inline-alert/inline-alert.component";
|
||||||
import { Endpoint, PingEndpoint } from "../../services/interface";
|
import { Endpoint, PingEndpoint } from "../../services/interface";
|
||||||
import { clone, compareValue, isEmptyObject } from "../../utils/utils";
|
import { clone, compareValue, CURRENT_BASE_HREF, isEmptyObject } from "../../utils/utils";
|
||||||
import { HttpClient } from "@angular/common/http";
|
import { HttpClient } from "@angular/common/http";
|
||||||
import { catchError } from "rxjs/operators";
|
import { catchError } from "rxjs/operators";
|
||||||
|
|
||||||
const FAKE_PASSWORD = "rjGcfuRu";
|
const FAKE_PASSWORD = "rjGcfuRu";
|
||||||
const FAKE_JSON_KEY = "No Change";
|
const FAKE_JSON_KEY = "No Change";
|
||||||
const METADATA_URL = "/api/replication/adapterinfos";
|
const METADATA_URL = CURRENT_BASE_HREF + "/replication/adapterinfos";
|
||||||
@Component({
|
@Component({
|
||||||
selector: "hbr-create-edit-endpoint",
|
selector: "hbr-create-edit-endpoint",
|
||||||
templateUrl: "./create-edit-endpoint.component.html",
|
templateUrl: "./create-edit-endpoint.component.html",
|
||||||
|
@ -10,6 +10,7 @@ import { IServiceConfig, SERVICE_CONFIG } from "../../entities/service.config";
|
|||||||
import { CreateEditLabelComponent } from "./create-edit-label.component";
|
import { CreateEditLabelComponent } from "./create-edit-label.component";
|
||||||
import { LabelDefaultService, LabelService } from "../../services/label.service";
|
import { LabelDefaultService, LabelService } from "../../services/label.service";
|
||||||
import { of } from "rxjs";
|
import { of } from "rxjs";
|
||||||
|
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||||
|
|
||||||
describe("CreateEditLabelComponent (inline template)", () => {
|
describe("CreateEditLabelComponent (inline template)", () => {
|
||||||
let mockOneData: Label = {
|
let mockOneData: Label = {
|
||||||
@ -27,7 +28,7 @@ describe("CreateEditLabelComponent (inline template)", () => {
|
|||||||
let fixture: ComponentFixture<CreateEditLabelComponent>;
|
let fixture: ComponentFixture<CreateEditLabelComponent>;
|
||||||
|
|
||||||
let config: IServiceConfig = {
|
let config: IServiceConfig = {
|
||||||
systemInfoEndpoint: "/api/label/testing"
|
systemInfoEndpoint: CURRENT_BASE_HREF + "/label/testing"
|
||||||
};
|
};
|
||||||
|
|
||||||
let labelService: LabelService;
|
let labelService: LabelService;
|
||||||
|
@ -39,6 +39,7 @@ import {LabelService} from "../../services/label.service";
|
|||||||
import {LabelPieceComponent} from "../label-piece/label-piece.component";
|
import {LabelPieceComponent} from "../label-piece/label-piece.component";
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { of } from "rxjs";
|
import { of } from "rxjs";
|
||||||
|
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||||
|
|
||||||
describe("CreateEditRuleComponent (inline template)", () => {
|
describe("CreateEditRuleComponent (inline template)", () => {
|
||||||
let mockRules: ReplicationRule[] = [
|
let mockRules: ReplicationRule[] = [
|
||||||
@ -221,8 +222,8 @@ describe("CreateEditRuleComponent (inline template)", () => {
|
|||||||
|
|
||||||
|
|
||||||
let config: IServiceConfig = {
|
let config: IServiceConfig = {
|
||||||
replicationBaseEndpoint: "/api/replication/testing",
|
replicationBaseEndpoint: CURRENT_BASE_HREF + "/replication/testing",
|
||||||
targetBaseEndpoint: "/api/registries/testing"
|
targetBaseEndpoint: CURRENT_BASE_HREF + "/registries/testing"
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
|
@ -18,7 +18,7 @@ import {
|
|||||||
import { IServiceConfig, SERVICE_CONFIG } from "../../entities/service.config";
|
import { IServiceConfig, SERVICE_CONFIG } from "../../entities/service.config";
|
||||||
import { OperationService } from "../operation/operation.service";
|
import { OperationService } from "../operation/operation.service";
|
||||||
|
|
||||||
import { click } from "../../utils/utils";
|
import { click, CURRENT_BASE_HREF } from "../../utils/utils";
|
||||||
import { of } from "rxjs";
|
import { of } from "rxjs";
|
||||||
import { HttpClientTestingModule } from "@angular/common/http/testing";
|
import { HttpClientTestingModule } from "@angular/common/http/testing";
|
||||||
import { HttpClient } from "@angular/common/http";
|
import { HttpClient } from "@angular/common/http";
|
||||||
@ -311,7 +311,7 @@ describe("EndpointComponent (inline template)", () => {
|
|||||||
let comp: EndpointComponent;
|
let comp: EndpointComponent;
|
||||||
let fixture: ComponentFixture<EndpointComponent>;
|
let fixture: ComponentFixture<EndpointComponent>;
|
||||||
let config: IServiceConfig = {
|
let config: IServiceConfig = {
|
||||||
systemInfoEndpoint: "/api/endpoints/testing"
|
systemInfoEndpoint: CURRENT_BASE_HREF + "/endpoints/testing"
|
||||||
};
|
};
|
||||||
|
|
||||||
let endpointService: EndpointService;
|
let endpointService: EndpointService;
|
||||||
@ -368,7 +368,7 @@ describe("EndpointComponent (inline template)", () => {
|
|||||||
|
|
||||||
it("should endpoint be initialized", () => {
|
it("should endpoint be initialized", () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(config.systemInfoEndpoint).toEqual("/api/endpoints/testing");
|
expect(config.systemInfoEndpoint).toEqual(CURRENT_BASE_HREF + "/endpoints/testing");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should open create endpoint modal", async(() => {
|
it("should open create endpoint modal", async(() => {
|
||||||
|
@ -8,6 +8,7 @@ import { IServiceConfig, SERVICE_CONFIG } from "../../entities/service.config";
|
|||||||
import { of } from "rxjs";
|
import { of } from "rxjs";
|
||||||
import { HttpResponse } from "@angular/common/http";
|
import { HttpResponse } from "@angular/common/http";
|
||||||
import { ChannelService } from "../../services/channel.service";
|
import { ChannelService } from "../../services/channel.service";
|
||||||
|
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||||
|
|
||||||
describe("ImageNameInputComponent (inline template)", () => {
|
describe("ImageNameInputComponent (inline template)", () => {
|
||||||
let comp: ImageNameInputComponent;
|
let comp: ImageNameInputComponent;
|
||||||
@ -28,7 +29,7 @@ describe("ImageNameInputComponent (inline template)", () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
let config: IServiceConfig = {
|
let config: IServiceConfig = {
|
||||||
projectBaseEndpoint: "/api/projects/testing"
|
projectBaseEndpoint: CURRENT_BASE_HREF + "/projects/testing"
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
|
@ -14,6 +14,7 @@ import {ErrorHandler} from "../../utils/error-handler/error-handler";
|
|||||||
import {IServiceConfig, SERVICE_CONFIG} from "../../entities/service.config";
|
import {IServiceConfig, SERVICE_CONFIG} from "../../entities/service.config";
|
||||||
import { OperationService } from "../operation/operation.service";
|
import { OperationService } from "../operation/operation.service";
|
||||||
import { of } from "rxjs";
|
import { of } from "rxjs";
|
||||||
|
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||||
|
|
||||||
describe('LabelComponent (inline template)', () => {
|
describe('LabelComponent (inline template)', () => {
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ describe('LabelComponent (inline template)', () => {
|
|||||||
let spyOneLabel: jasmine.Spy;
|
let spyOneLabel: jasmine.Spy;
|
||||||
|
|
||||||
let config: IServiceConfig = {
|
let config: IServiceConfig = {
|
||||||
systemInfoEndpoint: '/api/label/testing'
|
systemInfoEndpoint: CURRENT_BASE_HREF + '/label/testing'
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
|
@ -15,6 +15,7 @@ import { SERVICE_CONFIG, IServiceConfig } from '../../entities/service.config';
|
|||||||
import { ReplicationService, ReplicationDefaultService } from '../../services/replication.service';
|
import { ReplicationService, ReplicationDefaultService } from '../../services/replication.service';
|
||||||
import { OperationService } from "../operation/operation.service";
|
import { OperationService } from "../operation/operation.service";
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
|
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||||
|
|
||||||
describe('ListReplicationRuleComponent (inline template)', () => {
|
describe('ListReplicationRuleComponent (inline template)', () => {
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ describe('ListReplicationRuleComponent (inline template)', () => {
|
|||||||
let spyRules: jasmine.Spy;
|
let spyRules: jasmine.Spy;
|
||||||
|
|
||||||
let config: IServiceConfig = {
|
let config: IServiceConfig = {
|
||||||
replicationRuleEndpoint: '/api/policies/replication/testing'
|
replicationRuleEndpoint: CURRENT_BASE_HREF + '/policies/replication/testing'
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
|
@ -9,7 +9,7 @@ import { ErrorHandler } from '../../utils/error-handler';
|
|||||||
import { SharedModule } from '../../utils/shared/shared.module';
|
import { SharedModule } from '../../utils/shared/shared.module';
|
||||||
import { FilterComponent } from '../filter/filter.component';
|
import { FilterComponent } from '../filter/filter.component';
|
||||||
|
|
||||||
import { click } from '../../utils/utils';
|
import { click, CURRENT_BASE_HREF } from '../../utils/utils';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { delay } from 'rxjs/operators';
|
import { delay } from 'rxjs/operators';
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ describe('RecentLogComponent (inline template)', () => {
|
|||||||
data: []
|
data: []
|
||||||
};
|
};
|
||||||
let testConfig: IServiceConfig = {
|
let testConfig: IServiceConfig = {
|
||||||
logBaseEndpoint: "/api/logs/testing"
|
logBaseEndpoint: CURRENT_BASE_HREF + "/logs/testing"
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
@ -96,7 +96,7 @@ describe('RecentLogComponent (inline template)', () => {
|
|||||||
|
|
||||||
it('should inject the SERVICE_CONFIG', () => {
|
it('should inject the SERVICE_CONFIG', () => {
|
||||||
expect(serviceConfig).toBeTruthy();
|
expect(serviceConfig).toBeTruthy();
|
||||||
expect(serviceConfig.logBaseEndpoint).toEqual("/api/logs/testing");
|
expect(serviceConfig.logBaseEndpoint).toEqual(CURRENT_BASE_HREF + "/logs/testing");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get data from AccessLogService', async(() => {
|
it('should get data from AccessLogService', async(() => {
|
||||||
|
@ -6,13 +6,14 @@ import { OperationService } from './operation.service';
|
|||||||
import { HarborLibraryModule } from '../../harbor-library.module';
|
import { HarborLibraryModule } from '../../harbor-library.module';
|
||||||
import { IServiceConfig, SERVICE_CONFIG } from '../../entities/service.config';
|
import { IServiceConfig, SERVICE_CONFIG } from '../../entities/service.config';
|
||||||
import { OperateInfo } from './operate';
|
import { OperateInfo } from './operate';
|
||||||
|
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||||
|
|
||||||
describe('OperationComponent', () => {
|
describe('OperationComponent', () => {
|
||||||
|
|
||||||
let component: OperationComponent;
|
let component: OperationComponent;
|
||||||
let fixture: ComponentFixture<OperationComponent>;
|
let fixture: ComponentFixture<OperationComponent>;
|
||||||
let config: IServiceConfig = {
|
let config: IServiceConfig = {
|
||||||
configurationEndpoint: '/api/configurations/testing'
|
configurationEndpoint: CURRENT_BASE_HREF + '/configurations/testing'
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -10,6 +10,7 @@ import {SystemCVEWhitelist, SystemInfo} from '../../services/interface';
|
|||||||
import { Project } from './project';
|
import { Project } from './project';
|
||||||
import { UserPermissionService } from '../../services/permission.service';
|
import { UserPermissionService } from '../../services/permission.service';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
|
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||||
|
|
||||||
const mockSystemInfo: SystemInfo[] = [
|
const mockSystemInfo: SystemInfo[] = [
|
||||||
{
|
{
|
||||||
@ -80,8 +81,8 @@ const mockSystemWhitelist: SystemCVEWhitelist = {
|
|||||||
"project_id": 0
|
"project_id": 0
|
||||||
};
|
};
|
||||||
const config: IServiceConfig = {
|
const config: IServiceConfig = {
|
||||||
projectPolicyEndpoint: '/api/projects/testing',
|
projectPolicyEndpoint: CURRENT_BASE_HREF + '/projects/testing',
|
||||||
systemInfoEndpoint: '/api/systeminfo/testing',
|
systemInfoEndpoint: CURRENT_BASE_HREF + '/systeminfo/testing',
|
||||||
};
|
};
|
||||||
const projectService = {
|
const projectService = {
|
||||||
getProject() {
|
getProject() {
|
||||||
|
@ -26,6 +26,7 @@ import {FilterLabelComponent} from "../create-edit-rule/filter-label.component";
|
|||||||
import {LabelPieceComponent} from "../label-piece/label-piece.component";
|
import {LabelPieceComponent} from "../label-piece/label-piece.component";
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
|
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||||
|
|
||||||
|
|
||||||
describe('Replication Component (inline template)', () => {
|
describe('Replication Component (inline template)', () => {
|
||||||
@ -149,7 +150,7 @@ describe('Replication Component (inline template)', () => {
|
|||||||
let elJob: HTMLElement;
|
let elJob: HTMLElement;
|
||||||
|
|
||||||
let config: IServiceConfig = {
|
let config: IServiceConfig = {
|
||||||
replicationRuleEndpoint: '/api/policies/replication/testing'
|
replicationRuleEndpoint: CURRENT_BASE_HREF + '/policies/replication/testing'
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
|
@ -19,9 +19,9 @@ export interface IServiceConfig {
|
|||||||
* The base endpoint of the service used to handle the repositories of registry and/or tags of repository.
|
* The base endpoint of the service used to handle the repositories of registry and/or tags of repository.
|
||||||
* The endpoints of repository or tag(s) will be built based on this endpoint.
|
* The endpoints of repository or tag(s) will be built based on this endpoint.
|
||||||
* E.g:
|
* E.g:
|
||||||
* If the base endpoint is '/api/repositories',
|
* If the base endpoint is CURRENT_BASE_HREF + '/repositories',
|
||||||
* the repository endpoint will be '/api/repositories/:repo_id',
|
* the repository endpoint will be CURRENT_BASE_HREF + '/repositories/:repo_id',
|
||||||
* the tag(s) endpoint will be '/api/repositories/:repo_id/tags[/:tag_id]'.
|
* the tag(s) endpoint will be CURRENT_BASE_HREF + '/repositories/:repo_id/tags[/:tag_id]'.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* * {string}
|
* * {string}
|
||||||
@ -41,9 +41,9 @@ export interface IServiceConfig {
|
|||||||
* The base endpoint of the service used to handle the registry targets.
|
* The base endpoint of the service used to handle the registry targets.
|
||||||
* Registry target related endpoints will be built based on this endpoint.
|
* Registry target related endpoints will be built based on this endpoint.
|
||||||
* E.g:
|
* E.g:
|
||||||
* If the base endpoint is '/api/endpoints',
|
* If the base endpoint is CURRENT_BASE_HREF + '/endpoints',
|
||||||
* the endpoint for registry target will be '/api/endpoints/:endpoint_id',
|
* the endpoint for registry target will be CURRENT_BASE_HREF + '/endpoints/:endpoint_id',
|
||||||
* the endpoint for pinging registry target will be '/api/endpoints/:endpoint_id/ping'.
|
* the endpoint for pinging registry target will be CURRENT_BASE_HREF + '/endpoints/:endpoint_id/ping'.
|
||||||
*
|
*
|
||||||
* * {string}
|
* * {string}
|
||||||
* @memberOf IServiceConfig
|
* @memberOf IServiceConfig
|
||||||
@ -59,8 +59,8 @@ export interface IServiceConfig {
|
|||||||
* The base endpoint of the service used to handle the replication rules.
|
* The base endpoint of the service used to handle the replication rules.
|
||||||
* Replication rule related endpoints will be built based on this endpoint.
|
* Replication rule related endpoints will be built based on this endpoint.
|
||||||
* E.g:
|
* E.g:
|
||||||
* If the base endpoint is '/api/replication/rules',
|
* If the base endpoint is CURRENT_BASE_HREF + '/replication/rules',
|
||||||
* the endpoint for rule will be '/api/replication/rules/:rule_id'.
|
* the endpoint for rule will be CURRENT_BASE_HREF + '/replication/rules/:rule_id'.
|
||||||
*
|
*
|
||||||
* * {string}
|
* * {string}
|
||||||
* @memberOf IServiceConfig
|
* @memberOf IServiceConfig
|
||||||
@ -203,8 +203,8 @@ export interface IServiceConfig {
|
|||||||
* The base endpoint of the service used to handle the labels.
|
* The base endpoint of the service used to handle the labels.
|
||||||
* labels related endpoints will be built based on this endpoint.
|
* labels related endpoints will be built based on this endpoint.
|
||||||
* E.g:
|
* E.g:
|
||||||
* If the base endpoint is '/api/labels',
|
* If the base endpoint is CURRENT_BASE_HREF + '/labels',
|
||||||
* the label endpoint will be '/api/labels/:id'.
|
* the label endpoint will be CURRENT_BASE_HREF + '/labels/:id'.
|
||||||
*
|
*
|
||||||
* * {string}
|
* * {string}
|
||||||
* @memberOf IServiceConfig
|
* @memberOf IServiceConfig
|
||||||
@ -215,8 +215,8 @@ export interface IServiceConfig {
|
|||||||
* The base endpoint of the service used to handle the helm chart.
|
* The base endpoint of the service used to handle the helm chart.
|
||||||
* helm charts related endpoints will be built based on this endpoint.
|
* helm charts related endpoints will be built based on this endpoint.
|
||||||
* E.g:
|
* E.g:
|
||||||
* If the base endpoint is '/api/helmcharts',
|
* If the base endpoint is CURRENT_BASE_HREF + '/helmcharts',
|
||||||
* the helm chart endpoint will be '/api/helmcharts/:id'.
|
* the helm chart endpoint will be CURRENT_BASE_HREF + '/helmcharts/:id'.
|
||||||
*
|
*
|
||||||
* * {string}
|
* * {string}
|
||||||
* @memberOf IServiceConfig
|
* @memberOf IServiceConfig
|
||||||
|
@ -38,7 +38,7 @@ import {
|
|||||||
ErrorHandler,
|
ErrorHandler,
|
||||||
DefaultErrorHandler
|
DefaultErrorHandler
|
||||||
} from './utils/error-handler';
|
} from './utils/error-handler';
|
||||||
import { DEFAULT_LANG_COOKIE_KEY, DEFAULT_SUPPORTING_LANGS, DEFAULT_LANG } from './utils/utils';
|
import { DEFAULT_LANG_COOKIE_KEY, DEFAULT_SUPPORTING_LANGS, DEFAULT_LANG, CURRENT_BASE_HREF } from './utils/utils';
|
||||||
import { OperationService } from './components/operation/operation.service';
|
import { OperationService } from './components/operation/operation.service';
|
||||||
import { GcHistoryComponent } from "./components/config/gc/gc-history/gc-history.component";
|
import { GcHistoryComponent } from "./components/config/gc/gc-history/gc-history.component";
|
||||||
import { GcComponent } from "./components/config/gc/gc.component";
|
import { GcComponent } from "./components/config/gc/gc.component";
|
||||||
@ -80,16 +80,16 @@ import { TranslateServiceInitializer } from "./i18n";
|
|||||||
* this default configuration.
|
* this default configuration.
|
||||||
*/
|
*/
|
||||||
export const DefaultServiceConfig: IServiceConfig = {
|
export const DefaultServiceConfig: IServiceConfig = {
|
||||||
baseEndpoint: "/api",
|
baseEndpoint: CURRENT_BASE_HREF,
|
||||||
systemInfoEndpoint: "/api/systeminfo",
|
systemInfoEndpoint: CURRENT_BASE_HREF + "/systeminfo",
|
||||||
repositoryBaseEndpoint: "/api/repositories",
|
repositoryBaseEndpoint: CURRENT_BASE_HREF + "/repositories",
|
||||||
logBaseEndpoint: "/api/logs",
|
logBaseEndpoint: CURRENT_BASE_HREF + "/logs",
|
||||||
targetBaseEndpoint: "/api/registries",
|
targetBaseEndpoint: CURRENT_BASE_HREF + "/registries",
|
||||||
replicationBaseEndpoint: "/api/replication",
|
replicationBaseEndpoint: CURRENT_BASE_HREF + "/replication",
|
||||||
replicationRuleEndpoint: "/api/replication/policies",
|
replicationRuleEndpoint: CURRENT_BASE_HREF + "/replication/policies",
|
||||||
vulnerabilityScanningBaseEndpoint: "/api/repositories",
|
vulnerabilityScanningBaseEndpoint: CURRENT_BASE_HREF + "/repositories",
|
||||||
projectPolicyEndpoint: "/api/projects/configs",
|
projectPolicyEndpoint: CURRENT_BASE_HREF + "/projects/configs",
|
||||||
projectBaseEndpoint: "/api/projects",
|
projectBaseEndpoint: CURRENT_BASE_HREF + "/projects",
|
||||||
enablei18Support: false,
|
enablei18Support: false,
|
||||||
langCookieKey: DEFAULT_LANG_COOKIE_KEY,
|
langCookieKey: DEFAULT_LANG_COOKIE_KEY,
|
||||||
supportedLangs: DEFAULT_SUPPORTING_LANGS,
|
supportedLangs: DEFAULT_SUPPORTING_LANGS,
|
||||||
@ -98,13 +98,13 @@ export const DefaultServiceConfig: IServiceConfig = {
|
|||||||
langMessagePathForHttpLoader: "i18n/langs/",
|
langMessagePathForHttpLoader: "i18n/langs/",
|
||||||
langMessageFileSuffixForHttpLoader: "-lang.json",
|
langMessageFileSuffixForHttpLoader: "-lang.json",
|
||||||
localI18nMessageVariableMap: {},
|
localI18nMessageVariableMap: {},
|
||||||
configurationEndpoint: "/api/configurations",
|
configurationEndpoint: CURRENT_BASE_HREF + "/configurations",
|
||||||
scanJobEndpoint: "/api/jobs/scan",
|
scanJobEndpoint: CURRENT_BASE_HREF + "/jobs/scan",
|
||||||
labelEndpoint: "/api/labels",
|
labelEndpoint: CURRENT_BASE_HREF + "/labels",
|
||||||
helmChartEndpoint: "/api/chartrepo",
|
helmChartEndpoint: CURRENT_BASE_HREF + "/chartrepo",
|
||||||
downloadChartEndpoint: "/chartrepo",
|
downloadChartEndpoint: "/chartrepo",
|
||||||
gcEndpoint: "/api/system/gc",
|
gcEndpoint: CURRENT_BASE_HREF + "/system/gc",
|
||||||
ScanAllEndpoint: "/api/system/scanAll"
|
ScanAllEndpoint: CURRENT_BASE_HREF + "/system/scanAll"
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,10 +3,11 @@ import { TestBed, inject } from '@angular/core/testing';
|
|||||||
import { AccessLogService, AccessLogDefaultService } from './access-log.service';
|
import { AccessLogService, AccessLogDefaultService } from './access-log.service';
|
||||||
import { SharedModule } from '../utils/shared/shared.module';
|
import { SharedModule } from '../utils/shared/shared.module';
|
||||||
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
||||||
|
import { CURRENT_BASE_HREF } from "../utils/utils";
|
||||||
|
|
||||||
describe('AccessLogService', () => {
|
describe('AccessLogService', () => {
|
||||||
const mockConfig: IServiceConfig = {
|
const mockConfig: IServiceConfig = {
|
||||||
logBaseEndpoint: "/api/logs/testing"
|
logBaseEndpoint: CURRENT_BASE_HREF + "/logs/testing"
|
||||||
};
|
};
|
||||||
|
|
||||||
let config: IServiceConfig;
|
let config: IServiceConfig;
|
||||||
@ -36,7 +37,7 @@ describe('AccessLogService', () => {
|
|||||||
|
|
||||||
it('should inject the right config', () => {
|
it('should inject the right config', () => {
|
||||||
expect(config).toBeTruthy();
|
expect(config).toBeTruthy();
|
||||||
expect(config.logBaseEndpoint).toEqual("/api/logs/testing");
|
expect(config.logBaseEndpoint).toEqual(CURRENT_BASE_HREF + "/logs/testing");
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -4,7 +4,11 @@ import { AccessLog, AccessLogItem } from "./interface";
|
|||||||
import { Injectable, Inject } from "@angular/core";
|
import { Injectable, Inject } from "@angular/core";
|
||||||
import { SERVICE_CONFIG, IServiceConfig } from "../entities/service.config";
|
import { SERVICE_CONFIG, IServiceConfig } from "../entities/service.config";
|
||||||
import { HttpClient, HttpResponse } from "@angular/common/http";
|
import { HttpClient, HttpResponse } from "@angular/common/http";
|
||||||
import { buildHttpRequestOptionsWithObserveResponse, HTTP_GET_OPTIONS_OBSERVE_RESPONSE } from "../utils/utils";
|
import {
|
||||||
|
buildHttpRequestOptionsWithObserveResponse,
|
||||||
|
CURRENT_BASE_HREF,
|
||||||
|
HTTP_GET_OPTIONS_OBSERVE_RESPONSE
|
||||||
|
} from "../utils/utils";
|
||||||
import { map, catchError } from "rxjs/operators";
|
import { map, catchError } from "rxjs/operators";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,7 +81,7 @@ export class AccessLogDefaultService extends AccessLogService {
|
|||||||
? this.config.logBaseEndpoint
|
? this.config.logBaseEndpoint
|
||||||
: "";
|
: "";
|
||||||
if (url === "") {
|
if (url === "") {
|
||||||
url = "/api/logs";
|
url = CURRENT_BASE_HREF + "/logs";
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.http
|
return this.http
|
||||||
|
@ -3,10 +3,11 @@ import { TestBed, inject } from '@angular/core/testing';
|
|||||||
import { ConfigurationService, ConfigurationDefaultService } from './configuration.service';
|
import { ConfigurationService, ConfigurationDefaultService } from './configuration.service';
|
||||||
import { SharedModule } from '../utils/shared/shared.module';
|
import { SharedModule } from '../utils/shared/shared.module';
|
||||||
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
||||||
|
import { CURRENT_BASE_HREF } from "../utils/utils";
|
||||||
|
|
||||||
describe('ConfigurationService', () => {
|
describe('ConfigurationService', () => {
|
||||||
const mockConfig: IServiceConfig = {
|
const mockConfig: IServiceConfig = {
|
||||||
configurationEndpoint: "/api/configurations/testing"
|
configurationEndpoint: CURRENT_BASE_HREF + "/configurations/testing"
|
||||||
};
|
};
|
||||||
|
|
||||||
let config: IServiceConfig;
|
let config: IServiceConfig;
|
||||||
@ -36,7 +37,7 @@ describe('ConfigurationService', () => {
|
|||||||
|
|
||||||
it('should inject the right config', () => {
|
it('should inject the right config', () => {
|
||||||
expect(config).toBeTruthy();
|
expect(config).toBeTruthy();
|
||||||
expect(config.configurationEndpoint).toEqual("/api/configurations/testing");
|
expect(config.configurationEndpoint).toEqual(CURRENT_BASE_HREF + "/configurations/testing");
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -4,7 +4,7 @@ import { map, catchError } from "rxjs/operators";
|
|||||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||||
|
|
||||||
import { SERVICE_CONFIG, IServiceConfig } from "../entities/service.config";
|
import { SERVICE_CONFIG, IServiceConfig } from "../entities/service.config";
|
||||||
import { HTTP_JSON_OPTIONS, HTTP_GET_OPTIONS } from "../utils/utils";
|
import { HTTP_JSON_OPTIONS, HTTP_GET_OPTIONS, CURRENT_BASE_HREF } from "../utils/utils";
|
||||||
import { Configuration } from "../components/config/config";
|
import { Configuration } from "../components/config/config";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,7 +52,7 @@ export class ConfigurationDefaultService extends ConfigurationService {
|
|||||||
this._baseUrl =
|
this._baseUrl =
|
||||||
this.config && this.config.configurationEndpoint
|
this.config && this.config.configurationEndpoint
|
||||||
? this.config.configurationEndpoint
|
? this.config.configurationEndpoint
|
||||||
: "/api/configurations";
|
: CURRENT_BASE_HREF + "/configurations";
|
||||||
}
|
}
|
||||||
|
|
||||||
getConfigurations():
|
getConfigurations():
|
||||||
|
@ -2,13 +2,14 @@ import { TestBed, inject } from '@angular/core/testing';
|
|||||||
import { SharedModule } from '../utils/shared/shared.module';
|
import { SharedModule } from '../utils/shared/shared.module';
|
||||||
import { IServiceConfig, SERVICE_CONFIG } from '../entities/service.config';
|
import { IServiceConfig, SERVICE_CONFIG } from '../entities/service.config';
|
||||||
import { EndpointService, EndpointDefaultService } from './endpoint.service';
|
import { EndpointService, EndpointDefaultService } from './endpoint.service';
|
||||||
|
import { CURRENT_BASE_HREF } from "../utils/utils";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
describe('EndpointService', () => {
|
describe('EndpointService', () => {
|
||||||
|
|
||||||
let mockEndpoint: IServiceConfig = {
|
let mockEndpoint: IServiceConfig = {
|
||||||
targetBaseEndpoint: '/api/endpoint/testing'
|
targetBaseEndpoint: CURRENT_BASE_HREF + '/endpoint/testing'
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -6,7 +6,7 @@ import { IServiceConfig, SERVICE_CONFIG } from "../entities/service.config";
|
|||||||
import {
|
import {
|
||||||
buildHttpRequestOptions,
|
buildHttpRequestOptions,
|
||||||
HTTP_JSON_OPTIONS,
|
HTTP_JSON_OPTIONS,
|
||||||
HTTP_GET_OPTIONS
|
HTTP_GET_OPTIONS, CURRENT_BASE_HREF
|
||||||
} from "../utils/utils";
|
} from "../utils/utils";
|
||||||
import { RequestQueryParams } from "./RequestQueryParams";
|
import { RequestQueryParams } from "./RequestQueryParams";
|
||||||
import { Endpoint, ReplicationRule, PingEndpoint } from "./interface";
|
import { Endpoint, ReplicationRule, PingEndpoint } from "./interface";
|
||||||
@ -145,7 +145,7 @@ export class EndpointDefaultService extends EndpointService {
|
|||||||
super();
|
super();
|
||||||
this._endpointUrl = config.targetBaseEndpoint
|
this._endpointUrl = config.targetBaseEndpoint
|
||||||
? config.targetBaseEndpoint
|
? config.targetBaseEndpoint
|
||||||
: "/api/registries";
|
: CURRENT_BASE_HREF + "/registries";
|
||||||
}
|
}
|
||||||
|
|
||||||
public getEndpoints(
|
public getEndpoints(
|
||||||
@ -180,7 +180,7 @@ export class EndpointDefaultService extends EndpointService {
|
|||||||
|
|
||||||
public getAdapters(): Observable<any> {
|
public getAdapters(): Observable<any> {
|
||||||
return this.http
|
return this.http
|
||||||
.get(`/api/replication/adapters`)
|
.get(`${ CURRENT_BASE_HREF }/replication/adapters`)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,11 +3,12 @@ import { TestBed, inject } from '@angular/core/testing';
|
|||||||
import { JobLogService, JobLogDefaultService } from './job-log.service';
|
import { JobLogService, JobLogDefaultService } from './job-log.service';
|
||||||
import { SharedModule } from '../utils/shared/shared.module';
|
import { SharedModule } from '../utils/shared/shared.module';
|
||||||
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
||||||
|
import { CURRENT_BASE_HREF } from "../utils/utils";
|
||||||
|
|
||||||
describe('JobLogService', () => {
|
describe('JobLogService', () => {
|
||||||
const mockConfig: IServiceConfig = {
|
const mockConfig: IServiceConfig = {
|
||||||
replicationBaseEndpoint: "/api/replication/testing",
|
replicationBaseEndpoint: CURRENT_BASE_HREF + "/replication/testing",
|
||||||
scanJobEndpoint: "/api/jobs/scan/testing"
|
scanJobEndpoint: CURRENT_BASE_HREF + "/jobs/scan/testing"
|
||||||
};
|
};
|
||||||
|
|
||||||
let config: IServiceConfig;
|
let config: IServiceConfig;
|
||||||
@ -33,7 +34,7 @@ describe('JobLogService', () => {
|
|||||||
|
|
||||||
it('should be initialized', inject([JobLogDefaultService], (service: JobLogService) => {
|
it('should be initialized', inject([JobLogDefaultService], (service: JobLogService) => {
|
||||||
expect(service).toBeTruthy();
|
expect(service).toBeTruthy();
|
||||||
expect(config.replicationBaseEndpoint).toEqual("/api/replication/testing");
|
expect(config.replicationBaseEndpoint).toEqual(CURRENT_BASE_HREF + "/replication/testing");
|
||||||
expect(config.scanJobEndpoint).toEqual("/api/jobs/scan/testing");
|
expect(config.scanJobEndpoint).toEqual(CURRENT_BASE_HREF + "/jobs/scan/testing");
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Injectable, Inject } from "@angular/core";
|
import { Injectable, Inject } from "@angular/core";
|
||||||
import { HttpClient } from "@angular/common/http";
|
import { HttpClient } from "@angular/common/http";
|
||||||
import { SERVICE_CONFIG, IServiceConfig } from "../entities/service.config";
|
import { SERVICE_CONFIG, IServiceConfig } from "../entities/service.config";
|
||||||
import { HTTP_GET_OPTIONS, HTTP_GET_OPTIONS_TEXT } from "../utils/utils";
|
import { CURRENT_BASE_HREF, HTTP_GET_OPTIONS, HTTP_GET_OPTIONS_TEXT } from "../utils/utils";
|
||||||
import { map, catchError } from "rxjs/operators";
|
import { map, catchError } from "rxjs/operators";
|
||||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||||
/**
|
/**
|
||||||
@ -49,10 +49,10 @@ export class JobLogDefaultService extends JobLogService {
|
|||||||
super();
|
super();
|
||||||
this._replicationJobBaseUrl = config.replicationBaseEndpoint
|
this._replicationJobBaseUrl = config.replicationBaseEndpoint
|
||||||
? config.replicationBaseEndpoint
|
? config.replicationBaseEndpoint
|
||||||
: "/api/replication";
|
: CURRENT_BASE_HREF + "/replication";
|
||||||
this._scanningJobBaseUrl = config.scanJobEndpoint
|
this._scanningJobBaseUrl = config.scanJobEndpoint
|
||||||
? config.scanJobEndpoint
|
? config.scanJobEndpoint
|
||||||
: "/api/jobs/scan";
|
: CURRENT_BASE_HREF + "/jobs/scan";
|
||||||
this._supportedJobTypes = ["replication", "scan"];
|
this._supportedJobTypes = ["replication", "scan"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import { RequestQueryParams } from "./RequestQueryParams";
|
|||||||
import { Label } from "./interface";
|
import { Label } from "./interface";
|
||||||
|
|
||||||
import { IServiceConfig, SERVICE_CONFIG } from "../entities/service.config";
|
import { IServiceConfig, SERVICE_CONFIG } from "../entities/service.config";
|
||||||
import { buildHttpRequestOptions, HTTP_JSON_OPTIONS } from "../utils/utils";
|
import { buildHttpRequestOptions, CURRENT_BASE_HREF, HTTP_JSON_OPTIONS } from "../utils/utils";
|
||||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||||
|
|
||||||
export abstract class LabelService {
|
export abstract class LabelService {
|
||||||
@ -78,8 +78,8 @@ export class LabelDefaultService extends LabelService {
|
|||||||
private http: HttpClient
|
private http: HttpClient
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this.labelUrl = config.labelEndpoint ? config.labelEndpoint : "/api/labels";
|
this.labelUrl = config.labelEndpoint ? config.labelEndpoint : CURRENT_BASE_HREF + "/labels";
|
||||||
this.chartUrl = config.helmChartEndpoint ? config.helmChartEndpoint : "/api/chartrepo";
|
this.chartUrl = config.helmChartEndpoint ? config.helmChartEndpoint : CURRENT_BASE_HREF + "/chartrepo";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import { Observable, forkJoin, of, throwError as observableThrowError } from "rx
|
|||||||
import { map, tap, publishReplay, refCount } from "rxjs/operators";
|
import { map, tap, publishReplay, refCount } from "rxjs/operators";
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { CacheObservable } from "../utils/cache-util";
|
import { CacheObservable } from "../utils/cache-util";
|
||||||
|
import { CURRENT_BASE_HREF } from "../utils/utils";
|
||||||
|
|
||||||
|
|
||||||
interface Permission {
|
interface Permission {
|
||||||
@ -53,7 +54,7 @@ export class UserPermissionDefaultService extends UserPermissionService {
|
|||||||
|
|
||||||
@CacheObservable({ maxAge: 1000 * 60 })
|
@CacheObservable({ maxAge: 1000 * 60 })
|
||||||
private getPermissions(scope: string, relative?: boolean): Observable<Array<Permission>> {
|
private getPermissions(scope: string, relative?: boolean): Observable<Array<Permission>> {
|
||||||
const url = `/api/users/current/permissions?scope=${scope}&relative=${relative ? 'true' : 'false'}`;
|
const url = `${ CURRENT_BASE_HREF }/users/current/permissions?scope=${scope}&relative=${relative ? 'true' : 'false'}`;
|
||||||
return this.http.get<Array<Permission>>(url);
|
return this.http.get<Array<Permission>>(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import { ProjectPolicy } from "../components/project-policy-config/project-polic
|
|||||||
import {
|
import {
|
||||||
HTTP_JSON_OPTIONS,
|
HTTP_JSON_OPTIONS,
|
||||||
HTTP_GET_OPTIONS,
|
HTTP_GET_OPTIONS,
|
||||||
buildHttpRequestOptionsWithObserveResponse
|
buildHttpRequestOptionsWithObserveResponse, CURRENT_BASE_HREF
|
||||||
} from "../utils/utils";
|
} from "../utils/utils";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,7 +100,7 @@ export class ProjectDefaultService extends ProjectService {
|
|||||||
}
|
}
|
||||||
let baseUrl: string = this.config.projectBaseEndpoint
|
let baseUrl: string = this.config.projectBaseEndpoint
|
||||||
? this.config.projectBaseEndpoint
|
? this.config.projectBaseEndpoint
|
||||||
: "/api/projects";
|
: CURRENT_BASE_HREF + "/projects";
|
||||||
return this.http
|
return this.http
|
||||||
.get<Project>(`${baseUrl}/${projectId}`, HTTP_GET_OPTIONS)
|
.get<Project>(`${baseUrl}/${projectId}`, HTTP_GET_OPTIONS)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
@ -114,7 +114,7 @@ export class ProjectDefaultService extends ProjectService {
|
|||||||
): any {
|
): any {
|
||||||
let baseUrl: string = this.config.projectBaseEndpoint
|
let baseUrl: string = this.config.projectBaseEndpoint
|
||||||
? this.config.projectBaseEndpoint
|
? this.config.projectBaseEndpoint
|
||||||
: "/api/projects";
|
: CURRENT_BASE_HREF + "/projects";
|
||||||
return this.http
|
return this.http
|
||||||
.put<any>(
|
.put<any>(
|
||||||
`${baseUrl}/${projectId}`,
|
`${baseUrl}/${projectId}`,
|
||||||
@ -145,13 +145,13 @@ export class ProjectDefaultService extends ProjectService {
|
|||||||
params = params.set('public', '' + isPublic);
|
params = params.set('public', '' + isPublic);
|
||||||
}
|
}
|
||||||
return this.http
|
return this.http
|
||||||
.get<HttpResponse<Project[]>>(`/api/projects`, buildHttpRequestOptionsWithObserveResponse(params)).pipe(
|
.get<HttpResponse<Project[]>>(`${ CURRENT_BASE_HREF }/projects`, buildHttpRequestOptionsWithObserveResponse(params)).pipe(
|
||||||
catchError(error => observableThrowError(error)), );
|
catchError(error => observableThrowError(error)), );
|
||||||
}
|
}
|
||||||
|
|
||||||
public createProject(name: string, metadata: any, countLimit: number, storageLimit: number): Observable<any> {
|
public createProject(name: string, metadata: any, countLimit: number, storageLimit: number): Observable<any> {
|
||||||
return this.http
|
return this.http
|
||||||
.post(`/api/projects`,
|
.post(`${ CURRENT_BASE_HREF }/projects`,
|
||||||
JSON.stringify({'project_name': name, 'metadata': {
|
JSON.stringify({'project_name': name, 'metadata': {
|
||||||
public: metadata.public ? 'true' : 'false',
|
public: metadata.public ? 'true' : 'false',
|
||||||
},
|
},
|
||||||
@ -163,13 +163,13 @@ export class ProjectDefaultService extends ProjectService {
|
|||||||
|
|
||||||
public deleteProject(projectId: number): Observable<any> {
|
public deleteProject(projectId: number): Observable<any> {
|
||||||
return this.http
|
return this.http
|
||||||
.delete(`/api/projects/${projectId}`)
|
.delete(`${ CURRENT_BASE_HREF }/projects/${projectId}`)
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public checkProjectExists(projectName: string): Observable<any> {
|
public checkProjectExists(projectName: string): Observable<any> {
|
||||||
return this.http
|
return this.http
|
||||||
.head(`/api/projects/?project_name=${projectName}`).pipe(
|
.head(`${ CURRENT_BASE_HREF }/projects/?project_name=${projectName}`).pipe(
|
||||||
catchError(error => {
|
catchError(error => {
|
||||||
if (error && error.status === 404) {
|
if (error && error.status === 404) {
|
||||||
return of(error);
|
return of(error);
|
||||||
@ -180,12 +180,12 @@ export class ProjectDefaultService extends ProjectService {
|
|||||||
|
|
||||||
public checkProjectMember(projectId: number): Observable<any> {
|
public checkProjectMember(projectId: number): Observable<any> {
|
||||||
return this.http
|
return this.http
|
||||||
.get(`/api/projects/${projectId}/members`, HTTP_GET_OPTIONS).pipe(
|
.get(`${ CURRENT_BASE_HREF }/projects/${projectId}/members`, HTTP_GET_OPTIONS).pipe(
|
||||||
catchError(error => observableThrowError(error)), );
|
catchError(error => observableThrowError(error)), );
|
||||||
}
|
}
|
||||||
public getProjectSummary(projectId: number): Observable<any> {
|
public getProjectSummary(projectId: number): Observable<any> {
|
||||||
return this.http
|
return this.http
|
||||||
.get(`/api/projects/${projectId}/summary`, HTTP_GET_OPTIONS).pipe(
|
.get(`${ CURRENT_BASE_HREF }/projects/${projectId}/summary`, HTTP_GET_OPTIONS).pipe(
|
||||||
catchError(error => observableThrowError(error)), );
|
catchError(error => observableThrowError(error)), );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,12 @@ import { TestBed, inject } from '@angular/core/testing';
|
|||||||
import { ReplicationService, ReplicationDefaultService } from './replication.service';
|
import { ReplicationService, ReplicationDefaultService } from './replication.service';
|
||||||
import { SharedModule } from '../utils/shared/shared.module';
|
import { SharedModule } from '../utils/shared/shared.module';
|
||||||
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
||||||
|
import { CURRENT_BASE_HREF } from "../utils/utils";
|
||||||
|
|
||||||
describe('ReplicationService', () => {
|
describe('ReplicationService', () => {
|
||||||
const mockConfig: IServiceConfig = {
|
const mockConfig: IServiceConfig = {
|
||||||
replicationRuleEndpoint: "/api/policies/replication/testing",
|
replicationRuleEndpoint: CURRENT_BASE_HREF + "/policies/replication/testing",
|
||||||
replicationBaseEndpoint: "/api/replication/testing"
|
replicationBaseEndpoint: CURRENT_BASE_HREF + "/replication/testing"
|
||||||
};
|
};
|
||||||
|
|
||||||
let config: IServiceConfig;
|
let config: IServiceConfig;
|
||||||
@ -37,7 +38,7 @@ describe('ReplicationService', () => {
|
|||||||
|
|
||||||
it('should inject the right config', () => {
|
it('should inject the right config', () => {
|
||||||
expect(config).toBeTruthy();
|
expect(config).toBeTruthy();
|
||||||
expect(config.replicationRuleEndpoint).toEqual("/api/policies/replication/testing");
|
expect(config.replicationRuleEndpoint).toEqual(CURRENT_BASE_HREF + "/policies/replication/testing");
|
||||||
expect(config.replicationBaseEndpoint).toEqual("/api/replication/testing");
|
expect(config.replicationBaseEndpoint).toEqual(CURRENT_BASE_HREF + "/replication/testing");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -6,7 +6,7 @@ import {
|
|||||||
HTTP_JSON_OPTIONS,
|
HTTP_JSON_OPTIONS,
|
||||||
HTTP_GET_OPTIONS,
|
HTTP_GET_OPTIONS,
|
||||||
buildHttpRequestOptionsWithObserveResponse,
|
buildHttpRequestOptionsWithObserveResponse,
|
||||||
HTTP_GET_OPTIONS_OBSERVE_RESPONSE
|
HTTP_GET_OPTIONS_OBSERVE_RESPONSE, CURRENT_BASE_HREF
|
||||||
} from "../utils/utils";
|
} from "../utils/utils";
|
||||||
import {
|
import {
|
||||||
ReplicationJob,
|
ReplicationJob,
|
||||||
@ -219,11 +219,11 @@ export class ReplicationDefaultService extends ReplicationService {
|
|||||||
super();
|
super();
|
||||||
this._ruleBaseUrl = config.replicationRuleEndpoint
|
this._ruleBaseUrl = config.replicationRuleEndpoint
|
||||||
? config.replicationRuleEndpoint
|
? config.replicationRuleEndpoint
|
||||||
: "/api/replication/policies";
|
: CURRENT_BASE_HREF + "/replication/policies";
|
||||||
this._replicateUrl = config.replicationBaseEndpoint
|
this._replicateUrl = config.replicationBaseEndpoint
|
||||||
? config.replicationBaseEndpoint
|
? config.replicationBaseEndpoint
|
||||||
: "/api/replication";
|
: CURRENT_BASE_HREF + "/replication";
|
||||||
this._baseUrl = config.baseEndpoint ? config.baseEndpoint : "/api";
|
this._baseUrl = config.baseEndpoint ? config.baseEndpoint : CURRENT_BASE_HREF + "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Private methods
|
// Private methods
|
||||||
|
@ -2,7 +2,7 @@ import { Label } from "./interface";
|
|||||||
import { Inject, Injectable } from "@angular/core";
|
import { Inject, Injectable } from "@angular/core";
|
||||||
import { HttpClient } from "@angular/common/http";
|
import { HttpClient } from "@angular/common/http";
|
||||||
import { IServiceConfig, SERVICE_CONFIG } from "../entities/service.config";
|
import { IServiceConfig, SERVICE_CONFIG } from "../entities/service.config";
|
||||||
import { buildHttpRequestOptions, HTTP_JSON_OPTIONS } from "../utils/utils";
|
import { buildHttpRequestOptions, CURRENT_BASE_HREF, HTTP_JSON_OPTIONS } from "../utils/utils";
|
||||||
import { RequestQueryParams } from "./RequestQueryParams";
|
import { RequestQueryParams } from "./RequestQueryParams";
|
||||||
import { map, catchError } from "rxjs/operators";
|
import { map, catchError } from "rxjs/operators";
|
||||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||||
@ -40,7 +40,7 @@ export class LabelDefaultService extends LabelService {
|
|||||||
super();
|
super();
|
||||||
this._labelUrl = config.labelEndpoint
|
this._labelUrl = config.labelEndpoint
|
||||||
? config.labelEndpoint
|
? config.labelEndpoint
|
||||||
: "/api/labels";
|
: CURRENT_BASE_HREF + "/labels";
|
||||||
}
|
}
|
||||||
|
|
||||||
getLabels(
|
getLabels(
|
||||||
|
@ -2,7 +2,7 @@ import { Observable } from "rxjs";
|
|||||||
import { HttpClient } from "@angular/common/http";
|
import { HttpClient } from "@angular/common/http";
|
||||||
import { Injectable, Inject } from "@angular/core";
|
import { Injectable, Inject } from "@angular/core";
|
||||||
import { RetagRequest } from "./interface";
|
import { RetagRequest } from "./interface";
|
||||||
import { HTTP_JSON_OPTIONS } from "../utils/utils";
|
import { CURRENT_BASE_HREF, HTTP_JSON_OPTIONS } from "../utils/utils";
|
||||||
import { catchError } from "rxjs/operators";
|
import { catchError } from "rxjs/operators";
|
||||||
import { throwError as observableThrowError } from "rxjs/index";
|
import { throwError as observableThrowError } from "rxjs/index";
|
||||||
import { IServiceConfig, SERVICE_CONFIG } from "../entities/service.config";
|
import { IServiceConfig, SERVICE_CONFIG } from "../entities/service.config";
|
||||||
@ -44,7 +44,7 @@ export class RetagDefaultService extends RetagService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
retag(request: RetagRequest): Observable<any> {
|
retag(request: RetagRequest): Observable<any> {
|
||||||
let baseUrl: string = this.config.repositoryBaseEndpoint ? this.config.repositoryBaseEndpoint : '/api/repositories';
|
let baseUrl: string = this.config.repositoryBaseEndpoint ? this.config.repositoryBaseEndpoint : CURRENT_BASE_HREF + '/repositories';
|
||||||
return this.http
|
return this.http
|
||||||
.post(`${baseUrl}/${request.targetProject}/${request.targetRepo}/tags`,
|
.post(`${baseUrl}/${request.targetProject}/${request.targetRepo}/tags`,
|
||||||
{
|
{
|
||||||
|
@ -3,10 +3,11 @@ import { TestBed, inject } from '@angular/core/testing';
|
|||||||
import { ScanningResultService, ScanningResultDefaultService } from './scanning.service';
|
import { ScanningResultService, ScanningResultDefaultService } from './scanning.service';
|
||||||
import { SharedModule } from '../utils/shared/shared.module';
|
import { SharedModule } from '../utils/shared/shared.module';
|
||||||
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
||||||
|
import { CURRENT_BASE_HREF } from "../utils/utils";
|
||||||
|
|
||||||
describe('ScanningResultService', () => {
|
describe('ScanningResultService', () => {
|
||||||
const mockConfig: IServiceConfig = {
|
const mockConfig: IServiceConfig = {
|
||||||
vulnerabilityScanningBaseEndpoint: "/api/vulnerability/testing"
|
vulnerabilityScanningBaseEndpoint: CURRENT_BASE_HREF + "/vulnerability/testing"
|
||||||
};
|
};
|
||||||
|
|
||||||
let config: IServiceConfig;
|
let config: IServiceConfig;
|
||||||
@ -36,6 +37,6 @@ describe('ScanningResultService', () => {
|
|||||||
|
|
||||||
it('should inject the right config', () => {
|
it('should inject the right config', () => {
|
||||||
expect(config).toBeTruthy();
|
expect(config).toBeTruthy();
|
||||||
expect(config.vulnerabilityScanningBaseEndpoint).toEqual("/api/vulnerability/testing");
|
expect(config.vulnerabilityScanningBaseEndpoint).toEqual(CURRENT_BASE_HREF + "/vulnerability/testing");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -2,7 +2,12 @@ import { HttpClient, HttpHeaders } from "@angular/common/http";
|
|||||||
import { Injectable, Inject } from "@angular/core";
|
import { Injectable, Inject } from "@angular/core";
|
||||||
|
|
||||||
import { SERVICE_CONFIG, IServiceConfig } from "../entities/service.config";
|
import { SERVICE_CONFIG, IServiceConfig } from "../entities/service.config";
|
||||||
import { buildHttpRequestOptions, DEFAULT_SUPPORTED_MIME_TYPE, HTTP_JSON_OPTIONS } from "../utils/utils";
|
import {
|
||||||
|
buildHttpRequestOptions,
|
||||||
|
CURRENT_BASE_HREF,
|
||||||
|
DEFAULT_SUPPORTED_MIME_TYPE,
|
||||||
|
HTTP_JSON_OPTIONS
|
||||||
|
} from "../utils/utils";
|
||||||
import { RequestQueryParams } from "./RequestQueryParams";
|
import { RequestQueryParams } from "./RequestQueryParams";
|
||||||
import { VulnerabilityDetail, VulnerabilitySummary } from "./interface";
|
import { VulnerabilityDetail, VulnerabilitySummary } from "./interface";
|
||||||
import { map, catchError } from "rxjs/operators";
|
import { map, catchError } from "rxjs/operators";
|
||||||
@ -91,7 +96,7 @@ export abstract class ScanningResultService {
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ScanningResultDefaultService extends ScanningResultService {
|
export class ScanningResultDefaultService extends ScanningResultService {
|
||||||
_baseUrl: string = "/api/v2.0/projects";
|
_baseUrl: string = CURRENT_BASE_HREF + "/projects";
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private http: HttpClient,
|
private http: HttpClient,
|
||||||
@ -151,7 +156,7 @@ export class ScanningResultDefaultService extends ScanningResultService {
|
|||||||
|
|
||||||
return this.http
|
return this.http
|
||||||
.post(
|
.post(
|
||||||
`/api/v2.0/projects//${projectName}/repositories/${repoName}/artifacts/${artifactId}/scan`,
|
`${ CURRENT_BASE_HREF }/projects//${projectName}/repositories/${repoName}/artifacts/${artifactId}/scan`,
|
||||||
HTTP_JSON_OPTIONS
|
HTTP_JSON_OPTIONS
|
||||||
)
|
)
|
||||||
.pipe(map(() => {
|
.pipe(map(() => {
|
||||||
@ -169,12 +174,12 @@ export class ScanningResultDefaultService extends ScanningResultService {
|
|||||||
, catchError(error => observableThrowError(error)));
|
, catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
getScannerMetadata(uuid: string): Observable<any> {
|
getScannerMetadata(uuid: string): Observable<any> {
|
||||||
return this.http.get(`/api/scanners/${uuid}/metadata`)
|
return this.http.get(`${ CURRENT_BASE_HREF }/scanners/${uuid}/metadata`)
|
||||||
.pipe(map(response => response as any))
|
.pipe(map(response => response as any))
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
getProjectScanner(projectId: number): Observable<any> {
|
getProjectScanner(projectId: number): Observable<any> {
|
||||||
return this.http.get(`/api/projects/${projectId}/scanner`)
|
return this.http.get(`${ CURRENT_BASE_HREF }/projects/${projectId}/scanner`)
|
||||||
.pipe(map(response => response as any))
|
.pipe(map(response => response as any))
|
||||||
.pipe(catchError(error => observableThrowError(error)));
|
.pipe(catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,11 @@ import { TestBed, inject } from '@angular/core/testing';
|
|||||||
import { SystemInfoService, SystemInfoDefaultService } from './system-info.service';
|
import { SystemInfoService, SystemInfoDefaultService } from './system-info.service';
|
||||||
import { SharedModule } from '../utils/shared/shared.module';
|
import { SharedModule } from '../utils/shared/shared.module';
|
||||||
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
||||||
|
import { CURRENT_BASE_HREF } from "../utils/utils";
|
||||||
|
|
||||||
describe('SystemInfoService', () => {
|
describe('SystemInfoService', () => {
|
||||||
const mockConfig: IServiceConfig = {
|
const mockConfig: IServiceConfig = {
|
||||||
systemInfoEndpoint: "/api/systeminfo/testing"
|
systemInfoEndpoint: CURRENT_BASE_HREF + "/systeminfo/testing"
|
||||||
};
|
};
|
||||||
|
|
||||||
let config: IServiceConfig;
|
let config: IServiceConfig;
|
||||||
@ -36,6 +37,6 @@ describe('SystemInfoService', () => {
|
|||||||
|
|
||||||
it('should inject the right config', () => {
|
it('should inject the right config', () => {
|
||||||
expect(config).toBeTruthy();
|
expect(config).toBeTruthy();
|
||||||
expect(config.systemInfoEndpoint).toEqual("/api/systeminfo/testing");
|
expect(config.systemInfoEndpoint).toEqual(CURRENT_BASE_HREF + "/systeminfo/testing");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -4,7 +4,7 @@ import { map, catchError } from "rxjs/operators";
|
|||||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||||
import {SystemCVEWhitelist, SystemInfo} from './interface';
|
import {SystemCVEWhitelist, SystemInfo} from './interface';
|
||||||
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
||||||
import {HTTP_GET_OPTIONS, HTTP_JSON_OPTIONS} from "../utils/utils";
|
import { CURRENT_BASE_HREF, HTTP_GET_OPTIONS, HTTP_JSON_OPTIONS } from "../utils/utils";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get System information about current backend server.
|
* Get System information about current backend server.
|
||||||
@ -42,18 +42,18 @@ export class SystemInfoDefaultService extends SystemInfoService {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
getSystemInfo(): Observable<SystemInfo> {
|
getSystemInfo(): Observable<SystemInfo> {
|
||||||
let url = this.config.systemInfoEndpoint ? this.config.systemInfoEndpoint : '/api/systeminfo';
|
let url = this.config.systemInfoEndpoint ? this.config.systemInfoEndpoint : CURRENT_BASE_HREF + '/systeminfo';
|
||||||
return this.http.get(url, HTTP_GET_OPTIONS)
|
return this.http.get(url, HTTP_GET_OPTIONS)
|
||||||
.pipe(map(systemInfo => systemInfo as SystemInfo)
|
.pipe(map(systemInfo => systemInfo as SystemInfo)
|
||||||
, catchError(error => observableThrowError(error)));
|
, catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
public getSystemWhitelist(): Observable<SystemCVEWhitelist> {
|
public getSystemWhitelist(): Observable<SystemCVEWhitelist> {
|
||||||
return this.http.get("/api/system/CVEWhitelist", HTTP_GET_OPTIONS)
|
return this.http.get(CURRENT_BASE_HREF + "/system/CVEWhitelist", HTTP_GET_OPTIONS)
|
||||||
.pipe(map(systemCVEWhitelist => systemCVEWhitelist as SystemCVEWhitelist)
|
.pipe(map(systemCVEWhitelist => systemCVEWhitelist as SystemCVEWhitelist)
|
||||||
, catchError(error => observableThrowError(error)));
|
, catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
public updateSystemWhitelist(systemCVEWhitelist: SystemCVEWhitelist): Observable<any> {
|
public updateSystemWhitelist(systemCVEWhitelist: SystemCVEWhitelist): Observable<any> {
|
||||||
return this.http.put("/api/system/CVEWhitelist", JSON.stringify(systemCVEWhitelist), HTTP_JSON_OPTIONS)
|
return this.http.put(CURRENT_BASE_HREF + "/system/CVEWhitelist", JSON.stringify(systemCVEWhitelist), HTTP_JSON_OPTIONS)
|
||||||
.pipe(map(response => response)
|
.pipe(map(response => response)
|
||||||
, catchError(error => observableThrowError(error)));
|
, catchError(error => observableThrowError(error)));
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ import { TestBed, inject } from '@angular/core/testing';
|
|||||||
import { SharedModule } from '../utils/shared/shared.module';
|
import { SharedModule } from '../utils/shared/shared.module';
|
||||||
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
||||||
import { TagService, TagDefaultService } from './tag.service';
|
import { TagService, TagDefaultService } from './tag.service';
|
||||||
|
import { CURRENT_BASE_HREF } from "../utils/utils";
|
||||||
|
|
||||||
|
|
||||||
describe('TagService', () => {
|
describe('TagService', () => {
|
||||||
@ -22,7 +23,7 @@ describe('TagService', () => {
|
|||||||
// ];
|
// ];
|
||||||
|
|
||||||
const mockConfig: IServiceConfig = {
|
const mockConfig: IServiceConfig = {
|
||||||
repositoryBaseEndpoint: "/api/repositories/testing"
|
repositoryBaseEndpoint: CURRENT_BASE_HREF + "/repositories/testing"
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -5,7 +5,7 @@ import { SERVICE_CONFIG, IServiceConfig } from "../entities/service.config";
|
|||||||
import {
|
import {
|
||||||
buildHttpRequestOptions,
|
buildHttpRequestOptions,
|
||||||
HTTP_JSON_OPTIONS,
|
HTTP_JSON_OPTIONS,
|
||||||
HTTP_GET_OPTIONS
|
HTTP_GET_OPTIONS, CURRENT_BASE_HREF
|
||||||
} from "../utils/utils";
|
} from "../utils/utils";
|
||||||
import { RequestQueryParams } from "./RequestQueryParams";
|
import { RequestQueryParams } from "./RequestQueryParams";
|
||||||
import { Tag, Manifest } from "./interface";
|
import { Tag, Manifest } from "./interface";
|
||||||
@ -89,10 +89,10 @@ export class TagDefaultService extends TagService {
|
|||||||
super();
|
super();
|
||||||
this._baseUrl = this.config.repositoryBaseEndpoint
|
this._baseUrl = this.config.repositoryBaseEndpoint
|
||||||
? this.config.repositoryBaseEndpoint
|
? this.config.repositoryBaseEndpoint
|
||||||
: "/api/repositories";
|
: CURRENT_BASE_HREF + "/repositories";
|
||||||
this._labelUrl = this.config.labelEndpoint
|
this._labelUrl = this.config.labelEndpoint
|
||||||
? this.config.labelEndpoint
|
? this.config.labelEndpoint
|
||||||
: "/api/labels";
|
: CURRENT_BASE_HREF + "/labels";
|
||||||
}
|
}
|
||||||
|
|
||||||
public newTag(
|
public newTag(
|
||||||
@ -104,7 +104,7 @@ export class TagDefaultService extends TagService {
|
|||||||
if (!projectName || !repositoryName || !digest || !tagName) {
|
if (!projectName || !repositoryName || !digest || !tagName) {
|
||||||
return observableThrowError("Bad argument");
|
return observableThrowError("Bad argument");
|
||||||
}
|
}
|
||||||
let url: string = `/api/v2.0/projects/${projectName}/repositories/${repositoryName}/artifacts/${digest}/tags`;
|
let url: string = `${ CURRENT_BASE_HREF }/projects/${projectName}/repositories/${repositoryName}/artifacts/${digest}/tags`;
|
||||||
return this.http
|
return this.http
|
||||||
.post(url, tagName, HTTP_JSON_OPTIONS)
|
.post(url, tagName, HTTP_JSON_OPTIONS)
|
||||||
.pipe(map(response => response)
|
.pipe(map(response => response)
|
||||||
@ -121,7 +121,7 @@ export class TagDefaultService extends TagService {
|
|||||||
return observableThrowError("Bad argument");
|
return observableThrowError("Bad argument");
|
||||||
}
|
}
|
||||||
|
|
||||||
let url: string = `/api/v2.0/projects/${projectName}/repositories/${repositoryName}/artifacts/${digest}/tags/${tagName}`;
|
let url: string = `${ CURRENT_BASE_HREF }/projects/${projectName}/repositories/${repositoryName}/artifacts/${digest}/tags/${tagName}`;
|
||||||
return this.http
|
return this.http
|
||||||
.delete(url, HTTP_JSON_OPTIONS)
|
.delete(url, HTTP_JSON_OPTIONS)
|
||||||
.pipe(map(response => response)
|
.pipe(map(response => response)
|
||||||
|
@ -6,6 +6,17 @@ import { DebugElement } from '@angular/core';
|
|||||||
import { Comparator, State, HttpOptionInterface, HttpOptionTextInterface, QuotaUnitInterface } from '../services/interface';
|
import { Comparator, State, HttpOptionInterface, HttpOptionTextInterface, QuotaUnitInterface } from '../services/interface';
|
||||||
import { QuotaUnits, StorageMultipleConstant, LimitCount } from '../entities/shared.const';
|
import { QuotaUnits, StorageMultipleConstant, LimitCount } from '../entities/shared.const';
|
||||||
import { AbstractControl } from "@angular/forms";
|
import { AbstractControl } from "@angular/forms";
|
||||||
|
/**
|
||||||
|
* Api levels
|
||||||
|
*/
|
||||||
|
enum APILevels {
|
||||||
|
V1 = '',
|
||||||
|
V2 = '/v2.0'
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Current base href
|
||||||
|
*/
|
||||||
|
export const CURRENT_BASE_HREF = '/api' + APILevels.V2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert the different async channels to the Promise<T> type.
|
* Convert the different async channels to the Promise<T> type.
|
||||||
|
Loading…
Reference in New Issue
Block a user