示例#1
0
 public function testAddKey()
 {
     $key = SshPrivateKey::fromFile("{$this->keysDir}/id_nopass_rsa");
     $agent = new SshAgent();
     // Agent is not running so not possible to add a key to it
     $this->assertFalse($agent->addKey($key));
     $agent->start();
     $this->assertTrue($agent->addKey($key));
 }
示例#2
0
 public function testPrivateKeyGetPassword()
 {
     // Private key without a password
     $key = SshPrivateKey::fromFile("{$this->keysDir}/id_nopass_rsa");
     $this->assertFalse($key->hasPassword());
     $this->assertEquals('', $key->getPassword());
     // Private key with password
     $key = SshPrivateKey::fromFile("{$this->keysDir}/id_pass_rsa", 'abc123');
     $this->assertTrue($key->hasPassword());
     $this->assertEquals('abc123', $key->getPassword());
 }