Added test for RemoteFilesystem TLS options setup

main
Pádraic Brady 11 years ago
parent fa54b7054c
commit 1e1e713329

@ -52,7 +52,7 @@ class RemoteFilesystem
if (isset($options['ssl']['cafile'])
&& (!is_readable($options['ssl']['cafile'])
|| !openssl_x509_parse(file_get_contents($options['ssl']['cafile'])))) { //check return value and test (it's subject to change)
throw new TransportException('The configured cafile could was not valid or could not be read.');
throw new TransportException('The configured cafile was not valid or could not be read.');
}
// handle the other externally set options normally.

@ -178,6 +178,28 @@ class RemoteFilesystemTest extends \PHPUnit_Framework_TestCase
unlink($file);
}
/**
* @group TLS
*/
public function testGetOptionsForUrlCreatesSecureTlsDefaults()
{
$io = $this->getMock('Composer\IO\IOInterface');
$res = $this->callGetOptionsForUrl($io, array('http://example.org', array('ssl'=>array('cafile'=>'/some/path/file.crt'))));
$this->assertTrue(isset($res['ssl']['ciphers']));
$this->assertRegExp("|!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK|", $res['ssl']['ciphers']);
$this->assertTrue($res['ssl']['verify_peer']);
$this->assertTrue($res['ssl']['SNI_enabled']);
$this->assertEquals(7, $res['ssl']['verify_depth']);
$this->assertEquals('example.org', $res['ssl']['CN_match']);
$this->assertEquals('example.org', $res['ssl']['SNI_server_name']);
$this->assertEquals('/some/path/file.crt', $res['ssl']['cafile']);
if (version_compare(PHP_VERSION, '5.4.13') >= 0) {
$this->assertTrue($res['ssl']['disable_compression']);
}
}
protected function callGetOptionsForUrl($io, array $args = array(), array $options = array())
{
$fs = new RemoteFilesystem($io, $options);

Loading…
Cancel
Save