Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#3242) Attempt default credentials for sources #3252

Merged
merged 2 commits into from
Jul 10, 2023

Conversation

corbob
Copy link
Member

@corbob corbob commented Jul 5, 2023

Description Of Changes

Attempt to use the default credentials for the first attempt at a source.

Important note of behaviour change: If we are not able to authenticate with a source, we now prompt 3 times instead of 4, and the first one is prefaced with an Invalid credentials specified warning.

Motivation and Context

When attempting a query to a source that requires credentials, we were always prompting for credentials. This prevents attempting the default credentials unless entering an empty password. We should attempt initially with the default credentials, and only prompt if it's a retry for credentials.

Testing

  1. Ran Test Kitchen test suites. All tests behaved as expected.
  2. Ran some manual tests against an authenticated source without username/password. Confirmed it still prompted for credentials.
  3. Ran some manual tests against a Windows authenticated source without username/password. Confirmed that it worked correctly.

Automated test suite:

  1. Installed the (signed) choco build from Team City
  2. Ran new ./Invoke-AuthedTests.ps1 script
  3. Confirmed that all test failures reported were explainable.

Some output screenshots of the authenticated tests without username/password provided:

  • Chocolatey CLI 2.1.0
2023-07-05_06-34-09 - Chocolatey CLI debug build image

Operating Systems Testing

  • Windows Server 2016
  • Windows Server 2019

Change Types Made

  • Bug fix (non-breaking change).
  • Feature / Enhancement (non-breaking change).
  • Breaking change (fix or feature that could cause existing functionality to change).
  • Documentation changes.
  • PowerShell code changes.

Change Checklist

  • Requires a change to the documentation.
  • Documentation has been updated.
  • Tests to cover my changes, have been added.
  • All new and existing tests passed?
  • PowerShell code changes: PowerShell v2 compatibility checked?

Related Issue

Fixes #3242

corbob added 2 commits July 4, 2023 19:34
When attempting a query to a source that requires credentials, we were
always prompting for credentials. This prevents attempting the default
credentials unless entering an empty password. We should attempt
initially with the default credentials, and only prompt if it's a retry
for credentials.
Add a script to take in a repository and API Key so that the tests can
be run against an authenticated end point using Windows Authentication.
@corbob corbob force-pushed the attempt-default-credentials branch from a9b8b3e to dbc39db Compare July 5, 2023 23:30
@corbob corbob marked this pull request as ready for review July 6, 2023 00:23
@corbob corbob requested a review from gep13 July 6, 2023 00:23
Copy link
Member

@vexx32 vexx32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to work as described in a test environment. Nice work, Cory! Thanks for sorting this out! 💖

@vexx32 vexx32 merged commit 5747de4 into chocolatey:develop Jul 10, 2023
@corbob corbob deleted the attempt-default-credentials branch July 11, 2023 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants