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

Introduce gitlab-protocol option to force the gitlab repos to use https or git protocol (#9401)

This commit is contained in:
Brad Jones 2021-05-27 15:05:53 -06:00 committed by GitHub
parent c8de960018
commit dd625669e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 67 additions and 6 deletions

View file

@ -561,6 +561,38 @@ JSON;
$driver->initialize();
}
public function testProtocolOverrideRepositoryUrlGeneration()
{
// @link http://doc.gitlab.com/ce/api/projects.html#get-single-project
$projectData = <<<JSON
{
"id": 17,
"default_branch": "mymaster",
"visibility": "private",
"http_url_to_repo": "https://gitlab.com/mygroup/myproject.git",
"ssh_url_to_repo": "git@gitlab.com:mygroup/myproject.git",
"last_activity_at": "2014-12-01T09:17:51.000+01:00",
"name": "My Project",
"name_with_namespace": "My Group / My Project",
"path": "myproject",
"path_with_namespace": "mygroup/myproject",
"web_url": "https://gitlab.com/mygroup/myproject"
}
JSON;
$apiUrl = 'https://gitlab.com/api/v4/projects/mygroup%2Fmyproject';
$url = 'git@gitlab.com:mygroup/myproject';
$this->mockResponse($apiUrl, array(), $projectData)
->shouldBeCalledTimes(1)
;
$config = clone $this->config;
$config->merge(array('config' => array('gitlab-protocol' => 'http')));
$driver = new GitLabDriver(array('url' => $url), $this->io->reveal(), $config, $this->httpDownloader->reveal(), $this->process->reveal());
$driver->initialize();
$this->assertEquals('https://gitlab.com/mygroup/myproject.git', $driver->getRepositoryUrl(), 'Repository URL matches config request for http not git');
}
private function mockResponse($url, $options, $return)
{
return $this->httpDownloader