Skip to content

Commit 9e62f86

Browse files
committed
Add a test for empty users.
1 parent f5478f7 commit 9e62f86

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/config_test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { KubeConfig } from './config';
1111
import { Cluster, newClusters, newContexts, newUsers, User } from './config_types';
1212

1313
const kcFileName = 'testdata/kubeconfig.yaml';
14+
const kcNoUserFileName = 'testdata/empty-user-kubeconfig.yaml';
1415

1516
/* tslint:disable: no-empty */
1617
describe('Config', () => { });
@@ -165,6 +166,13 @@ describe('KubeConfig', () => {
165166
});
166167
});
167168

169+
describe('loadEmptyUser', () => {
170+
it('should load a kubeconfig with an empty user', () => {
171+
const kc = new KubeConfig();
172+
kc.loadFromFile(kcNoUserFileName);
173+
});
174+
});
175+
168176
describe('applyHTTPSOptions', () => {
169177
it('should apply cert configs', () => {
170178
const kc = new KubeConfig();

testdata/empty-user-kubeconfig.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: v1
2+
clusters:
3+
- cluster:
4+
certificate-authority-data: Q0FEQVRB
5+
server: http://example.com
6+
name: cluster1
7+
- cluster:
8+
certificate-authority-data: Q0FEQVRBMg==
9+
server: http://example2.com
10+
insecure-skip-tls-verify: true
11+
name: cluster2
12+
13+
contexts:
14+
- context:
15+
cluster: cluster1
16+
user: user1
17+
name: context1
18+
- context:
19+
cluster: cluster2
20+
user: user2
21+
name: context2
22+
23+
current-context: context2
24+
kind: Config
25+
preferences: {}
26+
users:
27+
- name: user1
28+
user:
29+
- name: user2

0 commit comments

Comments
 (0)