Added a test to check the behaviour when no clusters are present in the configuration file

This commit is contained in:
Sergio Sisternes
2017-06-27 20:09:08 +02:00
parent b69f070bec
commit c38ee42c37
2 changed files with 32 additions and 0 deletions

View File

@@ -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>

View 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