From 92834c8a7342d1ab91ec61dcaf186052e8f952eb Mon Sep 17 00:00:00 2001 From: Safia Abdalla <safia@microsoft.com> Date: Tue, 5 Jul 2022 18:53:56 -0700 Subject: [PATCH] Reduce console spew when creating secrets in user-jwts (#42542) --- .../dotnet-user-jwts/src/Helpers/DevJwtCliHelpers.cs | 8 ++++---- src/Tools/dotnet-user-jwts/test/UserJwtsTests.cs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Tools/dotnet-user-jwts/src/Helpers/DevJwtCliHelpers.cs b/src/Tools/dotnet-user-jwts/src/Helpers/DevJwtCliHelpers.cs index 7a7dc7541c3..2dbdda44f2e 100644 --- a/src/Tools/dotnet-user-jwts/src/Helpers/DevJwtCliHelpers.cs +++ b/src/Tools/dotnet-user-jwts/src/Helpers/DevJwtCliHelpers.cs @@ -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); if (string.IsNullOrEmpty(id)) { - return UserSecretsCreator.CreateUserSecretsId(reporter, projectFilePath, projectFilePath); + return UserSecretsCreator.CreateUserSecretsId(NullReporter.Singleton, projectFilePath, projectFilePath); } return id; } @@ -52,7 +52,7 @@ internal static class DevJwtCliHelpers return false; } - userSecretsId = GetOrSetUserSecretsId(reporter, project); + userSecretsId = GetOrSetUserSecretsId(project); if (userSecretsId == null) { reporter.Error($"Project does not contain a user secrets ID."); diff --git a/src/Tools/dotnet-user-jwts/test/UserJwtsTests.cs b/src/Tools/dotnet-user-jwts/test/UserJwtsTests.cs index 8947aa2234f..b8e0902112c 100644 --- a/src/Tools/dotnet-user-jwts/test/UserJwtsTests.cs +++ b/src/Tools/dotnet-user-jwts/test/UserJwtsTests.cs @@ -49,7 +49,7 @@ public class UserJwtsTests : IClassFixture<UserJwtsTestFixture> 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()); } @@ -62,7 +62,7 @@ public class UserJwtsTests : IClassFixture<UserJwtsTestFixture> 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); } -- GitLab