-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Adds the ability to specify an appsettings file for user-jwts #58605
base: main
Are you sure you want to change the base?
Conversation
@dotnet-policy-service agree company="Stack Overflow" |
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 :) |
Copilot
AI
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.
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);
|
||
var appSettings = JsonSerializer.Deserialize<JsonObject>(File.ReadAllText(appsettings)); | ||
Assert.Equal("dotnet-user-jwts", appSettings["Authentication"]["Schemes"]["Bearer"]["ValidIssuer"].GetValue<string>()); | ||
app.Run(["create", "--project", project, "--issuer", "new-issuer", "--appsettings-file", "appsettings.Local.json"]); |
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 method call should use parentheses instead of square brackets.
app.Run(["create", "--project", project, "--issuer", "new-issuer", "--appsettings-file", "appsettings.Local.json"]); | |
app.Run(new[] { "create", "--project", project, "--issuer", "new-issuer", "--appsettings-file", "appsettings.Local.json" }); |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
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 isn't a good suggestion. We're taking advantage of the new collection expressions language feature here.
} | ||
else if (!File.Exists(Path.Combine(Path.GetDirectoryName(projectPath), appsettingsFile))) | ||
{ | ||
reporter.Error(Resources.FormatRemoveCommand_AppsettingsFileNotFound_Error(Path.GetDirectoryName(projectPath))); |
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))); |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
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 :)
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. 🤔 |
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
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-jwts
tool amendsappsettings.Development.json
when adding a mock JWT scheme for local testing. Many people useappsettings.Development.json
for environments other than local development, i.e. a cloud Development environment, and so this amendment causes issues. In my particular case, we haveappsettings.Local.json
instead 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