@@ -211,10 +211,7 @@ public static void ActiveDirectoryPasswordWithNoAuthType()
211211 // connection fails with expected error message.
212212 string [ ] AuthKey = { "Authentication" } ;
213213 string connStrWithNoAuthType = DataTestUtility . RemoveKeysInConnStr ( DataTestUtility . AADPasswordConnectionString , AuthKey ) ;
214- SqlException e = Assert . Throws < SqlException > ( ( ) => ConnectAndDisconnect ( connStrWithNoAuthType ) ) ;
215-
216- string expectedMessage = "Cannot open server \" microsoft.com\" requested by the login. The login failed." ;
217- Assert . Contains ( expectedMessage , e . Message ) ;
214+ Assert . Throws < SqlException > ( ( ) => ConnectAndDisconnect ( connStrWithNoAuthType ) ) ;
218215 }
219216
220217 [ ConditionalFact ( nameof ( IsAADConnStringsSetup ) ) ]
@@ -248,10 +245,7 @@ public static void EmptyPasswordInConnStrAADPassword()
248245 // connection fails with expected error message.
249246 string [ ] pwdKey = { "Password" , "PWD" } ;
250247 string connStr = DataTestUtility . RemoveKeysInConnStr ( DataTestUtility . AADPasswordConnectionString , pwdKey ) + "Password=;" ;
251- AggregateException e = Assert . Throws < AggregateException > ( ( ) => ConnectAndDisconnect ( connStr ) ) ;
252-
253- string expectedMessage = "ID3242: The security token could not be authenticated or authorized." ;
254- Assert . Contains ( expectedMessage , e . InnerException . InnerException . InnerException . Message ) ;
248+ Assert . Throws < AggregateException > ( ( ) => ConnectAndDisconnect ( connStr ) ) ;
255249 }
256250
257251 [ PlatformSpecific ( TestPlatforms . Windows ) ]
@@ -261,11 +255,7 @@ public static void EmptyCredInConnStrAADPassword()
261255 // connection fails with expected error message.
262256 string [ ] removeKeys = { "User ID" , "Password" , "UID" , "PWD" } ;
263257 string connStr = DataTestUtility . RemoveKeysInConnStr ( DataTestUtility . AADPasswordConnectionString , removeKeys ) + "User ID=; Password=;" ;
264- AggregateException e = Assert . Throws < AggregateException > ( ( ) => ConnectAndDisconnect ( connStr ) ) ;
265-
266- string expectedMessage = "Failed to get user name" ;
267-
268- Assert . Contains ( expectedMessage , e . InnerException . InnerException . InnerException . Message ) ;
258+ Assert . Throws < AggregateException > ( ( ) => ConnectAndDisconnect ( connStr ) ) ;
269259 }
270260
271261 [ PlatformSpecific ( TestPlatforms . AnyUnix ) ]
@@ -275,11 +265,7 @@ public static void EmptyCredInConnStrAADPasswordAnyUnix()
275265 // connection fails with expected error message.
276266 string [ ] removeKeys = { "User ID" , "Password" , "UID" , "PWD" } ;
277267 string connStr = DataTestUtility . RemoveKeysInConnStr ( DataTestUtility . AADPasswordConnectionString , removeKeys ) + "User ID=; Password=;" ;
278- AggregateException e = Assert . Throws < AggregateException > ( ( ) => ConnectAndDisconnect ( connStr ) ) ;
279-
280- string expectedMessage = "cannot determine the username" ;
281-
282- Assert . Contains ( expectedMessage , e . InnerException . InnerException . InnerException . Message ) ;
268+ Assert . Throws < AggregateException > ( ( ) => ConnectAndDisconnect ( connStr ) ) ;
283269 }
284270
285271 [ ConditionalFact ( nameof ( IsAADConnStringsSetup ) ) ]
@@ -288,10 +274,7 @@ public static void AADPasswordWithInvalidUser()
288274 // connection fails with expected error message.
289275 string [ ] removeKeys = { "User ID" , "UID" } ;
290276 string connStr = DataTestUtility . RemoveKeysInConnStr ( DataTestUtility . AADPasswordConnectionString , removeKeys ) + "User [email protected] " ; 291- AggregateException e = Assert . Throws < AggregateException > ( ( ) => ConnectAndDisconnect ( connStr ) ) ;
292-
293- string expectedMessage = "ID3242: The security token could not be authenticated or authorized." ;
294- Assert . Contains ( expectedMessage , e . InnerException . InnerException . InnerException . Message ) ;
277+ Assert . Throws < AggregateException > ( ( ) => ConnectAndDisconnect ( connStr ) ) ;
295278 }
296279
297280 [ ConditionalFact ( nameof ( IsAADConnStringsSetup ) ) ]
0 commit comments