public void GeneratedPasswordShouldNotBeEmpty() { var serviceInfo = new ServiceInformation( "testService", new PasswordRestriction(SymbolsType.LowcaseLatin)); var password = ServicePasswordGenerator.GeneratePassword(serviceInfo, _userPassword); Assert.IsTrue(password.Length > 0); }
public void SecondaryGeneratedPasswordShouldBeSame() { var serviceInfo = new ServiceInformation( "testService", new PasswordRestriction(SymbolsType.LowcaseLatin)); var password = ServicePasswordGenerator.GeneratePassword(serviceInfo, _userPassword); var secondaryGenerated = ServicePasswordGenerator.GeneratePassword(serviceInfo, _userPassword); Assert.AreEqual(password, secondaryGenerated); }
public void ResultPasswordWithOtherUserPasswordShouldNotBeSame() { var serviceInfo = new ServiceInformation( "testService", new PasswordRestriction(SymbolsType.LowcaseLatin)); var password = ServicePasswordGenerator.GeneratePassword(serviceInfo, _userPassword); _userPassword = "******"; var otherPassword = ServicePasswordGenerator.GeneratePassword(serviceInfo, _userPassword); Assert.AreNotEqual(password, otherPassword); }
public void PasswordWithEqualsMinAndMaxLengthShouldBeSameLength() { var serviceWithLotSymbolTypes = new ServiceInformation( "testService", new PasswordRestriction( SymbolsType.LowcaseLatin | SymbolsType.UpcaseLatin | SymbolsType.Digital, passwordMinLength: 5, passwordMaxLength: 5)); var password = ServicePasswordGenerator.GeneratePassword( serviceWithLotSymbolTypes, _userPassword); Assert.IsTrue(password.Length == 5); }
public void LongPasswordShouldBeSuccessfulGenerated() { var serviceWithLotSymbolTypes = new ServiceInformation( "testService", new PasswordRestriction( SymbolsType.LowcaseLatin | SymbolsType.UpcaseLatin | SymbolsType.Digital, passwordMinLength: 2000, passwordMaxLength: 3000)); var password = ServicePasswordGenerator.GeneratePassword( serviceWithLotSymbolTypes, _userPassword); Assert.IsTrue(password.Length >= 2000); Assert.IsTrue(password.Length <= 3000); }
public void PasswordShouldContainsDifferentSymbols() { var serviceWithLotSymbolTypes = new ServiceInformation( "testService", new PasswordRestriction( SymbolsType.LowcaseLatin | SymbolsType.UpcaseLatin | SymbolsType.Digital)); var password = ServicePasswordGenerator.GeneratePassword( serviceWithLotSymbolTypes, _userPassword); Assert.IsTrue( SymbolsType.LowcaseLatin.GetSymbols().Any(symbol => password.Contains(symbol))); Assert.IsTrue( SymbolsType.UpcaseLatin.GetSymbols().Any(symbol => password.Contains(symbol))); Assert.IsTrue( SymbolsType.Digital.GetSymbols().Any(symbol => password.Contains(symbol))); }
public void PasswordForOtherServiceShouldNotBeSame() { var firstService = new ServiceInformation( "testService", new PasswordRestriction(SymbolsType.LowcaseLatin)); var password = ServicePasswordGenerator.GeneratePassword( firstService, _userPassword); var secondService = new ServiceInformation( "testService", new PasswordRestriction(SymbolsType.LowcaseLatin)); var otherPassword = ServicePasswordGenerator.GeneratePassword( secondService, _userPassword); Assert.AreNotEqual(password, otherPassword); }
public GeneratePasswordPageViewModel( IServicesManager servicesManager, ISessionStateService sessionStateService, INavigationService navigationService) { Contract.Assert(sessionStateService != null); _sessionStateService = sessionStateService; _service = null; _servicePassword = null; GenerateServicePassword = new LambdaCommand( parameter => { var password = parameter as string; if (password?.Length > 0) { ServicePassword = ServicePasswordGenerator.GeneratePassword( Service, password); } }, _ => Service != null); CopyServicePassword = new LambdaCommand( _ => { _dataPackage.SetText(ServicePassword); Clipboard.SetContent(_dataPackage); }, _ => ServicePassword?.Length > 0); RemoveService = new LambdaCommand( _ => { servicesManager.RemoveServiceAsync(Service.UniqueToken); navigationService.GoBack(); }); }