1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 00:22:53 +00:00

GitHubDriver: stricter URL validation to avoid issues with undefined index owner (#10985)

This commit is contained in:
Stephan 2022-08-16 10:08:03 +01:00 committed by GitHub
parent b0674c421a
commit 1f0bd51f55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 4 deletions

View file

@ -342,14 +342,16 @@ class GitHubDriverTest extends TestCase
}
/**
* @dataProvider invalidUrlProvider
* @param string $url
* @return void
*/
public function initializeInvalidReoUrl()
public function testInitializeInvalidReoUrl($url)
{
$this->setExpectedException('\InvalidArgumentException');
$repoConfig = array(
'url' => 'https://github.com/acme',
'url' => $url,
);
$io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
@ -361,6 +363,18 @@ class GitHubDriverTest extends TestCase
$gitHubDriver->initialize();
}
/**
* @return list<array{bool, string}>
*/
public function invalidUrlProvider()
{
return array(
array(false, 'https://github.com/acme'),
array(false, 'https://github.com/acme/repository/releases'),
array(false, 'https://github.com/acme/repository/pulls'),
);
}
/**
* @dataProvider supportsProvider
* @param bool $expected
@ -382,6 +396,8 @@ class GitHubDriverTest extends TestCase
array(false, 'https://github.com/acme'),
array(true, 'https://github.com/acme/repository'),
array(true, 'git@github.com:acme/repository.git'),
array(false, 'https://github.com/acme/repository/releases'),
array(false, 'https://github.com/acme/repository/pulls'),
);
}