示例#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>();
            }
        }
示例#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>();
            }
        }
示例#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();
            }
        }
示例#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));
            }
        }