private static void Authenticate(TFSCredentials credentials) { NetworkCredential netCred = new NetworkCredential(credentials.username, credentials.password); Microsoft.VisualStudio.Services.Common.WindowsCredential winCred = new Microsoft.VisualStudio.Services.Common.WindowsCredential(netCred); VssCredentials vssCred = new VssClientCredentials(winCred); _tfs = new TfsTeamProjectCollection(new Uri("https://tfs.aurigo.com/tfs/DefaultCollection"), vssCred); _tfs.Authenticate(); }
// POST: api/TFS/5 public HttpResponseMessage Post(int id, [FromBody] TFSCredentials credentials) { try { //Get the latest suites for a team with the given credentials TFS.GetLatestTestSuites(id, credentials); return(Request.CreateResponse(HttpStatusCode.OK, true)); } catch (Exception) { return(Request.CreateResponse(HttpStatusCode.BadRequest, false)); } }
public static void GetLatestTestSuites(int TeamId, TFSCredentials credentials) { if (getLatestInProgress.Contains(TeamId)) { return; } try { getLatestInProgress.Add(TeamId); Authenticate(credentials); GetLatestSuites(TeamId); UpdateTotalTestNumbers(TeamId); } finally { getLatestInProgress.Remove(TeamId); } }