public async Task Should_remove_tokens_for_user_email() { // given string email1 = "*****@*****.**"; string tokenForUser1 = "token stuart 1"; string tokenForUser1_b = "token stuart 2"; string email2 = "*****@*****.**"; string tokenForUser2 = "token for bob"; UserRefreshTokenRepository repository = CreateRepository(); await repository.AddRefreshToken("jwt1", tokenForUser1, email1, "ip1"); await repository.AddRefreshToken("jwt2", tokenForUser1_b, email1, "ip2"); await repository.AddRefreshToken("jwt3", tokenForUser2, email2, "ip3"); // when await repository.DeleteRefreshTokens(email1); // then UserRefreshToken deletedToken1 = await repository.GetRefreshToken(tokenForUser1); UserRefreshToken deletedToken2 = await repository.GetRefreshToken(tokenForUser1_b); UserRefreshToken activeToken = await repository.GetRefreshToken(tokenForUser2); deletedToken1.ShouldBeNull(); deletedToken2.ShouldBeNull(); activeToken.ShouldNotBeNull(); }
public async Task Should_remove_token_per_device() { // given var now = DateTime.UtcNow; string email = "*****@*****.**"; string firstRefreshToken = "F5 F5"; string firstDeviceIpAddress = "8.8.8.8"; string secondRefreshToken = "F6 F6"; string secondDeviceIpAddress = "8.8.8.9"; UserRefreshTokenRepository repository = CreateRepository(); // when await repository.AddRefreshToken(email, firstRefreshToken, firstDeviceIpAddress); await repository.AddRefreshToken(email, secondRefreshToken, secondDeviceIpAddress); await repository.DeleteRefreshTokens(email, firstDeviceIpAddress); // then UserRefreshToken token1 = await repository.GetRefreshToken(email, firstDeviceIpAddress); UserRefreshToken token2 = await repository.GetRefreshToken(email, secondDeviceIpAddress); token1.ShouldBeNull(); token2.ShouldNotBeNull(); }
public async Task Should_remove_token() { // given string email1 = "*****@*****.**"; string refreshToken = "token stuart 1"; UserRefreshTokenRepository repository = CreateRepository(); await repository.AddRefreshToken("jwt1", refreshToken, email1, "ip1"); // when await repository.DeleteRefreshToken(refreshToken); // then UserRefreshToken deletedToken = await repository.GetRefreshToken(refreshToken); deletedToken.ShouldBeNull(); }