Esempio n. 1
0
        public void update_an_existing_history()
        {
            var history = new LoginFailureHistory
            {
                Id       = "AlreadyFailed",
                Attempts = 2
            };

            theContainer.GetInstance <ITransaction>().Execute <IDocumentSession>(repo => { repo.Store(history); });


            var request = new LoginRequest
            {
                Status         = LoginStatus.Failed,
                UserName       = history.Id,
                NumberOfTries  = 3,
                LockedOutUntil = DateTime.Today.ToUniversalTime()
            };

            var auditor = theContainer.GetInstance <PersistedLoginAuditor>();

            auditor.Audit(request);


            var history2 = theContainer.GetInstance <IDocumentSession>()
                           .Load <LoginFailureHistory>(request.UserName);

            history2.Attempts.ShouldBe(request.NumberOfTries);
            history2.LockedOutTime.ShouldBe(request.LockedOutUntil);
        }
        public void when_logging_success_wipe_clean_the_login_failure_history()
        {
            var history = new LoginFailureHistory
            {
                Id       = "doofus",
                Attempts = 3
            };

            theContainer.GetInstance <ITransaction>().Execute <IDocumentSession>(repo =>
            {
                repo.Store(history);
            });



            var request = new LoginRequest
            {
                Status   = LoginStatus.Succeeded,
                UserName = history.Id
            };

            var auditor = theContainer.GetInstance <PersistedLoginAuditor>();

            auditor.Audit(request);
        }
Esempio n. 3
0
        public void apply_history_when_there_is_prior_history()
        {
            var history = new LoginFailureHistory
            {
                Id            = "AlreadyLockedOut",
                Attempts      = 3,
                LockedOutTime = DateTime.Today.AddMinutes(30)
            };

            theContainer.GetInstance <ITransaction>().Execute <IDocumentSession>(repo => repo.Store(history));

            var auditor = theContainer.GetInstance <PersistedLoginAuditor>();
            var request = new LoginRequest
            {
                UserName = history.Id
            };

            auditor.ApplyHistory(request);

            request.NumberOfTries.ShouldBe(history.Attempts);
            request.LockedOutUntil.ShouldBe(history.LockedOutTime.Value);
        }
        public void apply_history_when_there_is_prior_history()
        {
            var history = new LoginFailureHistory
            {
                Id = "AlreadyLockedOut",
                Attempts = 3,
                LockedOutTime = DateTime.Today.AddMinutes(30)
            };

            theContainer.GetInstance<ITransaction>().Execute<IDocumentSession>(repo => repo.Store(history));

            var auditor = theContainer.GetInstance<PersistedLoginAuditor>();
            var request = new LoginRequest
            {
                UserName = history.Id
            };

            auditor.ApplyHistory(request);

            request.NumberOfTries.ShouldEqual(history.Attempts);
            request.LockedOutUntil.ShouldEqual(history.LockedOutTime.Value);
        }
        public void when_logging_success_wipe_clean_the_login_failure_history()
        {
            var history = new LoginFailureHistory
            {
                Id = "doofus",
                Attempts = 3
            };

            theContainer.GetInstance<ITransaction>().Execute<IDocumentSession>(repo =>
            {
                repo.Store(history);
            });




            var request = new LoginRequest
            {
                Status = LoginStatus.Succeeded,
                UserName = history.Id
            };

            var auditor = theContainer.GetInstance<PersistedLoginAuditor>();
            auditor.Audit(request);


        }
        public void update_an_existing_history()
        {
            var history = new LoginFailureHistory
            {
                Id = "AlreadyFailed",
                Attempts = 2
            };

            theContainer.GetInstance<ITransaction>().Execute<IDocumentSession>(repo =>
            {
                repo.Store(history);
            });


            var request = new LoginRequest
            {
                Status = LoginStatus.Failed,
                UserName = history.Id,
                NumberOfTries = 3,
                LockedOutUntil = DateTime.Today.ToUniversalTime()

            };

            var auditor = theContainer.GetInstance<PersistedLoginAuditor>();
            auditor.Audit(request);


            var history2 = theContainer.GetInstance<IDocumentSession>()
                        .Load<LoginFailureHistory>(request.UserName);

            history2.Attempts.ShouldEqual(request.NumberOfTries);
            history2.LockedOutTime.ShouldEqual(request.LockedOutUntil);

        }
        public void apply_history_when_there_is_prior_history()
        {
            var history = new LoginFailureHistory
            {
                UserName = "******",
                Attempts = 3,
                LockedOutTime = DateTime.Today.AddMinutes(30)
            };

            theContainer.GetInstance<ITransaction>().WithRepository(repo => repo.Update(history));
            waitForHistoryToAppear(history.UserName);

            var auditor = theContainer.GetInstance<PersistedLoginAuditor>();
            var request = new LoginRequest
            {
                UserName = history.UserName
            };

            auditor.ApplyHistory(request);

            request.NumberOfTries.ShouldEqual(history.Attempts);
            request.LockedOutUntil.ShouldEqual(history.LockedOutTime.Value);
        }
        public void update_an_existing_history()
        {
            var history = new LoginFailureHistory
            {
                UserName = "******",
                Attempts = 2
            };

            theContainer.GetInstance<ITransaction>().WithRepository(repo =>
            {
                repo.Update(history);
            });

            waitForHistoryToAppear(history.UserName);

            var request = new LoginRequest
            {
                Status = LoginStatus.Failed,
                UserName = history.UserName,
                NumberOfTries = 3,
                LockedOutUntil = DateTime.Today.ToUniversalTime()

            };

            var auditor = theContainer.GetInstance<PersistedLoginAuditor>();
            auditor.Audit(request);

            waitForHistoryToAppear(request.UserName);

            var history2 = theContainer.GetInstance<IEntityRepository>()
                        .FindWhere<LoginFailureHistory>(x => x.UserName == request.UserName);

            history2.Attempts.ShouldEqual(request.NumberOfTries);
            history2.LockedOutTime.ShouldEqual(request.LockedOutUntil);

        }
        public void when_logging_success_wipe_clean_the_login_failure_history()
        {
            var history = new LoginFailureHistory
            {
                UserName = "******",
                Attempts = 3
            };

            theContainer.GetInstance<ITransaction>().WithRepository(repo =>
            {
                repo.Update(history);
            });

            waitForHistoryToAppear(history.UserName);



            var request = new LoginRequest
            {
                Status = LoginStatus.Succeeded,
                UserName = history.UserName
            };

            var auditor = theContainer.GetInstance<PersistedLoginAuditor>();
            auditor.Audit(request);

            waitForHistoryToDisappear(history.UserName);

        }