From 524d1be20087cea9e4ee53b791972608894f16bd Mon Sep 17 00:00:00 2001 From: Mike Delez <60604010+mdelez@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:38:11 +0200 Subject: [PATCH 1/2] chore!: remove zio endpoint implementation --- src/api/endpoint.ts | 2 +- src/knora-api-config.spec.ts | 56 ++---------------------------------- src/knora-api-config.ts | 22 -------------- 3 files changed, 3 insertions(+), 77 deletions(-) diff --git a/src/api/endpoint.ts b/src/api/endpoint.ts index aa5e2de08..d425e0620 100644 --- a/src/api/endpoint.ts +++ b/src/api/endpoint.ts @@ -233,7 +233,7 @@ export class Endpoint { */ private setAjaxRequest(path: string, method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", body?: any, headers?: IHeaderOptions): AjaxRequest { - let apiUrl = this.knoraApiConfig.zioEndpointsList.includes(this.path) ? this.knoraApiConfig.zioApiUrl : this.knoraApiConfig.apiUrl; + let apiUrl = this.knoraApiConfig.apiUrl; let ajaxRequest: AjaxRequest = { url: apiUrl + this.path + path, diff --git a/src/knora-api-config.spec.ts b/src/knora-api-config.spec.ts index 3f1a455a5..a0c17dbec 100644 --- a/src/knora-api-config.spec.ts +++ b/src/knora-api-config.spec.ts @@ -11,8 +11,6 @@ describe("Test class KnoraApiConfig", () => { apiPath?: string; jsonWebToken?: string; logErrors?: boolean; - zioPrefix?: "/zio" | ":5555"; - zioEndpoints?: string[] } it("should verify parameters", () => { @@ -42,8 +40,6 @@ describe("Test class KnoraApiConfig", () => { apiPort: 1234, apiPath: "/api", jsonWebToken: "GAGA", - zioPrefix: "/zio", - zioEndpoints: ['/admin/projects'], }, { apiProtocol: "http", @@ -52,8 +48,6 @@ describe("Test class KnoraApiConfig", () => { apiPath: "/api", jsonWebToken: "GAGA", logErrors: false, - zioPrefix: ":5555", - zioEndpoints: ['/admin/projects'], }, { apiProtocol: "http", @@ -62,14 +56,12 @@ describe("Test class KnoraApiConfig", () => { apiPath: "/api", jsonWebToken: "GAGA", logErrors: true, - zioPrefix: ":5555", - zioEndpoints: ['/admin/projects'], } ]; - params.forEach(({apiProtocol, apiHost, apiPort, apiPath, jsonWebToken, logErrors, zioPrefix, zioEndpoints}) => { + params.forEach(({apiProtocol, apiHost, apiPort, apiPath, jsonWebToken, logErrors}) => { - const config = new KnoraApiConfig(apiProtocol, apiHost, apiPort, apiPath, jsonWebToken, logErrors , zioPrefix, zioEndpoints); + const config = new KnoraApiConfig(apiProtocol, apiHost, apiPort, apiPath, jsonWebToken, logErrors); expect(config).toEqual(jasmine.any(KnoraApiConfig)); expect(config.apiProtocol).toEqual(apiProtocol); @@ -88,8 +80,6 @@ describe("Test class KnoraApiConfig", () => { expect(config.apiPath).toEqual(apiPath === undefined ? "" : apiPath); expect(config.jsonWebToken).toEqual(jsonWebToken === undefined ? "" : jsonWebToken); expect(config.logErrors).toEqual(logErrors === undefined ? false : logErrors); - expect(config.zioPrefix).toEqual(zioPrefix === undefined ? "/zio" : zioPrefix) - expect(config.zioEndpoints).toEqual(zioEndpoints === undefined ? [] : zioEndpoints) }); @@ -151,46 +141,4 @@ describe("Test class KnoraApiConfig", () => { }); - describe("Test property zioApiUrl", () => { - - interface IZioApiUrlData { - param: { - apiProtocol: "http" | "https", - apiHost: string, - zioPrefix?: "/zio" | ":5555", - apiPath?: string, - }; - result: string; - } - - it("should return correct value", () => { - - const data: IZioApiUrlData[] = [ - { - param: {apiProtocol: "http", apiHost: "domain.com", zioPrefix: "/zio"}, - result: "http://domain.com/zio" - }, - { - param: {apiProtocol: "http", apiHost: "domain.com", zioPrefix: ":5555"}, - result: "http://domain.com:5555" - }, - { - param: {apiProtocol: "http", apiHost: "domain.com", zioPrefix: "/zio", apiPath: "/api"}, - result: "http://domain.com/zio/api" - }, - { - param: {apiProtocol: "http", apiHost: "domain.com", zioPrefix: ":5555", apiPath: "/api"}, - result: "http://domain.com:5555/api" - } - ]; - - data.forEach(({param, result}) => { - const config = new KnoraApiConfig(param.apiProtocol, param.apiHost, null, param.apiPath, undefined, false, param.zioPrefix); - expect(config.zioApiUrl).toBe(result); - }); - - }); - - }); - }); diff --git a/src/knora-api-config.ts b/src/knora-api-config.ts index 90d77e0e1..2dcafdd6a 100644 --- a/src/knora-api-config.ts +++ b/src/knora-api-config.ts @@ -22,24 +22,6 @@ export class KnoraApiConfig { ); } - /** - * The full zio http API URL - */ - get zioApiUrl(): string { - return ( - (this.apiProtocol + "://" + this.apiHost) + - this.zioPrefix + - this.apiPath - ); - } - - /** - * List of endpoints using zio http - */ - get zioEndpointsList(): string[] { - return this.zioEndpoints; - } - /** * @param apiProtocol the protocol of the API (http or https) * @param apiHost the DSP-API base URL @@ -47,8 +29,6 @@ export class KnoraApiConfig { * @param apiPath the base path following host and port, if any. * @param jsonWebToken token to identify the user * @param logErrors determines whether errors should be logged to the console - * @param zioPrefix prefix for zio routes, ":5555" is used locally whereas "/zio" is used on servers - * @param zioEndpoints list of zio endpoints */ constructor(public apiProtocol: "http" | "https", public apiHost: string, @@ -56,8 +36,6 @@ export class KnoraApiConfig { public apiPath: string = "", public jsonWebToken: string = "", public logErrors: boolean = false, - public zioPrefix: "/zio" | ":5555" = "/zio", - public zioEndpoints: string[] = [] ) { // Remove port in case it's the default one From c2bf5ea293662cbc3c4d151319811ceae83d03ae Mon Sep 17 00:00:00 2001 From: Mike Delez <60604010+mdelez@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:46:20 +0200 Subject: [PATCH 2/2] fix e2e tests --- test-framework/src/app/app.component.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test-framework/src/app/app.component.ts b/test-framework/src/app/app.component.ts index 21b0bba58..fb1dfbc94 100644 --- a/test-framework/src/app/app.component.ts +++ b/test-framework/src/app/app.component.ts @@ -176,8 +176,7 @@ export class AppComponent implements OnInit { undefined, undefined, true, - ':5555', - ['/admin/projects']); + ); this.knoraApiConnection = new KnoraApiConnection(config); // console.log(this.knoraApiConnection); this.userCache = new UserCache(this.knoraApiConnection);