Skip to content

Commit a2c3ec6

Browse files
committed
test: change assignments of authorization headers
1 parent ecff6ab commit a2c3ec6

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/config_test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ describe('KubeConfig', () => {
962962
const opts = {} as RequestOptions;
963963

964964
await config.applyToHTTPSOptions(opts);
965-
strictEqual(opts.headers!.Authorization, `Bearer ${token}`);
965+
strictEqual(opts.headers!['Authorization'], `Bearer ${token}`);
966966
});
967967
it('should populate from auth provider', async () => {
968968
const config = new KubeConfig();
@@ -982,11 +982,11 @@ describe('KubeConfig', () => {
982982
const opts = {} as RequestOptions;
983983

984984
await config.applyToHTTPSOptions(opts);
985-
strictEqual(opts.headers!.Authorization, `Bearer ${token}`);
985+
strictEqual(opts.headers!['Authorization'], `Bearer ${token}`);
986986
opts.headers = {};
987987
opts.headers.Host = 'foo.com';
988988
await config.applyToHTTPSOptions(opts);
989-
strictEqual(opts.headers.Authorization, `Bearer ${token}`);
989+
strictEqual(opts.headers!['Authorization'], `Bearer ${token}`);
990990
});
991991

992992
it('should populate from auth provider without expirty', async () => {
@@ -1006,7 +1006,7 @@ describe('KubeConfig', () => {
10061006
const opts = {} as RequestOptions;
10071007

10081008
await config.applyToHTTPSOptions(opts);
1009-
strictEqual(opts.headers!.Authorization, `Bearer ${token}`);
1009+
strictEqual(opts.headers!['Authorization'], `Bearer ${token}`);
10101010
});
10111011

10121012
it('should populate rejectUnauthorized=false when skipTLSVerify is set', async () => {
@@ -1115,7 +1115,7 @@ describe('KubeConfig', () => {
11151115
);
11161116
const opts = {} as RequestOptions;
11171117
await config.applyToHTTPSOptions(opts);
1118-
strictEqual(opts.headers!.Authorization, `Bearer ${token}`);
1118+
strictEqual(opts.headers!['Authorization'], `Bearer ${token}`);
11191119
});
11201120

11211121
it('should exec with expired token', async () => {
@@ -1143,7 +1143,7 @@ describe('KubeConfig', () => {
11431143
);
11441144
const opts = {} as RequestOptions;
11451145
await config.applyToHTTPSOptions(opts);
1146-
strictEqual(opts.headers!.Authorization, `Bearer ${token}`);
1146+
strictEqual(opts.headers!['Authorization'], `Bearer ${token}`);
11471147
});
11481148

11491149
it('should exec without access-token', async () => {
@@ -1170,7 +1170,7 @@ describe('KubeConfig', () => {
11701170
);
11711171
const opts = {} as RequestOptions;
11721172
await config.applyToHTTPSOptions(opts);
1173-
strictEqual(opts.headers!.Authorization, `Bearer ${token}`);
1173+
strictEqual(opts.headers!['Authorization'], `Bearer ${token}`);
11741174
});
11751175
it('should exec without access-token', async () => {
11761176
// TODO: fix this test for Windows
@@ -1196,7 +1196,7 @@ describe('KubeConfig', () => {
11961196
);
11971197
const opts = {} as RequestOptions;
11981198
await config.applyToHTTPSOptions(opts);
1199-
strictEqual(opts.headers!.Authorization, `Bearer ${token}`);
1199+
strictEqual(opts.headers!['Authorization'], `Bearer ${token}`);
12001200
});
12011201
it('should exec succesfully with spaces in cmd', async () => {
12021202
// TODO: fix this test for Windows
@@ -1222,7 +1222,7 @@ describe('KubeConfig', () => {
12221222
);
12231223
const opts = {} as RequestOptions;
12241224
await config.applyToHTTPSOptions(opts);
1225-
strictEqual(opts.headers!.Authorization, `Bearer ${token}`);
1225+
strictEqual(opts.headers!['Authorization'], `Bearer ${token}`);
12261226
});
12271227
it('should exec with exec auth and env vars', async () => {
12281228
// TODO: fix this test for Windows
@@ -1255,7 +1255,7 @@ describe('KubeConfig', () => {
12551255
// TODO: inject the exec command here and validate env vars?
12561256
const opts = {} as RequestOptions;
12571257
await config.applyToHTTPSOptions(opts);
1258-
strictEqual(opts.headers!.Authorization, `Bearer ${token}`);
1258+
strictEqual(opts.headers!['Authorization'], `Bearer ${token}`);
12591259
});
12601260
it('should exec with exec auth', async () => {
12611261
// TODO: fix this test for Windows
@@ -1288,7 +1288,7 @@ describe('KubeConfig', () => {
12881288
// TODO: inject the exec command here?
12891289
const opts = {} as RequestOptions;
12901290
await config.applyToHTTPSOptions(opts);
1291-
strictEqual(opts.headers!.Authorization, `Bearer ${token}`);
1291+
strictEqual(opts.headers!['Authorization'], `Bearer ${token}`);
12921292
});
12931293
it('should exec with exec auth (other location)', async () => {
12941294
// TODO: fix this test for Windows
@@ -1316,7 +1316,7 @@ describe('KubeConfig', () => {
13161316
// TODO: inject the exec command here?
13171317
const opts = {} as RequestOptions;
13181318
await config.applyToHTTPSOptions(opts);
1319-
strictEqual(opts.headers!.Authorization, `Bearer ${token}`);
1319+
strictEqual(opts.headers!['Authorization'], `Bearer ${token}`);
13201320
});
13211321
it('should cache exec with name', async () => {
13221322
// TODO: fix this test for Windows
@@ -1776,7 +1776,7 @@ describe('KubeConfig', () => {
17761776
// Simulate token retrieval
17771777
const token = 'test-token';
17781778
opts.headers = opts.headers || {};
1779-
opts.headers.Authorization = `Bearer ${token}`;
1779+
opts.headers['Authorization'] = `Bearer ${token}`;
17801780
} else {
17811781
throw new Error('No custom configuration found');
17821782
}
@@ -1802,7 +1802,7 @@ describe('KubeConfig', () => {
18021802
const opts: RequestOptions = {};
18031803
await kc.applyToHTTPSOptions(opts);
18041804

1805-
strictEqual(opts.headers!.Authorization, 'Bearer test-token');
1805+
strictEqual(opts.headers!['Authorization'], 'Bearer test-token');
18061806
});
18071807
});
18081808

src/exec_auth_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ describe('ExecAuth', () => {
486486
},
487487
opts,
488488
);
489-
strictEqual(opts.headers?.Authorization, 'Bearer foo');
489+
strictEqual(opts.headers!['Authorization'], 'Bearer foo');
490490
});
491491
it('should handle null credentials correctly', async () => {
492492
const auth = new ExecAuth();

0 commit comments

Comments
 (0)