1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-10 00:53:06 +00:00
This commit is contained in:
Jordi Boggiano 2022-08-17 15:20:07 +03:00 committed by GitHub
parent 6e205a0c84
commit 131da999ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
357 changed files with 5943 additions and 9174 deletions

View file

@ -20,8 +20,6 @@ class TlsHelperTest extends TestCase
/**
* @dataProvider dataCheckCertificateHost
*
* @param bool $expectedResult
* @param string $hostname
* @param string[] $certNames
*/
public function testCheckCertificateHost(bool $expectedResult, string $hostname, array $certNames): void
@ -43,28 +41,28 @@ class TlsHelperTest extends TestCase
public function dataCheckCertificateHost(): array
{
return array(
array(true, 'getcomposer.org', array('getcomposer.org')),
array(true, 'getcomposer.org', array('getcomposer.org', 'packagist.org')),
array(true, 'getcomposer.org', array('packagist.org', 'getcomposer.org')),
array(true, 'foo.getcomposer.org', array('*.getcomposer.org')),
array(false, 'xyz.foo.getcomposer.org', array('*.getcomposer.org')),
array(true, 'foo.getcomposer.org', array('getcomposer.org', '*.getcomposer.org')),
array(true, 'foo.getcomposer.org', array('foo.getcomposer.org', 'foo*.getcomposer.org')),
array(true, 'foo1.getcomposer.org', array('foo.getcomposer.org', 'foo*.getcomposer.org')),
array(true, 'foo2.getcomposer.org', array('foo.getcomposer.org', 'foo*.getcomposer.org')),
array(false, 'foo2.another.getcomposer.org', array('foo.getcomposer.org', 'foo*.getcomposer.org')),
array(false, 'test.example.net', array('**.example.net', '**.example.net')),
array(false, 'test.example.net', array('t*t.example.net', 't*t.example.net')),
array(false, 'xyz.example.org', array('*z.example.org', '*z.example.org')),
array(false, 'foo.bar.example.com', array('foo.*.example.com', 'foo.*.example.com')),
array(false, 'example.com', array('example.*', 'example.*')),
array(true, 'localhost', array('localhost')),
array(false, 'localhost', array('*')),
array(false, 'localhost', array('local*')),
array(false, 'example.net', array('*.net', '*.org', 'ex*.net')),
array(true, 'example.net', array('*.net', '*.org', 'example.net')),
);
return [
[true, 'getcomposer.org', ['getcomposer.org']],
[true, 'getcomposer.org', ['getcomposer.org', 'packagist.org']],
[true, 'getcomposer.org', ['packagist.org', 'getcomposer.org']],
[true, 'foo.getcomposer.org', ['*.getcomposer.org']],
[false, 'xyz.foo.getcomposer.org', ['*.getcomposer.org']],
[true, 'foo.getcomposer.org', ['getcomposer.org', '*.getcomposer.org']],
[true, 'foo.getcomposer.org', ['foo.getcomposer.org', 'foo*.getcomposer.org']],
[true, 'foo1.getcomposer.org', ['foo.getcomposer.org', 'foo*.getcomposer.org']],
[true, 'foo2.getcomposer.org', ['foo.getcomposer.org', 'foo*.getcomposer.org']],
[false, 'foo2.another.getcomposer.org', ['foo.getcomposer.org', 'foo*.getcomposer.org']],
[false, 'test.example.net', ['**.example.net', '**.example.net']],
[false, 'test.example.net', ['t*t.example.net', 't*t.example.net']],
[false, 'xyz.example.org', ['*z.example.org', '*z.example.org']],
[false, 'foo.bar.example.com', ['foo.*.example.com', 'foo.*.example.com']],
[false, 'example.com', ['example.*', 'example.*']],
[true, 'localhost', ['localhost']],
[false, 'localhost', ['*']],
[false, 'localhost', ['local*']],
[false, 'example.net', ['*.net', '*.org', 'ex*.net']],
[true, 'example.net', ['*.net', '*.org', 'example.net']],
];
}
public function testGetCertificateNames(): void
@ -76,10 +74,10 @@ class TlsHelperTest extends TestCase
$names = TlsHelper::getCertificateNames($certificate);
$this->assertSame('example.net', $names['cn']);
$this->assertSame(array(
$this->assertSame([
'example.com',
'getcomposer.org',
'composer.example.org',
), $names['san']);
], $names['san']);
}
}