コード例 #1
0
ファイル: PasswordCredentialTest.php プロジェクト: bravo3/ssh
 /**
  * @group server
  * @medium
  */
 public function testPasswordAuthentication()
 {
     $connection = new Connection(\properties::$host, \properties::$port, new PasswordCredential(\properties::$user, \properties::$pass));
     $this->assertTrue($connection->connect());
     $this->assertTrue($connection->authenticate());
     $this->assertTrue($connection->isAuthenticated());
     $connection->disconnect();
 }
コード例 #2
0
ファイル: PublicKeyTest.php プロジェクト: bravo3/ssh
 /**
  * @dataProvider keyFileProvider
  * @group server
  * @medium
  */
 public function testNoPublicKey($public, $private, $password)
 {
     $credential = new KeyCredential(\properties::$user, null, $private, $password);
     $connection = new Connection(\properties::$host, \properties::$port, $credential);
     $this->assertTrue($connection->connect());
     $this->assertTrue($connection->authenticate());
     $this->assertTrue($connection->isAuthenticated());
     $connection->disconnect();
 }
コード例 #3
0
ファイル: ShellTest.php プロジェクト: bravo3/ssh
 /**
  * Get an authenticated connection ready for transaction testing
  *
  * @param bool $doAuth
  * @throws \Exception
  * @return Shell
  */
 protected function getShell()
 {
     $connection = new Connection(\properties::$host, \properties::$port, new PasswordCredential(\properties::$user, \properties::$pass));
     if (!$connection->connect()) {
         throw new \Exception("Error connecting to test server");
     }
     if (!$connection->authenticate()) {
         throw new \Exception("Error authenticating on test server");
     }
     return $connection->getShell();
 }
コード例 #4
0
ファイル: ConnectionTest.php プロジェクト: bravo3/ssh
 /**
  * @small
  */
 public function testLogger()
 {
     $logger = new Logger();
     $connection = new Connection(self::DEFAULT_HOST);
     $connection->setLogger($logger);
     try {
         $connection->authenticate();
         // will fail - not connected
     } catch (NotConnectedException $e) {
     }
     $this->assertEquals("error: Not connected\n", $logger->getHistory());
 }
コード例 #5
0
ファイル: Bakery.php プロジェクト: bravo3/bakery
 /**
  * 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;
 }