出于测试目的提供无效的 TFS 凭据

发布于 2024-12-21 10:36:17 字数 643 浏览 3 评论 0原文

我遇到的情况是,测试提供了无效的 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 NetworkCredentialsProviderclass simply returns the NetworkCredentialsupplied in its constructor.

Previously this was possible with the TeamFoundationServer class (which is now deprecated).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

数理化全能战士 2024-12-28 10:36:17

这是我一直在寻找的答案:

var account = new NetworkCredential(user.UserName, user.Password, user.Domain);
teamProjectCollection = new TfsTeamProjectCollection(new Uri(serverUri),account);
teamProjectCollection.Authenticate();

抱歉产生噪音!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文