public function sshConnectionTestViaBastion()
{
$instance = $this->getMock('AwsInspector\\Model\\Ec2\\Instance', ['getJumpHost'], [['Tags' => [['Key' => 'inspector', 'Value' => 'User:Foo,Type:Bastion,Environment:dpl']], 'PrivateIpAddress' => '4.5.7.6']]);
$instance->method('getJumpHost')->willReturn(new Instance(['Tags' => [['Key' => 'inspector', 'Value' => 'User:Bar']], 'PrivateIpAddress' => '1.2.3.4']));
/* @var $instance Instance */
$this->assertEquals('User:Foo,Type:Bastion,Environment:dpl', $instance->getTag('inspector'));
$connection = $instance->getSshConnection();
$this->assertEquals('4.5.7.6', $connection->getHost());
$this->assertEquals('Foo', $connection->getUsername());
$proxyCommand = "ssh -o ConnectTimeout=5 -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null [email protected] 'nc %h %p'";
$command = 'ssh -o ProxyCommand="' . $proxyCommand . '" -o ConnectTimeout=5 -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null [email protected]';
$this->assertEquals($command, $connection->__toString());
}