public void PasswordShouldFailValidationAfterExpiryTime() { var oneTimePasswordService = new OneTimePasswordService(this.passwordStoreMoq.Object, this.configurationMoq.Object); var password = oneTimePasswordService.Generate(userId); Thread.Sleep((expiryInSeconds + 1) * 1000); if (oneTimePasswordService.Validate(this.userId, password)) Assert.Fail("Password should have expired."); }
public void PasswordShouldValidateBeforeExpiry() { var otp = new OneTimePassword(this.userId, "testPassword"); passwordStoreMoq.Setup(x => x.Read(this.userId)).Returns(otp); var oneTimePasswordService = new OneTimePasswordService(this.passwordStoreMoq.Object, this.configurationMoq.Object); var password = oneTimePasswordService.Generate(userId); if (!oneTimePasswordService.Validate(this.userId, otp.Password)) Assert.Fail("Password should have validated."); }
public void GenerateUniquePasswordTest() { var oneTimePasswordService = new OneTimePasswordService(this.passwordStoreMoq.Object, this.configurationMoq.Object); var passwords = new List<string>(); string password = string.Empty; for (int i = 0; i < 100; i++) { password = oneTimePasswordService.Generate(userId); if (passwords.Contains(password)) Assert.Fail("Password was not unique."); passwords.Add(password); } }
public OneTimePasswordController() { _oneTimePasswordService = new OneTimePasswordService(); }
public void Setup() { otpService = new OneTimePasswordService("testingFile.txt"); userId = Guid.NewGuid(); }