public void ExecuteSingleCommand_ThrowsApplicationExceptionWithDefaultData(string host, int port, string user, string pass)
        {
            var    sut = new SshSessionBase(host, port, user, pass);
            var    cmd = new SshCmdBase(sut);
            Action act = () => cmd.ExecuteCmd("echo test");

            act.ShouldThrow <ApplicationException>()
            .WithMessage("Connection Info not set!");
        }
        public void ExecuteSingleCommand_ReturnsFalseWithBadIpAddress(string host, int port, string user, string pass)
        {
            var sut = new SshSessionBase(host, port, user, pass);
            var cmd = new SshCmdBase(sut);

            cmd.ExecuteCmd("echo test");

            cmd.IsExecuted.Should().BeFalse();
        }
        public void ExecuteSingleCommand_DoesNotThrowExceptionWithBadIpAddress()
        {
            var    sut = new SshSessionBase("0.0.0.0", 22, "user", "pass");
            var    cmd = new SshCmdBase(sut);
            Action act = () => cmd.ExecuteCmd("echo test");

            act.ShouldNotThrow();
            cmd.CmdText.Should().Be("echo test");
            cmd.StdOutText.Should().BeNull();
            cmd.StdErrText.Should().BeNull();
        }
Beispiel #4
0
        /// <summary>
        /// Creates an SshSession with methods that will interact with a console
        /// </summary>
        public SshConsole()
        {
            // Restore from either the embedded default settings file, or the last host info that was saved in a prior session to a user settings file
            string host = Properties.Settings.Default.HostName;
            int    port = Properties.Settings.Default.HostPort;
            string user = Properties.Settings.Default.Username;
            string pass = Properties.Settings.Default.Password;

            // Create the local Ssh session with basic password authentication
            _localSsh = new SshSessionBase(host, port, user, pass);
        }