diff --git a/goofy-client/libs/environment-shared/src/index.ts b/goofy-client/libs/environment-shared/src/index.ts index 383ec972f1ababfc899ce9e307289b6d9219b772..f7eb1ed0c419f217608d6a6a155bfa0cd4c63e83 100644 --- a/goofy-client/libs/environment-shared/src/index.ts +++ b/goofy-client/libs/environment-shared/src/index.ts @@ -21,6 +21,6 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -export * from './lib/environment.model'; export * from './lib/environment.module'; export * from './lib/environment.service'; + diff --git a/goofy-client/libs/tech-shared/src/lib/interceptor/xhr.interceptor.spec.ts b/goofy-client/libs/tech-shared/src/lib/interceptor/xhr.interceptor.spec.ts index f324e0cc6c1562ddebdb2d44c2685f9fb0b84489..5b91bc43068843b7fcc84c5791146696c0a2557e 100644 --- a/goofy-client/libs/tech-shared/src/lib/interceptor/xhr.interceptor.spec.ts +++ b/goofy-client/libs/tech-shared/src/lib/interceptor/xhr.interceptor.spec.ts @@ -22,44 +22,27 @@ * unter der Lizenz sind dem Lizenztext zu entnehmen. */ import { HttpRequest } from '@angular/common/http'; -import { Environment } from '@goofy-client/environment-shared'; +import { faker } from '@faker-js/faker'; +import { HttpMethod } from '../tech.model'; import { XhrInterceptor } from './xhr.interceptor'; describe('XhrInterceptor', () => { let interceptor: XhrInterceptor; - const apiHost: string = 'http://kop/api' - const apiUrl: string = apiHost + '/vorgaenge'; - const nonApiUrl: string = 'http://kop/vorgang/123'; - const envConfig: Environment = { - remoteHost: apiHost, - authServer: '', - clientId: '', - realm: '', - production: false - }; + const url: string = faker.internet.url(); beforeEach(() => { - interceptor = new XhrInterceptor(envConfig); + interceptor = new XhrInterceptor(); }) it('should be created', () => { expect(interceptor).toBeTruthy(); }); - describe('isApiRequest', () => { - it('should return true for API URL', () => { - expect(interceptor.isApiRequest(apiUrl)).toBeTruthy() - }) - - it('should return false for non-API URL', () => { - expect(interceptor.isApiRequest(nonApiUrl)).toBeFalsy() - }) - }) - describe('addHeader', () => { + it('should add X-Requested-With header', () => { - const request: HttpRequest<unknown> = new HttpRequest('GET', apiUrl); + const request: HttpRequest<unknown> = new HttpRequest(HttpMethod.GET, url); const result: HttpRequest<unknown> = interceptor.addHeader(request); diff --git a/goofy-client/libs/tech-shared/src/lib/interceptor/xhr.interceptor.ts b/goofy-client/libs/tech-shared/src/lib/interceptor/xhr.interceptor.ts index a62b7a5ee796a1056dfa4bde088e0e2b9f6a8767..6d606a89bdca4aa6290ea82f5ab04d44d864a326 100644 --- a/goofy-client/libs/tech-shared/src/lib/interceptor/xhr.interceptor.ts +++ b/goofy-client/libs/tech-shared/src/lib/interceptor/xhr.interceptor.ts @@ -22,26 +22,14 @@ * unter der Lizenz sind dem Lizenztext zu entnehmen. */ import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http'; -import { Inject, Injectable } from '@angular/core'; -import { Environment, ENVIRONMENT_CONFIG } from '@goofy-client/environment-shared'; +import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; @Injectable() export class XhrInterceptor implements HttpInterceptor { - constructor(@Inject(ENVIRONMENT_CONFIG) private envConfig: Environment) { - } - intercept(req: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> { - if (this.isApiRequest(req.url)) { - return next.handle(this.addHeader(req)); - } - return next.handle(req); - } - - isApiRequest(url: string): boolean { - const urlObject: URL = new URL(url); - return urlObject.pathname.startsWith('/api'); + return next.handle(this.addHeader(req)); } addHeader(req: HttpRequest<unknown>): HttpRequest<unknown> {