Terminate() 공개 메소드

public Terminate ( ) : void
리턴 void
예제 #1
0
        public void InitializeTest()
        {
            const string initalizeResultName = "KEEAGENT_INIT_RESULT";

              using (KeePassAppDomain testDomain1 = new KeePassAppDomain()) {
            testDomain1.StartKeePass(true, true, 1, true);
            testDomain1.DoCallBack(delegate()
            {
              IPluginHost td1PluginHost = KeePass.Program.MainForm.PluginHost;
              try {
            KeeAgentExt td1KeeAgentExt = new KeeAgentExt();
            KeePass.Program.MainForm.Invoke((MethodInvoker)delegate()
            {
              bool td1InitalizeResult = td1KeeAgentExt.Initialize(td1PluginHost);
              td1KeeAgentExt.Terminate();
              AppDomain.CurrentDomain.SetData(initalizeResultName,
                td1InitalizeResult);
            });
              } catch (Exception) {
            // TODO do we want to pass this exception back to test?
              }
            });

            bool expected = true;
            bool actual = (bool)testDomain1.GetData(initalizeResultName);
            Assert.AreEqual(expected, actual);
              }
        }
예제 #2
0
        public void TestIOProtocolExt()
        {
            using (KeePassAppDomain testDomain1 = new KeePassAppDomain()) {
            testDomain1.StartKeePass(true, false, 1, true);
            testDomain1.DoCallBack(delegate()
            {
              KeePass.Program.MainForm.Invoke((MethodInvoker)delegate()
              {
            /* initialize plugins */

            KeeAgentExt td1KeeAgentExt = new KeeAgentExt();
            IOProtocolExtExt td1IOProtocolExt = new IOProtocolExtExt();

            IPluginHost td1PluginHost = KeePass.Program.MainForm.PluginHost;
            td1KeeAgentExt.Initialize(td1PluginHost);
            td1IOProtocolExt.Initialize(td1PluginHost);
            KeePass.Program.MainForm.FormClosing += delegate(
              Object source, FormClosingEventArgs args)
            {
              td1KeeAgentExt.Terminate();
              td1IOProtocolExt.Terminate();
            };

            var extType = td1KeeAgentExt.GetType ();
            var mAgentField = extType.GetField ("mAgent",
                                                BindingFlags.Instance | BindingFlags.NonPublic);
            var agent = mAgentField.GetValue (td1KeeAgentExt) as IAgent;

            // test not valid in client mode
            Assert.That(agent, Is.AssignableTo<Agent>());

            // override confirm callback so we don't have to click OK
            (agent as Agent).ConfirmUserPermissionCallback =
              delegate(ISshKey aKey)
              {
                return true;
              };

            /* load ssh key */
            var keyFileDir = Path.GetFullPath (Path.Combine (
              "..", "..", "..", "SshAgentLib", "SshAgentLibTests", "Resources"));
            var keyFilePath = Path.Combine(keyFileDir, "rsa_with_passphrase");
            Assert.That(File.Exists(keyFilePath), "Cannot locate key file: " + keyFilePath);

            KeyFormatter.GetPassphraseCallback getPassphraseCallback =
              delegate()
              {
                var passphrase = "passphrase";
                var securePassphrase = new SecureString();
                foreach (char c in passphrase) {
                  securePassphrase.AppendChar(c);
                }
                return securePassphrase;
              };
            var constraints = new List<Agent.KeyConstraint>();
            constraints.addConfirmConstraint();
            agent.AddKeyFromFile(keyFilePath, getPassphraseCallback, constraints);

            /* run test */
            IOConnectionInfo ioConnectionInfo = new IOConnectionInfo();
            ioConnectionInfo.Path = "sftp://satest/test.kdbx";
            ioConnectionInfo.UserName = "******";
            bool fileExists = IOConnection.FileExists(ioConnectionInfo);
            Assert.IsTrue(fileExists, "Is satest VM running?");

            /* the problem we are checking for is that IOConnection.FileExists
             * does not lock up. Originally, in KeeAgent, WinPagent ran on main
             * thread and caused lock-up here. So, we are looking to see if the
             * test times out or not. */
              });
            });
              }
        }