@@ -36,7 +36,22 @@ public class KubernetesClientConfigurationTests
36
36
/// <summary>
37
37
/// Sample configuration file with incorrect cluster/server structure on purpose
38
38
/// </summary>
39
- private static readonly string kubeConfigNoCluster = "assets/kubeconfig.no-cluster.yml" ;
39
+ private static readonly string kubeConfigNoCluster = "assets/kubeconfig.no-cluster.yml" ;
40
+
41
+ /// <summary>
42
+ /// Sample configuration file with incorrect match in cluster name
43
+ /// </summary>
44
+ private static readonly string kubeConfigClusterMissmatch = "assets/kubeconfig.cluster-missmatch.yml" ;
45
+
46
+ /// <summary>
47
+ /// Sample configuration file with incorrect TLS configuration in cluster section
48
+ /// </summary>
49
+ private static readonly string kubeConfigTlsNoSkipError = "assets/kubeconfig.tls-no-skip-error.yml" ;
50
+
51
+ /// <summary>
52
+ /// Sample configuration file with incorrect TLS configuration in cluster section
53
+ /// </summary>
54
+ private static readonly string kubeConfigTlsSkip = "assets/kubeconfig.tls-skip.yml" ;
40
55
41
56
/// <summary>
42
57
/// The configuration file is not present. An KubeConfigException should be thrown
@@ -175,6 +190,39 @@ public void ClusterNotFound()
175
190
{
176
191
var fi = new FileInfo ( kubeConfigNoCluster ) ;
177
192
Assert . Throws < k8s . Exceptions . KubeConfigException > ( ( ) => new KubernetesClientConfiguration ( fi ) ) ;
193
+ }
194
+
195
+ /// <summary>
196
+ /// Checks that a KubeConfigException is thrown when the cluster defined in clusters and contexts do not match
197
+ /// </summary>
198
+ [ Fact ]
199
+ public void ClusterNameMissmatch ( )
200
+ {
201
+ var fi = new FileInfo ( kubeConfigClusterMissmatch ) ;
202
+ Assert . Throws < k8s . Exceptions . KubeConfigException > ( ( ) => new KubernetesClientConfiguration ( fi ) ) ;
203
+ }
204
+
205
+ /// <summary>
206
+ /// Checks that a KubeConfigException is thrown when no certificate-authority-data is set and user do not require tls skip
207
+ /// </summary>
208
+ [ Fact ]
209
+ public void CheckClusterTlsCorrectness ( )
210
+ {
211
+ var fi = new FileInfo ( kubeConfigTlsNoSkipError ) ;
212
+ Assert . Throws < k8s . Exceptions . KubeConfigException > ( ( ) => new KubernetesClientConfiguration ( fi ) ) ;
213
+ }
214
+
215
+ /// <summary>
216
+ /// Checks that a KubeConfigException is thrown when no certificate-authority-data is set and user do not require tls skip
217
+ /// </summary>
218
+ [ Fact ]
219
+ public void CheckClusterTlsSkipCorrectness ( )
220
+ {
221
+ var fi = new FileInfo ( kubeConfigTlsSkip ) ;
222
+ var cfg = new KubernetesClientConfiguration ( fi ) ;
223
+ Assert . NotNull ( cfg . Host ) ;
224
+ Assert . Null ( cfg . SslCaCert ) ;
225
+ Assert . True ( cfg . SkipTlsVerify ) ;
178
226
}
179
227
180
228
// /// <summary>
0 commit comments