Added user-password test

This commit is contained in:
Sergio Sisternes
2017-06-27 19:19:02 +02:00
parent bead9e37cd
commit f7ac5b728b
2 changed files with 43 additions and 1 deletions

View File

@@ -13,8 +13,16 @@ namespace k8s.Tests
/// </summary>
private static readonly string kubeConfigFileName = "assets/kubeconfig.yml";
/// <summary>
/// Invalid test file with no context on purpose
/// </summary>
private static readonly string kubeConfigNoContexts = "assets/kubeconfig-no-context.yml";
/// <summary>
/// Sample configuration file with user/password authentication
/// </summary>
private static readonly string kubeConfigUserPassword = "assets/kubeconfig.user-pass.yml";
/// <summary>
/// Checks Host is loaded from the default configuration file
/// </summary>
@@ -100,7 +108,19 @@ namespace k8s.Tests
{
var fi = new FileInfo(kubeConfigNoContexts);
Assert.Throws<k8s.Exceptions.KubeConfigException>(() => new KubernetesClientConfiguration(fi, "context"));
}
}
/// <summary>
/// Checks user/password authentication information is read properly
/// </summary>
[Fact]
public void UserPasswordAuthentication()
{
var fi = new FileInfo(kubeConfigUserPassword);
var cfg = new KubernetesClientConfiguration(fi);
Assert.Equal("admin", cfg.Username);
Assert.Equal("secret", cfg.Password);
}
// /// <summary>
// /// Checks if the are pods

View File

@@ -0,0 +1,22 @@
# 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
clusters:
- cluster:
certificate-authority-data: path/to/my/cafile
server: https://horse.org:4443
name: horse-cluster
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