Merge pull request #6 from sesispla/master
Basic tests for configuration and credentials
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
public class User
|
public class User
|
||||||
{
|
{
|
||||||
[YamlMember(Alias = "user")]
|
[YamlMember(Alias = "user")]
|
||||||
public UserCrednetials UserCredentials { get; set; }
|
public UserCredentials UserCredentials { get; set; }
|
||||||
|
|
||||||
[YamlMember(Alias = "name")]
|
[YamlMember(Alias = "name")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
using YamlDotNet.RepresentationModel;
|
using YamlDotNet.RepresentationModel;
|
||||||
using YamlDotNet.Serialization;
|
using YamlDotNet.Serialization;
|
||||||
|
|
||||||
public class UserCrednetials
|
public class UserCredentials
|
||||||
{
|
{
|
||||||
[YamlMember(Alias = "client-certificate-data")]
|
[YamlMember(Alias = "client-certificate-data")]
|
||||||
public string ClientCertificateData { get; set; }
|
public string ClientCertificateData { get; set; }
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
[YamlMember(Alias = "token")]
|
[YamlMember(Alias = "token")]
|
||||||
public string Token { get; set; }
|
public string Token { get; set; }
|
||||||
|
|
||||||
[YamlMember(Alias = "userName")]
|
[YamlMember(Alias = "username")]
|
||||||
public string UserName { get; set; }
|
public string UserName { get; set; }
|
||||||
|
|
||||||
[YamlMember(Alias = "password")]
|
[YamlMember(Alias = "password")]
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<TargetFramework>netcoreapp1.1</TargetFramework>
|
<TargetFramework>netcoreapp1.1</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Remove="GlobalSuppressions.cs" />
|
<Compile Remove="GlobalSuppressions.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="1.1.0" />
|
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="1.1.0" />
|
||||||
|
|||||||
@@ -96,13 +96,14 @@ namespace k8s
|
|||||||
{
|
{
|
||||||
Context activeContext;
|
Context activeContext;
|
||||||
|
|
||||||
|
if (k8SConfig.Contexts == null)
|
||||||
|
{
|
||||||
|
throw new KubeConfigException("No contexts found in kubeconfig");
|
||||||
|
}
|
||||||
|
|
||||||
// set the currentCOntext to passed context if not null
|
// set the currentCOntext to passed context if not null
|
||||||
if (!string.IsNullOrWhiteSpace(currentContext))
|
if (!string.IsNullOrWhiteSpace(currentContext))
|
||||||
{
|
{
|
||||||
if (k8SConfig.Contexts == null)
|
|
||||||
{
|
|
||||||
throw new KubeConfigException("No contexts found in kubeconfig");
|
|
||||||
}
|
|
||||||
|
|
||||||
activeContext = k8SConfig.Contexts.FirstOrDefault(c => c.Name.Equals(currentContext, StringComparison.OrdinalIgnoreCase));
|
activeContext = k8SConfig.Contexts.FirstOrDefault(c => c.Name.Equals(currentContext, StringComparison.OrdinalIgnoreCase));
|
||||||
if (activeContext != null)
|
if (activeContext != null)
|
||||||
@@ -127,6 +128,11 @@ namespace k8s
|
|||||||
this.CurrentContext = activeContext.Name;
|
this.CurrentContext = activeContext.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (k8SConfig.Clusters == null)
|
||||||
|
{
|
||||||
|
throw new KubeConfigException($"clusters not found for current-context :{activeContext} in kubeconfig");
|
||||||
|
}
|
||||||
|
|
||||||
var clusterDetails = k8SConfig.Clusters.FirstOrDefault(c => c.Name.Equals(activeContext.ContextDetails.Cluster, StringComparison.OrdinalIgnoreCase));
|
var clusterDetails = k8SConfig.Clusters.FirstOrDefault(c => c.Name.Equals(activeContext.ContextDetails.Cluster, StringComparison.OrdinalIgnoreCase));
|
||||||
if (clusterDetails?.ClusterEndpoint != null)
|
if (clusterDetails?.ClusterEndpoint != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,11 +1,68 @@
|
|||||||
using System;
|
using System;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using k8s;
|
using k8s;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace k8s.Tests
|
namespace k8s.Tests
|
||||||
{
|
{
|
||||||
public class KubernetesClientConfigurationTests
|
public class KubernetesClientConfigurationTests
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This file contains a sample kubeconfig file
|
||||||
|
/// </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>
|
||||||
|
/// Sample configuration file with incorrect user credentials structures on purpose
|
||||||
|
/// </summary>
|
||||||
|
private static readonly string kubeConfigNoCredentials = "assets/kubeconfig.no-credentials.yml";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sample configuration file with incorrect cluster/server structure on purpose
|
||||||
|
/// </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>
|
||||||
|
/// Sample configuration file with incorrect match in cluster name
|
||||||
|
/// </summary>
|
||||||
|
private static readonly string kubeConfigClusterMissmatch = "assets/kubeconfig.cluster-missmatch.yml";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sample configuration file with incorrect TLS configuration in cluster section
|
||||||
|
/// </summary>
|
||||||
|
private static readonly string kubeConfigTlsNoSkipError = "assets/kubeconfig.tls-no-skip-error.yml";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sample configuration file with incorrect TLS configuration in cluster section
|
||||||
|
/// </summary>
|
||||||
|
private static readonly string kubeConfigTlsSkip = "assets/kubeconfig.tls-skip.yml";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The configuration file is not present. An KubeConfigException should be thrown
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void ConfigurationFileNotFound()
|
||||||
|
{
|
||||||
|
var fi = new FileInfo("/path/to/nowhere");
|
||||||
|
Assert.Throws<k8s.Exceptions.KubeConfigException>(() => new KubernetesClientConfiguration(fi));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks Host is loaded from the default configuration file
|
/// Checks Host is loaded from the default configuration file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -15,18 +72,170 @@ namespace k8s.Tests
|
|||||||
var cfg = new KubernetesClientConfiguration();
|
var cfg = new KubernetesClientConfiguration();
|
||||||
Assert.NotNull(cfg.Host);
|
Assert.NotNull(cfg.Host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if host is properly loaded, per context
|
||||||
|
/// </summary>
|
||||||
|
[Theory]
|
||||||
|
[InlineData("federal-context", "https://horse.org:4443")]
|
||||||
|
[InlineData("queen-anne-context", "https://pig.org:443")]
|
||||||
|
public void ContextHostTest(string context, string host)
|
||||||
|
{
|
||||||
|
var fi = new FileInfo(kubeConfigFileName);
|
||||||
|
var cfg = new KubernetesClientConfiguration(fi, context);
|
||||||
|
Assert.Equal(host, cfg.Host);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if the are pods
|
/// Checks if user-based token is loaded properly from the config file, per context
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
/// <param name="username"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
[Theory]
|
||||||
|
[InlineData("queen-anne-context", "black-token")]
|
||||||
|
public void ContextUserTokenTest(string context, string token)
|
||||||
|
{
|
||||||
|
var fi = new FileInfo(kubeConfigFileName);
|
||||||
|
var cfg = new KubernetesClientConfiguration(fi, context);
|
||||||
|
Assert.Equal(context, cfg.CurrentContext);
|
||||||
|
Assert.Null(cfg.Username);
|
||||||
|
Assert.Equal(token, cfg.AccessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if certificate-based authentication is loaded properly from the config file, per context
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context">Context to retreive the configuration</param>
|
||||||
|
/// <param name="clientCertData">'client-certificate-data' node content</param>
|
||||||
|
/// <param name="clientCertKey">'client-key-data' content</param>
|
||||||
|
[Theory]
|
||||||
|
[InlineData("federal-context", "path/to/my/client/cert" ,"path/to/my/client/key")]
|
||||||
|
public void ContextCertificateTest(string context, string clientCertData, string clientCertKey)
|
||||||
|
{
|
||||||
|
var fi = new FileInfo(kubeConfigFileName);
|
||||||
|
var cfg = new KubernetesClientConfiguration(fi, context);
|
||||||
|
Assert.Equal(context, cfg.CurrentContext);
|
||||||
|
Assert.Equal(cfg.ClientCertificateData, clientCertData);
|
||||||
|
Assert.Equal(cfg.ClientCertificateKey, clientCertKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test that an Exception is thrown when initializating a KubernetClientConfiguration whose config file Context is not present
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ListDefaultNamespacedPod()
|
public void ContextNotFoundTest()
|
||||||
{
|
{
|
||||||
var k8sClientConfig = new KubernetesClientConfiguration();
|
var fi = new FileInfo(kubeConfigFileName);
|
||||||
IKubernetes client = new Kubernetes(k8sClientConfig);
|
Assert.Throws<k8s.Exceptions.KubeConfigException>(() => new KubernetesClientConfiguration(fi, "context-not-found"));
|
||||||
var listTask = client.ListNamespacedPodWithHttpMessagesAsync("default").Result;
|
|
||||||
var list = listTask.Body;
|
|
||||||
Assert.NotEqual(0, list.Items.Count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test if KubeConfigException is thrown when no Contexts and we use the default context name
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void NoContexts()
|
||||||
|
{
|
||||||
|
var fi = new FileInfo(kubeConfigNoContexts);
|
||||||
|
Assert.Throws<k8s.Exceptions.KubeConfigException>(() => new KubernetesClientConfiguration(fi));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test if KubeConfigException is thrown when no Contexts are set and we specify a concrete context name
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void NoContextsExplicit()
|
||||||
|
{
|
||||||
|
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 that a KubeConfigException is thrown when incomplete user credentials
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void IncompleteUserCredentials()
|
||||||
|
{
|
||||||
|
var fi = new FileInfo(kubeConfigNoCredentials);
|
||||||
|
Assert.Throws<k8s.Exceptions.KubeConfigException>(() => new KubernetesClientConfiguration(fi));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks that a KubeConfigException is thrown when the server property is not set in cluster
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void ServerNotFound()
|
||||||
|
{
|
||||||
|
var fi = new FileInfo(kubeConfigNoServer);
|
||||||
|
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 that a KubeConfigException is thrown when the cluster defined in clusters and contexts do not match
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void ClusterNameMissmatch()
|
||||||
|
{
|
||||||
|
var fi = new FileInfo(kubeConfigClusterMissmatch);
|
||||||
|
Assert.Throws<k8s.Exceptions.KubeConfigException>(() => new KubernetesClientConfiguration(fi));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks that a KubeConfigException is thrown when no certificate-authority-data is set and user do not require tls skip
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void CheckClusterTlsCorrectness()
|
||||||
|
{
|
||||||
|
var fi = new FileInfo(kubeConfigTlsNoSkipError);
|
||||||
|
Assert.Throws<k8s.Exceptions.KubeConfigException>(() => new KubernetesClientConfiguration(fi));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks that a KubeConfigException is thrown when no certificate-authority-data is set and user do not require tls skip
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void CheckClusterTlsSkipCorrectness()
|
||||||
|
{
|
||||||
|
var fi = new FileInfo(kubeConfigTlsSkip);
|
||||||
|
var cfg = new KubernetesClientConfiguration(fi);
|
||||||
|
Assert.NotNull(cfg.Host);
|
||||||
|
Assert.Null(cfg.SslCaCert);
|
||||||
|
Assert.True(cfg.SkipTlsVerify);
|
||||||
|
}
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// /// Checks if the are pods
|
||||||
|
// /// </summary>
|
||||||
|
// [Fact]
|
||||||
|
// public void ListDefaultNamespacedPod()
|
||||||
|
// {
|
||||||
|
// var k8sClientConfig = new KubernetesClientConfiguration();
|
||||||
|
// IKubernetes client = new Kubernetes(k8sClientConfig);
|
||||||
|
// var listTask = client.ListNamespacedPodWithHttpMessagesAsync("default").Result;
|
||||||
|
// var list = listTask.Body;
|
||||||
|
// Assert.NotEqual(0, list.Items.Count);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
60
tests/KubernetesClientCredentialsTests.cs
Normal file
60
tests/KubernetesClientCredentialsTests.cs
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
using System;
|
||||||
|
using Xunit;
|
||||||
|
using k8s;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace k8s.Tests
|
||||||
|
{
|
||||||
|
public class KubernetesClientCredentialsTests
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Checks that a ArgumentNullException is thrown when trying to create a KubernetesClientCredentials with null token
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void TokenNull()
|
||||||
|
{
|
||||||
|
Assert.Throws<ArgumentNullException>(() => new KubernetesClientCredentials(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks that a ArgumentNullException is thrown when trying to create a KubernetesClientCredentials with null username
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void UsernameNull()
|
||||||
|
{
|
||||||
|
Assert.Throws<ArgumentNullException>(() => new KubernetesClientCredentials(null,"password"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks that a ArgumentNullException is thrown when trying to create a KubernetesClientCredentials with null password
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void PasswordNull()
|
||||||
|
{
|
||||||
|
Assert.Throws<ArgumentNullException>(() => new KubernetesClientCredentials("username", null));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks that the Token is set with no exceptions
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void ValidTokenIsSet()
|
||||||
|
{
|
||||||
|
var token = "mytoken";
|
||||||
|
var credentials = new KubernetesClientCredentials(token);
|
||||||
|
Assert.NotNull(credentials);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks that the Username and Password is set with no exceptions
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void ValidUserPasswordIsSet()
|
||||||
|
{
|
||||||
|
var username = "myuser";
|
||||||
|
var password = "mypassword";
|
||||||
|
var credentials = new KubernetesClientCredentials(username, password);
|
||||||
|
Assert.NotNull(credentials);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
29
tests/assets/kubeconfig-no-context.yml
Normal file
29
tests/assets/kubeconfig-no-context.yml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# 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:
|
||||||
|
server: http://cow.org:8080
|
||||||
|
name: cow-cluster
|
||||||
|
- cluster:
|
||||||
|
certificate-authority-data: path/to/my/cafile
|
||||||
|
server: https://horse.org:4443
|
||||||
|
name: horse-cluster
|
||||||
|
- cluster:
|
||||||
|
insecure-skip-tls-verify: true
|
||||||
|
server: https://pig.org:443
|
||||||
|
name: pig-cluster
|
||||||
|
kind: Config
|
||||||
|
users:
|
||||||
|
- name: blue-user
|
||||||
|
user:
|
||||||
|
token: blue-token
|
||||||
|
- name: green-user
|
||||||
|
user:
|
||||||
|
client-certificate-data: path/to/my/client/cert
|
||||||
|
client-key-data: path/to/my/client/key
|
||||||
|
- name: black-user
|
||||||
|
user:
|
||||||
|
token: black-token
|
||||||
22
tests/assets/kubeconfig.cluster-missmatch.yml
Normal file
22
tests/assets/kubeconfig.cluster-missmatch.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: bad-name-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
|
||||||
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
|
||||||
20
tests/assets/kubeconfig.no-credentials.yml
Normal file
20
tests/assets/kubeconfig.no-credentials.yml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# 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:
|
||||||
21
tests/assets/kubeconfig.no-server.yml
Normal file
21
tests/assets/kubeconfig.no-server.yml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# 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
|
||||||
|
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
|
||||||
25
tests/assets/kubeconfig.tls-no-skip-error.yml
Normal file
25
tests/assets/kubeconfig.tls-no-skip-error.yml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# 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:
|
||||||
|
server: http://cow.org:8080
|
||||||
|
name: cow-cluster
|
||||||
|
- 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:
|
||||||
|
client-certificate-data: path/to/my/client/cert
|
||||||
|
client-key-data: path/to/my/client/key
|
||||||
22
tests/assets/kubeconfig.tls-skip.yml
Normal file
22
tests/assets/kubeconfig.tls-skip.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:
|
||||||
|
insecure-skip-tls-verify: true
|
||||||
|
server: https://horse.org:443
|
||||||
|
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
|
||||||
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
|
||||||
40
tests/assets/kubeconfig.yml
Normal file
40
tests/assets/kubeconfig.yml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# 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:
|
||||||
|
server: http://cow.org:8080
|
||||||
|
name: cow-cluster
|
||||||
|
- cluster:
|
||||||
|
certificate-authority-data: path/to/my/cafile
|
||||||
|
server: https://horse.org:4443
|
||||||
|
name: horse-cluster
|
||||||
|
- cluster:
|
||||||
|
insecure-skip-tls-verify: true
|
||||||
|
server: https://pig.org:443
|
||||||
|
name: pig-cluster
|
||||||
|
contexts:
|
||||||
|
- context:
|
||||||
|
cluster: horse-cluster
|
||||||
|
namespace: chisel-ns
|
||||||
|
user: green-user
|
||||||
|
name: federal-context
|
||||||
|
- context:
|
||||||
|
cluster: pig-cluster
|
||||||
|
namespace: saw-ns
|
||||||
|
user: black-user
|
||||||
|
name: queen-anne-context
|
||||||
|
kind: Config
|
||||||
|
users:
|
||||||
|
- name: blue-user
|
||||||
|
user:
|
||||||
|
token: blue-token
|
||||||
|
- name: green-user
|
||||||
|
user:
|
||||||
|
client-certificate-data: path/to/my/client/cert
|
||||||
|
client-key-data: path/to/my/client/key
|
||||||
|
- name: black-user
|
||||||
|
user:
|
||||||
|
token: black-token
|
||||||
@@ -10,6 +10,9 @@
|
|||||||
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
|
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
|
||||||
<PackageReference Include="YamlDotNet.NetCore" Version="1.0.0" />
|
<PackageReference Include="YamlDotNet.NetCore" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="assets/*" CopyToOutputDirectory="Always" />
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\src\KubernetesClient.csproj" />
|
<ProjectReference Include="..\src\KubernetesClient.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user