Skip to content

testconsole: 401 Unauthorised when attempting to retrieve automated test runs #1420

@dave-sampson13

Description

@dave-sampson13

Awesome task!

I'm using the testconsole to test my configuration & handlebars template. If I issue myself a PAT with full access, everything works fine. However, if I attempt to restrict the permissions in the PAT to those I would expect it to need, it only goes so far before encountering a 401 Unauthorised when attempting to retrieve details of automated test runs (there are none in my project, by the way), which then seemingly causes it to lose all the work items it had previously successfully retrieved, and consequently the markdown file produced is largely empty.

I tracked the issue down to

, specifically
let buildTestResults = await (testAPI.getTestResultsByBuild(teamProject, buildId));
which uses testAPI.getTestResultsByBuild and hates me & the PAT I rode in on.

The doco is fairly limited on what access this extension method & the APIs it calls needs, so running a bit blind, but my work-around for now has been to comment out the majority of this function (because I don't have any automated tests anyway), and then everything works just fine. Ideally though I wouldn't need to do that, & instead it'd be good to:

  1. Know exactly what permissions the PAT I use with the testconsole needs so I don't need to create a PAT with full access (indeed some Azure DevOps organisations I work with don't even allow the creation of full access PATs)
  2. More gracefully handle this case of the 401, so that although it might result in no tests being retrieved, at least it wouldn't result in the whole object structure being empty, particularly the work items, not sure why this should impact them

Thanks for your help, let me know if you need any more information!

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    To Do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions