Skip to content

Commit 2ff7b31

Browse files
committed
Added basic tests for KubernetesClientCredentials
1 parent 1571aa4 commit 2ff7b31

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
using System;
2+
using Xunit;
3+
using k8s;
4+
using System.IO;
5+
6+
namespace k8s.Tests
7+
{
8+
public class KubernetesClientCredentialsTests
9+
{
10+
/// <summary>
11+
/// Checks that a ArgumentNullException is thrown when trying to create a KubernetesClientCredentials with null token
12+
/// </summary>
13+
[Fact]
14+
public void TokenNull()
15+
{
16+
Assert.Throws<ArgumentNullException>(() => new KubernetesClientCredentials(null));
17+
}
18+
19+
/// <summary>
20+
/// Checks that a ArgumentNullException is thrown when trying to create a KubernetesClientCredentials with null username
21+
/// </summary>
22+
[Fact]
23+
public void UsernameNull()
24+
{
25+
Assert.Throws<ArgumentNullException>(() => new KubernetesClientCredentials(null,"password"));
26+
}
27+
28+
/// <summary>
29+
/// Checks that a ArgumentNullException is thrown when trying to create a KubernetesClientCredentials with null password
30+
/// </summary>
31+
[Fact]
32+
public void PasswordNull()
33+
{
34+
Assert.Throws<ArgumentNullException>(() => new KubernetesClientCredentials("username", null));
35+
}
36+
37+
/// <summary>
38+
/// Checks that the Token is set with no exceptions
39+
/// </summary>
40+
[Fact]
41+
public void ValidTokenIsSet()
42+
{
43+
var token = "mytoken";
44+
var credentials = new KubernetesClientCredentials(token);
45+
Assert.NotNull(credentials);
46+
}
47+
48+
/// <summary>
49+
/// Checks that the Username and Password is set with no exceptions
50+
/// </summary>
51+
[Fact]
52+
public void ValidUserPasswordIsSet()
53+
{
54+
var username = "myuser";
55+
var password = "mypassword";
56+
var credentials = new KubernetesClientCredentials(username, password);
57+
Assert.NotNull(credentials);
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)