File tree Expand file tree Collapse file tree 3 files changed +71
-0
lines changed Expand file tree Collapse file tree 3 files changed +71
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,16 @@ public class KubernetesClientConfigurationTests
23
23
/// </summary>
24
24
private static readonly string kubeConfigUserPassword = "assets/kubeconfig.user-pass.yml" ;
25
25
26
+ /// <summary>
27
+ /// Sample configuration file with incorrect user credentials structures on purpose
28
+ /// </summary>
29
+ private static readonly string kubeConfigNoCredentials = "assets/kubeconfig.no-credentials.yml" ;
30
+
31
+ /// <summary>
32
+ /// Sample configuration file with incorrect cluster/server structure on purpose
33
+ /// </summary>
34
+ private static readonly string kubeConfigNoServer = "assets/kubeconfig.no-server.yml" ;
35
+
26
36
/// <summary>
27
37
/// The configuration file is not present. An KubeConfigException should be thrown
28
38
/// </summary>
@@ -132,6 +142,26 @@ public void UserPasswordAuthentication()
132
142
Assert . Equal ( "secret" , cfg . Password ) ;
133
143
}
134
144
145
+ /// <summary>
146
+ /// Checks that a KubeConfigException is thrown when incomplete user credentials
147
+ /// </summary>
148
+ [ Fact ]
149
+ public void IncompleteUserCredentials ( )
150
+ {
151
+ var fi = new FileInfo ( kubeConfigNoCredentials ) ;
152
+ Assert . Throws < k8s . Exceptions . KubeConfigException > ( ( ) => new KubernetesClientConfiguration ( fi ) ) ;
153
+ }
154
+
155
+ /// <summary>
156
+ /// Checks that a KubeConfigException is thrown when the server property is not set in cluster
157
+ /// </summary>
158
+ [ Fact ]
159
+ public void ServerNotFound ( )
160
+ {
161
+ var fi = new FileInfo ( kubeConfigNoServer ) ;
162
+ Assert . Throws < k8s . Exceptions . KubeConfigException > ( ( ) => new KubernetesClientConfiguration ( fi ) ) ;
163
+ }
164
+
135
165
// /// <summary>
136
166
// /// Checks if the are pods
137
167
// /// </summary>
Original file line number Diff line number Diff line change
1
+ # Sample file based on https://kubernetes.io/docs/tasks/access-application-cluster/authenticate-across-clusters-kubeconfig/
2
+ # WARNING: File includes minor fixes
3
+ ---
4
+ current-context : federal-context
5
+ apiVersion : v1
6
+ clusters :
7
+ - cluster :
8
+ certificate-authority-data : path/to/my/cafile
9
+ server : https://horse.org:4443
10
+ name : horse-cluster
11
+ contexts :
12
+ - context :
13
+ cluster : horse-cluster
14
+ namespace : chisel-ns
15
+ user : green-user
16
+ name : federal-context
17
+ kind : Config
18
+ users :
19
+ - name : green-user
20
+ user:
Original file line number Diff line number Diff line change
1
+ # Sample file based on https://kubernetes.io/docs/tasks/access-application-cluster/authenticate-across-clusters-kubeconfig/
2
+ # WARNING: File includes minor fixes
3
+ ---
4
+ current-context : federal-context
5
+ apiVersion : v1
6
+ clusters :
7
+ - cluster :
8
+ certificate-authority-data : path/to/my/cafile
9
+ name : horse-cluster
10
+ contexts :
11
+ - context :
12
+ cluster : horse-cluster
13
+ namespace : chisel-ns
14
+ user : green-user
15
+ name : federal-context
16
+ kind : Config
17
+ users :
18
+ - name : green-user
19
+ user :
20
+ password : secret
21
+ username : admin
You can’t perform that action at this time.
0 commit comments