2017-09-27 21:52:58 -07:00
|
|
|
using System;
|
|
|
|
|
using Xunit;
|
|
|
|
|
using k8s;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace k8s.Tests
|
|
|
|
|
{
|
2017-11-08 14:22:10 +08:00
|
|
|
public class CertUtilsTests
|
2017-09-27 21:52:58 -07:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This file contains a sample kubeconfig file
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static readonly string kubeConfigFileName = "assets/kubeconfig.yml";
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Checks that a certificate can be loaded from files.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void LoadFromFiles()
|
|
|
|
|
{
|
2018-04-18 21:52:19 -07:00
|
|
|
var cfg = KubernetesClientConfiguration.BuildConfigFromConfigFile(kubeConfigFileName, "federal-context");
|
2017-09-27 21:52:58 -07:00
|
|
|
|
|
|
|
|
// Just validate that this doesn't throw and private key is non-null
|
2017-11-08 14:22:10 +08:00
|
|
|
var cert = CertUtils.GeneratePfx(cfg);
|
2017-09-27 21:52:58 -07:00
|
|
|
Assert.NotNull(cert.PrivateKey);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Checks that a certificate can be loaded from inline.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void LoadFromInlineData()
|
|
|
|
|
{
|
2018-04-18 21:52:19 -07:00
|
|
|
var cfg = KubernetesClientConfiguration.BuildConfigFromConfigFile(kubeConfigFileName, "victorian-context");
|
2017-09-27 21:52:58 -07:00
|
|
|
|
|
|
|
|
// Just validate that this doesn't throw and private key is non-null
|
2017-11-08 14:22:10 +08:00
|
|
|
var cert = CertUtils.GeneratePfx(cfg);
|
2017-09-27 21:52:58 -07:00
|
|
|
Assert.NotNull(cert.PrivateKey);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-11-08 14:22:10 +08:00
|
|
|
}
|