diff --git a/integration/hello-world/e2e/interceptors.spec.ts b/integration/hello-world/e2e/interceptors.spec.ts index 4dcdb9ab0..dbfb7ed9a 100644 --- a/integration/hello-world/e2e/interceptors.spec.ts +++ b/integration/hello-world/e2e/interceptors.spec.ts @@ -44,12 +44,16 @@ export class StatusInterceptor { @Injectable() export class HeaderInterceptor { - constructor(private authorization: string){} + constructor(private headers: object){} intercept(context: ExecutionContext, next: CallHandler) { const ctx = context.switchToHttp(); const res = ctx.getResponse(); - res.header('Authorization', this.authorization); + for (const key in this.headers) { + if (this.headers.hasOwnProperty(key)) { + res.header(key, this.headers[key]); + } + } return next.handle().pipe(map(data => ({ data }))); } } @@ -125,8 +129,12 @@ describe('Interceptors', () => { }); it(`should modify Authorization header`, async () => { + const customHeaders = { + Authorization: 'jwt', + }; + app = (await createTestModule( - new HeaderInterceptor('jwt'), + new HeaderInterceptor(customHeaders), )).createNestApplication(); await app.init(); diff --git a/scripts/test.sh b/scripts/test.sh old mode 100644 new mode 100755