@@ -211,10 +211,7 @@ public static void ActiveDirectoryPasswordWithNoAuthType()
211
211
// connection fails with expected error message.
212
212
string [ ] AuthKey = { "Authentication" } ;
213
213
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 ) ) ;
218
215
}
219
216
220
217
[ ConditionalFact ( nameof ( IsAADConnStringsSetup ) ) ]
@@ -248,10 +245,7 @@ public static void EmptyPasswordInConnStrAADPassword()
248
245
// connection fails with expected error message.
249
246
string [ ] pwdKey = { "Password" , "PWD" } ;
250
247
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 ) ) ;
255
249
}
256
250
257
251
[ PlatformSpecific ( TestPlatforms . Windows ) ]
@@ -261,11 +255,7 @@ public static void EmptyCredInConnStrAADPassword()
261
255
// connection fails with expected error message.
262
256
string [ ] removeKeys = { "User ID" , "Password" , "UID" , "PWD" } ;
263
257
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 ) ) ;
269
259
}
270
260
271
261
[ PlatformSpecific ( TestPlatforms . AnyUnix ) ]
@@ -275,11 +265,7 @@ public static void EmptyCredInConnStrAADPasswordAnyUnix()
275
265
// connection fails with expected error message.
276
266
string [ ] removeKeys = { "User ID" , "Password" , "UID" , "PWD" } ;
277
267
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 ) ) ;
283
269
}
284
270
285
271
[ ConditionalFact ( nameof ( IsAADConnStringsSetup ) ) ]
@@ -288,10 +274,7 @@ public static void AADPasswordWithInvalidUser()
288
274
// connection fails with expected error message.
289
275
string [ ] removeKeys = { "User ID" , "UID" } ;
290
276
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 ) ) ;
295
278
}
296
279
297
280
[ ConditionalFact ( nameof ( IsAADConnStringsSetup ) ) ]
0 commit comments