Exemplo n.º 1
0
        public void JwToken_Should_Be_Expired()
        {
            var securitySettings = A.Fake <ISecuritySettings>();

            A.CallTo(() => securitySettings.AccessTokenLifespanSeconds).Returns(1);

            IAccessTokenService accessTokenService = new AccessTokenService(_jwtService, _accountRepository, securitySettings);

            var accessToken = accessTokenService.CreateToken("fake");

            // set to expire in 1 second
            Thread.Sleep(2000);

            var isTokenExpired = _jwtService.IsTokenExpired(accessToken);

            Assert.IsTrue(isTokenExpired);
        }