diff --git a/tests/KubernetesClientConfigurationTests.cs b/tests/KubernetesClientConfigurationTests.cs
index f4f9e91..32d59ec 100755
--- a/tests/KubernetesClientConfigurationTests.cs
+++ b/tests/KubernetesClientConfigurationTests.cs
@@ -13,8 +13,16 @@ namespace k8s.Tests
///
private static readonly string kubeConfigFileName = "assets/kubeconfig.yml";
+ ///
+ /// Invalid test file with no context on purpose
+ ///
private static readonly string kubeConfigNoContexts = "assets/kubeconfig-no-context.yml";
+ ///
+ /// Sample configuration file with user/password authentication
+ ///
+ private static readonly string kubeConfigUserPassword = "assets/kubeconfig.user-pass.yml";
+
///
/// Checks Host is loaded from the default configuration file
///
@@ -100,7 +108,19 @@ namespace k8s.Tests
{
var fi = new FileInfo(kubeConfigNoContexts);
Assert.Throws(() => new KubernetesClientConfiguration(fi, "context"));
- }
+ }
+
+ ///
+ /// Checks user/password authentication information is read properly
+ ///
+ [Fact]
+ public void UserPasswordAuthentication()
+ {
+ var fi = new FileInfo(kubeConfigUserPassword);
+ var cfg = new KubernetesClientConfiguration(fi);
+ Assert.Equal("admin", cfg.Username);
+ Assert.Equal("secret", cfg.Password);
+ }
// ///
// /// Checks if the are pods
diff --git a/tests/assets/kubeconfig.user-pass.yml b/tests/assets/kubeconfig.user-pass.yml
new file mode 100644
index 0000000..b426ef5
--- /dev/null
+++ b/tests/assets/kubeconfig.user-pass.yml
@@ -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
\ No newline at end of file