Ejemplo n.º 1
0
        public async Task ShouldRemoveBySubject()
        {
            //Arrange
            var tokenDesc = new RefreshTokenDescription
            {
                LoginRequest = new LoginRequest
                {
                    Subject = Subject
                },
                NotAfter = DateTime.Now.AddMinutes(1)
            };

            //Act

            await Registry.Register(Token1, tokenDesc);

            await Registry.Register(Token2, tokenDesc);

            await Registry.RemoveBySubject(Subject);

            var storedToken1Desc = await Registry.Get(Token1);

            var storedToken2Desc = await Registry.Get(Token2);

            //Assert
            Assert.Null(storedToken1Desc);
            Assert.Null(storedToken2Desc);
        }
Ejemplo n.º 2
0
        public Task Register(string token, RefreshTokenDescription desc)
        {
            _loginRequests.Add(token, desc.LoginRequest);

            if (!_subjectTokenList.TryGetValue(desc.LoginRequest.Subject, out var l))
            {
                l = new List <string>();
                _subjectTokenList.Add(desc.LoginRequest.Subject, l);
            }

            l.Add(token);

            return(Task.CompletedTask);
        }
Ejemplo n.º 3
0
        public async Task ShouldProvideRegisteredToken()
        {
            //Arrange
            var tokenDesc = new RefreshTokenDescription
            {
                LoginRequest = new LoginRequest
                {
                    Subject = "uid"
                },
                NotAfter = DateTime.Now.AddMinutes(1)
            };

            //Act

            await Registry.Register(Token1, tokenDesc);

            var storedTokenDesc = await Registry.Get(Token1);

            //Assert
            Assert.NotNull(storedTokenDesc);
            Assert.Equal("uid", storedTokenDesc.Subject);
        }