Skip to content

Commit c83e613

Browse files
committed
Merge branch 'creds' of https://github.com/brendandburns/csharp into creds
2 parents ed50fc2 + 2a14c3f commit c83e613

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/UtilTests.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using Xunit;
3+
using k8s;
4+
using System.IO;
5+
6+
namespace k8s.Tests
7+
{
8+
public class UtilsTests
9+
{
10+
/// <summary>
11+
/// This file contains a sample kubeconfig file
12+
/// </summary>
13+
private static readonly string kubeConfigFileName = "assets/kubeconfig.yml";
14+
15+
/// <summary>
16+
/// Checks that a certificate can be loaded from files.
17+
/// </summary>
18+
[Fact]
19+
public void LoadFromFiles()
20+
{
21+
var fi = new FileInfo(kubeConfigFileName);
22+
var cfg = new KubernetesClientConfiguration(fi, "federal-context");
23+
24+
// Just validate that this doesn't throw and private key is non-null
25+
var cert = Utils.GeneratePfx(cfg);
26+
Assert.NotNull(cert.PrivateKey);
27+
}
28+
29+
/// <summary>
30+
/// Checks that a certificate can be loaded from inline.
31+
/// </summary>
32+
[Fact]
33+
public void LoadFromInlineData()
34+
{
35+
var fi = new FileInfo(kubeConfigFileName);
36+
var cfg = new KubernetesClientConfiguration(fi, "victorian-context");
37+
38+
// Just validate that this doesn't throw and private key is non-null
39+
var cert = Utils.GeneratePfx(cfg);
40+
Assert.NotNull(cert.PrivateKey);
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)