From 465d1fdd44219eed0c9db5dba4b870394495020b Mon Sep 17 00:00:00 2001 From: Phansys Date: Fri, 14 Jun 2013 18:32:27 -0300 Subject: [PATCH 1/2] Allowed to 5 auth requests before fail (https://github.com/composer/composer/blob/6687743adbac1fe73ca81912a6ef29ceb6e5cc2f/src/Composer/Util/Svn.php#L115). --- src/Composer/Util/Svn.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Composer/Util/Svn.php b/src/Composer/Util/Svn.php index 92694ea78..fcfac6d7e 100644 --- a/src/Composer/Util/Svn.php +++ b/src/Composer/Util/Svn.php @@ -20,6 +20,8 @@ use Composer\IO\IOInterface; */ class Svn { + const MAX_QTY_AUTH_TRIES = 5; + /** * @var array */ @@ -50,6 +52,11 @@ class Svn */ protected $process; + /** + * @var integer + */ + protected $qtyAuthTries = 0; + /** * @param string $url * @param \Composer\IO\IOInterface $io @@ -112,11 +119,8 @@ class Svn ); } - // TODO keep a count of user auth attempts and ask 5 times before - // failing hard (currently it fails hard directly if the URL has credentials) - - // try to authenticate - if (!$this->hasAuth()) { + // try to authenticate if maximum quantity of tries not reached + if ($this->qtyAuthTries++ < self::MAX_QTY_AUTH_TRIES || !$this->hasAuth()) { $this->doAuthDance(); // restart the process From 57dd70a1850d1a1c9491ca3b9d95cbeb80614c69 Mon Sep 17 00:00:00 2001 From: Phansys Date: Fri, 14 Jun 2013 21:16:24 -0300 Subject: [PATCH 2/2] Updated tests for SVN driver. --- tests/Composer/Test/Repository/Vcs/SvnDriverTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php b/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php index 2a4ab00c3..d9bd53321 100644 --- a/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php @@ -23,7 +23,7 @@ class SvnDriverTest extends \PHPUnit_Framework_TestCase public function testWrongCredentialsInUrl() { $console = $this->getMock('Composer\IO\IOInterface'); - $console->expects($this->once()) + $console->expects($this->exactly(6)) ->method('isInteractive') ->will($this->returnValue(true)); @@ -35,7 +35,7 @@ class SvnDriverTest extends \PHPUnit_Framework_TestCase $process->expects($this->at(1)) ->method('execute') ->will($this->returnValue(1)); - $process->expects($this->once()) + $process->expects($this->exactly(7)) ->method('getErrorOutput') ->will($this->returnValue($output)); $process->expects($this->at(2))