diff --git a/.gitignore b/.gitignore index 590ca81..c8df63f 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,5 @@ project.lock.json .testPublish/ .build/ /.vs/ +*.nuget.props +*.nuget.targets diff --git a/UserSecrets.sln b/UserSecrets.sln index 971d2ce..3ba2d09 100644 --- a/UserSecrets.sln +++ b/UserSecrets.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.24709.0 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{01661652-A100-41E3-AE6E-E6151EB85666}" EndProject @@ -8,8 +8,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Extensions.Config EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{9444A5DC-EE0B-4245-B81B-2CEF6F842F3D}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Extensions.SecretManager.Tests", "test\Microsoft.Extensions.SecretManager.Tests\Microsoft.Extensions.SecretManager.Tests.xproj", "{113EBBD2-E857-4CAF-9B53-7A8742CBCD4A}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CD87E04A-587D-44A6-BB15-A966DB3C18CF}" ProjectSection(SolutionItems) = preProject global.json = global.json @@ -17,6 +15,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Extensions.SecretManager.Tools", "src\Microsoft.Extensions.SecretManager.Tools\Microsoft.Extensions.SecretManager.Tools.xproj", "{8730E848-CA0F-4E0A-9A2F-BC22AD0B2C4E}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Extensions.SecretManager.Tools.Tests", "test\Microsoft.Extensions.SecretManager.Tools.Tests\Microsoft.Extensions.SecretManager.Tools.Tests.xproj", "{7B331122-83B1-4F08-A119-DC846959844C}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Extensions.Configuration.UserSecrets.Tests", "test\Microsoft.Extensions.Configuration.UserSecrets.Tests\Microsoft.Extensions.Configuration.UserSecrets.Tests.xproj", "{AC7FAD2A-5763-404D-B0FC-3CCA81A16B0A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -27,21 +29,26 @@ Global {58B6443B-1278-4DF9-B7BB-DDF3BFFCF868}.Debug|Any CPU.Build.0 = Debug|Any CPU {58B6443B-1278-4DF9-B7BB-DDF3BFFCF868}.Release|Any CPU.ActiveCfg = Release|Any CPU {58B6443B-1278-4DF9-B7BB-DDF3BFFCF868}.Release|Any CPU.Build.0 = Release|Any CPU - {113EBBD2-E857-4CAF-9B53-7A8742CBCD4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {113EBBD2-E857-4CAF-9B53-7A8742CBCD4A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {113EBBD2-E857-4CAF-9B53-7A8742CBCD4A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {113EBBD2-E857-4CAF-9B53-7A8742CBCD4A}.Release|Any CPU.Build.0 = Release|Any CPU {8730E848-CA0F-4E0A-9A2F-BC22AD0B2C4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8730E848-CA0F-4E0A-9A2F-BC22AD0B2C4E}.Debug|Any CPU.Build.0 = Debug|Any CPU {8730E848-CA0F-4E0A-9A2F-BC22AD0B2C4E}.Release|Any CPU.ActiveCfg = Release|Any CPU {8730E848-CA0F-4E0A-9A2F-BC22AD0B2C4E}.Release|Any CPU.Build.0 = Release|Any CPU + {7B331122-83B1-4F08-A119-DC846959844C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7B331122-83B1-4F08-A119-DC846959844C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7B331122-83B1-4F08-A119-DC846959844C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7B331122-83B1-4F08-A119-DC846959844C}.Release|Any CPU.Build.0 = Release|Any CPU + {AC7FAD2A-5763-404D-B0FC-3CCA81A16B0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AC7FAD2A-5763-404D-B0FC-3CCA81A16B0A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC7FAD2A-5763-404D-B0FC-3CCA81A16B0A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AC7FAD2A-5763-404D-B0FC-3CCA81A16B0A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {58B6443B-1278-4DF9-B7BB-DDF3BFFCF868} = {01661652-A100-41E3-AE6E-E6151EB85666} - {113EBBD2-E857-4CAF-9B53-7A8742CBCD4A} = {9444A5DC-EE0B-4245-B81B-2CEF6F842F3D} {8730E848-CA0F-4E0A-9A2F-BC22AD0B2C4E} = {01661652-A100-41E3-AE6E-E6151EB85666} + {7B331122-83B1-4F08-A119-DC846959844C} = {9444A5DC-EE0B-4245-B81B-2CEF6F842F3D} + {AC7FAD2A-5763-404D-B0FC-3CCA81A16B0A} = {9444A5DC-EE0B-4245-B81B-2CEF6F842F3D} EndGlobalSection EndGlobal diff --git a/src/Microsoft.Extensions.SecretManager.Tools/Program.cs b/src/Microsoft.Extensions.SecretManager.Tools/Program.cs index b0aec79..8269752 100644 --- a/src/Microsoft.Extensions.SecretManager.Tools/Program.cs +++ b/src/Microsoft.Extensions.SecretManager.Tools/Program.cs @@ -224,18 +224,25 @@ private void PrintAll(IDictionary secrets) } } - private void ProcessSecretFile(string projectPath, Action> observer, bool persist = true) + private void ProcessSecretFile(string projectPath, Action> observer, bool persist = true) { Logger.LogDebug(Resources.Message_Project_File_Path, projectPath); var secretsFilePath = PathHelper.GetSecretsPath(projectPath); Logger.LogDebug(Resources.Message_Secret_File_Path, secretsFilePath); + + { + // workaround https://github.com/aspnet/Configuration/issues/478 + // TODO remove when tool upgrades to use 1.1.0 + Directory.CreateDirectory(Path.GetDirectoryName(secretsFilePath)); + } + var secrets = new ConfigurationBuilder() - .AddJsonFile(secretsFilePath, optional: true) + .AddJsonFile(secretsFilePath, optional: true, reloadOnChange: false) .Build() .AsEnumerable() .Where(i => i.Value != null) .ToDictionary(i => i.Key, i => i.Value, StringComparer.OrdinalIgnoreCase); - + observer(secrets); if (persist) diff --git a/src/Microsoft.Extensions.SecretManager.Tools/Properties/AssemblyInfo.cs b/src/Microsoft.Extensions.SecretManager.Tools/Properties/AssemblyInfo.cs index 1318947..8d8d881 100644 --- a/src/Microsoft.Extensions.SecretManager.Tools/Properties/AssemblyInfo.cs +++ b/src/Microsoft.Extensions.SecretManager.Tools/Properties/AssemblyInfo.cs @@ -3,9 +3,7 @@ using System.Reflection; using System.Resources; -using System.Runtime.CompilerServices; -[assembly: InternalsVisibleTo("Microsoft.Extensions.SecretManager.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: NeutralResourcesLanguage("en-us")] [assembly: AssemblyCompany("Microsoft Corporation.")] diff --git a/src/Microsoft.Extensions.SecretManager.Tools/Properties/InternalsVisibleTo.cs b/src/Microsoft.Extensions.SecretManager.Tools/Properties/InternalsVisibleTo.cs new file mode 100644 index 0000000..8057e7a --- /dev/null +++ b/src/Microsoft.Extensions.SecretManager.Tools/Properties/InternalsVisibleTo.cs @@ -0,0 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Microsoft.Extensions.SecretManager.Tools.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] \ No newline at end of file diff --git a/src/Microsoft.Extensions.SecretManager.Tools/Properties/Resources.Designer.cs b/src/Microsoft.Extensions.SecretManager.Tools/Properties/Resources.Designer.cs index b5a30fd..c79e6e1 100644 --- a/src/Microsoft.Extensions.SecretManager.Tools/Properties/Resources.Designer.cs +++ b/src/Microsoft.Extensions.SecretManager.Tools/Properties/Resources.Designer.cs @@ -1,5 +1,5 @@ // -namespace Microsoft.Extensions.SecretManager +namespace Microsoft.Extensions.SecretManager.Tools { using System.Globalization; using System.Reflection; @@ -8,7 +8,7 @@ namespace Microsoft.Extensions.SecretManager internal static class Resources { private static readonly ResourceManager _resourceManager - = new ResourceManager("Microsoft.Extensions.SecretManager.Resources", typeof(Resources).GetTypeInfo().Assembly); + = new ResourceManager("Microsoft.Extensions.SecretManager.Tools.Resources", typeof(Resources).GetTypeInfo().Assembly); /// /// Command failed : {message} diff --git a/src/Microsoft.Extensions.SecretManager.Tools/project.json b/src/Microsoft.Extensions.SecretManager.Tools/project.json index 1b96bb8..74b703a 100644 --- a/src/Microsoft.Extensions.SecretManager.Tools/project.json +++ b/src/Microsoft.Extensions.SecretManager.Tools/project.json @@ -8,12 +8,7 @@ "nowarn": [ "CS1591" ], - "xmlDoc": true, - "embed": { - "mappings": { - "Microsoft.Extensions.SecretManager.Resources": "Resources.resx" - } - } + "xmlDoc": true }, "description": "Command line tool to manage user secrets for Microsoft.Extensions.Configuration.", "packOptions": { @@ -28,18 +23,21 @@ ] }, "dependencies": { - "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0-*", - "Microsoft.Extensions.CommandLineUtils": "1.1.0-*", - "Microsoft.Extensions.Logging": "1.1.0-*", + "Microsoft.Extensions.Configuration.UserSecrets": { + "version": "1.0.0", + "target": "package" + }, + "Microsoft.Extensions.CommandLineUtils": "1.0.0", + "Microsoft.Extensions.Logging": "1.0.0", "Newtonsoft.Json": "9.0.1", - "System.Runtime.InteropServices.RuntimeInformation": "4.0.0-*", - "System.Runtime.Serialization.Primitives": "4.1.1-*" + "System.Runtime.InteropServices.RuntimeInformation": "4.0.0", + "System.Runtime.Serialization.Primitives": "4.1.1" }, "frameworks": { "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.0.0-*", + "version": "1.0.0", "type": "platform" } } diff --git a/test/Microsoft.Extensions.SecretManager.Tests/ConfigurationExtensionTests.cs b/test/Microsoft.Extensions.Configuration.UserSecrets.Tests/ConfigurationExtensionTests.cs similarity index 64% rename from test/Microsoft.Extensions.SecretManager.Tests/ConfigurationExtensionTests.cs rename to test/Microsoft.Extensions.Configuration.UserSecrets.Tests/ConfigurationExtensionTests.cs index f0c5ef6..b7e5b3e 100644 --- a/test/Microsoft.Extensions.SecretManager.Tests/ConfigurationExtensionTests.cs +++ b/test/Microsoft.Extensions.Configuration.UserSecrets.Tests/ConfigurationExtensionTests.cs @@ -2,14 +2,42 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.Extensions.SecretManager.Tests; -using Microsoft.Extensions.SecretManager.Tools; +using System.Linq; +using System.IO; +using System.Text; +using Newtonsoft.Json.Linq; using Xunit; namespace Microsoft.Extensions.Configuration.UserSecrets.Tests { public class ConfigurationExtensionTests { + private void SetSecret(string id, string key, string value) + { + var secretsFilePath = PathHelper.GetSecretsPathFromSecretsId(id); + var secrets = new ConfigurationBuilder() + .AddJsonFile(secretsFilePath, optional: true) + .Build() + .AsEnumerable() + .Where(i => i.Value != null) + .ToDictionary(i => i.Key, i => i.Value, StringComparer.OrdinalIgnoreCase); + + secrets[key] = value; + + Directory.CreateDirectory(Path.GetDirectoryName(secretsFilePath)); + + var contents = new JObject(); + if (secrets != null) + { + foreach (var secret in secrets.AsEnumerable()) + { + contents[secret.Key] = secret.Value; + } + } + + File.WriteAllText(secretsFilePath, contents.ToString(), Encoding.UTF8); + } + [Fact] public void AddUserSecrets_Does_Not_Fail_On_Non_Existing_File_Explicitly_Passed() @@ -36,10 +64,7 @@ public void AddUserSecrets_With_An_Existing_Secret_File() string userSecretsId; var projectPath = UserSecretHelper.GetTempSecretProject(out userSecretsId); - var logger = new TestLogger(); - var secretManager = new Program() { Logger = logger }; - - secretManager.Run(new string[] { "set", "Facebook:AppSecret", "value1", "-p", projectPath }); + SetSecret(userSecretsId, "Facebook:AppSecret", "value1"); var builder = new ConfigurationBuilder().SetBasePath(projectPath).AddUserSecrets(); @@ -55,10 +80,7 @@ public void AddUserSecrets_With_SecretsId_Passed_Explicitly() string userSecretsId; var projectPath = UserSecretHelper.GetTempSecretProject(out userSecretsId); - var logger = new TestLogger(); - var secretManager = new Program() { Logger = logger }; - - secretManager.Run(new string[] { "set", "Facebook:AppSecret", "value1", "-p", projectPath }); + SetSecret(userSecretsId, "Facebook:AppSecret", "value1"); var builder = new ConfigurationBuilder() .AddUserSecrets(userSecretsId: userSecretsId); diff --git a/test/Microsoft.Extensions.Configuration.UserSecrets.Tests/Microsoft.Extensions.Configuration.UserSecrets.Tests.xproj b/test/Microsoft.Extensions.Configuration.UserSecrets.Tests/Microsoft.Extensions.Configuration.UserSecrets.Tests.xproj new file mode 100644 index 0000000..292e03d --- /dev/null +++ b/test/Microsoft.Extensions.Configuration.UserSecrets.Tests/Microsoft.Extensions.Configuration.UserSecrets.Tests.xproj @@ -0,0 +1,21 @@ + + + + 14.0.25420 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + ac7fad2a-5763-404d-b0fc-3cca81a16b0a + Microsoft.Extensions.Configuration.UserSecrets.Tests + .\obj + .\bin\ + + + 2.0 + + + + + + \ No newline at end of file diff --git a/test/Microsoft.Extensions.SecretManager.Tests/PathHelperTests.cs b/test/Microsoft.Extensions.Configuration.UserSecrets.Tests/PathHelperTests.cs similarity index 94% rename from test/Microsoft.Extensions.SecretManager.Tests/PathHelperTests.cs rename to test/Microsoft.Extensions.Configuration.UserSecrets.Tests/PathHelperTests.cs index 23cb30b..3f93910 100644 --- a/test/Microsoft.Extensions.SecretManager.Tests/PathHelperTests.cs +++ b/test/Microsoft.Extensions.Configuration.UserSecrets.Tests/PathHelperTests.cs @@ -3,10 +3,9 @@ using System; using System.IO; -using Microsoft.Extensions.Configuration.UserSecrets; using Xunit; -namespace Microsoft.Extensions.SecretManager.Tests +namespace Microsoft.Extensions.Configuration.UserSecrets.Tests { public class PathHelperTests { @@ -20,7 +19,7 @@ public void Gives_Correct_Secret_Path() var root = Environment.GetEnvironmentVariable("APPDATA") ?? // On Windows it goes to %APPDATA%\Microsoft\UserSecrets\ Environment.GetEnvironmentVariable("HOME"); // On Mac/Linux it goes to ~/.microsoft/usersecrets/ - var expectedSecretPath = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("APPDATA"))? + var expectedSecretPath = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("APPDATA")) ? Path.Combine(root, "Microsoft", "UserSecrets", userSecretsId, "secrets.json") : Path.Combine(root, ".microsoft", "usersecrets", userSecretsId, "secrets.json"); @@ -70,7 +69,7 @@ public void Throws_If_UserSecretId_Contains_Invalid_Characters() PathHelper.GetSecretsPath(projectPath); }); } - + UserSecretHelper.DeleteTempSecretProject(projectPath); } } diff --git a/test/Microsoft.Extensions.SecretManager.Tests/project.json b/test/Microsoft.Extensions.Configuration.UserSecrets.Tests/project.json similarity index 68% rename from test/Microsoft.Extensions.SecretManager.Tests/project.json rename to test/Microsoft.Extensions.Configuration.UserSecrets.Tests/project.json index dc24daa..7456fa2 100644 --- a/test/Microsoft.Extensions.SecretManager.Tests/project.json +++ b/test/Microsoft.Extensions.Configuration.UserSecrets.Tests/project.json @@ -1,11 +1,14 @@ { "buildOptions": { "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk" + "keyFile": "../../tools/Key.snk", + "compile": { + "include": "../Shared/*.cs" + } }, "dependencies": { "dotnet-test-xunit": "2.2.0-*", - "Microsoft.Extensions.SecretManager.Tools": "1.0.0-*", + "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0-*", "xunit": "2.2.0-*" }, "testRunner": "xunit", diff --git a/test/Microsoft.Extensions.SecretManager.Tests/Microsoft.Extensions.SecretManager.Tests.xproj b/test/Microsoft.Extensions.SecretManager.Tools.Tests/Microsoft.Extensions.SecretManager.Tools.Tests.xproj similarity index 58% rename from test/Microsoft.Extensions.SecretManager.Tests/Microsoft.Extensions.SecretManager.Tests.xproj rename to test/Microsoft.Extensions.SecretManager.Tools.Tests/Microsoft.Extensions.SecretManager.Tools.Tests.xproj index b84d321..2f0849b 100644 --- a/test/Microsoft.Extensions.SecretManager.Tests/Microsoft.Extensions.SecretManager.Tests.xproj +++ b/test/Microsoft.Extensions.SecretManager.Tools.Tests/Microsoft.Extensions.SecretManager.Tools.Tests.xproj @@ -1,12 +1,13 @@  - + - 14.0 + 14.0.25420 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + - 113ebbd2-e857-4caf-9b53-7a8742cbcd4a + 7b331122-83b1-4f08-a119-dc846959844c + Microsoft.Extensions.SecretManager.Tools.Tests .\obj .\bin\ @@ -16,5 +17,5 @@ - + \ No newline at end of file diff --git a/test/Microsoft.Extensions.SecretManager.Tests/SecretManagerTests.cs b/test/Microsoft.Extensions.SecretManager.Tools.Tests/SecretManagerTests.cs similarity index 99% rename from test/Microsoft.Extensions.SecretManager.Tests/SecretManagerTests.cs rename to test/Microsoft.Extensions.SecretManager.Tools.Tests/SecretManagerTests.cs index a308cb1..12c98b6 100644 --- a/test/Microsoft.Extensions.SecretManager.Tests/SecretManagerTests.cs +++ b/test/Microsoft.Extensions.SecretManager.Tools.Tests/SecretManagerTests.cs @@ -6,6 +6,7 @@ using System.IO; using System.Text; using Microsoft.Extensions.Configuration.UserSecrets; +using Microsoft.Extensions.Configuration.UserSecrets.Tests; using Microsoft.Extensions.SecretManager.Tools; using Xunit; diff --git a/test/Microsoft.Extensions.SecretManager.Tests/TestLogger.cs b/test/Microsoft.Extensions.SecretManager.Tools.Tests/TestLogger.cs similarity index 100% rename from test/Microsoft.Extensions.SecretManager.Tests/TestLogger.cs rename to test/Microsoft.Extensions.SecretManager.Tools.Tests/TestLogger.cs diff --git a/test/Microsoft.Extensions.SecretManager.Tools.Tests/project.json b/test/Microsoft.Extensions.SecretManager.Tools.Tests/project.json new file mode 100644 index 0000000..63c2e81 --- /dev/null +++ b/test/Microsoft.Extensions.SecretManager.Tools.Tests/project.json @@ -0,0 +1,29 @@ +{ + "buildOptions": { + "warningsAsErrors": true, + "keyFile": "../../tools/Key.snk", + "compile": { + "include": "../Shared/*.cs" + } + }, + "dependencies": { + "dotnet-test-xunit": "2.2.0-*", + "Microsoft.Extensions.Configuration.UserSecrets": { + "version": "1.0.0", + "target": "package" + }, + "Microsoft.Extensions.SecretManager.Tools": "1.0.0-*", + "xunit": "2.2.0-*" + }, + "testRunner": "xunit", + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0", + "type": "platform" + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.Extensions.SecretManager.Tests/UserSecretHelper.cs b/test/Shared/UserSecretHelper.cs similarity index 78% rename from test/Microsoft.Extensions.SecretManager.Tests/UserSecretHelper.cs rename to test/Shared/UserSecretHelper.cs index 943158a..87dbddc 100644 --- a/test/Microsoft.Extensions.SecretManager.Tests/UserSecretHelper.cs +++ b/test/Shared/UserSecretHelper.cs @@ -5,9 +5,9 @@ using System.IO; using Newtonsoft.Json; -namespace Microsoft.Extensions.SecretManager.Tests +namespace Microsoft.Extensions.Configuration.UserSecrets.Tests { - public class UserSecretHelper + internal class UserSecretHelper { internal static string GetTempSecretProject() { @@ -17,11 +17,11 @@ internal static string GetTempSecretProject() internal static string GetTempSecretProject(out string userSecretsId) { - var projectPath = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())); + var projectPath = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), "usersecretstest", Guid.NewGuid().ToString())); userSecretsId = Guid.NewGuid().ToString(); File.WriteAllText( Path.Combine(projectPath.FullName, "project.json"), - string.Format("{{\"userSecretsId\": {0}}}", JsonConvert.ToString(userSecretsId))); + JsonConvert.SerializeObject(new { userSecretsId })); return projectPath.FullName; } @@ -29,7 +29,7 @@ internal static void SetTempSecretInProject(string projectPath, string userSecre { File.WriteAllText( Path.Combine(projectPath, "project.json"), - string.Format("{{\"userSecretsId\": {0}}}", JsonConvert.ToString(userSecretsId))); + JsonConvert.SerializeObject(new { userSecretsId })); } internal static void DeleteTempSecretProject(string projectPath)