Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ internal bool GetSignatureVerificationResult(string keyStoreName, string masterK

string cacheLookupKey = GetCacheLookupKey(masterKeyPath, allowEnclaveComputations, signature, keyStoreName);

return _cache.TryGetValue<bool>(cacheLookupKey, out bool value);
return _cache.TryGetValue<bool>(cacheLookupKey, out bool value) && value;
Comment thread
cheenamalhotra marked this conversation as resolved.
Outdated
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using Xunit;

namespace Microsoft.Data.SqlClient.UnitTests
{
public class SignatureVerificationCacheTests
Comment thread
paulmedynski marked this conversation as resolved.
{
[Fact]
public void GetSignatureVerificationResult_DoesNotTreatCachedFailureAsSuccess()
{
ColumnMasterKeyMetadataSignatureVerificationCache cache = ColumnMasterKeyMetadataSignatureVerificationCache.Instance;
string keyStoreName = $"TEST_PROVIDER_{Guid.NewGuid():N}";
string masterKeyPath = $"https://unit-test/{Guid.NewGuid():N}";
byte[] signature = [1, 2, 3, 4];

cache.AddSignatureVerificationResult(keyStoreName, masterKeyPath, allowEnclaveComputations: true, signature, result: false);

Assert.False(cache.GetSignatureVerificationResult(keyStoreName, masterKeyPath, allowEnclaveComputations: true, signature));
}

[Fact]
public void GetSignatureVerificationResult_ReturnsTrueForCachedSuccess()
{
ColumnMasterKeyMetadataSignatureVerificationCache cache = ColumnMasterKeyMetadataSignatureVerificationCache.Instance;
string keyStoreName = $"TEST_PROVIDER_{Guid.NewGuid():N}";
string masterKeyPath = $"https://unit-test/{Guid.NewGuid():N}";
byte[] signature = [4, 3, 2, 1];

cache.AddSignatureVerificationResult(keyStoreName, masterKeyPath, allowEnclaveComputations: true, signature, result: true);

Assert.True(cache.GetSignatureVerificationResult(keyStoreName, masterKeyPath, allowEnclaveComputations: true, signature));
}
}
}
Loading