chore(host): pin ZB.MOM.WW.Auth 0.3.0 + ApiKeys.SqlServer; InboundApiKeyStoreOptions (Provider Sqlite|SqlServer, ReadProvider fails the boot on an unknown value)

Claude-Session: https://claude.ai/code/session_013L3XdmVii9i5sY4FChU8pB
This commit is contained in:
Joseph Doherty
2026-09-02 22:46:11 -04:00
parent 08405c1ca1
commit afe59a5518
4 changed files with 112 additions and 4 deletions
@@ -0,0 +1,70 @@
using Microsoft.Extensions.Configuration;
namespace ZB.MOM.WW.ScadaBridge.Host.Tests;
public class InboundApiKeyStoreOptionsTests
{
private static IConfiguration BuildConfig(Dictionary<string, string?> values)
{
return new ConfigurationBuilder()
.AddInMemoryCollection(values)
.Build();
}
[Fact]
public void Provider_DefaultsToSqlite()
{
Assert.Equal(InboundApiKeyStoreProvider.Sqlite, new InboundApiKeyStoreOptions().Provider);
var configuration = new ConfigurationBuilder().Build();
Assert.Equal(InboundApiKeyStoreProvider.Sqlite, InboundApiKeyStoreOptions.ReadProvider(configuration));
}
[Theory]
[InlineData("sqlserver", InboundApiKeyStoreProvider.SqlServer)]
[InlineData("SQLSERVER", InboundApiKeyStoreProvider.SqlServer)]
[InlineData("SqlServer", InboundApiKeyStoreProvider.SqlServer)]
[InlineData("sqlite", InboundApiKeyStoreProvider.Sqlite)]
public void Provider_ParsesCaseInsensitively(string value, InboundApiKeyStoreProvider expected)
{
var configuration = BuildConfig(new Dictionary<string, string?>
{
[$"{InboundApiKeyStoreOptions.SectionPath}:Provider"] = value,
});
Assert.Equal(expected, InboundApiKeyStoreOptions.ReadProvider(configuration));
}
[Theory]
[InlineData("Postgres")]
[InlineData("7")]
public void Provider_RejectsUnknownValue(string value)
{
var configuration = BuildConfig(new Dictionary<string, string?>
{
[$"{InboundApiKeyStoreOptions.SectionPath}:Provider"] = value,
});
var ex = Assert.Throws<InvalidOperationException>(() => InboundApiKeyStoreOptions.ReadProvider(configuration));
Assert.Contains("Sqlite", ex.Message);
Assert.Contains("SqlServer", ex.Message);
}
[Fact]
public void Binds_ImportFromSqlitePath()
{
var configuration = BuildConfig(new Dictionary<string, string?>
{
[$"{InboundApiKeyStoreOptions.SectionPath}:Provider"] = "SqlServer",
[$"{InboundApiKeyStoreOptions.SectionPath}:ImportFromSqlitePath"] = "/app/data/inbound-api-keys.db",
});
var options = configuration.GetSection(InboundApiKeyStoreOptions.SectionPath).Get<InboundApiKeyStoreOptions>();
Assert.NotNull(options);
Assert.Equal(InboundApiKeyStoreProvider.SqlServer, options!.Provider);
Assert.Equal("/app/data/inbound-api-keys.db", options.ImportFromSqlitePath);
}
}