This repository was archived by the owner on Mar 20, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +32
-4
lines changed
tests/KubernetesClient.Tests Expand file tree Collapse file tree 2 files changed +32
-4
lines changed Original file line number Diff line number Diff line change 3
3
using System . Linq ;
4
4
using System . Net ;
5
5
using System . Net . Http . Headers ;
6
+ using System . Runtime . InteropServices ;
6
7
using System . Security . Cryptography ;
7
8
using System . Security . Cryptography . X509Certificates ;
8
9
using System . Text ;
@@ -177,10 +178,18 @@ public void Cert()
177
178
var clientCertificateData = File . ReadAllText ( "assets/client-certificate-data.txt" ) ;
178
179
179
180
X509Certificate2 serverCertificate = null ;
180
- using ( MemoryStream serverCertificateStream = new MemoryStream ( Convert . FromBase64String ( serverCertificateData ) ) )
181
+
182
+ if ( RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) )
181
183
{
182
- serverCertificate = OpenCertificateStore ( serverCertificateStream ) ;
184
+ using ( MemoryStream serverCertificateStream = new MemoryStream ( Convert . FromBase64String ( serverCertificateData ) ) )
185
+ {
186
+ serverCertificate = OpenCertificateStore ( serverCertificateStream ) ;
187
+ }
183
188
}
189
+ else
190
+ {
191
+ serverCertificate = new X509Certificate2 ( Convert . FromBase64String ( serverCertificateData ) , "" ) ;
192
+ }
184
193
185
194
var clientCertificate = new X509Certificate2 ( Convert . FromBase64String ( clientCertificateData ) , "" ) ;
186
195
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
1
3
using System . IO ;
4
+ using System . Linq ;
2
5
using k8s . Models ;
3
6
using Xunit ;
4
7
@@ -50,10 +53,26 @@ public void WriteToString()
50
53
} ;
51
54
52
55
var yaml = Yaml . SaveToString ( pod ) ;
53
- Assert . Equal ( @"apiVersion: v1
56
+ Assert . True ( ToLines ( @"apiVersion: v1
54
57
kind: Pod
55
58
metadata:
56
- name: foo" , yaml ) ;
59
+ name: foo" ) . SequenceEqual ( ToLines ( yaml ) ) ) ;
60
+ }
61
+
62
+ private static IEnumerable < string > ToLines ( string s )
63
+ {
64
+ using ( var reader = new StringReader ( s ) )
65
+ {
66
+ for ( ; ; )
67
+ {
68
+ var line = reader . ReadLine ( ) ;
69
+ if ( line == null )
70
+ {
71
+ yield break ;
72
+ }
73
+ yield return line ;
74
+ }
75
+ }
57
76
}
58
77
59
78
[ Fact ]
You can’t perform that action at this time.
0 commit comments