Reputation: 10280
I'm having a scenario where a test is supplying invalid TFS credentials in order to fail authentication. However, TfsTeamProjectCollection
is picking up my own credentials and always succeeds the call to Authenticate()
. Is there a way to force invalid credentials? Here's what I am doing:
var account = new NetworkCredential(user.UserName, user.Password, user.Domain);
var provider = new NetworkCredentialsProvider(account);
teamProjectCollection = new TfsTeamProjectCollection(
new Uri(serverUri),
provider);
teamProjectCollection.Authenticate(); // should throw with invalid credentials
The NetworkCredentialsProvider
class simply returns the NetworkCredential
supplied in its constructor.
Previously this was possible with the TeamFoundationServer
class (which is now deprecated).
Upvotes: 0
Views: 408
Reputation: 10280
Here's the answer I was looking for:
var account = new NetworkCredential(user.UserName, user.Password, user.Domain);
teamProjectCollection = new TfsTeamProjectCollection(new Uri(serverUri),account);
teamProjectCollection.Authenticate();
Sorry for the noise!
Upvotes: 3