Added user-password test
This commit is contained in:
@@ -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>
|
||||
@@ -102,6 +110,18 @@ namespace k8s.Tests
|
||||
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
|
||||
// /// </summary>
|
||||
|
||||
22
tests/assets/kubeconfig.user-pass.yml
Normal file
22
tests/assets/kubeconfig.user-pass.yml
Normal 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
|
||||
Reference in New Issue
Block a user