public void Get_SessionSecurityTokenDeletedFromCache_ReturnsNull(SessionSecurityTokenCache memoryCache, SessionSecurityTokenStore store)
        {
            var token = CreateToken(DateTime.UtcNow, TimeSpan.MaxValue);
            var key   = CreateKeyFromToken(token);

            var cache = new TestableDatabaseSecurityTokenCache(memoryCache, store);

            cache.AddOrUpdate(key, token, token.KeyExpirationTime);
            cache.Remove(key);

            var roundtrippedToken = cache.Get(key);

            roundtrippedToken.Should().BeNull();
        }
        public void Get_SessionSecurityTokenNotInCache_ReturnsNull(SessionSecurityTokenCache memoryCache, SessionSecurityTokenStore store)
        {
            var token = CreateToken(DateTime.UtcNow, TimeSpan.MaxValue);
            var key   = CreateKeyFromToken(token);

            var cache = new TestableDatabaseSecurityTokenCache(memoryCache, store);

            var roundtrippedToken = cache.Get(key);

            roundtrippedToken.Should().BeNull();
        }
        public void AddOrUpdate_EternalSessionSecurityToken_GetReturnsToken(SessionSecurityTokenCache memoryCache, SessionSecurityTokenStore store)
        {
            var token = CreateToken(DateTime.UtcNow, TimeSpan.MaxValue);
            var key   = CreateKeyFromToken(token);

            var cache = new TestableDatabaseSecurityTokenCache(memoryCache, store);

            cache.AddOrUpdate(key, token, token.KeyExpirationTime);
            var roundtrippedToken = cache.Get(key);

            roundtrippedToken.ShouldBeEquivalentTo(token);
        }
        public void AddOrUpdate_SessionSecurityTokenExpiredInCache_GetReturnsToken(SessionSecurityTokenCache memoryCache, SessionSecurityTokenStore store)
        {
            // It is, unfortunately, impossible to create a SessionSecurityToken that is expired...
            var token = CreateToken(DateTime.UtcNow, TimeSpan.FromMilliseconds(500));
            var key   = CreateKeyFromToken(token);

            var cache = new TestableDatabaseSecurityTokenCache(memoryCache, store);

            cache.AddOrUpdate(key, token, token.KeyExpirationTime);

            Thread.Sleep(TimeSpan.FromSeconds(1));

            var roundtrippedToken = cache.Get(key);

            roundtrippedToken.ShouldBeEquivalentTo(token);
        }
示例#5
0
 public TestableDatabaseSecurityTokenCache(SessionSecurityTokenCache sessionSecurityTokenCache, SessionSecurityTokenStore sessionSecurityTokenStore)
 {
     m_MemoryCache = sessionSecurityTokenCache;
     m_SessionSecurityTokenStore = sessionSecurityTokenStore;
 }