public void MsalDistributedTokenCacheAdapterOptions_DisableL1Cache(bool disableL1Cache) { // Arrange var msalDistributedTokenOptions = Options.Create( new MsalDistributedTokenCacheAdapterOptions() { DisableL1Cache = disableL1Cache, }); BuildTheRequiredServices(); // Act var testCache = new TestMsalDistributedTokenCacheAdapter( new TestDistributedCache(), msalDistributedTokenOptions, _provider.GetService <ILogger <MsalDistributedTokenCacheAdapter> >()); // Assert Assert.NotNull(testCache); Assert.NotNull(testCache._distributedCache); if (!disableL1Cache) { Assert.NotNull(testCache._memoryCache); Assert.Equal(0, testCache._memoryCache.Count); } else { Assert.Null(testCache._memoryCache); } }
public L1L2CacheTests() { BuildTheRequiredServices(); _testCacheAdapter = new TestMsalDistributedTokenCacheAdapter( MakeMockDistributedCache(), _provider.GetService <IOptions <MsalDistributedTokenCacheAdapterOptions> >(), _provider.GetService <ILogger <MsalDistributedTokenCacheAdapter> >()); }
public async Task EncryptionTestAsync(bool isEncrypted) { // Arrange byte[] cache = new byte[] { 1, 2, 3, 4 }; BuildTheRequiredServices(isEncrypted); _testCacheAdapter = _provider.GetService <IMsalTokenCacheProvider>() as TestMsalDistributedTokenCacheAdapter; TestTokenCache tokenCache = new TestTokenCache(); TokenCacheNotificationArgs args = InstantiateTokenCacheNotificationArgs(tokenCache); _testCacheAdapter.Initialize(tokenCache); // Act await tokenCache._beforeAccess(args).ConfigureAwait(false); tokenCache.cache = cache; await tokenCache._afterAccess(args).ConfigureAwait(false); // Assert Assert.Equal(1, _testCacheAdapter._memoryCache.Count); Assert.NotEqual(cache.SequenceEqual(GetFirstCacheValue()), isEncrypted); }
public void MsalDistributedTokenCacheAdapterOptions_L1ExpirationTimeRatio(double expirationRatio) { // Arrange var msalDistributedTokenOptions = Options.Create( new MsalDistributedTokenCacheAdapterOptions() { L1ExpirationTimeRatio = expirationRatio, AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(3), }); BuildTheRequiredServices(); // Act var testCache = new TestMsalDistributedTokenCacheAdapter( new TestDistributedCache(), msalDistributedTokenOptions, _provider.GetService <ILogger <MsalDistributedTokenCacheAdapter> >()); // Assert Assert.NotNull(testCache); Assert.NotNull(testCache._distributedCache); Assert.NotNull(testCache._memoryCache); Assert.Equal(0, testCache._memoryCache.Count); }
private static void AssertCacheValues(TestMsalDistributedTokenCacheAdapter testCache) { Assert.NotNull(testCache); Assert.NotNull(testCache._distributedCache); Assert.NotNull(testCache._memoryCache); }