Example #1
0
 /**
  * @small
  */
 public function testBadConnection()
 {
     $logger = new Logger();
     $connection = new Connection('invalid.host');
     $connection->setLogger($logger);
     $this->assertFalse($connection->connect());
     $this->assertFalse($connection->isConnected());
     $this->assertContains('Disconnected', $logger->getHistory());
 }
Example #2
0
 /**
  * Connect to the host via all tunnel nodes
  *
  * @return Connection|null
  */
 protected function connect()
 {
     // Connect to target host
     $this->status(Phase::CONNECTION(), 0, 0, "Connecting to target host " . $this->host->getHostname() . ':' . $this->host->getPort());
     $con = new Connection($this->host->getHostname(), $this->host->getPort(), $this->host->getCredential());
     $con->setLogger($this->logger);
     if (!$con->connect()) {
         $this->status(Phase::ERROR(), 0, 0, "Failed to connect to target host");
         $con->disconnectChain();
         return null;
     }
     if (!$con->authenticate()) {
         $this->status(Phase::ERROR(), 0, 0, "Failed to authenticate on target host");
         $con->disconnectChain();
         return null;
     }
     return $con;
 }