Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Tools/dotnet-user-jwts/src/Helpers/DevJwtCliHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer.Tools;

internal static class DevJwtCliHelpers
{
public static string GetOrSetUserSecretsId(IReporter reporter, string projectFilePath)
public static string GetOrSetUserSecretsId(string projectFilePath)
{
var resolver = new ProjectIdResolver(reporter, projectFilePath);
var resolver = new ProjectIdResolver(NullReporter.Singleton, projectFilePath);
var id = resolver.Resolve(projectFilePath, configuration: null);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not pass in a higher configuration level by default and then we can have an option like user-secrets to have a different config level to get verbose logs:
https://source.dot.net/#dotnet-user-secrets/CommandLineOptions.cs,39

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We don't currently have a verbose flag on the tool, but even if we did I think we'd end up passing either a ConsoleReporter or NullReporter here depending on whether or not that verbose flag is set.

if (string.IsNullOrEmpty(id))
{
return UserSecretsCreator.CreateUserSecretsId(reporter, projectFilePath, projectFilePath);
return UserSecretsCreator.CreateUserSecretsId(NullReporter.Singleton, projectFilePath, projectFilePath);
}
return id;
}
Expand Down Expand Up @@ -52,7 +52,7 @@ public static bool GetProjectAndSecretsId(string projectPath, IReporter reporter
return false;
}

userSecretsId = GetOrSetUserSecretsId(reporter, project);
userSecretsId = GetOrSetUserSecretsId(project);
if (userSecretsId == null)
{
reporter.Error($"Project does not contain a user secrets ID.");
Expand Down
4 changes: 2 additions & 2 deletions src/Tools/dotnet-user-jwts/test/UserJwtsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void List_HandlesNoSecretsInProject()
var app = new Program(_console);

app.Run(new[] { "list", "--project", project });
Assert.Contains("Set UserSecretsId to ", _console.GetOutput());
Assert.DoesNotContain("Set UserSecretsId to ", _console.GetOutput());
Assert.Contains("No JWTs created yet!", _console.GetOutput());
}

Expand All @@ -62,7 +62,7 @@ public void Create_CreatesSecretOnNoSecretInproject()
app.Run(new[] { "create", "--project", project });
var output = _console.GetOutput();
Assert.DoesNotContain("could not find SecretManager.targets", output);
Assert.Contains("Set UserSecretsId to ", output);
Assert.DoesNotContain("Set UserSecretsId to ", output);
Assert.Contains("New JWT saved", output);
}

Expand Down