fix: save llm key without extra secret

This commit is contained in:
2026-08-22 22:25:07 +08:00
parent f8f0b3c4fd
commit acf6356ba6
4 changed files with 14 additions and 25 deletions
@@ -9,11 +9,11 @@ public sealed class LlmSecretProtectorTests
[Fact]
public void Protect_RoundTripsWithoutEmbeddingPlaintext()
{
var encryptionKey = Convert.ToBase64String(RandomNumberGenerator.GetBytes(32));
var configuration = new ConfigurationBuilder()
.AddInMemoryCollection(new Dictionary<string, string?>
{
["Secrets:EncryptionKey"] = encryptionKey,
["Jwt:Secret"] = Convert.ToBase64String(
RandomNumberGenerator.GetBytes(48)),
})
.Build();
var protector = new LlmSecretProtector(configuration);
@@ -26,14 +26,14 @@ public sealed class LlmSecretProtectorTests
}
[Fact]
public void Protect_RejectsMissingEncryptionKey()
public void Protect_RejectsMissingServerSecret()
{
var protector = new LlmSecretProtector(new ConfigurationBuilder().Build());
var exception = Assert.Throws<InvalidOperationException>(
() => protector.Protect("sk-test"));
Assert.Contains("Secrets__EncryptionKey", exception.Message);
Assert.Contains("JWT 密钥", exception.Message);
}
[Fact]