/// <summary> /// Auto-Type Function. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SprEngine_FilterCompile(object sender, SprEventArgs e) { if ((e.Context.Flags & SprCompileFlags.ExtActive) == SprCompileFlags.ExtActive && e.Text.IndexOf(Settings.AutoTypeFieldName.ExtWithBrackets(), StringComparison.InvariantCultureIgnoreCase) >= 0) { if (TOTPEntryValidator.HasSeed(e.Context.Entry)) { if (TOTPEntryValidator.SettingsValidate(e.Context.Entry)) { string[] settings = TOTPEntryValidator.SettingsGet(e.Context.Entry); TOTPProvider totpGenerator = new TOTPProvider(settings, this.TimeCorrections); string invalidCharacters; if (TOTPEntryValidator.SeedValidate(e.Context.Entry, out invalidCharacters)) { e.Context.Entry.Touch(false); string totp = totpGenerator.GenerateByByte(Base32.Decode(TOTPEntryValidator.SeedGet(e.Context.Entry).ReadString().ExtWithoutSpaces())); e.Text = StrUtil.ReplaceCaseInsensitive(e.Text, Settings.AutoTypeFieldName.ExtWithBrackets(), totp); } else { e.Text = string.Empty; MessageService.ShowWarning(Localization.Strings.ErrorBadSeed + invalidCharacters.ExtWithParenthesis().ExtWithSpaceBefore()); } if (totpGenerator.TimeCorrectionError) { MessageService.ShowWarning(Localization.Strings.WarningBadURL); } } else { e.Text = string.Empty; MessageService.ShowWarning(Localization.Strings.ErrorBadSettings); } } else { e.Text = string.Empty; MessageService.ShowWarning(Localization.Strings.ErrorNoSeed); } } }
public void SettingsGet_EntryHasNoSettings_ReturnsDefaultSettings() { var act = _sut.SettingsGet(_entry); act.Should().BeEquivalentTo("30", "6"); }