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

Cleaner exit when user credentials are incorrect #2296

Merged
merged 20 commits into from
Nov 20, 2024

Conversation

craddm
Copy link
Contributor

@craddm craddm commented Nov 15, 2024

✅ Checklist

  • You have given your pull request a meaningful title (e.g. Enable foobar integration rather than 515 foobar).
  • You are targeting the appropriate branch. If you're not certain which one this is, it should be develop.
  • Your branch is up-to-date with the target branch (it probably was when you started, but it may have changed since then).

🚦 Depends on

⤴️ Summary

When the user rejects the current credentials when asked to confirm they are correct, code would still continue to run, resulting in numerous additional, unnecessary and misleading error messages.

In addition, when the user rejects the Graph API credentials as incorrect, there is currently no clear way to change those credentials.
Graph API log-in is, unlike Az CLI log-in, not done by the user at the command line.

This PR simply exits when the user confirms that the credentials are incorrect, and prints only informative error messages.
In addition, it advises the user how to remove the cached Graph API credentials so as to be able to login with other credentials.

🌂 Related issues

Closes #2280
Closes #2153

🔬 Tests

Tested locally

@craddm craddm changed the base branch from develop to release-v5.1.0 November 15, 2024 16:09
Copy link

github-actions bot commented Nov 15, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  data_safe_haven/exceptions
  __init__.py
  data_safe_haven/external/api
  credentials.py 231-235
  graph_api.py 840
Project Total  

This report was generated by python-coverage-comment-action

@craddm craddm marked this pull request as ready for review November 15, 2024 16:19
@craddm craddm requested a review from a team as a code owner November 15, 2024 16:19
Copy link
Member

@JimMadge JimMadge left a comment

Choose a reason for hiding this comment

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

I don't think this is how we should solve this. We want to catch the problem and raise a suitable exception, which is handled by the command function.

data_safe_haven/external/api/credentials.py Outdated Show resolved Hide resolved
@craddm craddm changed the base branch from release-v5.1.0 to develop November 18, 2024 10:58
@JimMadge JimMadge assigned craddm and JimMadge and unassigned craddm Nov 18, 2024
@JimMadge
Copy link
Member

Example output

Screenshot 2024-11-20 at 10 02 17

@JimMadge JimMadge self-requested a review November 20, 2024 11:08
@JimMadge JimMadge dismissed their stale review November 20, 2024 11:08

My own review

Copy link
Member

@JimMadge JimMadge left a comment

Choose a reason for hiding this comment

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

@craddm Could you take a look at this and say what you think?

I can't request a review from you as you opened the PR 😆

@craddm
Copy link
Contributor Author

craddm commented Nov 20, 2024

LGTM

@JimMadge JimMadge merged commit de14322 into alan-turing-institute:develop Nov 20, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
2 participants