Skip to content

Commit

Permalink
Add test to verify finger print is only verified when provided
Browse files Browse the repository at this point in the history
  • Loading branch information
Willem Stuursma committed Oct 7, 2016
1 parent bc91984 commit 3cd1c81
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/SftpAdapterTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,30 @@ public function testHostFingerprintIsVerifiedIfProvided ()
$adapter->connect();
}

public function testHostFingerprintNotIsVerifiedIfNotProvided ()
{
$adapter = new SftpAdapter([
'host' => 'example.org',
'username' => 'user',
'password' => '123456',
]);

$connection = Mockery::mock('phpseclib\Net\SFTP');

$connection->shouldReceive('getServerPublicHostKey')
->never();

$connection->shouldReceive('login')
->with('user', '123456')
->andReturn(TRUE);

$connection->shouldReceive('disconnect');

$adapter->setNetSftpConnection($connection);

$adapter->connect();
}

/**
* @expectedException LogicException
* @expectedExceptionMessage The authenticity of host example.org can't be established.
Expand Down

0 comments on commit 3cd1c81

Please sign in to comment.