@@ -218,6 +218,62 @@ public void ReadEndpointsSection_ReturnsCollection()
218218 Assert . True ( cert4 . AllowInvalid ) ;
219219 }
220220
221+ [ Fact ]
222+ public void ReadEndpointWithSingleHttpProtocolSet_ReturnsCorrectValue ( )
223+ {
224+ var config = new ConfigurationBuilder ( ) . AddInMemoryCollection ( new [ ]
225+ {
226+ new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
227+ new KeyValuePair < string , string > ( "Endpoints:End1:Protocols" , "Http1" ) ,
228+ } ) . Build ( ) ;
229+ var reader = new ConfigurationReader ( config ) ;
230+
231+ var endpoint = reader . Endpoints . First ( ) ;
232+ Assert . Equal ( HttpProtocols . Http1 , endpoint . Protocols ) ;
233+ }
234+
235+ [ Fact ]
236+ public void ReadEndpointWithMultipleHttpProtocolsSet_ReturnsCorrectValue ( )
237+ {
238+ var config = new ConfigurationBuilder ( ) . AddInMemoryCollection ( new [ ]
239+ {
240+ new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
241+ new KeyValuePair < string , string > ( "Endpoints:End1:Protocols" , "Http1AndHttp2" ) ,
242+ } ) . Build ( ) ;
243+ var reader = new ConfigurationReader ( config ) ;
244+
245+ var endpoint = reader . Endpoints . First ( ) ;
246+ Assert . Equal ( HttpProtocols . Http1AndHttp2 , endpoint . Protocols ) ;
247+ }
248+
249+ [ Fact ]
250+ public void ReadEndpointWithUnionHttpProtocolsSet_ReturnsCorrectValue ( )
251+ {
252+ var config = new ConfigurationBuilder ( ) . AddInMemoryCollection ( new [ ]
253+ {
254+ new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
255+ new KeyValuePair < string , string > ( "Endpoints:End1:Protocols" , "Http2 | Http1" ) ,
256+ } ) . Build ( ) ;
257+ var reader = new ConfigurationReader ( config ) ;
258+
259+ var endpoint = reader . Endpoints . First ( ) ;
260+ Assert . Equal ( HttpProtocols . Http1AndHttp2 , endpoint . Protocols ) ;
261+ }
262+
263+ [ Fact ]
264+ public void ReadEndpointWithUnionHttpProtocolsSet_ReturnsNullForBadPart ( )
265+ {
266+ var config = new ConfigurationBuilder ( ) . AddInMemoryCollection ( new [ ]
267+ {
268+ new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
269+ new KeyValuePair < string , string > ( "Endpoints:End1:Protocols" , "Http2 | Http0" ) ,
270+ } ) . Build ( ) ;
271+ var reader = new ConfigurationReader ( config ) ;
272+
273+ var endpoint = reader . Endpoints . First ( ) ;
274+ Assert . Null ( endpoint . Protocols ) ;
275+ }
276+
221277 [ Fact ]
222278 public void ReadEndpointWithSingleSslProtocolSet_ReturnsCorrectValue ( )
223279 {
@@ -251,6 +307,51 @@ public void ReadEndpointWithMultipleSslProtocolsSet_ReturnsCorrectValue()
251307#pragma warning restore SYSLIB0039
252308 }
253309
310+ [ Fact ]
311+ public void ReadEndpointWithUnionSslProtocolSet_ReturnsCorrectValue ( )
312+ {
313+ var config = new ConfigurationBuilder ( ) . AddInMemoryCollection ( new [ ]
314+ {
315+ new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
316+ new KeyValuePair < string , string > ( "Endpoints:End1:SslProtocols:0" , "Tls12 | Tls11" ) ,
317+ } ) . Build ( ) ;
318+ var reader = new ConfigurationReader ( config ) ;
319+
320+ var endpoint = reader . Endpoints . First ( ) ;
321+ #pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
322+ Assert . Equal ( SslProtocols . Tls11 | SslProtocols . Tls12 , endpoint . SslProtocols ) ;
323+ #pragma warning restore SYSLIB0039
324+ }
325+
326+ [ Fact ]
327+ public void ReadEndpointWithUnionSslProtocolSet_ReturnsNoneForBadPart ( )
328+ {
329+ var config = new ConfigurationBuilder ( ) . AddInMemoryCollection ( new [ ]
330+ {
331+ new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
332+ new KeyValuePair < string , string > ( "Endpoints:End1:SslProtocols:0" , "Tls12 | Tls0" ) ,
333+ } ) . Build ( ) ;
334+ var reader = new ConfigurationReader ( config ) ;
335+
336+ var endpoint = reader . Endpoints . First ( ) ;
337+ Assert . Equal ( SslProtocols . None , endpoint . SslProtocols ) ;
338+ }
339+
340+ [ Fact ]
341+ public void ReadEndpointWithUnionSslProtocolSet_ReturnsNoneForBadPartInAnyChild ( )
342+ {
343+ var config = new ConfigurationBuilder ( ) . AddInMemoryCollection ( new [ ]
344+ {
345+ new KeyValuePair < string , string > ( "Endpoints:End1:Url" , "http://*:5001" ) ,
346+ new KeyValuePair < string , string > ( "Endpoints:End1:SslProtocols:0" , "Tls11" ) ,
347+ new KeyValuePair < string , string > ( "Endpoints:End1:SslProtocols:1" , "Tls12 | Tls0" ) ,
348+ } ) . Build ( ) ;
349+ var reader = new ConfigurationReader ( config ) ;
350+
351+ var endpoint = reader . Endpoints . First ( ) ;
352+ Assert . Equal ( SslProtocols . None , endpoint . SslProtocols ) ;
353+ }
354+
254355 [ Fact ]
255356 public void ReadEndpointWithSslProtocolSet_ReadsCaseInsensitive ( )
256357 {
0 commit comments