@@ -135,6 +135,9 @@ public void SslProtocols_InvalidValue()
135135 [ InlineData ( "contoso.redis.cache.usgovcloudapi.net:6380" , true ) ]
136136 [ InlineData ( "contoso.redis.cache.sovcloud-api.de:6380" , true ) ]
137137 [ InlineData ( "contoso.redis.cache.sovcloud-api.fr:6380" , true ) ]
138+ [ InlineData ( "contoso.redis.cache.windows.net:6379" , false ) ] // non-SSL port
139+ [ InlineData ( "contoso.redis.cache.windows.net:10000" , false ) ] // wrong port
140+ [ InlineData ( "contoso.redis.cache.windows.net" , false ) ] // no port
138141 public void ConfigurationOptionsDefaultForAzure ( string hostAndPort , bool sslShouldBeEnabled )
139142 {
140143 Version defaultAzureVersion = new ( 6 , 0 , 0 ) ;
@@ -149,11 +152,16 @@ public void ConfigurationOptionsDefaultForAzure(string hostAndPort, bool sslShou
149152 [ InlineData ( "contoso.redis.chinacloudapi.cn:10000" , true ) ]
150153 [ InlineData ( "contoso.redis.usgovcloudapi.net:10000" , true ) ]
151154 [ InlineData ( "contoso.redisenterprise.cache.azure.net:10000" , true ) ]
155+ [ InlineData ( "contoso.REDIS.sovcloud-api.de:10000" , true ) ] // added a few upper case chars to validate comparison
156+ [ InlineData ( "contoso.redis.sovcloud-api.fr:10000" , true ) ]
157+ [ InlineData ( "contoso.redis.azure.net:6379" , true ) ] // AMR port is usually 10000, assume SSL regardless
158+ [ InlineData ( "contoso.redis.azure.net:6380" , true ) ] // AMR port is usually 10000, assume SSL regardless
159+ [ InlineData ( "contoso.redis.azure.net" , true ) ] // no port, assume SSL
152160 public void ConfigurationOptionsDefaultForAzureManagedRedis ( string hostAndPort , bool sslShouldBeEnabled )
153161 {
154- Version defaultAzureVersion = new ( 7 , 4 , 0 ) ;
162+ Version defaultAzureManagedRedisVersion = new ( 7 , 4 , 0 ) ;
155163 var options = ConfigurationOptions . Parse ( hostAndPort ) ;
156- Assert . True ( options . DefaultVersion . Equals ( defaultAzureVersion ) ) ;
164+ Assert . True ( options . DefaultVersion . Equals ( defaultAzureManagedRedisVersion ) ) ;
157165 Assert . False ( options . AbortOnConnectFail ) ;
158166 Assert . Equal ( sslShouldBeEnabled , options . Ssl ) ;
159167 }
@@ -166,12 +174,26 @@ public void ConfigurationOptionsForAzureWhenSpecified()
166174 Assert . True ( options . AbortOnConnectFail ) ;
167175 }
168176
169- [ Fact ]
170- public void ConfigurationOptionsDefaultForNonAzure ( )
177+ [ Theory ]
178+ [ InlineData ( "redis.contoso.com" ) ] // no port
179+ [ InlineData ( "redis.contoso.com:xx" ) ] // invalid port
180+ [ InlineData ( "redis.contoso.com:6379" ) ] // valid port
181+ [ InlineData ( "contoso.Xredis.cache.windows.net:6380" ) ] // almost an Azure Cache for Redis host name
182+ [ InlineData ( "contoso.redis.cache.windows.netX:6380" ) ] // almost an Azure Cache for Redis host name
183+ [ InlineData ( "contoso.redis.cache.windows.net.X:6380" ) ] // almost an Azure Cache for Redis host name
184+ [ InlineData ( "contoso.Xredis.azure.net:10000" ) ] // almost an Azure Managed Redis host name
185+ [ InlineData ( "contoso.redis.azure.netX:10000" ) ] // almost an Azure Managed Redis host name
186+ [ InlineData ( "contoso.redis.azure.net.X:10000" ) ] // almost an Azure Managed Redis host name
187+ [ InlineData ( "contoso.redis.cache.windows.net:xx" ) ] // Azure Cache for Redis host name with invalid port
188+ [ InlineData ( "contoso.redis.cache.windows.net:" ) ] // Azure Cache for Redis host name with missing port
189+ [ InlineData ( "contoso.redis.azure.net:xx" ) ] // AMR host name with invalid port
190+ [ InlineData ( "contoso.redis.azure.net:" ) ] // AMR host name with missing port
191+ public void ConfigurationOptionsDefaultForNonAzure ( string hostAndPort )
171192 {
172- var options = ConfigurationOptions . Parse ( "redis.contoso.com" ) ;
193+ var options = ConfigurationOptions . Parse ( hostAndPort ) ;
173194 Assert . True ( options . DefaultVersion . Equals ( DefaultVersion ) ) ;
174195 Assert . True ( options . AbortOnConnectFail ) ;
196+ Assert . False ( options . Ssl ) ;
175197 }
176198
177199 [ Fact ]
0 commit comments