mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 12:15:20 +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 * as Controllers from '../controllers';
|
||||
import { CURRENT_BASE_HREF } from "../../src/lib/utils/utils";
|
||||
|
||||
|
||||
const mockApi: Express = express();
|
||||
@ -9,7 +10,7 @@ mockApi.get('/', (req, res) => {
|
||||
res.send('Hello World!');
|
||||
});
|
||||
|
||||
mockApi.get('/api/scanners', Controllers.getScanner);
|
||||
mockApi.get(CURRENT_BASE_HREF + '/scanners', Controllers.getScanner);
|
||||
|
||||
mockApi.listen(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 { catchError, map } from 'rxjs/operators';
|
||||
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) { }
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { TestBed, inject, getTestBed } from '@angular/core/testing';
|
||||
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
|
||||
import { PasswordSettingService } from './password-setting.service';
|
||||
import { CURRENT_BASE_HREF } from "../../../lib/utils/utils";
|
||||
|
||||
describe('PasswordSettingService', () => {
|
||||
let injector: TestBed;
|
||||
@ -32,7 +33,7 @@ describe('PasswordSettingService', () => {
|
||||
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');
|
||||
req.flush(null);
|
||||
});
|
||||
|
@ -16,9 +16,9 @@ import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
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 resetPasswordEndpoint = "/c/reset";
|
||||
|
||||
|
@ -4,6 +4,7 @@ import { CookieService } from 'ngx-cookie';
|
||||
import { AppConfigService } from './app-config.service';
|
||||
import { AppConfig } from './app-config';
|
||||
import { Component } from '@angular/core';
|
||||
import { CURRENT_BASE_HREF } from "../lib/utils/utils";
|
||||
|
||||
describe('AppConfigService', () => {
|
||||
let injector: TestBed;
|
||||
@ -35,7 +36,7 @@ describe('AppConfigService', () => {
|
||||
expect(res).toEqual(systeminfo);
|
||||
});
|
||||
|
||||
const req = httpMock.expectOne('/api/systeminfo');
|
||||
const req = httpMock.expectOne(CURRENT_BASE_HREF + '/systeminfo');
|
||||
expect(req.request.method).toBe('GET');
|
||||
req.flush(systeminfo);
|
||||
expect(service.getConfig()).toEqual(systeminfo);
|
||||
|
@ -19,9 +19,9 @@ import { CookieKeyOfAdmiral, HarborQueryParamKey } from './shared/shared.const';
|
||||
import { maintainUrlQueryParmas } from './shared/shared.utils';
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
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";
|
||||
export const systemInfoEndpoint = "/api/systeminfo";
|
||||
export const systemInfoEndpoint = CURRENT_BASE_HREF + "/systeminfo";
|
||||
/**
|
||||
* 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 { HarborLibraryModule } from "../lib/harbor-library.module";
|
||||
import { HTTP_INTERCEPTORS } from '@angular/common/http';
|
||||
import { BaseHrefInterceptService } from "./base-href-intercept.service";
|
||||
|
||||
registerLocaleData(zh, 'zh-cn');
|
||||
registerLocaleData(es, 'es-es');
|
||||
@ -99,7 +98,6 @@ export function getCurrentLanguage(translateService: TranslateService) {
|
||||
multi: true
|
||||
},
|
||||
{ provide: LOCALE_ID, useValue: "en-US" },
|
||||
{ provide: HTTP_INTERCEPTORS, useClass: BaseHrefInterceptService, 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 { Injector } from '@angular/core';
|
||||
import { SearchResults } from './search-results';
|
||||
import { CURRENT_BASE_HREF } from "../../../lib/utils/utils";
|
||||
|
||||
describe('GlobalSearchService', () => {
|
||||
let injector: TestBed;
|
||||
@ -31,7 +32,7 @@ describe('GlobalSearchService', () => {
|
||||
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');
|
||||
req.flush(new SearchResults());
|
||||
});
|
||||
|
@ -16,9 +16,9 @@ import { HttpClient } from '@angular/common/http';
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
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
|
||||
*
|
||||
|
@ -16,12 +16,12 @@ import { HttpClient } from '@angular/common/http';
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
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 emailEndpoint = "/api/email/ping";
|
||||
const ldapEndpoint = "/api/ldap/ping";
|
||||
const oidcEndpoint = "/api/system/oidc/ping";
|
||||
const configEndpoint = CURRENT_BASE_HREF + "/configurations";
|
||||
const emailEndpoint = CURRENT_BASE_HREF + "/email/ping";
|
||||
const ldapEndpoint = CURRENT_BASE_HREF + "/ldap/ping";
|
||||
const oidcEndpoint = CURRENT_BASE_HREF + "/system/oidc/ping";
|
||||
|
||||
@Injectable()
|
||||
export class ConfigurationService {
|
||||
|
@ -4,6 +4,7 @@ import { forkJoin, Observable, throwError as observableThrowError } from "rxjs";
|
||||
import { catchError, map } from "rxjs/operators";
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
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";
|
||||
|
||||
@ -13,35 +14,35 @@ export class ConfigScannerService {
|
||||
constructor( private http: HttpClient) {}
|
||||
getScannersByName(name: string): Observable<Scanner[]> {
|
||||
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(map(response => response as Scanner[]));
|
||||
}
|
||||
getScannersByEndpointUrl(endpointUrl: string): Observable<Scanner[]> {
|
||||
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(map(response => response as Scanner[]));
|
||||
}
|
||||
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)));
|
||||
}
|
||||
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)));
|
||||
}
|
||||
getScanners(): Observable<Scanner[]> {
|
||||
return this.http.get('/api/scanners')
|
||||
return this.http.get(CURRENT_BASE_HREF + '/scanners')
|
||||
.pipe(map(response => response as Scanner[]))
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
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)));
|
||||
}
|
||||
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)));
|
||||
}
|
||||
deleteScanners(scanners: Scanner[]): Observable<any> {
|
||||
@ -54,25 +55,25 @@ export class ConfigScannerService {
|
||||
}
|
||||
}
|
||||
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(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
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)));
|
||||
}
|
||||
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(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
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)));
|
||||
}
|
||||
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(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
@ -3,10 +3,10 @@ import {catchError, map} from 'rxjs/operators';
|
||||
import { Injectable } from "@angular/core";
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
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 ldapGroupSearchEndpoint = "/api/ldap/groups/search?groupname=";
|
||||
const userGroupEndpoint = CURRENT_BASE_HREF + "/usergroups";
|
||||
const ldapGroupSearchEndpoint = CURRENT_BASE_HREF + "/ldap/groups/search?groupname=";
|
||||
|
||||
@Injectable()
|
||||
export class GroupService {
|
||||
|
@ -18,10 +18,14 @@ import {map, catchError} from 'rxjs/operators';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http';
|
||||
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";
|
||||
|
||||
export const logEndpoint = '/api/logs';
|
||||
export const logEndpoint = CURRENT_BASE_HREF + '/logs';
|
||||
|
||||
@Injectable()
|
||||
export class AuditLogService {
|
||||
@ -46,7 +50,7 @@ export class AuditLogService {
|
||||
params = params.set('page_size', <string>queryParam.page_size);
|
||||
}
|
||||
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(
|
||||
catchError(error => observableThrowError(error)), );
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import { User } from '../../user/user';
|
||||
import { Member } from './member';
|
||||
import {throwError as observableThrowError, Observable } from "rxjs";
|
||||
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()
|
||||
export class MemberService {
|
||||
@ -26,7 +26,7 @@ export class MemberService {
|
||||
|
||||
listMembers(projectId: number, entity_name: string): Observable<Member[]> {
|
||||
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[]),
|
||||
catchError(error => observableThrowError(error)), );
|
||||
}
|
||||
@ -41,7 +41,7 @@ export class MemberService {
|
||||
return;
|
||||
}
|
||||
return this.http.post(
|
||||
`/api/projects/${projectId}/members`,
|
||||
`${ CURRENT_BASE_HREF }/projects/${projectId}/members`,
|
||||
{
|
||||
role_id: roleId,
|
||||
member_user: member_user
|
||||
@ -52,7 +52,7 @@ export class MemberService {
|
||||
|
||||
addGroupMember(projectId: number, group: any, roleId: number): Observable<any> {
|
||||
return this.http
|
||||
.post(`/api/projects/${projectId}/members`,
|
||||
.post(`${ CURRENT_BASE_HREF }/projects/${projectId}/members`,
|
||||
{ role_id: roleId, member_group: group},
|
||||
HTTP_JSON_OPTIONS).pipe(
|
||||
catchError(error => observableThrowError(error)), );
|
||||
@ -60,13 +60,13 @@ export class MemberService {
|
||||
|
||||
changeMemberRole(projectId: number, userId: number, roleId: number): Observable<any> {
|
||||
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)));
|
||||
}
|
||||
|
||||
deleteMember(projectId: number, memberId: number): Observable<any> {
|
||||
return this.http
|
||||
.delete(`/api/projects/${projectId}/members/${memberId}`)
|
||||
.delete(`${ CURRENT_BASE_HREF }/projects/${projectId}/members/${memberId}`)
|
||||
.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 { ArtifactDefaultService } from "../artifact/artifact.service";
|
||||
import { IServiceConfig, SERVICE_CONFIG } from "../../../../lib/entities/service.config";
|
||||
import { CURRENT_BASE_HREF } from "../../../../lib/utils/utils";
|
||||
|
||||
describe('ArtifactListPageComponent', () => {
|
||||
let component: ArtifactListPageComponent;
|
||||
@ -70,7 +71,7 @@ describe('ArtifactListPageComponent', () => {
|
||||
}
|
||||
};
|
||||
const config: IServiceConfig = {
|
||||
repositoryBaseEndpoint: "/api/repositories/testing"
|
||||
repositoryBaseEndpoint: CURRENT_BASE_HREF + "/repositories/testing"
|
||||
};
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
@ -3,17 +3,18 @@ import { ArtifactAdditionsComponent } from './artifact-additions.component';
|
||||
import { AdditionLinks } from "../../../../../../ng-swagger-gen/models/addition-links";
|
||||
import { IServiceConfig, SERVICE_CONFIG } from "../../../../../lib/entities/service.config";
|
||||
import { ProjectModule } from "../../../project.module";
|
||||
import { CURRENT_BASE_HREF } from "../../../../../lib/utils/utils";
|
||||
|
||||
|
||||
describe('ArtifactAdditionsComponent', () => {
|
||||
const mockedAdditionLinks: AdditionLinks = {
|
||||
vulnerabilities: {
|
||||
absolute: false,
|
||||
href: "api/v2/test"
|
||||
href: CURRENT_BASE_HREF + "/test"
|
||||
}
|
||||
};
|
||||
const config: IServiceConfig = {
|
||||
baseEndpoint: "/api/v2"
|
||||
baseEndpoint: CURRENT_BASE_HREF
|
||||
};
|
||||
let component: ArtifactAdditionsComponent;
|
||||
let fixture: ComponentFixture<ArtifactAdditionsComponent>;
|
||||
|
@ -7,6 +7,7 @@ import { ArtifactDependency } from "../models";
|
||||
import { AdditionLink } from "../../../../../../../ng-swagger-gen/models/addition-link";
|
||||
import { IServiceConfig, SERVICE_CONFIG } from "../../../../../../lib/entities/service.config";
|
||||
import { ErrorHandler } from "../../../../../../lib/utils/error-handler";
|
||||
import { CURRENT_BASE_HREF } from "../../../../../../lib/utils/utils";
|
||||
|
||||
|
||||
describe('DependenciesComponent', () => {
|
||||
@ -35,7 +36,7 @@ describe('DependenciesComponent', () => {
|
||||
href: '/test'
|
||||
};
|
||||
const config: IServiceConfig = {
|
||||
repositoryBaseEndpoint: "/api/repositories/testing"
|
||||
repositoryBaseEndpoint: CURRENT_BASE_HREF + "/repositories/testing"
|
||||
};
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
@ -7,6 +7,7 @@ import { AdditionLink } from "../../../../../../../ng-swagger-gen/models/additio
|
||||
import { IServiceConfig, SERVICE_CONFIG } from "../../../../../../lib/entities/service.config";
|
||||
import { ErrorHandler } from "../../../../../../lib/utils/error-handler";
|
||||
import { ProjectModule } from "../../../../project.module";
|
||||
import { CURRENT_BASE_HREF } from "../../../../../../lib/utils/utils";
|
||||
|
||||
describe('SummaryComponent', () => {
|
||||
let component: SummaryComponent;
|
||||
@ -160,7 +161,7 @@ describe('SummaryComponent', () => {
|
||||
}
|
||||
};
|
||||
const config: IServiceConfig = {
|
||||
repositoryBaseEndpoint: "/api/repositories/testing"
|
||||
repositoryBaseEndpoint: CURRENT_BASE_HREF + "/repositories/testing"
|
||||
};
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
@ -9,6 +9,7 @@ import { SharedModule } from "../../../../../lib/utils/shared/shared.module";
|
||||
import { ErrorHandler } from "../../../../../lib/utils/error-handler";
|
||||
import { TagService } from "../../../../../lib/services";
|
||||
import { OperationService } from "../../../../../lib/components/operation/operation.service";
|
||||
import { CURRENT_BASE_HREF } from "../../../../../lib/utils/utils";
|
||||
|
||||
|
||||
describe('ArtifactTagComponent', () => {
|
||||
@ -22,7 +23,7 @@ describe('ArtifactTagComponent', () => {
|
||||
deleteTag: () => of(null),
|
||||
};
|
||||
const config: IServiceConfig = {
|
||||
repositoryBaseEndpoint: "/api/repositories/testing"
|
||||
repositoryBaseEndpoint: CURRENT_BASE_HREF + "/repositories/testing"
|
||||
};
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
@ -2,11 +2,12 @@ import { TestBed, inject } from '@angular/core/testing';
|
||||
import { IServiceConfig, SERVICE_CONFIG } from "../../../../lib/entities/service.config";
|
||||
import { SharedModule } from "../../../../lib/utils/shared/shared.module";
|
||||
import { TagDefaultService, TagService } from "../../../../lib/services";
|
||||
import { CURRENT_BASE_HREF } from "../../../../lib/utils/utils";
|
||||
|
||||
describe('TagService', () => {
|
||||
|
||||
const mockConfig: IServiceConfig = {
|
||||
repositoryBaseEndpoint: "/api/repositories/testing"
|
||||
repositoryBaseEndpoint: CURRENT_BASE_HREF + "/repositories/testing"
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -5,7 +5,7 @@ import { Observable, throwError as observableThrowError, Subject } from "rxjs";
|
||||
import { Manifest, RequestQueryParams } from "../../../../lib/services";
|
||||
import { IServiceConfig, SERVICE_CONFIG } from "../../../../lib/entities/service.config";
|
||||
import {
|
||||
buildHttpRequestOptionsWithObserveResponse,
|
||||
buildHttpRequestOptionsWithObserveResponse, CURRENT_BASE_HREF,
|
||||
HTTP_GET_OPTIONS,
|
||||
HTTP_JSON_OPTIONS
|
||||
} from "../../../../lib/utils/utils";
|
||||
@ -122,10 +122,10 @@ export class ArtifactDefaultService extends ArtifactService {
|
||||
super();
|
||||
this._baseUrl = this.config.repositoryBaseEndpoint
|
||||
? this.config.repositoryBaseEndpoint
|
||||
: "/api/repositories";
|
||||
: CURRENT_BASE_HREF + "/repositories";
|
||||
this._labelUrl = 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");
|
||||
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
|
||||
return this.http
|
||||
.get<HttpResponse<Artifact[]>>(url, buildHttpRequestOptionsWithObserveResponse(queryParams))
|
||||
@ -164,7 +164,7 @@ export class ArtifactDefaultService extends ArtifactService {
|
||||
if (!artifactDigest) {
|
||||
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>;
|
||||
}
|
||||
public deleteArtifact(
|
||||
@ -176,7 +176,7 @@ export class ArtifactDefaultService extends ArtifactService {
|
||||
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
|
||||
.delete(url, HTTP_JSON_OPTIONS)
|
||||
.pipe(map(response => response)
|
||||
@ -195,7 +195,7 @@ export class ArtifactDefaultService extends ArtifactService {
|
||||
}
|
||||
|
||||
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
|
||||
.post(_addLabelToImageUrl, { id: labelId }, HTTP_JSON_OPTIONS)
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
@ -212,7 +212,7 @@ export class ArtifactDefaultService extends ArtifactService {
|
||||
}
|
||||
|
||||
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
|
||||
.delete(_addLabelToImageUrl)
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
|
@ -25,6 +25,7 @@ import { ProjectModule } from "../project.module";
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { Repository as NewRepository } from "../../../../ng-swagger-gen/models/repository";
|
||||
import { StrictHttpResponse as __StrictHttpResponse } from '../../../../ng-swagger-gen/strict-http-response';
|
||||
import { CURRENT_BASE_HREF } from "../../../lib/utils/utils";
|
||||
|
||||
describe('RepositoryComponentGridview (inline template)', () => {
|
||||
|
||||
@ -73,9 +74,9 @@ describe('RepositoryComponentGridview (inline template)', () => {
|
||||
let mockRepo: NewRepository[] = mockRepoData;
|
||||
let mockNginxRepo: NewRepository[] = mockRepoNginxData;
|
||||
let config: IServiceConfig = {
|
||||
repositoryBaseEndpoint: '/api/repository/testing',
|
||||
systemInfoEndpoint: '/api/systeminfo/testing',
|
||||
targetBaseEndpoint: '/api/tag/testing'
|
||||
repositoryBaseEndpoint: CURRENT_BASE_HREF + '/repository/testing',
|
||||
systemInfoEndpoint: CURRENT_BASE_HREF + '/systeminfo/testing',
|
||||
targetBaseEndpoint: CURRENT_BASE_HREF + '/tag/testing'
|
||||
};
|
||||
const fakedErrorHandler = {
|
||||
error() {
|
||||
|
@ -3,11 +3,12 @@ import { TestBed, inject } from '@angular/core/testing';
|
||||
import { RepositoryService, RepositoryDefaultService } from './repository.service';
|
||||
import { IServiceConfig, SERVICE_CONFIG } from "../../../lib/entities/service.config";
|
||||
import { SharedModule } from "../../../lib/utils/shared/shared.module";
|
||||
import { CURRENT_BASE_HREF } from "../../../lib/utils/utils";
|
||||
|
||||
|
||||
describe('RepositoryService', () => {
|
||||
const mockConfig: IServiceConfig = {
|
||||
repositoryBaseEndpoint: "/api/repositories/testing"
|
||||
repositoryBaseEndpoint: CURRENT_BASE_HREF + "/repositories/testing"
|
||||
};
|
||||
|
||||
let config: IServiceConfig;
|
||||
@ -37,7 +38,7 @@ describe('RepositoryService', () => {
|
||||
|
||||
it('should inject the right config', () => {
|
||||
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 { Repository, RepositoryItem, RequestQueryParams } from "../../../lib/services";
|
||||
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.
|
||||
@ -86,7 +90,7 @@ export class RepositoryDefaultService extends RepositoryService {
|
||||
if (repositoryName && repositoryName.trim() !== '') {
|
||||
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))
|
||||
.pipe(map(response => {
|
||||
let result: Repository = {
|
||||
@ -123,7 +127,7 @@ export class RepositoryDefaultService extends RepositoryService {
|
||||
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}`;
|
||||
return this.http.put(url, { 'description': description }, HTTP_JSON_OPTIONS)
|
||||
.pipe(map(response => response)
|
||||
@ -134,7 +138,7 @@ export class RepositoryDefaultService extends RepositoryService {
|
||||
if (!repositoryName) {
|
||||
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}`;
|
||||
|
||||
return this.http.delete(url, HTTP_JSON_OPTIONS)
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
ScanningResultService,
|
||||
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 { ErrorHandler } from "../../../../lib/utils/error-handler";
|
||||
import { ChannelService } from "../../../../lib/services/channel.service";
|
||||
@ -22,7 +22,7 @@ describe('ResultBarChartComponent (inline template)', () => {
|
||||
let fixture: ComponentFixture<ResultBarChartComponent>;
|
||||
let serviceConfig: IServiceConfig;
|
||||
let testConfig: IServiceConfig = {
|
||||
vulnerabilityScanningBaseEndpoint: "/api/vulnerability/testing"
|
||||
vulnerabilityScanningBaseEndpoint: CURRENT_BASE_HREF + "/vulnerability/testing"
|
||||
};
|
||||
let mockData: VulnerabilitySummary = {
|
||||
scan_status: VULNERABILITY_SCAN_STATUS.SUCCESS,
|
||||
@ -75,7 +75,7 @@ describe('ResultBarChartComponent (inline template)', () => {
|
||||
it('should be created', () => {
|
||||
expect(component).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', () => {
|
||||
|
@ -11,7 +11,12 @@ import { ScannerVo, ScanningResultService, VulnerabilitySummary } from "../../..
|
||||
import { ArtifactDefaultService } from "../artifact/artifact.service";
|
||||
import { ErrorHandler } from "../../../../lib/utils/error-handler";
|
||||
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";
|
||||
|
||||
|
||||
@ -200,7 +205,7 @@ export class ResultBarChartComponent implements OnInit, OnDestroy {
|
||||
}, duration);
|
||||
}
|
||||
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`;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import { SharedModule } from "../../../../lib/utils/shared/shared.module";
|
||||
import { FilterComponent } from "../../../../lib/components/filter/filter.component";
|
||||
import { ChannelService } from "../../../../lib/services/channel.service";
|
||||
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)', () => {
|
||||
let component: ResultGridComponent;
|
||||
let fixture: ComponentFixture<ResultGridComponent>;
|
||||
@ -23,7 +23,7 @@ describe('ResultGridComponent (inline template)', () => {
|
||||
let spy: jasmine.Spy;
|
||||
let mockHasScanImagePermission: boolean = true;
|
||||
let testConfig: IServiceConfig = {
|
||||
vulnerabilityScanningBaseEndpoint: "/api/vulnerability/testing"
|
||||
vulnerabilityScanningBaseEndpoint: CURRENT_BASE_HREF + "/vulnerability/testing"
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
@ -90,7 +90,7 @@ describe('ResultGridComponent (inline template)', () => {
|
||||
|
||||
it('should inject the SERVICE_CONFIG', () => {
|
||||
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', () => {
|
||||
|
@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ResultTipComponent } from './result-tip.component';
|
||||
import { IServiceConfig, SERVICE_CONFIG } from "../../../../lib/entities/service.config";
|
||||
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";
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ describe('ResultTipComponent (inline template)', () => {
|
||||
let component: ResultTipComponent;
|
||||
let fixture: ComponentFixture<ResultTipComponent>;
|
||||
let testConfig: IServiceConfig = {
|
||||
vulnerabilityScanningBaseEndpoint: "/api/vulnerability/testing"
|
||||
vulnerabilityScanningBaseEndpoint: CURRENT_BASE_HREF + "/vulnerability/testing"
|
||||
};
|
||||
let mockData: VulnerabilitySummary = {
|
||||
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 { catchError, map } from "rxjs/operators";
|
||||
import { Robot } from './robot';
|
||||
import { CURRENT_BASE_HREF } from "../../../lib/utils/utils";
|
||||
|
||||
@Injectable()
|
||||
export class RobotApiRepository {
|
||||
@ -10,33 +11,33 @@ export class RobotApiRepository {
|
||||
|
||||
public postRobot(projectId, param): Observable<any> {
|
||||
return this.http
|
||||
.post(`/api/projects/${projectId}/robots`, param)
|
||||
.post(`${ CURRENT_BASE_HREF }/projects/${projectId}/robots`, param)
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public deleteRobot(projectId, id): Observable<any> {
|
||||
return this.http
|
||||
.delete(`/api/projects/${projectId}/robots/${id}`)
|
||||
.delete(`${ CURRENT_BASE_HREF }/projects/${projectId}/robots/${id}`)
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public listRobot(projectId): Observable<Robot[]> {
|
||||
return this.http
|
||||
.get(`/api/projects/${projectId}/robots`)
|
||||
.get(`${ CURRENT_BASE_HREF }/projects/${projectId}/robots`)
|
||||
.pipe(map(response => response as Robot[]))
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public getRobot(projectId, id): Observable<Robot[]> {
|
||||
return this.http
|
||||
.get(`/api/projects/${projectId}/robots/${id}`)
|
||||
.get(`${ CURRENT_BASE_HREF }/projects/${projectId}/robots/${id}`)
|
||||
.pipe(map(response => response as Robot[]))
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public toggleDisabledAccount(projectId, id, data): Observable<any> {
|
||||
return this.http
|
||||
.put(`/api/projects/${projectId}/robots/${id}`, data)
|
||||
.put(`${ CURRENT_BASE_HREF }/projects/${projectId}/robots/${id}`, data)
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import { ImmutableRetentionRule, RuleMetadate } from "../tag-retention/retention
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Project } from "../../project";
|
||||
import { HTTP_JSON_OPTIONS } from "../../../../lib/utils/utils";
|
||||
import { CURRENT_BASE_HREF, HTTP_JSON_OPTIONS } from "../../../../lib/utils/utils";
|
||||
|
||||
|
||||
@Injectable()
|
||||
@ -33,34 +33,34 @@ export class ImmutableTagService {
|
||||
}
|
||||
|
||||
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(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
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(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
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)));
|
||||
}
|
||||
|
||||
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(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import { Retention, RuleMetadate } from "./retention";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Project } from "../../project";
|
||||
import { buildHttpRequestOptionsWithObserveResponse } from "../../../../lib/utils/utils";
|
||||
import { buildHttpRequestOptionsWithObserveResponse, CURRENT_BASE_HREF } from "../../../../lib/utils/utils";
|
||||
|
||||
@Injectable()
|
||||
export class TagRetentionService {
|
||||
@ -65,45 +65,45 @@ export class TagRetentionService {
|
||||
}
|
||||
|
||||
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(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
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(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
createRetention(retention: Retention) {
|
||||
return this.http.post(`/api/retentions`, retention)
|
||||
return this.http.post(`${ CURRENT_BASE_HREF }/retentions`, retention)
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
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(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
@ -113,7 +113,8 @@ export class TagRetentionService {
|
||||
params = params.set('page', page + '').set('page_size', pageSize + '');
|
||||
}
|
||||
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)), );
|
||||
}
|
||||
|
||||
@ -122,12 +123,12 @@ export class TagRetentionService {
|
||||
if (page && 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))
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
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 { HttpClient } from "@angular/common/http";
|
||||
import { Webhook, LastTrigger } from "./webhook";
|
||||
import { CURRENT_BASE_HREF } from "../../../lib/utils/utils";
|
||||
|
||||
@Injectable()
|
||||
export class WebhookService {
|
||||
@ -23,34 +24,34 @@ export class WebhookService {
|
||||
|
||||
public listWebhook(projectId: number): Observable<Webhook[]> {
|
||||
return this.http
|
||||
.get(`/api/projects/${projectId}/webhook/policies`)
|
||||
.get(`${ CURRENT_BASE_HREF }/projects/${projectId}/webhook/policies`)
|
||||
.pipe(map(response => response as Webhook[]))
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public listLastTrigger(projectId: number): Observable<LastTrigger[]> {
|
||||
return this.http
|
||||
.get(`/api/projects/${projectId}/webhook/lasttrigger`)
|
||||
.get(`${ CURRENT_BASE_HREF }/projects/${projectId}/webhook/lasttrigger`)
|
||||
.pipe(map(response => response as LastTrigger[]))
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public editWebhook(projectId: number, policyId: number, data: any): Observable<any> {
|
||||
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)));
|
||||
}
|
||||
|
||||
public createWebhook(projectId: number, data: any): Observable<any> {
|
||||
return this.http
|
||||
.post(`/api/projects/${projectId}/webhook/policies`, data)
|
||||
.post(`${ CURRENT_BASE_HREF }/projects/${projectId}/webhook/policies`, data)
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
|
||||
public testEndpoint(projectId: number, param): Observable<any> {
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
@ -20,16 +20,22 @@ import { Member } from '../project/member/member';
|
||||
import { SignInCredential } from './sign-in-credential';
|
||||
import { enLang } from './shared.const';
|
||||
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";
|
||||
|
||||
const signInUrl = '/c/login';
|
||||
const currentUserEndpoint = "/api/users/current";
|
||||
const currentUserEndpoint = CURRENT_BASE_HREF + "/users/current";
|
||||
const signOffEndpoint = "/c/log_out";
|
||||
const accountEndpoint = "/api/users/:id";
|
||||
const accountEndpoint = CURRENT_BASE_HREF + "/users/:id";
|
||||
const langEndpoint = "/language";
|
||||
const userExistsEndpoint = "/c/userExists";
|
||||
const renameAdminEndpoint = '/api/internal/renameadmin';
|
||||
const renameAdminEndpoint = CURRENT_BASE_HREF + '/internal/renameadmin';
|
||||
const langMap = {
|
||||
"zh": "zh-CN",
|
||||
"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 { ErrorHandler } from "../../lib/utils/error-handler";
|
||||
import { HarborLibraryModule } from "../../lib/harbor-library.module";
|
||||
import { CURRENT_BASE_HREF } from "../../lib/utils/utils";
|
||||
|
||||
const uiLibConfig: IServiceConfig = {
|
||||
enablei18Support: true,
|
||||
@ -53,24 +54,24 @@ const uiLibConfig: IServiceConfig = {
|
||||
langMessageLoader: "http",
|
||||
langMessagePathForHttpLoader: "i18n/lang/",
|
||||
langMessageFileSuffixForHttpLoader: "-lang.json",
|
||||
systemInfoEndpoint: "/api/systeminfo",
|
||||
repositoryBaseEndpoint: "/api/repositories",
|
||||
logBaseEndpoint: "/api/logs",
|
||||
targetBaseEndpoint: "/api/registries",
|
||||
replicationBaseEndpoint: "/api/replication",
|
||||
replicationRuleEndpoint: "/api/replication/policies",
|
||||
vulnerabilityScanningBaseEndpoint: "/api/repositories",
|
||||
projectPolicyEndpoint: "/api/projects/configs",
|
||||
projectBaseEndpoint: "/api/projects",
|
||||
systemInfoEndpoint: CURRENT_BASE_HREF + "/systeminfo",
|
||||
repositoryBaseEndpoint: CURRENT_BASE_HREF + "/repositories",
|
||||
logBaseEndpoint: CURRENT_BASE_HREF + "/logs",
|
||||
targetBaseEndpoint: CURRENT_BASE_HREF + "/registries",
|
||||
replicationBaseEndpoint: CURRENT_BASE_HREF + "/replication",
|
||||
replicationRuleEndpoint: CURRENT_BASE_HREF + "/replication/policies",
|
||||
vulnerabilityScanningBaseEndpoint: CURRENT_BASE_HREF + "/repositories",
|
||||
projectPolicyEndpoint: CURRENT_BASE_HREF + "/projects/configs",
|
||||
projectBaseEndpoint: CURRENT_BASE_HREF + "/projects",
|
||||
localI18nMessageVariableMap: {},
|
||||
configurationEndpoint: "/api/configurations",
|
||||
scanJobEndpoint: "/api/jobs/scan",
|
||||
labelEndpoint: "/api/labels",
|
||||
helmChartEndpoint: "/api/chartrepo",
|
||||
configurationEndpoint: CURRENT_BASE_HREF + "/configurations",
|
||||
scanJobEndpoint: CURRENT_BASE_HREF + "/jobs/scan",
|
||||
labelEndpoint: CURRENT_BASE_HREF + "/labels",
|
||||
helmChartEndpoint: CURRENT_BASE_HREF + "/chartrepo",
|
||||
downloadChartEndpoint: "/chartrepo",
|
||||
gcEndpoint: "/api/system/gc",
|
||||
ScanAllEndpoint: "/api/system/scanAll",
|
||||
quotaUrl: "/api/quotas"
|
||||
gcEndpoint: CURRENT_BASE_HREF + "/system/gc",
|
||||
ScanAllEndpoint: CURRENT_BASE_HREF + "/system/scanAll",
|
||||
quotaUrl: CURRENT_BASE_HREF + "/quotas"
|
||||
};
|
||||
|
||||
@NgModule({
|
||||
|
@ -17,11 +17,11 @@ import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
import { Statistics } from './statistics';
|
||||
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 volumesEndpoint = "/api/systeminfo/volumes";
|
||||
const statisticsEndpoint = CURRENT_BASE_HREF + "/statistics";
|
||||
const volumesEndpoint = CURRENT_BASE_HREF + "/systeminfo/volumes";
|
||||
/**
|
||||
* Declare service to handle the top repositories
|
||||
*
|
||||
|
@ -16,9 +16,9 @@ import { HttpClient } from '@angular/common/http';
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
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
|
||||
*
|
||||
|
@ -17,12 +17,17 @@ import { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
import { User, LDAPUser } 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 userListSearch = '/api/users/search?';
|
||||
const ldapUserEndpoint = '/api/ldap/users';
|
||||
const userMgmtEndpoint = CURRENT_BASE_HREF + '/users';
|
||||
const userListSearch = CURRENT_BASE_HREF + '/users/search?';
|
||||
const ldapUserEndpoint = CURRENT_BASE_HREF + '/ldap/users';
|
||||
|
||||
/**
|
||||
* 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 { of } from 'rxjs';
|
||||
import { GcJobData } from './gcLog';
|
||||
import { CURRENT_BASE_HREF } from "../../../utils/utils";
|
||||
|
||||
describe('GcComponent', () => {
|
||||
let component: GcComponent;
|
||||
let fixture: ComponentFixture<GcComponent>;
|
||||
let gcRepoService: GcRepoService;
|
||||
let config: IServiceConfig = {
|
||||
systemInfoEndpoint: "/api/system/gc"
|
||||
systemInfoEndpoint: CURRENT_BASE_HREF + "/system/gc"
|
||||
};
|
||||
let mockSchedule = [];
|
||||
let mockJobs: GcJobData[] = [
|
||||
|
@ -4,12 +4,13 @@ import { SERVICE_CONFIG, IServiceConfig } from '../../../../entities/service.con
|
||||
import { EditQuotaQuotaInterface } from '../../../../services';
|
||||
import { HarborLibraryModule } from '../../../../harbor-library.module';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { CURRENT_BASE_HREF } from "../../../../utils/utils";
|
||||
|
||||
describe('EditProjectQuotasComponent', () => {
|
||||
let component: EditProjectQuotasComponent;
|
||||
let fixture: ComponentFixture<EditProjectQuotasComponent>;
|
||||
let config: IServiceConfig = {
|
||||
quotaUrl: "/api/quotas/testing"
|
||||
quotaUrl: CURRENT_BASE_HREF + "/quotas/testing"
|
||||
};
|
||||
const mockedEditQuota: EditQuotaQuotaInterface = {
|
||||
editQuota: "Edit Default Project Quotas",
|
||||
|
@ -12,6 +12,7 @@ import { delay } from 'rxjs/operators';
|
||||
import {APP_BASE_HREF} from '@angular/common';
|
||||
import { HarborLibraryModule } from '../../../harbor-library.module';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { CURRENT_BASE_HREF } from "../../../utils/utils";
|
||||
describe('ProjectQuotasComponent', () => {
|
||||
let spy: jasmine.Spy;
|
||||
let spyUpdate: jasmine.Spy;
|
||||
@ -22,7 +23,7 @@ describe('ProjectQuotasComponent', () => {
|
||||
let fixture: ComponentFixture<ProjectQuotasComponent>;
|
||||
|
||||
let config: IServiceConfig = {
|
||||
quotaUrl: "/api/quotas/testing"
|
||||
quotaUrl: CURRENT_BASE_HREF + "/quotas/testing"
|
||||
};
|
||||
let mockQuotaList: Quota[] = [{
|
||||
id: 1111,
|
||||
|
@ -23,6 +23,7 @@ import {
|
||||
} from '../../services';
|
||||
import { Configuration } from './config';
|
||||
import { of } from 'rxjs';
|
||||
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||
|
||||
describe('RegistryConfigComponent (inline template)', () => {
|
||||
|
||||
@ -41,7 +42,7 @@ describe('RegistryConfigComponent (inline template)', () => {
|
||||
}
|
||||
};
|
||||
let config: IServiceConfig = {
|
||||
configurationEndpoint: '/api/configurations/testing'
|
||||
configurationEndpoint: CURRENT_BASE_HREF + '/configurations/testing'
|
||||
};
|
||||
let mockSystemInfo: SystemInfo = {
|
||||
"with_notary": true,
|
||||
|
@ -3,11 +3,12 @@ import { ReplicationConfigComponent } from "./replication-config.component";
|
||||
import { HarborLibraryModule } from "../../../harbor-library.module";
|
||||
import { IServiceConfig, SERVICE_CONFIG } from "../../../entities/service.config";
|
||||
import { Configuration } from "../config";
|
||||
import { CURRENT_BASE_HREF } from "../../../utils/utils";
|
||||
describe('ReplicationConfigComponent', () => {
|
||||
let component: ReplicationConfigComponent;
|
||||
let fixture: ComponentFixture<ReplicationConfigComponent>;
|
||||
const config: IServiceConfig = {
|
||||
baseEndpoint: "/api/testing"
|
||||
baseEndpoint: CURRENT_BASE_HREF + "/testing"
|
||||
};
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
@ -7,11 +7,12 @@ import { ErrorHandler } from "../../../utils/error-handler";
|
||||
import { of } from "rxjs";
|
||||
import { StringValueItem } from "../config";
|
||||
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
|
||||
import { CURRENT_BASE_HREF } from "../../../utils/utils";
|
||||
describe('SystemSettingsComponent', () => {
|
||||
let component: SystemSettingsComponent;
|
||||
let fixture: ComponentFixture<SystemSettingsComponent>;
|
||||
const config: IServiceConfig = {
|
||||
baseEndpoint: "/api/testing"
|
||||
baseEndpoint: CURRENT_BASE_HREF + "/testing"
|
||||
};
|
||||
const mockedWhitelist = {
|
||||
id: 1,
|
||||
|
@ -5,6 +5,7 @@ import { ErrorHandler } from '../../../utils/error-handler';
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {ScanningMetrics} from "../config";
|
||||
import {catchError, map} from "rxjs/operators";
|
||||
import { CURRENT_BASE_HREF } from "../../../utils/utils";
|
||||
|
||||
|
||||
@Injectable()
|
||||
@ -51,21 +52,21 @@ export class ScanAllRepoService {
|
||||
return this.scanApiRepository.putSchedule(param);
|
||||
}
|
||||
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(map(response => response as 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(map(response => response as ScanningMetrics));
|
||||
}
|
||||
getScanners(): Observable<any> {
|
||||
return this.http.get('/api/scanners')
|
||||
return this.http.get(CURRENT_BASE_HREF + '/scanners')
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
@ -7,11 +7,12 @@ import { IServiceConfig, SERVICE_CONFIG } from "../../../entities/service.config
|
||||
import { ScanningMetrics } from "../config";
|
||||
import { SharedModule } from "../../../utils/shared/shared.module";
|
||||
import { ErrorHandler } from "../../../utils/error-handler";
|
||||
import { CURRENT_BASE_HREF } from "../../../utils/utils";
|
||||
|
||||
let component: VulnerabilityConfigComponent;
|
||||
let fixture: ComponentFixture<VulnerabilityConfigComponent>;
|
||||
let config: IServiceConfig = {
|
||||
configurationEndpoint: '/api/configurations/testing'
|
||||
configurationEndpoint: CURRENT_BASE_HREF + '/configurations/testing'
|
||||
};
|
||||
let mockedSchedule = {"schedule": null};
|
||||
let mockedScheduledMetrics: ScanningMetrics = {
|
||||
|
@ -6,6 +6,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { ConfirmationTargets } from '../../entities/shared.const';
|
||||
import { ConfirmationMessage } from './confirmation-message';
|
||||
import { BatchInfo } from './confirmation-batch-message';
|
||||
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||
|
||||
|
||||
describe('ConfirmationDialogComponent', () => {
|
||||
@ -13,7 +14,7 @@ describe('ConfirmationDialogComponent', () => {
|
||||
let comp: ConfirmationDialogComponent;
|
||||
let fixture: ComponentFixture<ConfirmationDialogComponent>;
|
||||
let config: IServiceConfig = {
|
||||
configurationEndpoint: '/api/configurations/testing'
|
||||
configurationEndpoint: CURRENT_BASE_HREF + '/configurations/testing'
|
||||
};
|
||||
const deletionMessage: ConfirmationMessage = new ConfirmationMessage(
|
||||
"MEMBER.DELETION_TITLE",
|
||||
|
@ -21,6 +21,7 @@ import { IServiceConfig, SERVICE_CONFIG } from "../../entities/service.config";
|
||||
import { of } from "rxjs";
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { HttpClientTestingModule } from "@angular/common/http/testing";
|
||||
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||
|
||||
describe("CreateEditEndpointComponent (inline template)", () => {
|
||||
let mockData: Endpoint = {
|
||||
@ -254,7 +255,7 @@ describe("CreateEditEndpointComponent (inline template)", () => {
|
||||
let fixture: ComponentFixture<CreateEditEndpointComponent>;
|
||||
|
||||
let config: IServiceConfig = {
|
||||
systemInfoEndpoint: "/api/endpoints/testing"
|
||||
systemInfoEndpoint: CURRENT_BASE_HREF + "/endpoints/testing"
|
||||
};
|
||||
|
||||
let endpointService: EndpointService;
|
||||
@ -326,6 +327,6 @@ describe("CreateEditEndpointComponent (inline template)", () => {
|
||||
|
||||
it("should endpoint be initialized", () => {
|
||||
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 { InlineAlertComponent } from "../inline-alert/inline-alert.component";
|
||||
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 { catchError } from "rxjs/operators";
|
||||
|
||||
const FAKE_PASSWORD = "rjGcfuRu";
|
||||
const FAKE_JSON_KEY = "No Change";
|
||||
const METADATA_URL = "/api/replication/adapterinfos";
|
||||
const METADATA_URL = CURRENT_BASE_HREF + "/replication/adapterinfos";
|
||||
@Component({
|
||||
selector: "hbr-create-edit-endpoint",
|
||||
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 { LabelDefaultService, LabelService } from "../../services/label.service";
|
||||
import { of } from "rxjs";
|
||||
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||
|
||||
describe("CreateEditLabelComponent (inline template)", () => {
|
||||
let mockOneData: Label = {
|
||||
@ -27,7 +28,7 @@ describe("CreateEditLabelComponent (inline template)", () => {
|
||||
let fixture: ComponentFixture<CreateEditLabelComponent>;
|
||||
|
||||
let config: IServiceConfig = {
|
||||
systemInfoEndpoint: "/api/label/testing"
|
||||
systemInfoEndpoint: CURRENT_BASE_HREF + "/label/testing"
|
||||
};
|
||||
|
||||
let labelService: LabelService;
|
||||
|
@ -39,6 +39,7 @@ import {LabelService} from "../../services/label.service";
|
||||
import {LabelPieceComponent} from "../label-piece/label-piece.component";
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { of } from "rxjs";
|
||||
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||
|
||||
describe("CreateEditRuleComponent (inline template)", () => {
|
||||
let mockRules: ReplicationRule[] = [
|
||||
@ -221,8 +222,8 @@ describe("CreateEditRuleComponent (inline template)", () => {
|
||||
|
||||
|
||||
let config: IServiceConfig = {
|
||||
replicationBaseEndpoint: "/api/replication/testing",
|
||||
targetBaseEndpoint: "/api/registries/testing"
|
||||
replicationBaseEndpoint: CURRENT_BASE_HREF + "/replication/testing",
|
||||
targetBaseEndpoint: CURRENT_BASE_HREF + "/registries/testing"
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
|
@ -18,7 +18,7 @@ import {
|
||||
import { IServiceConfig, SERVICE_CONFIG } from "../../entities/service.config";
|
||||
import { OperationService } from "../operation/operation.service";
|
||||
|
||||
import { click } from "../../utils/utils";
|
||||
import { click, CURRENT_BASE_HREF } from "../../utils/utils";
|
||||
import { of } from "rxjs";
|
||||
import { HttpClientTestingModule } from "@angular/common/http/testing";
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
@ -311,7 +311,7 @@ describe("EndpointComponent (inline template)", () => {
|
||||
let comp: EndpointComponent;
|
||||
let fixture: ComponentFixture<EndpointComponent>;
|
||||
let config: IServiceConfig = {
|
||||
systemInfoEndpoint: "/api/endpoints/testing"
|
||||
systemInfoEndpoint: CURRENT_BASE_HREF + "/endpoints/testing"
|
||||
};
|
||||
|
||||
let endpointService: EndpointService;
|
||||
@ -368,7 +368,7 @@ describe("EndpointComponent (inline template)", () => {
|
||||
|
||||
it("should endpoint be initialized", () => {
|
||||
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(() => {
|
||||
|
@ -8,6 +8,7 @@ import { IServiceConfig, SERVICE_CONFIG } from "../../entities/service.config";
|
||||
import { of } from "rxjs";
|
||||
import { HttpResponse } from "@angular/common/http";
|
||||
import { ChannelService } from "../../services/channel.service";
|
||||
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||
|
||||
describe("ImageNameInputComponent (inline template)", () => {
|
||||
let comp: ImageNameInputComponent;
|
||||
@ -28,7 +29,7 @@ describe("ImageNameInputComponent (inline template)", () => {
|
||||
];
|
||||
|
||||
let config: IServiceConfig = {
|
||||
projectBaseEndpoint: "/api/projects/testing"
|
||||
projectBaseEndpoint: CURRENT_BASE_HREF + "/projects/testing"
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
|
@ -14,6 +14,7 @@ import {ErrorHandler} from "../../utils/error-handler/error-handler";
|
||||
import {IServiceConfig, SERVICE_CONFIG} from "../../entities/service.config";
|
||||
import { OperationService } from "../operation/operation.service";
|
||||
import { of } from "rxjs";
|
||||
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||
|
||||
describe('LabelComponent (inline template)', () => {
|
||||
|
||||
@ -60,7 +61,7 @@ describe('LabelComponent (inline template)', () => {
|
||||
let spyOneLabel: jasmine.Spy;
|
||||
|
||||
let config: IServiceConfig = {
|
||||
systemInfoEndpoint: '/api/label/testing'
|
||||
systemInfoEndpoint: CURRENT_BASE_HREF + '/label/testing'
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
|
@ -15,6 +15,7 @@ import { SERVICE_CONFIG, IServiceConfig } from '../../entities/service.config';
|
||||
import { ReplicationService, ReplicationDefaultService } from '../../services/replication.service';
|
||||
import { OperationService } from "../operation/operation.service";
|
||||
import { of } from 'rxjs';
|
||||
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||
|
||||
describe('ListReplicationRuleComponent (inline template)', () => {
|
||||
|
||||
@ -56,7 +57,7 @@ describe('ListReplicationRuleComponent (inline template)', () => {
|
||||
let spyRules: jasmine.Spy;
|
||||
|
||||
let config: IServiceConfig = {
|
||||
replicationRuleEndpoint: '/api/policies/replication/testing'
|
||||
replicationRuleEndpoint: CURRENT_BASE_HREF + '/policies/replication/testing'
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
|
@ -9,7 +9,7 @@ import { ErrorHandler } from '../../utils/error-handler';
|
||||
import { SharedModule } from '../../utils/shared/shared.module';
|
||||
import { FilterComponent } from '../filter/filter.component';
|
||||
|
||||
import { click } from '../../utils/utils';
|
||||
import { click, CURRENT_BASE_HREF } from '../../utils/utils';
|
||||
import { of } from 'rxjs';
|
||||
import { delay } from 'rxjs/operators';
|
||||
|
||||
@ -33,7 +33,7 @@ describe('RecentLogComponent (inline template)', () => {
|
||||
data: []
|
||||
};
|
||||
let testConfig: IServiceConfig = {
|
||||
logBaseEndpoint: "/api/logs/testing"
|
||||
logBaseEndpoint: CURRENT_BASE_HREF + "/logs/testing"
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
@ -96,7 +96,7 @@ describe('RecentLogComponent (inline template)', () => {
|
||||
|
||||
it('should inject the SERVICE_CONFIG', () => {
|
||||
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(() => {
|
||||
|
@ -6,13 +6,14 @@ import { OperationService } from './operation.service';
|
||||
import { HarborLibraryModule } from '../../harbor-library.module';
|
||||
import { IServiceConfig, SERVICE_CONFIG } from '../../entities/service.config';
|
||||
import { OperateInfo } from './operate';
|
||||
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||
|
||||
describe('OperationComponent', () => {
|
||||
|
||||
let component: OperationComponent;
|
||||
let fixture: ComponentFixture<OperationComponent>;
|
||||
let config: IServiceConfig = {
|
||||
configurationEndpoint: '/api/configurations/testing'
|
||||
configurationEndpoint: CURRENT_BASE_HREF + '/configurations/testing'
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -10,6 +10,7 @@ import {SystemCVEWhitelist, SystemInfo} from '../../services/interface';
|
||||
import { Project } from './project';
|
||||
import { UserPermissionService } from '../../services/permission.service';
|
||||
import { of } from 'rxjs';
|
||||
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||
|
||||
const mockSystemInfo: SystemInfo[] = [
|
||||
{
|
||||
@ -80,8 +81,8 @@ const mockSystemWhitelist: SystemCVEWhitelist = {
|
||||
"project_id": 0
|
||||
};
|
||||
const config: IServiceConfig = {
|
||||
projectPolicyEndpoint: '/api/projects/testing',
|
||||
systemInfoEndpoint: '/api/systeminfo/testing',
|
||||
projectPolicyEndpoint: CURRENT_BASE_HREF + '/projects/testing',
|
||||
systemInfoEndpoint: CURRENT_BASE_HREF + '/systeminfo/testing',
|
||||
};
|
||||
const projectService = {
|
||||
getProject() {
|
||||
|
@ -26,6 +26,7 @@ import {FilterLabelComponent} from "../create-edit-rule/filter-label.component";
|
||||
import {LabelPieceComponent} from "../label-piece/label-piece.component";
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { of } from 'rxjs';
|
||||
import { CURRENT_BASE_HREF } from "../../utils/utils";
|
||||
|
||||
|
||||
describe('Replication Component (inline template)', () => {
|
||||
@ -149,7 +150,7 @@ describe('Replication Component (inline template)', () => {
|
||||
let elJob: HTMLElement;
|
||||
|
||||
let config: IServiceConfig = {
|
||||
replicationRuleEndpoint: '/api/policies/replication/testing'
|
||||
replicationRuleEndpoint: CURRENT_BASE_HREF + '/policies/replication/testing'
|
||||
};
|
||||
|
||||
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 endpoints of repository or tag(s) will be built based on this endpoint.
|
||||
* E.g:
|
||||
* If the base endpoint is '/api/repositories',
|
||||
* the repository endpoint will be '/api/repositories/:repo_id',
|
||||
* the tag(s) endpoint will be '/api/repositories/:repo_id/tags[/:tag_id]'.
|
||||
* If the base endpoint is CURRENT_BASE_HREF + '/repositories',
|
||||
* the repository endpoint will be CURRENT_BASE_HREF + '/repositories/:repo_id',
|
||||
* the tag(s) endpoint will be CURRENT_BASE_HREF + '/repositories/:repo_id/tags[/:tag_id]'.
|
||||
*
|
||||
*
|
||||
* * {string}
|
||||
@ -41,9 +41,9 @@ export interface IServiceConfig {
|
||||
* The base endpoint of the service used to handle the registry targets.
|
||||
* Registry target related endpoints will be built based on this endpoint.
|
||||
* E.g:
|
||||
* If the base endpoint is '/api/endpoints',
|
||||
* the endpoint for registry target will be '/api/endpoints/:endpoint_id',
|
||||
* the endpoint for pinging registry target will be '/api/endpoints/:endpoint_id/ping'.
|
||||
* If the base endpoint is CURRENT_BASE_HREF + '/endpoints',
|
||||
* the endpoint for registry target will be CURRENT_BASE_HREF + '/endpoints/:endpoint_id',
|
||||
* the endpoint for pinging registry target will be CURRENT_BASE_HREF + '/endpoints/:endpoint_id/ping'.
|
||||
*
|
||||
* * {string}
|
||||
* @memberOf IServiceConfig
|
||||
@ -59,8 +59,8 @@ export interface IServiceConfig {
|
||||
* The base endpoint of the service used to handle the replication rules.
|
||||
* Replication rule related endpoints will be built based on this endpoint.
|
||||
* E.g:
|
||||
* If the base endpoint is '/api/replication/rules',
|
||||
* the endpoint for rule will be '/api/replication/rules/:rule_id'.
|
||||
* If the base endpoint is CURRENT_BASE_HREF + '/replication/rules',
|
||||
* the endpoint for rule will be CURRENT_BASE_HREF + '/replication/rules/:rule_id'.
|
||||
*
|
||||
* * {string}
|
||||
* @memberOf IServiceConfig
|
||||
@ -203,8 +203,8 @@ export interface IServiceConfig {
|
||||
* The base endpoint of the service used to handle the labels.
|
||||
* labels related endpoints will be built based on this endpoint.
|
||||
* E.g:
|
||||
* If the base endpoint is '/api/labels',
|
||||
* the label endpoint will be '/api/labels/:id'.
|
||||
* If the base endpoint is CURRENT_BASE_HREF + '/labels',
|
||||
* the label endpoint will be CURRENT_BASE_HREF + '/labels/:id'.
|
||||
*
|
||||
* * {string}
|
||||
* @memberOf IServiceConfig
|
||||
@ -215,8 +215,8 @@ export interface IServiceConfig {
|
||||
* The base endpoint of the service used to handle the helm chart.
|
||||
* helm charts related endpoints will be built based on this endpoint.
|
||||
* E.g:
|
||||
* If the base endpoint is '/api/helmcharts',
|
||||
* the helm chart endpoint will be '/api/helmcharts/:id'.
|
||||
* If the base endpoint is CURRENT_BASE_HREF + '/helmcharts',
|
||||
* the helm chart endpoint will be CURRENT_BASE_HREF + '/helmcharts/:id'.
|
||||
*
|
||||
* * {string}
|
||||
* @memberOf IServiceConfig
|
||||
|
@ -38,7 +38,7 @@ import {
|
||||
ErrorHandler,
|
||||
DefaultErrorHandler
|
||||
} 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 { GcHistoryComponent } from "./components/config/gc/gc-history/gc-history.component";
|
||||
import { GcComponent } from "./components/config/gc/gc.component";
|
||||
@ -80,16 +80,16 @@ import { TranslateServiceInitializer } from "./i18n";
|
||||
* this default configuration.
|
||||
*/
|
||||
export const DefaultServiceConfig: IServiceConfig = {
|
||||
baseEndpoint: "/api",
|
||||
systemInfoEndpoint: "/api/systeminfo",
|
||||
repositoryBaseEndpoint: "/api/repositories",
|
||||
logBaseEndpoint: "/api/logs",
|
||||
targetBaseEndpoint: "/api/registries",
|
||||
replicationBaseEndpoint: "/api/replication",
|
||||
replicationRuleEndpoint: "/api/replication/policies",
|
||||
vulnerabilityScanningBaseEndpoint: "/api/repositories",
|
||||
projectPolicyEndpoint: "/api/projects/configs",
|
||||
projectBaseEndpoint: "/api/projects",
|
||||
baseEndpoint: CURRENT_BASE_HREF,
|
||||
systemInfoEndpoint: CURRENT_BASE_HREF + "/systeminfo",
|
||||
repositoryBaseEndpoint: CURRENT_BASE_HREF + "/repositories",
|
||||
logBaseEndpoint: CURRENT_BASE_HREF + "/logs",
|
||||
targetBaseEndpoint: CURRENT_BASE_HREF + "/registries",
|
||||
replicationBaseEndpoint: CURRENT_BASE_HREF + "/replication",
|
||||
replicationRuleEndpoint: CURRENT_BASE_HREF + "/replication/policies",
|
||||
vulnerabilityScanningBaseEndpoint: CURRENT_BASE_HREF + "/repositories",
|
||||
projectPolicyEndpoint: CURRENT_BASE_HREF + "/projects/configs",
|
||||
projectBaseEndpoint: CURRENT_BASE_HREF + "/projects",
|
||||
enablei18Support: false,
|
||||
langCookieKey: DEFAULT_LANG_COOKIE_KEY,
|
||||
supportedLangs: DEFAULT_SUPPORTING_LANGS,
|
||||
@ -98,13 +98,13 @@ export const DefaultServiceConfig: IServiceConfig = {
|
||||
langMessagePathForHttpLoader: "i18n/langs/",
|
||||
langMessageFileSuffixForHttpLoader: "-lang.json",
|
||||
localI18nMessageVariableMap: {},
|
||||
configurationEndpoint: "/api/configurations",
|
||||
scanJobEndpoint: "/api/jobs/scan",
|
||||
labelEndpoint: "/api/labels",
|
||||
helmChartEndpoint: "/api/chartrepo",
|
||||
configurationEndpoint: CURRENT_BASE_HREF + "/configurations",
|
||||
scanJobEndpoint: CURRENT_BASE_HREF + "/jobs/scan",
|
||||
labelEndpoint: CURRENT_BASE_HREF + "/labels",
|
||||
helmChartEndpoint: CURRENT_BASE_HREF + "/chartrepo",
|
||||
downloadChartEndpoint: "/chartrepo",
|
||||
gcEndpoint: "/api/system/gc",
|
||||
ScanAllEndpoint: "/api/system/scanAll"
|
||||
gcEndpoint: CURRENT_BASE_HREF + "/system/gc",
|
||||
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 { SharedModule } from '../utils/shared/shared.module';
|
||||
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
||||
import { CURRENT_BASE_HREF } from "../utils/utils";
|
||||
|
||||
describe('AccessLogService', () => {
|
||||
const mockConfig: IServiceConfig = {
|
||||
logBaseEndpoint: "/api/logs/testing"
|
||||
logBaseEndpoint: CURRENT_BASE_HREF + "/logs/testing"
|
||||
};
|
||||
|
||||
let config: IServiceConfig;
|
||||
@ -36,7 +37,7 @@ describe('AccessLogService', () => {
|
||||
|
||||
it('should inject the right config', () => {
|
||||
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 { SERVICE_CONFIG, IServiceConfig } from "../entities/service.config";
|
||||
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";
|
||||
|
||||
/**
|
||||
@ -77,7 +81,7 @@ export class AccessLogDefaultService extends AccessLogService {
|
||||
? this.config.logBaseEndpoint
|
||||
: "";
|
||||
if (url === "") {
|
||||
url = "/api/logs";
|
||||
url = CURRENT_BASE_HREF + "/logs";
|
||||
}
|
||||
|
||||
return this.http
|
||||
|
@ -3,10 +3,11 @@ import { TestBed, inject } from '@angular/core/testing';
|
||||
import { ConfigurationService, ConfigurationDefaultService } from './configuration.service';
|
||||
import { SharedModule } from '../utils/shared/shared.module';
|
||||
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
||||
import { CURRENT_BASE_HREF } from "../utils/utils";
|
||||
|
||||
describe('ConfigurationService', () => {
|
||||
const mockConfig: IServiceConfig = {
|
||||
configurationEndpoint: "/api/configurations/testing"
|
||||
configurationEndpoint: CURRENT_BASE_HREF + "/configurations/testing"
|
||||
};
|
||||
|
||||
let config: IServiceConfig;
|
||||
@ -36,7 +37,7 @@ describe('ConfigurationService', () => {
|
||||
|
||||
it('should inject the right config', () => {
|
||||
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 { 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";
|
||||
|
||||
/**
|
||||
@ -52,7 +52,7 @@ export class ConfigurationDefaultService extends ConfigurationService {
|
||||
this._baseUrl =
|
||||
this.config && this.config.configurationEndpoint
|
||||
? this.config.configurationEndpoint
|
||||
: "/api/configurations";
|
||||
: CURRENT_BASE_HREF + "/configurations";
|
||||
}
|
||||
|
||||
getConfigurations():
|
||||
|
@ -2,13 +2,14 @@ import { TestBed, inject } from '@angular/core/testing';
|
||||
import { SharedModule } from '../utils/shared/shared.module';
|
||||
import { IServiceConfig, SERVICE_CONFIG } from '../entities/service.config';
|
||||
import { EndpointService, EndpointDefaultService } from './endpoint.service';
|
||||
import { CURRENT_BASE_HREF } from "../utils/utils";
|
||||
|
||||
|
||||
|
||||
describe('EndpointService', () => {
|
||||
|
||||
let mockEndpoint: IServiceConfig = {
|
||||
targetBaseEndpoint: '/api/endpoint/testing'
|
||||
targetBaseEndpoint: CURRENT_BASE_HREF + '/endpoint/testing'
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -6,7 +6,7 @@ import { IServiceConfig, SERVICE_CONFIG } from "../entities/service.config";
|
||||
import {
|
||||
buildHttpRequestOptions,
|
||||
HTTP_JSON_OPTIONS,
|
||||
HTTP_GET_OPTIONS
|
||||
HTTP_GET_OPTIONS, CURRENT_BASE_HREF
|
||||
} from "../utils/utils";
|
||||
import { RequestQueryParams } from "./RequestQueryParams";
|
||||
import { Endpoint, ReplicationRule, PingEndpoint } from "./interface";
|
||||
@ -145,7 +145,7 @@ export class EndpointDefaultService extends EndpointService {
|
||||
super();
|
||||
this._endpointUrl = config.targetBaseEndpoint
|
||||
? config.targetBaseEndpoint
|
||||
: "/api/registries";
|
||||
: CURRENT_BASE_HREF + "/registries";
|
||||
}
|
||||
|
||||
public getEndpoints(
|
||||
@ -180,7 +180,7 @@ export class EndpointDefaultService extends EndpointService {
|
||||
|
||||
public getAdapters(): Observable<any> {
|
||||
return this.http
|
||||
.get(`/api/replication/adapters`)
|
||||
.get(`${ CURRENT_BASE_HREF }/replication/adapters`)
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,12 @@ import { TestBed, inject } from '@angular/core/testing';
|
||||
import { JobLogService, JobLogDefaultService } from './job-log.service';
|
||||
import { SharedModule } from '../utils/shared/shared.module';
|
||||
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
||||
import { CURRENT_BASE_HREF } from "../utils/utils";
|
||||
|
||||
describe('JobLogService', () => {
|
||||
const mockConfig: IServiceConfig = {
|
||||
replicationBaseEndpoint: "/api/replication/testing",
|
||||
scanJobEndpoint: "/api/jobs/scan/testing"
|
||||
replicationBaseEndpoint: CURRENT_BASE_HREF + "/replication/testing",
|
||||
scanJobEndpoint: CURRENT_BASE_HREF + "/jobs/scan/testing"
|
||||
};
|
||||
|
||||
let config: IServiceConfig;
|
||||
@ -33,7 +34,7 @@ describe('JobLogService', () => {
|
||||
|
||||
it('should be initialized', inject([JobLogDefaultService], (service: JobLogService) => {
|
||||
expect(service).toBeTruthy();
|
||||
expect(config.replicationBaseEndpoint).toEqual("/api/replication/testing");
|
||||
expect(config.scanJobEndpoint).toEqual("/api/jobs/scan/testing");
|
||||
expect(config.replicationBaseEndpoint).toEqual(CURRENT_BASE_HREF + "/replication/testing");
|
||||
expect(config.scanJobEndpoint).toEqual(CURRENT_BASE_HREF + "/jobs/scan/testing");
|
||||
}));
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Injectable, Inject } from "@angular/core";
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
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 { Observable, throwError as observableThrowError } from "rxjs";
|
||||
/**
|
||||
@ -49,10 +49,10 @@ export class JobLogDefaultService extends JobLogService {
|
||||
super();
|
||||
this._replicationJobBaseUrl = config.replicationBaseEndpoint
|
||||
? config.replicationBaseEndpoint
|
||||
: "/api/replication";
|
||||
: CURRENT_BASE_HREF + "/replication";
|
||||
this._scanningJobBaseUrl = config.scanJobEndpoint
|
||||
? config.scanJobEndpoint
|
||||
: "/api/jobs/scan";
|
||||
: CURRENT_BASE_HREF + "/jobs/scan";
|
||||
this._supportedJobTypes = ["replication", "scan"];
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ import { RequestQueryParams } from "./RequestQueryParams";
|
||||
import { Label } from "./interface";
|
||||
|
||||
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";
|
||||
|
||||
export abstract class LabelService {
|
||||
@ -78,8 +78,8 @@ export class LabelDefaultService extends LabelService {
|
||||
private http: HttpClient
|
||||
) {
|
||||
super();
|
||||
this.labelUrl = config.labelEndpoint ? config.labelEndpoint : "/api/labels";
|
||||
this.chartUrl = config.helmChartEndpoint ? config.helmChartEndpoint : "/api/chartrepo";
|
||||
this.labelUrl = config.labelEndpoint ? config.labelEndpoint : CURRENT_BASE_HREF + "/labels";
|
||||
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 { HttpClient } from '@angular/common/http';
|
||||
import { CacheObservable } from "../utils/cache-util";
|
||||
import { CURRENT_BASE_HREF } from "../utils/utils";
|
||||
|
||||
|
||||
interface Permission {
|
||||
@ -53,7 +54,7 @@ export class UserPermissionDefaultService extends UserPermissionService {
|
||||
|
||||
@CacheObservable({ maxAge: 1000 * 60 })
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import { ProjectPolicy } from "../components/project-policy-config/project-polic
|
||||
import {
|
||||
HTTP_JSON_OPTIONS,
|
||||
HTTP_GET_OPTIONS,
|
||||
buildHttpRequestOptionsWithObserveResponse
|
||||
buildHttpRequestOptionsWithObserveResponse, CURRENT_BASE_HREF
|
||||
} from "../utils/utils";
|
||||
|
||||
/**
|
||||
@ -100,7 +100,7 @@ export class ProjectDefaultService extends ProjectService {
|
||||
}
|
||||
let baseUrl: string = this.config.projectBaseEndpoint
|
||||
? this.config.projectBaseEndpoint
|
||||
: "/api/projects";
|
||||
: CURRENT_BASE_HREF + "/projects";
|
||||
return this.http
|
||||
.get<Project>(`${baseUrl}/${projectId}`, HTTP_GET_OPTIONS)
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
@ -114,7 +114,7 @@ export class ProjectDefaultService extends ProjectService {
|
||||
): any {
|
||||
let baseUrl: string = this.config.projectBaseEndpoint
|
||||
? this.config.projectBaseEndpoint
|
||||
: "/api/projects";
|
||||
: CURRENT_BASE_HREF + "/projects";
|
||||
return this.http
|
||||
.put<any>(
|
||||
`${baseUrl}/${projectId}`,
|
||||
@ -145,13 +145,13 @@ export class ProjectDefaultService extends ProjectService {
|
||||
params = params.set('public', '' + isPublic);
|
||||
}
|
||||
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)), );
|
||||
}
|
||||
|
||||
public createProject(name: string, metadata: any, countLimit: number, storageLimit: number): Observable<any> {
|
||||
return this.http
|
||||
.post(`/api/projects`,
|
||||
.post(`${ CURRENT_BASE_HREF }/projects`,
|
||||
JSON.stringify({'project_name': name, 'metadata': {
|
||||
public: metadata.public ? 'true' : 'false',
|
||||
},
|
||||
@ -163,13 +163,13 @@ export class ProjectDefaultService extends ProjectService {
|
||||
|
||||
public deleteProject(projectId: number): Observable<any> {
|
||||
return this.http
|
||||
.delete(`/api/projects/${projectId}`)
|
||||
.delete(`${ CURRENT_BASE_HREF }/projects/${projectId}`)
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public checkProjectExists(projectName: string): Observable<any> {
|
||||
return this.http
|
||||
.head(`/api/projects/?project_name=${projectName}`).pipe(
|
||||
.head(`${ CURRENT_BASE_HREF }/projects/?project_name=${projectName}`).pipe(
|
||||
catchError(error => {
|
||||
if (error && error.status === 404) {
|
||||
return of(error);
|
||||
@ -180,12 +180,12 @@ export class ProjectDefaultService extends ProjectService {
|
||||
|
||||
public checkProjectMember(projectId: number): Observable<any> {
|
||||
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)), );
|
||||
}
|
||||
public getProjectSummary(projectId: number): Observable<any> {
|
||||
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)), );
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,12 @@ import { TestBed, inject } from '@angular/core/testing';
|
||||
import { ReplicationService, ReplicationDefaultService } from './replication.service';
|
||||
import { SharedModule } from '../utils/shared/shared.module';
|
||||
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
||||
import { CURRENT_BASE_HREF } from "../utils/utils";
|
||||
|
||||
describe('ReplicationService', () => {
|
||||
const mockConfig: IServiceConfig = {
|
||||
replicationRuleEndpoint: "/api/policies/replication/testing",
|
||||
replicationBaseEndpoint: "/api/replication/testing"
|
||||
replicationRuleEndpoint: CURRENT_BASE_HREF + "/policies/replication/testing",
|
||||
replicationBaseEndpoint: CURRENT_BASE_HREF + "/replication/testing"
|
||||
};
|
||||
|
||||
let config: IServiceConfig;
|
||||
@ -37,7 +38,7 @@ describe('ReplicationService', () => {
|
||||
|
||||
it('should inject the right config', () => {
|
||||
expect(config).toBeTruthy();
|
||||
expect(config.replicationRuleEndpoint).toEqual("/api/policies/replication/testing");
|
||||
expect(config.replicationBaseEndpoint).toEqual("/api/replication/testing");
|
||||
expect(config.replicationRuleEndpoint).toEqual(CURRENT_BASE_HREF + "/policies/replication/testing");
|
||||
expect(config.replicationBaseEndpoint).toEqual(CURRENT_BASE_HREF + "/replication/testing");
|
||||
});
|
||||
});
|
||||
|
@ -6,7 +6,7 @@ import {
|
||||
HTTP_JSON_OPTIONS,
|
||||
HTTP_GET_OPTIONS,
|
||||
buildHttpRequestOptionsWithObserveResponse,
|
||||
HTTP_GET_OPTIONS_OBSERVE_RESPONSE
|
||||
HTTP_GET_OPTIONS_OBSERVE_RESPONSE, CURRENT_BASE_HREF
|
||||
} from "../utils/utils";
|
||||
import {
|
||||
ReplicationJob,
|
||||
@ -219,11 +219,11 @@ export class ReplicationDefaultService extends ReplicationService {
|
||||
super();
|
||||
this._ruleBaseUrl = config.replicationRuleEndpoint
|
||||
? config.replicationRuleEndpoint
|
||||
: "/api/replication/policies";
|
||||
: CURRENT_BASE_HREF + "/replication/policies";
|
||||
this._replicateUrl = config.replicationBaseEndpoint
|
||||
? config.replicationBaseEndpoint
|
||||
: "/api/replication";
|
||||
this._baseUrl = config.baseEndpoint ? config.baseEndpoint : "/api";
|
||||
: CURRENT_BASE_HREF + "/replication";
|
||||
this._baseUrl = config.baseEndpoint ? config.baseEndpoint : CURRENT_BASE_HREF + "";
|
||||
}
|
||||
|
||||
// Private methods
|
||||
|
@ -2,7 +2,7 @@ import { Label } from "./interface";
|
||||
import { Inject, Injectable } from "@angular/core";
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
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 { map, catchError } from "rxjs/operators";
|
||||
import { Observable, throwError as observableThrowError } from "rxjs";
|
||||
@ -40,7 +40,7 @@ export class LabelDefaultService extends LabelService {
|
||||
super();
|
||||
this._labelUrl = config.labelEndpoint
|
||||
? config.labelEndpoint
|
||||
: "/api/labels";
|
||||
: CURRENT_BASE_HREF + "/labels";
|
||||
}
|
||||
|
||||
getLabels(
|
||||
|
@ -2,7 +2,7 @@ import { Observable } from "rxjs";
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { Injectable, Inject } from "@angular/core";
|
||||
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 { throwError as observableThrowError } from "rxjs/index";
|
||||
import { IServiceConfig, SERVICE_CONFIG } from "../entities/service.config";
|
||||
@ -44,7 +44,7 @@ export class RetagDefaultService extends RetagService {
|
||||
}
|
||||
|
||||
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
|
||||
.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 { SharedModule } from '../utils/shared/shared.module';
|
||||
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
||||
import { CURRENT_BASE_HREF } from "../utils/utils";
|
||||
|
||||
describe('ScanningResultService', () => {
|
||||
const mockConfig: IServiceConfig = {
|
||||
vulnerabilityScanningBaseEndpoint: "/api/vulnerability/testing"
|
||||
vulnerabilityScanningBaseEndpoint: CURRENT_BASE_HREF + "/vulnerability/testing"
|
||||
};
|
||||
|
||||
let config: IServiceConfig;
|
||||
@ -36,6 +37,6 @@ describe('ScanningResultService', () => {
|
||||
|
||||
it('should inject the right config', () => {
|
||||
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 { 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 { VulnerabilityDetail, VulnerabilitySummary } from "./interface";
|
||||
import { map, catchError } from "rxjs/operators";
|
||||
@ -91,7 +96,7 @@ export abstract class ScanningResultService {
|
||||
|
||||
@Injectable()
|
||||
export class ScanningResultDefaultService extends ScanningResultService {
|
||||
_baseUrl: string = "/api/v2.0/projects";
|
||||
_baseUrl: string = CURRENT_BASE_HREF + "/projects";
|
||||
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
@ -151,7 +156,7 @@ export class ScanningResultDefaultService extends ScanningResultService {
|
||||
|
||||
return this.http
|
||||
.post(
|
||||
`/api/v2.0/projects//${projectName}/repositories/${repoName}/artifacts/${artifactId}/scan`,
|
||||
`${ CURRENT_BASE_HREF }/projects//${projectName}/repositories/${repoName}/artifacts/${artifactId}/scan`,
|
||||
HTTP_JSON_OPTIONS
|
||||
)
|
||||
.pipe(map(() => {
|
||||
@ -169,12 +174,12 @@ export class ScanningResultDefaultService extends ScanningResultService {
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
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(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
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(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
@ -3,10 +3,11 @@ import { TestBed, inject } from '@angular/core/testing';
|
||||
import { SystemInfoService, SystemInfoDefaultService } from './system-info.service';
|
||||
import { SharedModule } from '../utils/shared/shared.module';
|
||||
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
||||
import { CURRENT_BASE_HREF } from "../utils/utils";
|
||||
|
||||
describe('SystemInfoService', () => {
|
||||
const mockConfig: IServiceConfig = {
|
||||
systemInfoEndpoint: "/api/systeminfo/testing"
|
||||
systemInfoEndpoint: CURRENT_BASE_HREF + "/systeminfo/testing"
|
||||
};
|
||||
|
||||
let config: IServiceConfig;
|
||||
@ -36,6 +37,6 @@ describe('SystemInfoService', () => {
|
||||
|
||||
it('should inject the right config', () => {
|
||||
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 {SystemCVEWhitelist, SystemInfo} from './interface';
|
||||
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.
|
||||
@ -42,18 +42,18 @@ export class SystemInfoDefaultService extends SystemInfoService {
|
||||
super();
|
||||
}
|
||||
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)
|
||||
.pipe(map(systemInfo => systemInfo as SystemInfo)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
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)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
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)
|
||||
, catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import { TestBed, inject } from '@angular/core/testing';
|
||||
import { SharedModule } from '../utils/shared/shared.module';
|
||||
import { SERVICE_CONFIG, IServiceConfig } from '../entities/service.config';
|
||||
import { TagService, TagDefaultService } from './tag.service';
|
||||
import { CURRENT_BASE_HREF } from "../utils/utils";
|
||||
|
||||
|
||||
describe('TagService', () => {
|
||||
@ -22,7 +23,7 @@ describe('TagService', () => {
|
||||
// ];
|
||||
|
||||
const mockConfig: IServiceConfig = {
|
||||
repositoryBaseEndpoint: "/api/repositories/testing"
|
||||
repositoryBaseEndpoint: CURRENT_BASE_HREF + "/repositories/testing"
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -5,7 +5,7 @@ import { SERVICE_CONFIG, IServiceConfig } from "../entities/service.config";
|
||||
import {
|
||||
buildHttpRequestOptions,
|
||||
HTTP_JSON_OPTIONS,
|
||||
HTTP_GET_OPTIONS
|
||||
HTTP_GET_OPTIONS, CURRENT_BASE_HREF
|
||||
} from "../utils/utils";
|
||||
import { RequestQueryParams } from "./RequestQueryParams";
|
||||
import { Tag, Manifest } from "./interface";
|
||||
@ -89,10 +89,10 @@ export class TagDefaultService extends TagService {
|
||||
super();
|
||||
this._baseUrl = this.config.repositoryBaseEndpoint
|
||||
? this.config.repositoryBaseEndpoint
|
||||
: "/api/repositories";
|
||||
: CURRENT_BASE_HREF + "/repositories";
|
||||
this._labelUrl = this.config.labelEndpoint
|
||||
? this.config.labelEndpoint
|
||||
: "/api/labels";
|
||||
: CURRENT_BASE_HREF + "/labels";
|
||||
}
|
||||
|
||||
public newTag(
|
||||
@ -104,7 +104,7 @@ export class TagDefaultService extends TagService {
|
||||
if (!projectName || !repositoryName || !digest || !tagName) {
|
||||
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
|
||||
.post(url, tagName, HTTP_JSON_OPTIONS)
|
||||
.pipe(map(response => response)
|
||||
@ -121,7 +121,7 @@ export class TagDefaultService extends TagService {
|
||||
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
|
||||
.delete(url, HTTP_JSON_OPTIONS)
|
||||
.pipe(map(response => response)
|
||||
|
@ -6,6 +6,17 @@ import { DebugElement } from '@angular/core';
|
||||
import { Comparator, State, HttpOptionInterface, HttpOptionTextInterface, QuotaUnitInterface } from '../services/interface';
|
||||
import { QuotaUnits, StorageMultipleConstant, LimitCount } from '../entities/shared.const';
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user