fix(delmia-notifier)+chore(docker): review follow-ups — trim the env key like the file key, log which source supplied the key (never the key), hoist the not-configured message; README warns never to commit a filled-in appsettings.json; design-doc body lines updated; seed-delmia-api.sh no longer hides CLI errors and notes key names are not unique
Claude-Session: https://claude.ai/code/session_013L3XdmVii9i5sY4FChU8pB
This commit is contained in:
@@ -70,6 +70,31 @@ public class ConfigLoaderTests
|
||||
Assert.Equal("sbk_file", ConfigLoader.ResolveApiKey(_ => " ", cfg));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveApiKey_trims_env_value_like_the_file_value()
|
||||
{
|
||||
Assert.Equal("sbk_env", ConfigLoader.ResolveApiKey(_ => " sbk_env \t", new NotifierConfig()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveApiKey_reports_which_source_supplied_the_key()
|
||||
{
|
||||
var cfg = ConfigLoader.Load("{\"ScadaBridge\":{\"ApiKey\":\"sbk_file\"}}");
|
||||
ConfigLoader.ResolveApiKey(_ => "sbk_env", cfg, out var fromEnv);
|
||||
ConfigLoader.ResolveApiKey(_ => null, cfg, out var fromFile);
|
||||
ConfigLoader.ResolveApiKey(_ => null, new NotifierConfig(), out var none);
|
||||
Assert.Equal(ConfigLoader.ApiKeySourceEnvironment, fromEnv);
|
||||
Assert.Equal(ConfigLoader.ApiKeySourceFile, fromFile);
|
||||
Assert.Null(none);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Load_leaves_ApiKey_null_when_absent()
|
||||
{
|
||||
var cfg = ConfigLoader.Load("{\"ScadaBridge\":{\"BaseUrls\":\"http://x\"}}");
|
||||
Assert.Null(cfg.ScadaBridge.ApiKey);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveApiKey_returns_null_when_neither_source_set()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user