@@ -31,8 +31,8 @@ public void ReadCertificatesWhenEmptyCertificatesSection_ReturnsEmptyCollection(
31
31
{
32
32
var config = new ConfigurationBuilder ( ) . AddInMemoryCollection ( new [ ]
33
33
{
34
- new KeyValuePair < string , string > ( "Certificates" , "" ) ,
35
- } ) . Build ( ) ;
34
+ new KeyValuePair < string , string > ( "Certificates" , "" ) ,
35
+ } ) . Build ( ) ;
36
36
var reader = new ConfigurationReader ( config ) ;
37
37
var certificates = reader . Certificates ;
38
38
Assert . NotNull ( certificates ) ;
@@ -44,13 +44,13 @@ public void ReadCertificatesSection_ReturnsCollection()
44
44
{
45
45
var config = new ConfigurationBuilder ( ) . AddInMemoryCollection ( new [ ]
46
46
{
47
- new KeyValuePair < string , string > ( "Certificates:FileCert:Path" , "/path/cert.pfx" ) ,
48
- new KeyValuePair < string , string > ( "Certificates:FileCert:Password" , "certpassword" ) ,
49
- new KeyValuePair < string , string > ( "Certificates:StoreCert:Subject" , "certsubject" ) ,
50
- new KeyValuePair < string , string > ( "Certificates:StoreCert:Store" , "certstore" ) ,
51
- new KeyValuePair < string , string > ( "Certificates:StoreCert:Location" , "cetlocation" ) ,
52
- new KeyValuePair < string , string > ( "Certificates:StoreCert:AllowInvalid" , "true" ) ,
53
- } ) . Build ( ) ;
47
+ new KeyValuePair < string , string > ( "Certificates:FileCert:Path" , "/path/cert.pfx" ) ,
48
+ new KeyValuePair < string , string > ( "Certificates:FileCert:Password" , "certpassword" ) ,
49
+ new KeyValuePair < string , string > ( "Certificates:StoreCert:Subject" , "certsubject" ) ,
50
+ new KeyValuePair < string , string > ( "Certificates:StoreCert:Store" , "certstore" ) ,
51
+ new KeyValuePair < string , string > ( "Certificates:StoreCert:Location" , "cetlocation" ) ,
52
+ new KeyValuePair < string , string > ( "Certificates:StoreCert:AllowInvalid" , "true" ) ,
53
+ } ) . Build ( ) ;
54
54
var reader = new ConfigurationReader ( config ) ;
55
55
var certificates = reader . Certificates ;
56
56
Assert . NotNull ( certificates ) ;
@@ -76,9 +76,9 @@ public void ReadCertificatesSection_IsCaseInsensitive()
76
76
{
77
77
var config = new ConfigurationBuilder ( ) . AddInMemoryCollection ( new [ ]
78
78
{
79
- new KeyValuePair < string , string > ( "Certificates:filecert:Path" , "/path/cert.pfx" ) ,
80
- new KeyValuePair < string , string > ( "CERTIFICATES:FILECERT:PASSWORD" , "certpassword" ) ,
81
- } ) . Build ( ) ;
79
+ new KeyValuePair < string , string > ( "Certificates:filecert:Path" , "/path/cert.pfx" ) ,
80
+ new KeyValuePair < string , string > ( "CERTIFICATES:FILECERT:PASSWORD" , "certpassword" ) ,
81
+ } ) . Build ( ) ;
82
82
var reader = new ConfigurationReader ( config ) ;
83
83
var certificates = reader . Certificates ;
84
84
Assert . NotNull ( certificates ) ;
@@ -223,51 +223,57 @@ public void ReadEndpointWithSingleSslProtocolSet_ReturnsCorrectValue()
223
223
{
224
224
var config = new ConfigurationBuilder ( ) . AddInMemoryCollection ( new [ ]
225
225
{
226
- new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
227
- new KeyValuePair < string , string > ( "Endpoints:End1:SslProtocols:0" , "Tls11" ) ,
228
- } ) . Build ( ) ;
226
+ new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
227
+ new KeyValuePair < string , string > ( "Endpoints:End1:SslProtocols:0" , "Tls11" ) ,
228
+ } ) . Build ( ) ;
229
229
var reader = new ConfigurationReader ( config ) ;
230
230
231
231
var endpoint = reader . Endpoints . First ( ) ;
232
+ #pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
232
233
Assert . Equal ( SslProtocols . Tls11 , endpoint . SslProtocols ) ;
234
+ #pragma warning restore SYSLIB0039
233
235
}
234
236
235
237
[ Fact ]
236
238
public void ReadEndpointWithMultipleSslProtocolsSet_ReturnsCorrectValue ( )
237
239
{
238
240
var config = new ConfigurationBuilder ( ) . AddInMemoryCollection ( new [ ]
239
241
{
240
- new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
241
- new KeyValuePair < string , string > ( "Endpoints:End1:SslProtocols:0" , "Tls11" ) ,
242
- new KeyValuePair < string , string > ( "Endpoints:End1:SslProtocols:1" , "Tls12" ) ,
243
- } ) . Build ( ) ;
242
+ new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
243
+ new KeyValuePair < string , string > ( "Endpoints:End1:SslProtocols:0" , "Tls11" ) ,
244
+ new KeyValuePair < string , string > ( "Endpoints:End1:SslProtocols:1" , "Tls12" ) ,
245
+ } ) . Build ( ) ;
244
246
var reader = new ConfigurationReader ( config ) ;
245
247
246
248
var endpoint = reader . Endpoints . First ( ) ;
249
+ #pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
247
250
Assert . Equal ( SslProtocols . Tls11 | SslProtocols . Tls12 , endpoint . SslProtocols ) ;
251
+ #pragma warning restore SYSLIB0039
248
252
}
249
253
250
254
[ Fact ]
251
255
public void ReadEndpointWithSslProtocolSet_ReadsCaseInsensitive ( )
252
256
{
253
257
var config = new ConfigurationBuilder ( ) . AddInMemoryCollection ( new [ ]
254
258
{
255
- new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
256
- new KeyValuePair < string , string > ( "Endpoints:End1:SslProtocols:0" , "TLS11" ) ,
257
- } ) . Build ( ) ;
259
+ new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
260
+ new KeyValuePair < string , string > ( "Endpoints:End1:SslProtocols:0" , "TLS11" ) ,
261
+ } ) . Build ( ) ;
258
262
var reader = new ConfigurationReader ( config ) ;
259
263
260
264
var endpoint = reader . Endpoints . First ( ) ;
265
+ #pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
261
266
Assert . Equal ( SslProtocols . Tls11 , endpoint . SslProtocols ) ;
267
+ #pragma warning restore SYSLIB0039
262
268
}
263
269
264
270
[ Fact ]
265
271
public void ReadEndpointWithNoSslProtocolSettings_ReturnsNull ( )
266
272
{
267
273
var config = new ConfigurationBuilder ( ) . AddInMemoryCollection ( new [ ]
268
274
{
269
- new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
270
- } ) . Build ( ) ;
275
+ new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
276
+ } ) . Build ( ) ;
271
277
var reader = new ConfigurationReader ( config ) ;
272
278
273
279
var endpoint = reader . Endpoints . First ( ) ;
@@ -279,8 +285,8 @@ public void ReadEndpointWithEmptySniSection_ReturnsEmptyCollection()
279
285
{
280
286
var config = new ConfigurationBuilder ( ) . AddInMemoryCollection ( new [ ]
281
287
{
282
- new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
283
- } ) . Build ( ) ;
288
+ new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
289
+ } ) . Build ( ) ;
284
290
285
291
var reader = new ConfigurationReader ( config ) ;
286
292
@@ -294,9 +300,9 @@ public void ReadEndpointWithEmptySniKey_Throws()
294
300
{
295
301
var config = new ConfigurationBuilder ( ) . AddInMemoryCollection ( new [ ]
296
302
{
297
- new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
298
- new KeyValuePair < string , string > ( "Endpoints:End1:Sni::Protocols" , "Http1" ) ,
299
- } ) . Build ( ) ;
303
+ new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
304
+ new KeyValuePair < string , string > ( "Endpoints:End1:Sni::Protocols" , "Http1" ) ,
305
+ } ) . Build ( ) ;
300
306
301
307
var reader = new ConfigurationReader ( config ) ;
302
308
var end1Ex = Assert . Throws < InvalidOperationException > ( ( ) => reader . Endpoints ) ;
@@ -309,13 +315,13 @@ public void ReadEndpointWithSniConfigured_ReturnsCorrectValue()
309
315
{
310
316
var config = new ConfigurationBuilder ( ) . AddInMemoryCollection ( new [ ]
311
317
{
312
- new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
313
- new KeyValuePair < string , string > ( "Endpoints:End1:Sni:*.example.org:Protocols" , "Http1" ) ,
314
- new KeyValuePair < string , string > ( "Endpoints:End1:Sni:*.example.org:SslProtocols:0" , "Tls12" ) ,
315
- new KeyValuePair < string , string > ( "Endpoints:End1:Sni:*.example.org:Certificate:Path" , "/path/cert.pfx" ) ,
316
- new KeyValuePair < string , string > ( "Endpoints:End1:Sni:*.example.org:Certificate:Password" , "certpassword" ) ,
317
- new KeyValuePair < string , string > ( "Endpoints:End1:SNI:*.example.org:ClientCertificateMode" , "AllowCertificate" ) ,
318
- } ) . Build ( ) ;
318
+ new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
319
+ new KeyValuePair < string , string > ( "Endpoints:End1:Sni:*.example.org:Protocols" , "Http1" ) ,
320
+ new KeyValuePair < string , string > ( "Endpoints:End1:Sni:*.example.org:SslProtocols:0" , "Tls12" ) ,
321
+ new KeyValuePair < string , string > ( "Endpoints:End1:Sni:*.example.org:Certificate:Path" , "/path/cert.pfx" ) ,
322
+ new KeyValuePair < string , string > ( "Endpoints:End1:Sni:*.example.org:Certificate:Password" , "certpassword" ) ,
323
+ new KeyValuePair < string , string > ( "Endpoints:End1:SNI:*.example.org:ClientCertificateMode" , "AllowCertificate" ) ,
324
+ } ) . Build ( ) ;
319
325
320
326
var reader = new ConfigurationReader ( config ) ;
321
327
@@ -338,12 +344,14 @@ public void ReadEndpointDefaultsWithSingleSslProtocolSet_ReturnsCorrectValue()
338
344
{
339
345
var config = new ConfigurationBuilder ( ) . AddInMemoryCollection ( new [ ]
340
346
{
341
- new KeyValuePair < string , string > ( "EndpointDefaults:SslProtocols:0" , "Tls11" ) ,
342
- } ) . Build ( ) ;
347
+ new KeyValuePair < string , string > ( "EndpointDefaults:SslProtocols:0" , "Tls11" ) ,
348
+ } ) . Build ( ) ;
343
349
var reader = new ConfigurationReader ( config ) ;
344
350
345
351
var endpoint = reader . EndpointDefaults ;
352
+ #pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
346
353
Assert . Equal ( SslProtocols . Tls11 , endpoint . SslProtocols ) ;
354
+ #pragma warning restore SYSLIB0039
347
355
}
348
356
349
357
[ Fact ]
0 commit comments