1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 16:42:57 +00:00

Merge branch '2.2' into main

This commit is contained in:
Jordi Boggiano 2022-04-29 12:15:20 +02:00
commit 928e19e637
No known key found for this signature in database
GPG key ID: 7BBD42C429EC80BC
3 changed files with 51 additions and 1 deletions

View file

@ -12,6 +12,7 @@
namespace Composer\Test\Util;
use Composer\Downloader\TransportException;
use Composer\IO\IOInterface;
use Composer\Test\TestCase;
use Composer\Util\AuthHelper;
@ -511,6 +512,41 @@ class AuthHelperTest extends TestCase
$this->authHelper->storeAuth($origin, $storeAuth);
}
public function testPromptAuthIfNeededGitLabNoAuthChange(): void
{
self::expectException('Composer\Downloader\TransportException');
$origin = 'gitlab.com';
$this->io
->method('hasAuthentication')
->with($origin)
->willReturn(true);
$this->io
->method('getAuthentication')
->with($origin)
->willReturn(array(
'username' => 'gitlab-user',
'password' => 'gitlab-password',
));
$this->io
->expects($this->once())
->method('setAuthentication')
->with('gitlab.com', 'gitlab-user', 'gitlab-password');
$this->config
->method('get')
->willReturnMap(array(
array('github-domains', 0, array()),
array('gitlab-domains', 0, array('gitlab.com')),
array('gitlab-token', 0, array('gitlab.com' => array('username' => 'gitlab-user', 'token' => 'gitlab-password'))),
));
$this->authHelper->promptAuthIfNeeded('https://gitlab.com/acme/archive.zip', $origin, 404, 'GitLab requires authentication and it was not provided');
}
/**
* @param string $origin
* @param array<string, string|null> $auth