public void IsExpired29Minutes59Second() { // Arrange var token = new Token { CreateDate = DateTime.Now.AddSeconds(-1799) }; var validator = new DatabaseTokenValidator(null); // Act var actual = validator.IsExpired(token); // Assert Assert.IsFalse(actual); }
private static void ValidateToken(string token) { using (var dbContext = new BasicTokenDbContext()) { ITokenValidator validator = new DatabaseTokenValidator(dbContext); if (!validator.IsValid(token)) { throw new WebFaultException(HttpStatusCode.Forbidden); } // Add User ids to the header so the service has them if needed WebOperationContext.Current?.IncomingRequest.Headers.Add("User", validator.Token.User.Username); WebOperationContext.Current?.IncomingRequest.Headers.Add("UserId", validator.Token.User.Id.ToString()); } }