From 3573789628e048915c7a163de85f4d6990fa9f43 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 03:04:09 +0000 Subject: [PATCH 1/3] build(deps): bump @types/node from 22.15.11 to 22.15.14 Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 22.15.11 to 22.15.14. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-version: 22.15.14 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9dcae7a648..f629079291 100644 --- a/package-lock.json +++ b/package-lock.json @@ -992,9 +992,9 @@ } }, "node_modules/@types/node": { - "version": "22.15.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.11.tgz", - "integrity": "sha512-rlyK0vuU7VLEYQfXuC7QTFxDvkb6tKhDI7wR4r6ZzM0k8BJd44W0jxo6xmUjqSs4AlYmiYfLJU2f0pAG/FtCRw==", + "version": "22.15.14", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.14.tgz", + "integrity": "sha512-BL1eyu/XWsFGTtDWOYULQEs4KR0qdtYfCxYAUYRoB7JP7h9ETYLgQTww6kH8Sj2C0pFGgrpM0XKv6/kbIzYJ1g==", "license": "MIT", "dependencies": { "undici-types": "~6.21.0" From ecff6ab785a08e33f620403f24ded33bc233fe62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Str=C3=BCbing?= Date: Wed, 7 May 2025 09:54:01 +0200 Subject: [PATCH 2/3] refactor: assign authorization header correctly --- src/azure_auth.ts | 2 +- src/exec_auth.ts | 2 +- src/file_auth.ts | 2 +- src/gcp_auth.ts | 2 +- src/oidc_auth.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/azure_auth.ts b/src/azure_auth.ts index 1b69048ddd..2db7c6601e 100644 --- a/src/azure_auth.ts +++ b/src/azure_auth.ts @@ -29,7 +29,7 @@ export class AzureAuth implements Authenticator { public async applyAuthentication(user: User, opts: https.RequestOptions): Promise { const token = this.getToken(user); if (token) { - opts.headers!.Authorization = `Bearer ${token}`; + opts.headers!['Authorization'] = `Bearer ${token}`; } } diff --git a/src/exec_auth.ts b/src/exec_auth.ts index 3ac70dfa4e..fbd97a26f8 100644 --- a/src/exec_auth.ts +++ b/src/exec_auth.ts @@ -56,7 +56,7 @@ export class ExecAuth implements Authenticator { if (!opts.headers) { opts.headers = {} as OutgoingHttpHeaders; } - opts.headers!.Authorization = `Bearer ${token}`; + opts.headers!['Authorization'] = `Bearer ${token}`; } } diff --git a/src/file_auth.ts b/src/file_auth.ts index b8b7644636..d6d4f56c9b 100644 --- a/src/file_auth.ts +++ b/src/file_auth.ts @@ -20,7 +20,7 @@ export class FileAuth implements Authenticator { this.refreshToken(user.authProvider.config.tokenFile); } if (this.token) { - opts.headers!.Authorization = `Bearer ${this.token}`; + opts.headers!['Authorization'] = `Bearer ${this.token}`; } } diff --git a/src/gcp_auth.ts b/src/gcp_auth.ts index 0f3d680e08..1bf1089618 100644 --- a/src/gcp_auth.ts +++ b/src/gcp_auth.ts @@ -28,7 +28,7 @@ export class GoogleCloudPlatformAuth implements Authenticator { public async applyAuthentication(user: User, opts: https.RequestOptions): Promise { const token = this.getToken(user); if (token) { - opts.headers!.Authorization = `Bearer ${token}`; + opts.headers!['Authorization'] = `Bearer ${token}`; } } diff --git a/src/oidc_auth.ts b/src/oidc_auth.ts index af5e0c1311..f8c1536ac9 100644 --- a/src/oidc_auth.ts +++ b/src/oidc_auth.ts @@ -85,7 +85,7 @@ export class OpenIDConnectAuth implements Authenticator { ): Promise { const token = await this.getToken(user, overrideClient); if (token) { - opts.headers!.Authorization = `Bearer ${token}`; + opts.headers!['Authorization'] = `Bearer ${token}`; } } From a2c3ec61d175a0b3a06f92779a825f5c860ef2cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Str=C3=BCbing?= Date: Wed, 7 May 2025 09:56:58 +0200 Subject: [PATCH 3/3] test: change assignments of authorization headers --- src/config_test.ts | 28 ++++++++++++++-------------- src/exec_auth_test.ts | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/config_test.ts b/src/config_test.ts index c2544a82e8..ea8e4e2dc1 100644 --- a/src/config_test.ts +++ b/src/config_test.ts @@ -962,7 +962,7 @@ describe('KubeConfig', () => { const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should populate from auth provider', async () => { const config = new KubeConfig(); @@ -982,11 +982,11 @@ describe('KubeConfig', () => { const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); opts.headers = {}; opts.headers.Host = 'foo.com'; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should populate from auth provider without expirty', async () => { @@ -1006,7 +1006,7 @@ describe('KubeConfig', () => { const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should populate rejectUnauthorized=false when skipTLSVerify is set', async () => { @@ -1115,7 +1115,7 @@ describe('KubeConfig', () => { ); const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should exec with expired token', async () => { @@ -1143,7 +1143,7 @@ describe('KubeConfig', () => { ); const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should exec without access-token', async () => { @@ -1170,7 +1170,7 @@ describe('KubeConfig', () => { ); const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should exec without access-token', async () => { // TODO: fix this test for Windows @@ -1196,7 +1196,7 @@ describe('KubeConfig', () => { ); const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should exec succesfully with spaces in cmd', async () => { // TODO: fix this test for Windows @@ -1222,7 +1222,7 @@ describe('KubeConfig', () => { ); const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should exec with exec auth and env vars', async () => { // TODO: fix this test for Windows @@ -1255,7 +1255,7 @@ describe('KubeConfig', () => { // TODO: inject the exec command here and validate env vars? const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should exec with exec auth', async () => { // TODO: fix this test for Windows @@ -1288,7 +1288,7 @@ describe('KubeConfig', () => { // TODO: inject the exec command here? const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should exec with exec auth (other location)', async () => { // TODO: fix this test for Windows @@ -1316,7 +1316,7 @@ describe('KubeConfig', () => { // TODO: inject the exec command here? const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should cache exec with name', async () => { // TODO: fix this test for Windows @@ -1776,7 +1776,7 @@ describe('KubeConfig', () => { // Simulate token retrieval const token = 'test-token'; opts.headers = opts.headers || {}; - opts.headers.Authorization = `Bearer ${token}`; + opts.headers['Authorization'] = `Bearer ${token}`; } else { throw new Error('No custom configuration found'); } @@ -1802,7 +1802,7 @@ describe('KubeConfig', () => { const opts: RequestOptions = {}; await kc.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, 'Bearer test-token'); + strictEqual(opts.headers!['Authorization'], 'Bearer test-token'); }); }); diff --git a/src/exec_auth_test.ts b/src/exec_auth_test.ts index 9be3e262d5..e323b5880e 100644 --- a/src/exec_auth_test.ts +++ b/src/exec_auth_test.ts @@ -486,7 +486,7 @@ describe('ExecAuth', () => { }, opts, ); - strictEqual(opts.headers?.Authorization, 'Bearer foo'); + strictEqual(opts.headers!['Authorization'], 'Bearer foo'); }); it('should handle null credentials correctly', async () => { const auth = new ExecAuth();