public void Should_Not_Be_Expired() { // Arrange var refreshToken = new RefreshToken("token", DateTime.MaxValue, "ip", Guid.Empty, FakeDateTime.UtcNow); // Assert refreshToken.IsExpired(FakeDateTime.UtcNow).Should().BeFalse(); refreshToken.IsActive(FakeDateTime.UtcNow).Should().BeTrue(); }
private string ValidateRefreshToken(RefreshToken token) { if (token == null) { return("Invalid refresh token"); } return(token.IsExpired() ? "Expired refresh token" : null); }
public void IsExpired_ReturnsTrue_WhenTokenIsExpired() { //Arrange JsonWebToken token = new RefreshToken("token", 100); //Act var result = token.IsExpired(); //Assert Assert.True(result); }
public void IsExpired_ReturnsFalse_WhenTokenIsNotExpired() { //Arrange JsonWebToken token = new RefreshToken("token", DateTime.Now.AddSeconds(60).Ticks); //Act var result = token.IsExpired(); //Assert Assert.False(result); }
public void Should_Revoke() { // Arrange var refreshToken = new RefreshToken("token", DateTime.MaxValue, "ip", Guid.Empty, FakeDateTime.UtcNow); var command = new RevokeRefreshToken.Command() { RefreshToken = "token", RemoteIpAddress = "ip2" }; // Act refreshToken.Revoke(command, FakeDateTime.UtcNow); // Assert refreshToken.RevokedByIp.Should().BeEquivalentTo("ip2"); refreshToken.RevokedOn.Should().BeMoreThan(TimeSpan.Zero); refreshToken.IsActive(FakeDateTime.UtcNow).Should().BeFalse(); refreshToken.IsExpired(FakeDateTime.UtcNow).Should().BeFalse(); }