Example #1
0
        public void GetVersion_ReturnsFirstOutputLine()
        {
            var transportMock = new Mock <IGpgTransport>();

            transportMock.Setup(
                t => t.CallGpg(It.IsNotNull <string>(), It.IsAny <string>()))
            .Returns(new GpgResultBuilder()
                     .WithStdout("GPG version 1.0\r\nmore info")
                     .Build());
            var gpg = new GPG(transportMock.Object, Mock.Of <IGpgAgent>(), StubGpgResultVerifier.AlwaysValid, new GpgConfig());

            var version = gpg.GetVersion();

            version.ShouldBe("GPG version 1.0");
        }
Example #2
0
 /// <summary>
 /// Checks if all components are configured correctly.
 /// </summary>
 private void RunInitialCheck()
 {
     if (!Directory.Exists(ConfigManager.Config.PasswordStore.Location))
     {
         notificationService.ShowErrorWindow($"Could not find the password store at {Path.GetFullPath(ConfigManager.Config.PasswordStore.Location)}. Please make sure it exists.");
         Exit();
         return;
     }
     try
     {
         Log.Send("Using GPG version " + gpg.GetVersion());
     }
     catch (Win32Exception)
     {
         notificationService.ShowErrorWindow("Could not find GPG. Make sure your gpg-path is set correctly.");
         Exit();
         return;
     }
     catch (Exception e)
     {
         notificationService.ShowErrorWindow($"Failed to initialise GPG. {e.GetType().Name}: {e.Message}");
         Exit();
         return;
     }
     if (ConfigManager.Config.Gpg.GpgAgent.Preload)
     {
         Task.Run(() =>
         {
             try
             {
                 gpg.StartAgent();
             }
             catch (GpgError err)
             {
                 notificationService.ShowErrorWindow(err.Message);
             }
             // Ignore other exceptions. If it turns out GPG is misconfigured,
             // these errors will surface upon decryption/encryption.
             // The reason we catch GpgErrors here is so we can notify the user
             // if we don't detect any decryption keys.
         });
     }
 }
Example #3
0
        /// <summary>
        /// Display some information about configured variables.
        /// </summary>
        public void ShowDebugInfo()
        {
            // TODO: fetch Git reference from somewhere else
            var git     = (Git)syncService;
            var gitData = "";

            if (git != null)
            {
                gitData = $"\tbehind by:\t{git.GetTrackingDetails().BehindBy}\n" +
                          $"\tahead by:\t\t{git.GetTrackingDetails().AheadBy}\n";
            }

            var debugInfo = $"gpg.exe path:\t\t{gpg.GpgExePath}\n" +
                            $"gpg version:\t\t{gpg.GetVersion()}\n" +
                            $"gpg homedir:\t\t{gpg.GetConfiguredHomeDir()}\n" +
                            $"password store:\t\t{passwordManager.PasswordStore}\n" +
                            $"git enabled:\t\t{git != null}\n{gitData}";

            MessageBox.Show(debugInfo, "Debugging information", MessageBoxButton.OK, MessageBoxImage.None);
        }