Пример #1
0
        public void HasPasswordExpiredAppDataNull()
        {
            lithnetPwdProvider.Setup(a => a.GetExpiry(It.IsAny <IComputer>())).Returns((DateTime?)null);
            LapsAgent agent = this.BuildAgent();

            Assert.IsFalse(agent.HasPasswordExpired(this.computer.Object));
        }
Пример #2
0
        public void HasPasswordExpiredAppDataExpired()
        {
            lithnetPwdProvider.Setup(a => a.HasPasswordExpired(It.IsAny <IComputer>(), false)).Returns(true);

            LapsAgent agent = this.BuildAgent();

            Assert.IsTrue(agent.HasPasswordExpired(this.computer.Object));
        }
        public void HasPasswordExpiredAppDataNotExpired()
        {
            settings.SetupGet(a => a.WriteToLithnetAttributes).Returns(true);
            lithnetPwdProvider.Setup(a => a.GetExpiry(It.IsAny <IComputer>())).Returns(DateTime.UtcNow.AddDays(1));

            LapsAgent agent = this.BuildAgent();

            Assert.IsFalse(agent.HasPasswordExpired(this.computer.Object));
        }
Пример #4
0
        public void TestPasswordChangeAppData()
        {
            LapsAgent agent = this.BuildAgent();

            agent.ChangePassword(this.computer.Object);

            lithnetPwdProvider.Verify(v => v.UpdateCurrentPassword(It.IsAny <IComputer>(), It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <int>(), MsMcsAdmPwdBehaviour.Ignore), Times.Once);
            sam.Verify(v => v.SetLocalAccountPassword(It.IsAny <SecurityIdentifier>(), It.IsAny <string>()));
        }
        public void TestExitOnAgentDisabled()
        {
            this.settings.SetupGet(a => a.Enabled).Returns(false);

            LapsAgent agent = this.BuildAgent();

            agent.DoCheck();
            settings.VerifyGet(t => t.Enabled);
            settings.VerifyGet(t => t.WriteToLithnetAttributes, Times.Never);
        }
        public void HasPasswordExpiredMsMcsAdmPwdNotExpired()
        {
            settings.SetupGet(a => a.WriteToLithnetAttributes).Returns(false);
            settings.SetupGet(a => a.WriteToMsMcsAdmPasswordAttributes).Returns(true);
            admPwdProvider.Setup(a => a.GetExpiry(null)).Returns(DateTime.UtcNow.AddDays(1));

            LapsAgent agent = this.BuildAgent();

            Assert.IsFalse(agent.HasPasswordExpired(this.computer.Object));
        }
Пример #7
0
        public void TestExitOnAgentDisabled()
        {
            this.settings.SetupGet(a => a.Enabled).Returns(false);

            LapsAgent agent = this.BuildAgent();

            agent.DoCheck();
            settings.VerifyGet(t => t.Enabled);
            settings.VerifyGet(t => t.MsMcsAdmPwdBehaviour, Times.Never);
        }
        public void TestPasswordChangeLaps()
        {
            this.settings.SetupGet(a => a.WriteToMsMcsAdmPasswordAttributes).Returns(true);
            LapsAgent agent = this.BuildAgent();

            agent.ChangePassword(this.computer.Object);

            admPwdProvider.Verify(v => v.SetPassword(It.IsAny <IComputer>(), It.IsAny <string>(), It.IsAny <DateTime>()));
            lithnetPwdProvider.Verify(v => v.UpdateCurrentPassword(It.IsAny <IComputer>(), It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <int>()), Times.Never);
            sam.Verify(v => v.SetLocalAccountPassword(It.IsAny <SecurityIdentifier>(), It.IsAny <string>()));
        }
        public void TestExitOnNoPasswordProvidersEnabled()
        {
            this.settings.SetupGet(a => a.Enabled).Returns(true);
            this.settings.SetupGet(a => a.WriteToLithnetAttributes).Returns(false);
            this.settings.SetupGet(a => a.WriteToMsMcsAdmPasswordAttributes).Returns(false);

            LapsAgent agent = this.BuildAgent();

            agent.DoCheck();
            settings.VerifyGet(t => t.Enabled);
            directory.Verify(t => t.GetComputer(It.IsAny <string>()), Times.Never);
        }