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)); }
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()); }