Example #1
0
        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>();
            }
        }
Example #2
0
        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>();
            }
        }
Example #3
0
        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();
            }
        }
Example #4
0
        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));
            }
        }