Exemple #1
0
        protected void SetupData()
        {
            _serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
            _connectionInfo = new ConnectionInfo(
                _serverEndPoint.Address.ToString(),
                _serverEndPoint.Port,
                "user",
                new PasswordAuthenticationMethod("user", "password"));
            _connectionInfo.Timeout = TimeSpan.FromMilliseconds(200);
            _actualException        = null;
            _socketFactory          = new SocketFactory();

            _serverListener            = new AsyncSocketListener(_serverEndPoint);
            _serverListener.Connected += (socket) =>
            {
                _serverSocket = socket;

                // Since we're mocking the protocol version exchange, we can immediately send the bad
                // packet upon establishing the connection

                var badPacket = new byte[] { 0x0a, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05 };
                _serverSocket.Send(badPacket, 0, badPacket.Length, SocketFlags.None);
                _serverSocket.Shutdown(SocketShutdown.Send);
            };
            _serverListener.Start();

            _session = new Session(_connectionInfo, _serviceFactoryMock.Object, _socketFactoryMock.Object);

            _clientSocket = new DirectConnector(_socketFactory).Connect(_connectionInfo);
        }
        protected void Arrange()
        {
            _serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
            _connectionInfo = new ConnectionInfo(
                _serverEndPoint.Address.ToString(),
                _serverEndPoint.Port,
                "user",
                new PasswordAuthenticationMethod("user", "password"));
            _connectionInfo.Timeout = TimeSpan.FromMilliseconds(200);
            _actualException        = null;

            _serviceFactoryMock = new Mock <IServiceFactory>(MockBehavior.Strict);

            _serverListener            = new AsyncSocketListener(_serverEndPoint);
            _serverListener.Connected += (socket) =>
            {
                _serverSocket = socket;

                socket.Send(Encoding.ASCII.GetBytes("\r\n"));
                socket.Send(Encoding.ASCII.GetBytes("WELCOME banner\r\n"));
                socket.Send(Encoding.ASCII.GetBytes("SSH-2.0-SshStub\r\n"));
            };
            _serverListener.BytesReceived += (received, socket) =>
            {
                var badPacket = new byte[] { 0x0a, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05 };
                _serverSocket.Send(badPacket, 0, badPacket.Length, SocketFlags.None);
                _serverSocket.Shutdown(SocketShutdown.Send);
            };
            _serverListener.Start();
        }
Exemple #3
0
        public void SshConnectionExceptionConstructorTest1()
        {
            string message = string.Empty; // TODO: Initialize to an appropriate value
            SshConnectionException target = new SshConnectionException(message);

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
Exemple #4
0
        public void GetObjectDataTest()
        {
            SshConnectionException target  = new SshConnectionException(); // TODO: Initialize to an appropriate value
            SerializationInfo      info    = null;                         // TODO: Initialize to an appropriate value
            StreamingContext       context = new StreamingContext();       // TODO: Initialize to an appropriate value

            target.GetObjectData(info, context);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
Exemple #5
0
        public void SshConnectionExceptionConstructorTest3()
        {
            string                 message = string.Empty;                        // TODO: Initialize to an appropriate value
            DisconnectReason       disconnectReasonCode = new DisconnectReason(); // TODO: Initialize to an appropriate value
            Exception              inner  = null;                                 // TODO: Initialize to an appropriate value
            SshConnectionException target = new SshConnectionException(message, disconnectReasonCode, inner);

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
        protected override void SetupData()
        {
            base.SetupData();

            var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);

            _connectionInfo   = CreateConnectionInfo(serverEndPoint, TimeSpan.FromSeconds(5));
            _session          = new Session(_connectionInfo, _serviceFactoryMock.Object, _socketFactoryMock.Object);
            _connectException = new SshConnectionException();
        }
Exemple #7
0
 protected void Act()
 {
     try
     {
         _forwardedPort.Start();
         Assert.Fail();
     }
     catch (SshConnectionException ex)
     {
         _actualException = ex;
     }
 }
 protected void Act()
 {
     try
     {
         _protocolVersionExchange.Start(_clientVersion, _client, _timeout);
         Assert.Fail();
     }
     catch (SshConnectionException ex)
     {
         _actualException = ex;
     }
 }
 protected override void Act()
 {
     try
     {
         _session.Connect();
         Assert.Fail();
     }
     catch (SshConnectionException ex)
     {
         _actualException = ex;
     }
 }
Exemple #10
0
 protected virtual void Act()
 {
     try
     {
         {
             _session.Connect();
         }
     }
     catch (SshConnectionException ex)
     {
         _actualException = ex;
     }
 }
 protected virtual void Act()
 {
     try
     {
         using (_session = new Session(_connectionInfo, _serviceFactoryMock.Object))
         {
             _session.Connect();
         }
     }
     catch (SshConnectionException ex)
     {
         _actualException = ex;
     }
 }
Exemple #12
0
        public void SshConnectionExceptionConstructorTest()
        {
            SshConnectionException target = new SshConnectionException();

            Assert.Inconclusive("TODO: Implement code to verify target");
        }