出于测试目的提供无效的 TFS 凭据
我遇到的情况是,测试提供了无效的 TFS 凭据以使身份验证失败。但是,TfsTeamProjectCollection
正在获取我自己的凭据,并且始终成功调用 Authenticate()
。有没有办法强制无效的凭据?这就是我正在做的事情:
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
NetworkCredentialsProvider
类仅返回其构造函数中提供的NetworkCredential
。
以前,可以使用 TeamFoundationServer
类(现已弃用)实现此目的。
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).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我一直在寻找的答案:
抱歉产生噪音!
Here's the answer I was looking for:
Sorry for the noise!