From 1083e733c6d15f1655cfbe6a35ca6ed4ec8f3707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 19 Sep 2023 16:00:39 +0300 Subject: [PATCH 1/2] Call AddAppSettingsSecretsJson in test base classes for aspnet core --- .../AspNetCore/TestBase/AbpAspNetCoreIntegratedTestBase.cs | 1 + .../TestBase/AbpWebApplicationFactoryIntegratedTest.cs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpAspNetCoreIntegratedTestBase.cs b/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpAspNetCoreIntegratedTestBase.cs index 731b21ea03..a42cbae457 100644 --- a/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpAspNetCoreIntegratedTestBase.cs +++ b/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpAspNetCoreIntegratedTestBase.cs @@ -42,6 +42,7 @@ public abstract class AbpAspNetCoreIntegratedTestBase : AbpTestB protected virtual IHostBuilder CreateHostBuilder() { return Host.CreateDefaultBuilder() + .AddAppSettingsSecretsJson() .ConfigureWebHostDefaults(webBuilder => { if (typeof(TStartupModule).IsAssignableTo()) diff --git a/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpWebApplicationFactoryIntegratedTest.cs b/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpWebApplicationFactoryIntegratedTest.cs index c7b5f48ebe..9a6422ca97 100644 --- a/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpWebApplicationFactoryIntegratedTest.cs +++ b/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpWebApplicationFactoryIntegratedTest.cs @@ -27,7 +27,9 @@ public abstract class AbpWebApplicationFactoryIntegratedTest : WebAppl protected override IHost CreateHost(IHostBuilder builder) { - builder.ConfigureServices(ConfigureServices); + builder + .AddAppSettingsSecretsJson() + .ConfigureServices(ConfigureServices); return base.CreateHost(builder); } From 9031a4b7367477f0cfafd9a20f8e2720b69fa70e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 19 Sep 2023 16:05:46 +0300 Subject: [PATCH 2/2] Add secrets.json file to default configuration builder --- .../Extensions/Configuration/ConfigurationHelper.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.Core/Microsoft/Extensions/Configuration/ConfigurationHelper.cs b/framework/src/Volo.Abp.Core/Microsoft/Extensions/Configuration/ConfigurationHelper.cs index f31feff873..88bf37982e 100644 --- a/framework/src/Volo.Abp.Core/Microsoft/Extensions/Configuration/ConfigurationHelper.cs +++ b/framework/src/Volo.Abp.Core/Microsoft/Extensions/Configuration/ConfigurationHelper.cs @@ -18,11 +18,12 @@ public static class ConfigurationHelper var builder = new ConfigurationBuilder() .SetBasePath(options.BasePath!) - .AddJsonFile(options.FileName + ".json", optional: options.Optional, reloadOnChange: options.ReloadOnChange); + .AddJsonFile(options.FileName + ".json", optional: options.Optional, reloadOnChange: options.ReloadOnChange) + .AddJsonFile(options.FileName + ".secrets.json", optional: true, reloadOnChange: options.ReloadOnChange); if (!options.EnvironmentName.IsNullOrEmpty()) { - builder = builder.AddJsonFile($"{options.FileName}.{options.EnvironmentName}.json", optional: options.Optional, reloadOnChange: options.ReloadOnChange); + builder = builder.AddJsonFile($"{options.FileName}.{options.EnvironmentName}.json", optional: true, reloadOnChange: options.ReloadOnChange); } if (options.EnvironmentName == "Development")