File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -13,8 +13,16 @@ public class KubernetesClientConfigurationTests
13
13
/// </summary>
14
14
private static readonly string kubeConfigFileName = "assets/kubeconfig.yml" ;
15
15
16
+ /// <summary>
17
+ /// Invalid test file with no context on purpose
18
+ /// </summary>
16
19
private static readonly string kubeConfigNoContexts = "assets/kubeconfig-no-context.yml" ;
17
20
21
+ /// <summary>
22
+ /// Sample configuration file with user/password authentication
23
+ /// </summary>
24
+ private static readonly string kubeConfigUserPassword = "assets/kubeconfig.user-pass.yml" ;
25
+
18
26
/// <summary>
19
27
/// Checks Host is loaded from the default configuration file
20
28
/// </summary>
@@ -100,7 +108,19 @@ public void NoContextsExplicit()
100
108
{
101
109
var fi = new FileInfo ( kubeConfigNoContexts ) ;
102
110
Assert . Throws < k8s . Exceptions . KubeConfigException > ( ( ) => new KubernetesClientConfiguration ( fi , "context" ) ) ;
103
- }
111
+ }
112
+
113
+ /// <summary>
114
+ /// Checks user/password authentication information is read properly
115
+ /// </summary>
116
+ [ Fact ]
117
+ public void UserPasswordAuthentication ( )
118
+ {
119
+ var fi = new FileInfo ( kubeConfigUserPassword ) ;
120
+ var cfg = new KubernetesClientConfiguration ( fi ) ;
121
+ Assert . Equal ( "admin" , cfg . Username ) ;
122
+ Assert . Equal ( "secret" , cfg . Password ) ;
123
+ }
104
124
105
125
// /// <summary>
106
126
// /// Checks if the are pods
Original file line number Diff line number Diff line change
1
+ # Sample file based on https://kubernetes.io/docs/tasks/access-application-cluster/authenticate-across-clusters-kubeconfig/
2
+ # WARNING: File includes minor fixes
3
+ ---
4
+ current-context : federal-context
5
+ apiVersion : v1
6
+ clusters :
7
+ - cluster :
8
+ certificate-authority-data : path/to/my/cafile
9
+ server : https://horse.org:4443
10
+ name : horse-cluster
11
+ contexts :
12
+ - context :
13
+ cluster : horse-cluster
14
+ namespace : chisel-ns
15
+ user : green-user
16
+ name : federal-context
17
+ kind : Config
18
+ users :
19
+ - name : green-user
20
+ user :
21
+ password : secret
22
+ username : admin
You can’t perform that action at this time.
0 commit comments