private static Option <UserState> GetTestUserState()
        {
            var cache        = new MemoryCache(new MemoryCacheOptions());
            var stateManager = new UserStateManager(cache);

            var token = stateManager.CreateState(1, "ABC1234");

            return(stateManager.GetState(token));
        }
        public void CreateState_given_integer_returns_valid_guid_token()
        {
            var cache        = new MemoryCache(new MemoryCacheOptions());
            var stateManager = new UserStateManager(cache);

            var token = stateManager.CreateState(1, "ABC1234");

            Assert.True(Guid.TryParse(token, out _));
        }
예제 #3
0
        public void RequestIsValid_given_valid_token_returns_true()
        {
            var cache        = new MemoryCache(new MemoryCacheOptions());
            var stateManager = new UserStateManager(cache);

            var token = stateManager.CreateState(1, "ABC1234");

            Assert.True(SecurityFilter.RequestIsValid(token, "ABC1234", stateManager));
        }
        public void GetState_given_invalid_token_returns_Option_None()
        {
            var cache        = new MemoryCache(new MemoryCacheOptions());
            var stateManager = new UserStateManager(cache);

            stateManager.CreateState(1, "ABC1234");
            var result = stateManager.GetState("invalidToken");

            Assert.False(result.HasValue);
        }
예제 #5
0
        private static string CreateUserState(IMemoryCache cache, int userId, string sessionKey)
        {
            var sm = new UserStateManager(cache);

            return(sm.CreateState(userId, sessionKey));
        }