setSshKey() public méthode

public setSshKey ( string $path ) : void
$path string
Résultat void
Exemple #1
0
 /**
  * get an SSH client to contact this host
  *
  * @param  \DataSift\Storyplayer\PlayerLib\StoryTeller $st
  *         our ubiquitous state object
  * @param  \DataSift\Storyplayer\HostLib\HostDetails $hostDetails
  *         details about the host that you want a client for
  * @return \DataSift\Storyplayer\CommandLib\SshClient
  *         the SSH client for you to use
  */
 public function getClient($st, $hostDetails)
 {
     // shorthand
     $hostId = $hostDetails->hostId;
     // do we already have a client?
     if (isset($this->sshClients[$hostId])) {
         // yes - reuse it
         return $this->sshClients[$hostId];
     }
     // if we get here, we need to make a new client
     $sshClient = new SshClient($st, $hostDetails->sshOptions, $hostDetails->scpOptions);
     $sshClient->setIpAddress($hostDetails->ipAddress);
     $sshClient->setSshUsername($hostDetails->sshUsername);
     if (isset($hostDetails->sshKey)) {
         $sshClient->setSshKey($hostDetails->sshKey);
     }
     // all done
     $this->sshClients[$hostId] = $sshClient;
     return $sshClient;
 }
 /**
  * @covers DataSift\Storyplayer\CommandLib\SshClient::getSshKeyForUse
  */
 public function testCanGetSshKeyForUse()
 {
     // ----------------------------------------------------------------
     // setup your test
     // our $st object
     $i = new Injectables();
     $i->initOutputSupport();
     $i->initDataFormatterSupport();
     $i->initRuntimeConfigSupport($i);
     $st = new StoryTeller($i);
     // our test subject
     $obj = new SshClient($st);
     // what key will we use?
     $expectedKey = 'id_rsa';
     $expectedResult = "-i '" . $expectedKey . "'";
     // make sure that (if there is ever a default ssh key), it isn't
     // the string we're testing with
     $this->assertNotEquals($expectedResult, $obj->getSshKey());
     // ----------------------------------------------------------------
     // perform the change
     $obj->setSshKey($expectedKey);
     $actualResult = $obj->getSshKeyForUse();
     // ----------------------------------------------------------------
     // test the results
     $this->assertTrue(is_string($actualResult));
     $this->assertEquals($expectedResult, $actualResult);
 }