Added a test to check the behaviour when no clusters are present in the configuration file
This commit is contained in:
@@ -33,6 +33,11 @@ namespace k8s.Tests
|
||||
/// </summary>
|
||||
private static readonly string kubeConfigNoServer = "assets/kubeconfig.no-server.yml";
|
||||
|
||||
/// <summary>
|
||||
/// Sample configuration file with incorrect cluster/server structure on purpose
|
||||
/// </summary>
|
||||
private static readonly string kubeConfigNoCluster = "assets/kubeconfig.no-cluster.yml";
|
||||
|
||||
/// <summary>
|
||||
/// The configuration file is not present. An KubeConfigException should be thrown
|
||||
/// </summary>
|
||||
@@ -162,6 +167,16 @@ namespace k8s.Tests
|
||||
Assert.Throws<k8s.Exceptions.KubeConfigException>(() => new KubernetesClientConfiguration(fi));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks that a KubeConfigException is thrown when the clusters section is missing
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void ClusterNotFound()
|
||||
{
|
||||
var fi = new FileInfo(kubeConfigNoCluster);
|
||||
Assert.Throws<k8s.Exceptions.KubeConfigException>(() => new KubernetesClientConfiguration(fi));
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Checks if the are pods
|
||||
// /// </summary>
|
||||
|
||||
17
tests/assets/kubeconfig.no-cluster.yml
Normal file
17
tests/assets/kubeconfig.no-cluster.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
# Sample file based on https://kubernetes.io/docs/tasks/access-application-cluster/authenticate-across-clusters-kubeconfig/
|
||||
# WARNING: File includes minor fixes
|
||||
---
|
||||
current-context: federal-context
|
||||
apiVersion: v1
|
||||
contexts:
|
||||
- context:
|
||||
cluster: horse-cluster
|
||||
namespace: chisel-ns
|
||||
user: green-user
|
||||
name: federal-context
|
||||
kind: Config
|
||||
users:
|
||||
- name: green-user
|
||||
user:
|
||||
password: secret
|
||||
username: admin
|
||||
Reference in New Issue
Block a user