Browse Source
Merge pull request #17673 from abpframework/call-AddAppSettingsSecretsJson-in-tests
Add appsettings.secrets.json file to default configuration in tests
pull/17683/head
maliming
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
7 additions and
3 deletions
-
framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpAspNetCoreIntegratedTestBase.cs
-
framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpWebApplicationFactoryIntegratedTest.cs
-
framework/src/Volo.Abp.Core/Microsoft/Extensions/Configuration/ConfigurationHelper.cs
|
|
|
@ -42,6 +42,7 @@ public abstract class AbpAspNetCoreIntegratedTestBase<TStartupModule> : AbpTestB |
|
|
|
protected virtual IHostBuilder CreateHostBuilder() |
|
|
|
{ |
|
|
|
return Host.CreateDefaultBuilder() |
|
|
|
.AddAppSettingsSecretsJson() |
|
|
|
.ConfigureWebHostDefaults(webBuilder => |
|
|
|
{ |
|
|
|
if (typeof(TStartupModule).IsAssignableTo<IAbpModule>()) |
|
|
|
|
|
|
|
@ -27,7 +27,9 @@ public abstract class AbpWebApplicationFactoryIntegratedTest<TProgram> : WebAppl |
|
|
|
|
|
|
|
protected override IHost CreateHost(IHostBuilder builder) |
|
|
|
{ |
|
|
|
builder.ConfigureServices(ConfigureServices); |
|
|
|
builder |
|
|
|
.AddAppSettingsSecretsJson() |
|
|
|
.ConfigureServices(ConfigureServices); |
|
|
|
return base.CreateHost(builder); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -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") |
|
|
|
|