diff --git a/src/ApiService/ApiService/onefuzzlib/Secrets.cs b/src/ApiService/ApiService/onefuzzlib/Secrets.cs index 16a9ab3bca..127bd4c9c9 100644 --- a/src/ApiService/ApiService/onefuzzlib/Secrets.cs +++ b/src/ApiService/ApiService/onefuzzlib/Secrets.cs @@ -15,7 +15,7 @@ public async Task> StoreSecretData(SecretData secretData) { return new SecretData(new SecretAddress(address)); } - public Task GetSecretValue(ISecret data); + public Task GetSecretValue(ISecret data) where T : class; Task StoreSecret(ISecret secret); @@ -52,14 +52,20 @@ public async Task StoreSecret(ISecret secret) { }; } - public async Task GetSecretValue(ISecret data) { + public async Task GetSecretValue(ISecret data) where T : class { switch ((data)) { case SecretAddress secretAddress: var secretValue = (await GetSecret(secretAddress.Url))?.Value; if (secretValue is null) return default; + + if (typeof(T) == typeof(string)) { + return secretValue as T; + } + return JsonSerializer.Deserialize(secretValue, EntityConverter.GetJsonSerializerOptions()); + case SecretValue sValue: return sValue.Value; diff --git a/src/ApiService/Tests/OrmTest.cs b/src/ApiService/Tests/OrmTest.cs index e8936b7cd6..d52080b6a5 100644 --- a/src/ApiService/Tests/OrmTest.cs +++ b/src/ApiService/Tests/OrmTest.cs @@ -20,7 +20,7 @@ public sealed class TestSecretOperations : ISecretsOperations { private readonly ConcurrentDictionary _secrets = new(); - public Task GetSecretValue(ISecret data) { + public Task GetSecretValue(ISecret data) where T : class { switch (data) { case SecretAddress secretAddress: var key = Guid.Parse(secretAddress.Url.Authority);