@@ -8,43 +8,43 @@ namespace Servus.Akka.Tests.Transport;
88public sealed class ConnectionInfoSpec
99{
1010 [ Fact ( Timeout = 5000 ) ]
11- public void Should_store_all_properties ( )
11+ public void Should_store_endpoints_and_protocol ( )
1212 {
1313 var local = new IPEndPoint ( IPAddress . Loopback , 5000 ) ;
1414 var remote = new IPEndPoint ( IPAddress . Parse ( "192.168.1.1" ) , 443 ) ;
15- var sslProtocol = SslProtocols . Tls13 ;
16- var appProtocol = SslApplicationProtocol . Http2 ;
1715
18- var info = new ConnectionInfo ( local , remote , sslProtocol , appProtocol ) ;
16+ var info = new ConnectionInfo ( local , remote , TransportProtocol . Tcp ) ;
1917
2018 Assert . Equal ( local , info . Local ) ;
2119 Assert . Equal ( remote , info . Remote ) ;
22- Assert . Equal ( sslProtocol , info . NegotiatedSslProtocol ) ;
23- Assert . Equal ( appProtocol , info . NegotiatedApplicationProtocol ) ;
20+ Assert . Equal ( TransportProtocol . Tcp , info . Protocol ) ;
21+ Assert . Null ( info . Security ) ;
2422 }
2523
2624 [ Fact ( Timeout = 5000 ) ]
27- public void Should_support_null_ssl_properties ( )
25+ public void Should_store_security_info_when_provided ( )
2826 {
29- var local = new IPEndPoint ( IPAddress . Loopback , 8080 ) ;
30- var remote = new IPEndPoint ( IPAddress . Parse ( "10.0.0.1" ) , 80 ) ;
27+ var local = new IPEndPoint ( IPAddress . Loopback , 5000 ) ;
28+ var remote = new IPEndPoint ( IPAddress . Parse ( "192.168.1.1" ) , 443 ) ;
29+ var security = new SecurityInfo ( SslProtocols . Tls13 , SslApplicationProtocol . Http2 ) ;
3130
32- var info = new ConnectionInfo ( local , remote , NegotiatedSslProtocol : null , NegotiatedApplicationProtocol : null ) ;
31+ var info = new ConnectionInfo ( local , remote , TransportProtocol . Tls , security ) ;
3332
34- Assert . Equal ( local , info . Local ) ;
35- Assert . Equal ( remote , info . Remote ) ;
36- Assert . Null ( info . NegotiatedSslProtocol ) ;
37- Assert . Null ( info . NegotiatedApplicationProtocol ) ;
33+ Assert . Equal ( TransportProtocol . Tls , info . Protocol ) ;
34+ Assert . NotNull ( info . Security ) ;
35+ Assert . Equal ( SslProtocols . Tls13 , info . Security . Protocol ) ;
36+ Assert . Equal ( SslApplicationProtocol . Http2 , info . Security . ApplicationProtocol ) ;
3837 }
3938
4039 [ Fact ( Timeout = 5000 ) ]
4140 public void Equality_should_work_for_records ( )
4241 {
4342 var local = new IPEndPoint ( IPAddress . Loopback , 5000 ) ;
4443 var remote = new IPEndPoint ( IPAddress . Parse ( "192.168.1.1" ) , 443 ) ;
44+ var security = new SecurityInfo ( SslProtocols . Tls13 , SslApplicationProtocol . Http2 ) ;
4545
46- var info1 = new ConnectionInfo ( local , remote , SslProtocols . Tls13 , SslApplicationProtocol . Http2 ) ;
47- var info2 = new ConnectionInfo ( local , remote , SslProtocols . Tls13 , SslApplicationProtocol . Http2 ) ;
46+ var info1 = new ConnectionInfo ( local , remote , TransportProtocol . Tls , security ) ;
47+ var info2 = new ConnectionInfo ( local , remote , TransportProtocol . Tls , security ) ;
4848
4949 Assert . Equal ( info1 , info2 ) ;
5050 Assert . Equal ( info1 . GetHashCode ( ) , info2 . GetHashCode ( ) ) ;
@@ -57,8 +57,8 @@ public void Inequality_should_work_for_different_local_endpoint()
5757 var local2 = new IPEndPoint ( IPAddress . Loopback , 5001 ) ;
5858 var remote = new IPEndPoint ( IPAddress . Parse ( "192.168.1.1" ) , 443 ) ;
5959
60- var info1 = new ConnectionInfo ( local1 , remote , SslProtocols . Tls13 , SslApplicationProtocol . Http2 ) ;
61- var info2 = new ConnectionInfo ( local2 , remote , SslProtocols . Tls13 , SslApplicationProtocol . Http2 ) ;
60+ var info1 = new ConnectionInfo ( local1 , remote , TransportProtocol . Tcp ) ;
61+ var info2 = new ConnectionInfo ( local2 , remote , TransportProtocol . Tcp ) ;
6262
6363 Assert . NotEqual ( info1 , info2 ) ;
6464 }
@@ -70,50 +70,45 @@ public void Inequality_should_work_for_different_remote_endpoint()
7070 var remote1 = new IPEndPoint ( IPAddress . Parse ( "192.168.1.1" ) , 443 ) ;
7171 var remote2 = new IPEndPoint ( IPAddress . Parse ( "192.168.1.2" ) , 443 ) ;
7272
73- var info1 = new ConnectionInfo ( local , remote1 , SslProtocols . Tls13 , SslApplicationProtocol . Http2 ) ;
74- var info2 = new ConnectionInfo ( local , remote2 , SslProtocols . Tls13 , SslApplicationProtocol . Http2 ) ;
73+ var info1 = new ConnectionInfo ( local , remote1 , TransportProtocol . Tcp ) ;
74+ var info2 = new ConnectionInfo ( local , remote2 , TransportProtocol . Tcp ) ;
7575
7676 Assert . NotEqual ( info1 , info2 ) ;
7777 }
7878
7979 [ Fact ( Timeout = 5000 ) ]
80- public void Inequality_should_work_for_different_ssl_protocol ( )
80+ public void Inequality_should_work_for_different_protocol ( )
8181 {
8282 var local = new IPEndPoint ( IPAddress . Loopback , 5000 ) ;
8383 var remote = new IPEndPoint ( IPAddress . Parse ( "192.168.1.1" ) , 443 ) ;
8484
85- var info1 = new ConnectionInfo ( local , remote , SslProtocols . Tls13 , SslApplicationProtocol . Http2 ) ;
86- var info2 = new ConnectionInfo ( local , remote , SslProtocols . Tls12 , SslApplicationProtocol . Http2 ) ;
85+ var info1 = new ConnectionInfo ( local , remote , TransportProtocol . Tcp ) ;
86+ var info2 = new ConnectionInfo ( local , remote , TransportProtocol . Quic ) ;
8787
8888 Assert . NotEqual ( info1 , info2 ) ;
8989 }
9090
9191 [ Fact ( Timeout = 5000 ) ]
92- public void Inequality_should_work_for_different_app_protocol ( )
92+ public void Inequality_should_work_for_different_security ( )
9393 {
9494 var local = new IPEndPoint ( IPAddress . Loopback , 5000 ) ;
9595 var remote = new IPEndPoint ( IPAddress . Parse ( "192.168.1.1" ) , 443 ) ;
9696
97- var info1 = new ConnectionInfo ( local , remote , SslProtocols . Tls13 , SslApplicationProtocol . Http2 ) ;
98- var info2 = new ConnectionInfo ( local , remote , SslProtocols . Tls13 , SslApplicationProtocol . Http11 ) ;
97+ var info1 = new ConnectionInfo ( local , remote , TransportProtocol . Tls ,
98+ new SecurityInfo ( SslProtocols . Tls13 , SslApplicationProtocol . Http2 ) ) ;
99+ var info2 = new ConnectionInfo ( local , remote , TransportProtocol . Tls ,
100+ new SecurityInfo ( SslProtocols . Tls12 , SslApplicationProtocol . Http2 ) ) ;
99101
100102 Assert . NotEqual ( info1 , info2 ) ;
101103 }
102104
103105 [ Fact ( Timeout = 5000 ) ]
104- public void Should_support_mixed_null_ssl_fields ( )
106+ public void None_should_have_sensible_defaults ( )
105107 {
106- var local = new IPEndPoint ( IPAddress . Loopback , 5000 ) ;
107- var remote = new IPEndPoint ( IPAddress . Parse ( "192.168.1.1" ) , 443 ) ;
108-
109- var info1 = new ConnectionInfo ( local , remote , SslProtocols . Tls13 , NegotiatedApplicationProtocol : null ) ;
110- var info2 = new ConnectionInfo ( local , remote , NegotiatedSslProtocol : null , SslApplicationProtocol . Http2 ) ;
111-
112- Assert . Equal ( SslProtocols . Tls13 , info1 . NegotiatedSslProtocol ) ;
113- Assert . Null ( info1 . NegotiatedApplicationProtocol ) ;
108+ var none = ConnectionInfo . None ;
114109
115- Assert . Null ( info2 . NegotiatedSslProtocol ) ;
116- Assert . Equal ( SslApplicationProtocol . Http2 , info2 . NegotiatedApplicationProtocol ) ;
110+ Assert . Equal ( TransportProtocol . None , none . Protocol ) ;
111+ Assert . Null ( none . Security ) ;
117112 }
118113
119114 [ Fact ( Timeout = 5000 ) ]
@@ -122,8 +117,10 @@ public void Should_work_as_dictionary_key()
122117 var local = new IPEndPoint ( IPAddress . Loopback , 5000 ) ;
123118 var remote = new IPEndPoint ( IPAddress . Parse ( "192.168.1.1" ) , 443 ) ;
124119
125- var info1 = new ConnectionInfo ( local , remote , SslProtocols . Tls13 , SslApplicationProtocol . Http2 ) ;
126- var info2 = new ConnectionInfo ( local , remote , SslProtocols . Tls13 , SslApplicationProtocol . Http2 ) ;
120+ var info1 = new ConnectionInfo ( local , remote , TransportProtocol . Tls ,
121+ new SecurityInfo ( SslProtocols . Tls13 , SslApplicationProtocol . Http2 ) ) ;
122+ var info2 = new ConnectionInfo ( local , remote , TransportProtocol . Tls ,
123+ new SecurityInfo ( SslProtocols . Tls13 , SslApplicationProtocol . Http2 ) ) ;
127124
128125 var dict = new Dictionary < ConnectionInfo , string > { { info1 , "pooled" } } ;
129126
0 commit comments