public async Task ShouldNotFind() { await using (var context = new DbContextFactory().CreateContext()) { var service = new AuthServiceFactory().Create(context); FluentActions.Invoking(async() => await service.Authenticate(new Guid())) .Should().Throw <UserNotFoundException>(); } }
public async Task ShouldNotFindUser() { await using (var context = new DbContextFactory().CreateContext()) { var service = new AuthServiceFactory().Create(context); FluentActions.Invoking(async() => await service.UpdatePassword(Guid.Empty, "wrong")) .Should().Throw <UserNotFoundException>(); } }
public async Task ShouldNotFind() { await using (var context = new DbContextFactory().CreateContext()) { var service = new AuthServiceFactory().Create(context); FluentActions.Invoking(async() => await service.Login("*****@*****.**", "Wrong", false)) .Should().Throw <UserNotFoundException>(); } }
public async Task PasswordShouldBeIncorrect() { await using (var context = new DbContextFactory().CreateContext()) { var service = new AuthServiceFactory().Create(context); FluentActions.Invoking(async() => await service.Login("*****@*****.**", "Wrong", false)) .Should().Throw <IncorrectPasswordException>(); } }
public async Task ShouldLogin() { await using (var context = new DbContextFactory().CreateContext()) { var service = new AuthServiceFactory().Create(context); var result = await service.Authenticate(new Guid("046E876E-D413-45AF-AC2A-552D7AA46C5C")); result.Should().NotBeNull(); } }
public async Task ShouldLogin() { await using (var context = new DbContextFactory().CreateContext()) { var service = new AuthServiceFactory().Create(context); var result = await service.Login("*****@*****.**", "Password", false); result.Should().NotBeNull(); } }
public async Task ShouldReturn1DayToken() { await using (var context = new DbContextFactory().CreateContext()) { var service = new AuthServiceFactory().Create(context); var result = await service.Login("*****@*****.**", "Password", false); var handler = new JwtSecurityTokenHandler(); var token = handler.ReadJwtToken(result.Token); DateTime validFrom = token.ValidFrom; DateTime validTo = token.ValidTo; validTo.Should().Be(validFrom.AddDays(1)); } }
public async Task ShouldUpdatePassword() { await using (var context = new DbContextFactory().CreateContext()) { var service = new AuthServiceFactory().Create(context); Guid id = new Guid("046E876E-D413-45AF-AC2A-552D7AA46C5C"); var user = await context.Users.FirstOrDefaultAsync(x => x.Id == id); var prevPassword = user.Password; await service.UpdatePassword(id, "NewPassword"); user.Password.Should().NotBe(prevPassword); } }