1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 08:32:56 +00:00

Allow SVN to connect with credentials provided with the auth.json file

This commit is contained in:
Benjamin Grandfond 2014-05-30 17:14:43 +02:00
parent 7131607ad1
commit a21b0f82db
5 changed files with 91 additions and 25 deletions

View file

@ -1,6 +1,7 @@
<?php
namespace Composer\Test\Util;
use Composer\Config;
use Composer\IO\NullIO;
use Composer\Util\Svn;
@ -16,7 +17,7 @@ class SvnTest extends \PHPUnit_Framework_TestCase
*/
public function testCredentials($url, $expect)
{
$svn = new Svn($url, new NullIO);
$svn = new Svn($url, new NullIO, new Config());
$reflMethod = new \ReflectionMethod('Composer\\Util\\Svn', 'getCredentialString');
$reflMethod->setAccessible(true);
@ -41,7 +42,7 @@ class SvnTest extends \PHPUnit_Framework_TestCase
{
$url = 'http://svn.example.org';
$svn = new Svn($url, new NullIO());
$svn = new Svn($url, new NullIO(), new Config());
$reflMethod = new \ReflectionMethod('Composer\\Util\\Svn', 'getCommand');
$reflMethod->setAccessible(true);
@ -51,6 +52,26 @@ class SvnTest extends \PHPUnit_Framework_TestCase
);
}
public function testCredentialsFromConfig()
{
$url = 'http://svn.apache.org';
$config = new Config();
$config->merge(array(
'config' => array(
'http-basic' => array(
$url => array('username' => 'foo', 'password' => 'bar')
)
)
));
$svn = new Svn($url, new NullIO, $config);
$reflMethod = new \ReflectionMethod('Composer\\Util\\Svn', 'getCredentialString');
$reflMethod->setAccessible(true);
$this->assertEquals($this->getCmd(" --username 'foo' --password 'bar' "), $reflMethod->invoke($svn));
}
private function getCmd($cmd)
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {