-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Adds the ability to specify an appsettings file for user-jwts #58605
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
Conversation
|
@dotnet-policy-service agree company="Stack Overflow" |
captainsafia
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall!
It might be a good idea to move the validation logic that is duplicated across different source files into a single helper to make it easier to keep the validation logic in sync across the different commands.
@halter73 Can you sanity check my review here?
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
Thanks for taking a look @captainsafia I've moved the validation logic to reduce duplication as suggested :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 5 out of 7 changed files in this pull request and generated 2 comments.
Files not reviewed (2)
- src/Tools/dotnet-user-jwts/src/Resources.resx: Language not supported
- src/Tools/dotnet-user-jwts/src/Commands/RemoveCommand.cs: Evaluated as low risk
Comments suppressed due to low confidence (1)
src/Tools/dotnet-user-jwts/src/Helpers/DevJwtCliHelpers.cs:55
- The error message 'Resources.RemoveCommand_InvalidAppsettingsFile_Error' is unclear. It should be more descriptive, such as 'The specified appsettings file is invalid. Please provide a valid JSON file.'
reporter.Error(Resources.RemoveCommand_InvalidAppsettingsFile_Error);
| } | ||
| else if (!File.Exists(Path.Combine(Path.GetDirectoryName(projectPath), appsettingsFile))) | ||
| { | ||
| reporter.Error(Resources.FormatRemoveCommand_AppsettingsFileNotFound_Error(Path.GetDirectoryName(projectPath))); |
Copilot
AI
Dec 17, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message 'Resources.FormatRemoveCommand_AppsettingsFileNotFound_Error' should include the filename that was not found to provide more context to the user.
| reporter.Error(Resources.FormatRemoveCommand_AppsettingsFileNotFound_Error(Path.GetDirectoryName(projectPath))); | |
| reporter.Error(Resources.FormatRemoveCommand_AppsettingsFileNotFound_Error(Path.Combine(Path.GetDirectoryName(projectPath), appsettingsFile))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a good suggestion, especially if the user has provided a non-default value for the upsettings file. @ChrisAnn thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me, along with the suggested wording change copilot made above.
I've pushed the changes :)
captainsafia
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall!
Copilot provided one helpful suggestion that might be worthwhile to apply.
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Head branch was pushed to by a user without write access
|
Apologies for not running the tests locally after changing the error messages 🙈 |
🙊 Oops -- I should've caught that before approving and putting this PR on auto-merge. 😬 But hey....hurrah for CI catching human error? I wonder if Copilot would've flagged it. 🤔 |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
* Adds the ability to specify an appsettings file for user-jwts Addresses #56169 * Move the validation logic into a central location * Adds copilot suggestions to improve error messages * Fix tests after changing error message when appsettings not found
Adds the ability to specify an appsettings file for user-jwts
Adds the ability to specify an appsettings file for user-jwts
Description
Currently the
user-jwtstool amendsappsettings.Development.jsonwhen adding a mock JWT scheme for local testing. Many people useappsettings.Development.jsonfor environments other than local development, i.e. a cloud Development environment, and so this amendment causes issues. In my particular case, we haveappsettings.Local.jsoninstead and so the tool fails to execute because it cannot findappsettings.Development.json.As described in #56169 this affects multiple other teams too.
This PR allows for an appsettings file to be specified which will be amended instead of the default
appsettings.Development.json. The tool still assumes the file lives next to the project, as it currently does, and checks that the file both exists and ends in.json. Tests have been added to confirm the functionality.Fixes #56169