|
1 | 1 | import { readFileSync } from 'fs';
|
2 | 2 | import * as https from 'https';
|
| 3 | +import { Agent, RequestOptions } from 'https'; |
3 | 4 | import { join } from 'path';
|
4 |
| -import { RequestOptions, Agent } from 'https'; |
5 | 5 |
|
6 | 6 | import { expect, use } from 'chai';
|
7 | 7 | import chaiAsPromised from 'chai-as-promised';
|
8 | 8 | import mockfs = require('mock-fs');
|
9 | 9 | import * as path from 'path';
|
10 | 10 |
|
| 11 | +import { Headers } from 'node-fetch'; |
| 12 | +import { HttpMethod } from '.'; |
| 13 | +import { assertRequestAgentsEqual, assertRequestOptionsEqual } from '../test/match-buffer'; |
11 | 14 | import { CoreV1Api, RequestContext } from './api';
|
12 | 15 | import { bufferFromFileOrString, findHomeDir, findObject, KubeConfig, makeAbsolutePath } from './config';
|
13 |
| -import { Cluster, newClusters, newContexts, newUsers, User, ActionOnInvalid } from './config_types'; |
| 16 | +import { ActionOnInvalid, Cluster, newClusters, newContexts, newUsers, User } from './config_types'; |
14 | 17 | import { ExecAuth } from './exec_auth';
|
15 |
| -import { HttpMethod } from '.'; |
16 |
| -import { assertRequestOptionsEqual, assertRequestAgentsEqual } from '../test/match-buffer'; |
17 |
| -import { Headers } from 'node-fetch'; |
18 | 18 |
|
19 | 19 | const kcFileName = 'testdata/kubeconfig.yaml';
|
20 | 20 | const kc2FileName = 'testdata/kubeconfig-2.yaml';
|
@@ -264,16 +264,10 @@ describe('KubeConfig', () => {
|
264 | 264 | expect(requestInit.method).to.equal('POST');
|
265 | 265 | expect(requestInit.timeout).to.equal(5);
|
266 | 266 | expect((requestInit.headers as Headers).raw()).to.deep.equal({
|
267 |
| - "list": [ |
268 |
| - "a", |
269 |
| - "b", |
270 |
| - ], |
271 |
| - "number": [ |
272 |
| - "5", |
273 |
| - ], |
274 |
| - "string": [ |
275 |
| - "str", |
276 |
| - ], |
| 267 | + Authorization: ['Basic Zm9vOmJhcg=='], |
| 268 | + list: ['a', 'b'], |
| 269 | + number: ['5'], |
| 270 | + string: ['str'], |
277 | 271 | });
|
278 | 272 | assertRequestAgentsEqual(requestInit.agent as Agent, expectedAgent);
|
279 | 273 | });
|
@@ -316,7 +310,7 @@ describe('KubeConfig', () => {
|
316 | 310 | pfx: undefined,
|
317 | 311 | rejectUnauthorized: false,
|
318 | 312 | });
|
319 |
| - let expectedOptions: https.RequestOptions = { |
| 313 | + const expectedOptions: https.RequestOptions = { |
320 | 314 | auth: 'foo:bar',
|
321 | 315 | headers: {},
|
322 | 316 | rejectUnauthorized: false,
|
@@ -1180,10 +1174,10 @@ describe('KubeConfig', () => {
|
1180 | 1174 | // TODO: inject the exec command here?
|
1181 | 1175 | const opts = {} as RequestOptions;
|
1182 | 1176 | await config.applytoHTTPSOptions(opts);
|
1183 |
| - let execAuthenticator = (KubeConfig as any).authenticators.find( |
| 1177 | + const execAuthenticator = (KubeConfig as any).authenticators.find( |
1184 | 1178 | (authenticator) => authenticator instanceof ExecAuth,
|
1185 | 1179 | );
|
1186 |
| - expect(execAuthenticator.tokenCache['exec']).to.deep.equal(JSON.parse(responseStr)); |
| 1180 | + expect(execAuthenticator.tokenCache.exec).to.deep.equal(JSON.parse(responseStr)); |
1187 | 1181 | });
|
1188 | 1182 |
|
1189 | 1183 | it('should throw with no command.', () => {
|
@@ -1273,7 +1267,7 @@ describe('KubeConfig', () => {
|
1273 | 1267 | const kc = new KubeConfig();
|
1274 | 1268 | kc.addCluster({
|
1275 | 1269 | name: 'testCluster',
|
1276 |
| - server: `https://localhost:9889`, |
| 1270 | + server: 'https://localhost:9889', |
1277 | 1271 | skipTLSVerify: true,
|
1278 | 1272 | caFile: 'foo/bar.crt',
|
1279 | 1273 | });
|
@@ -1509,7 +1503,7 @@ describe('KubeConfig', () => {
|
1509 | 1503 | (kc as any).clusters = undefined;
|
1510 | 1504 | kc.addCluster({
|
1511 | 1505 | name: 'testCluster',
|
1512 |
| - server: `https://localhost:9889`, |
| 1506 | + server: 'https://localhost:9889', |
1513 | 1507 | skipTLSVerify: true,
|
1514 | 1508 | });
|
1515 | 1509 | (kc as any).users = undefined;
|
|
0 commit comments