diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index b4deda07a..35f6aa754 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -52,11 +52,11 @@ class GitDownloader extends VcsDownloader $this->io->write(" Checking out ".$ref); $command = 'cd %s && git remote set-url composer %s && git fetch composer && git fetch --tags composer'; - if (!$this->io->hasAuthorization('github.com')) { + if (!$this->io->hasAuthentication('github.com')) { // capture username/password from github URL if there is one $this->process->execute(sprintf('cd %s && git remote -v', escapeshellarg($path)), $output); if (preg_match('{^composer\s+https://(.+):(.+)@github.com/}im', $output, $match)) { - $this->io->setAuthorization('github.com', $match[1], $match[2]); + $this->io->setAuthentication('github.com', $match[1], $match[2]); } } @@ -287,7 +287,7 @@ class GitDownloader extends VcsDownloader if (0 !== $this->process->execute($command, $handler)) { // private github repository without git access, try https with auth if (preg_match('{^git@(github.com):(.+?)\.git$}i', $url, $match)) { - if (!$this->io->hasAuthorization($match[1])) { + if (!$this->io->hasAuthentication($match[1])) { $gitHubUtil = new GitHub($this->io, $this->config, $this->process); $message = 'Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos'; @@ -296,8 +296,8 @@ class GitDownloader extends VcsDownloader } } - if ($this->io->hasAuthorization($match[1])) { - $auth = $this->io->getAuthorization($match[1]); + if ($this->io->hasAuthentication($match[1])) { + $auth = $this->io->getAuthentication($match[1]); $url = 'https://'.$auth['username'] . ':' . $auth['password'] . '@'.$match[1].'/'.$match[2].'.git'; $command = call_user_func($commandCallable, $url); diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index 6495583c7..96d30aee8 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -152,7 +152,7 @@ class Factory // reload oauth token from config if available if ($tokens = $config->get('github-oauth')) { foreach ($tokens as $domain => $token) { - $io->setAuthorization($domain, $token, 'x-oauth-basic'); + $io->setAuthentication($domain, $token, 'x-oauth-basic'); } } diff --git a/src/Composer/IO/ConsoleIO.php b/src/Composer/IO/ConsoleIO.php index 4a31e15c6..c2dcc86ab 100644 --- a/src/Composer/IO/ConsoleIO.php +++ b/src/Composer/IO/ConsoleIO.php @@ -27,7 +27,7 @@ class ConsoleIO implements IOInterface protected $input; protected $output; protected $helperSet; - protected $authorizations = array(); + protected $authentications = array(); protected $lastMessage; /** @@ -189,17 +189,17 @@ class ConsoleIO implements IOInterface /** * {@inheritDoc} */ - public function getAuthorizations() + public function getAuthentications() { - return $this->authorizations; + return $this->authentications; } /** * {@inheritDoc} */ - public function hasAuthorization($repositoryName) + public function hasAuthentication($repositoryName) { - $auths = $this->getAuthorizations(); + $auths = $this->getAuthentications(); return isset($auths[$repositoryName]); } @@ -207,9 +207,9 @@ class ConsoleIO implements IOInterface /** * {@inheritDoc} */ - public function getAuthorization($repositoryName) + public function getAuthentication($repositoryName) { - $auths = $this->getAuthorizations(); + $auths = $this->getAuthentications(); return isset($auths[$repositoryName]) ? $auths[$repositoryName] : array('username' => null, 'password' => null); } @@ -217,8 +217,8 @@ class ConsoleIO implements IOInterface /** * {@inheritDoc} */ - public function setAuthorization($repositoryName, $username, $password = null) + public function setAuthentication($repositoryName, $username, $password = null) { - $this->authorizations[$repositoryName] = array('username' => $username, 'password' => $password); + $this->authentications[$repositoryName] = array('username' => $username, 'password' => $password); } } diff --git a/src/Composer/IO/IOInterface.php b/src/Composer/IO/IOInterface.php index 539688530..1cb896c5f 100644 --- a/src/Composer/IO/IOInterface.php +++ b/src/Composer/IO/IOInterface.php @@ -109,20 +109,20 @@ interface IOInterface public function askAndHideAnswer($question); /** - * Get all authorization informations entered. + * Get all authentication information entered. * - * @return array The map of authorization + * @return array The map of authentication data */ - public function getAuthorizations(); + public function getAuthentications(); /** - * Verify if the repository has a authorization informations. + * Verify if the repository has a authentication information. * * @param string $repositoryName The unique name of repository * * @return boolean */ - public function hasAuthorization($repositoryName); + public function hasAuthentication($repositoryName); /** * Get the username and password of repository. @@ -131,14 +131,14 @@ interface IOInterface * * @return array The 'username' and 'password' */ - public function getAuthorization($repositoryName); + public function getAuthentication($repositoryName); /** - * Set the authorization informations for the repository. + * Set the authentication information for the repository. * * @param string $repositoryName The unique name of repository * @param string $username The username * @param string $password The password */ - public function setAuthorization($repositoryName, $username, $password = null); + public function setAuthentication($repositoryName, $username, $password = null); } diff --git a/src/Composer/IO/NullIO.php b/src/Composer/IO/NullIO.php index b5ee190b3..670edd4b5 100644 --- a/src/Composer/IO/NullIO.php +++ b/src/Composer/IO/NullIO.php @@ -92,7 +92,7 @@ class NullIO implements IOInterface /** * {@inheritDoc} */ - public function getAuthorizations() + public function getAuthentications() { return array(); } @@ -100,7 +100,7 @@ class NullIO implements IOInterface /** * {@inheritDoc} */ - public function hasAuthorization($repositoryName) + public function hasAuthentication($repositoryName) { return false; } @@ -108,7 +108,7 @@ class NullIO implements IOInterface /** * {@inheritDoc} */ - public function getAuthorization($repositoryName) + public function getAuthentication($repositoryName) { return array('username' => null, 'password' => null); } @@ -116,7 +116,7 @@ class NullIO implements IOInterface /** * {@inheritDoc} */ - public function setAuthorization($repositoryName, $username, $password = null) + public function setAuthentication($repositoryName, $username, $password = null) { } } diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php index da840673c..1546b7852 100755 --- a/src/Composer/Repository/Vcs/GitHubDriver.php +++ b/src/Composer/Repository/Vcs/GitHubDriver.php @@ -267,7 +267,7 @@ class GitHubDriver extends VcsDriver return parent::getContents($url); case 403: - if (!$this->io->hasAuthorization($this->originUrl) && $gitHubUtil->authorizeOAuth($this->originUrl)) { + if (!$this->io->hasAuthentication($this->originUrl) && $gitHubUtil->authorizeOAuth($this->originUrl)) { return parent::getContents($url); } @@ -282,7 +282,7 @@ class GitHubDriver extends VcsDriver } } - if (!$this->io->hasAuthorization($this->originUrl)) { + if (!$this->io->hasAuthentication($this->originUrl)) { if (!$this->io->isInteractive()) { $this->io->write('GitHub API limit exhausted. Failed to get metadata for the '.$this->url.' repository, try running in interactive mode so that you can enter your GitHub credentials to increase the API limit'); throw $e; diff --git a/src/Composer/Repository/Vcs/VcsDriver.php b/src/Composer/Repository/Vcs/VcsDriver.php index 16af91946..777a11ea0 100644 --- a/src/Composer/Repository/Vcs/VcsDriver.php +++ b/src/Composer/Repository/Vcs/VcsDriver.php @@ -19,7 +19,7 @@ use Composer\Util\ProcessExecutor; use Composer\Util\RemoteFilesystem; /** - * A driver implementation for driver with authorization interaction. + * A driver implementation for driver with authentication interaction. * * @author François Pluchino */ diff --git a/src/Composer/Util/GitHub.php b/src/Composer/Util/GitHub.php index e4010e4e7..573ecf516 100644 --- a/src/Composer/Util/GitHub.php +++ b/src/Composer/Util/GitHub.php @@ -57,7 +57,7 @@ class GitHub // if available use token from git config if (0 === $this->process->execute('git config github.accesstoken', $output)) { - $this->io->setAuthorization($originUrl, trim($output), 'x-oauth-basic'); + $this->io->setAuthentication($originUrl, trim($output), 'x-oauth-basic'); return true; } @@ -85,7 +85,7 @@ class GitHub try { $username = $this->io->ask('Username: '); $password = $this->io->askAndHideAnswer('Password: '); - $this->io->setAuthorization($originUrl, $username, $password); + $this->io->setAuthentication($originUrl, $username, $password); // build up OAuth app name $appName = 'Composer'; @@ -114,7 +114,7 @@ class GitHub throw $e; } - $this->io->setAuthorization($originUrl, $contents['token'], 'x-oauth-basic'); + $this->io->setAuthentication($originUrl, $contents['token'], 'x-oauth-basic'); // store value in user config $githubTokens = $this->config->get('github-oauth') ?: array(); diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index 8f64b4407..aa1961c5a 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -221,7 +221,7 @@ class RemoteFilesystem $this->io->overwrite(' Authentication required ('.parse_url($this->fileUrl, PHP_URL_HOST).'):'); $username = $this->io->ask(' Username: '); $password = $this->io->askAndHideAnswer(' Password: '); - $this->io->setAuthorization($this->originUrl, $username, $password); + $this->io->setAuthentication($this->originUrl, $username, $password); $this->get($this->originUrl, $this->fileUrl, $this->fileName, $this->progress); } @@ -277,8 +277,8 @@ class RemoteFilesystem $headers[] = 'Accept-Encoding: gzip'; } - if ($this->io->hasAuthorization($originUrl)) { - $auth = $this->io->getAuthorization($originUrl); + if ($this->io->hasAuthentication($originUrl)) { + $auth = $this->io->getAuthentication($originUrl); $authStr = base64_encode($auth['username'] . ':' . $auth['password']); $headers[] = 'Authorization: Basic '.$authStr; } diff --git a/tests/Composer/Test/IO/ConsoleIOTest.php b/tests/Composer/Test/IO/ConsoleIOTest.php index f3ea6b15d..0d76758d4 100644 --- a/tests/Composer/Test/IO/ConsoleIOTest.php +++ b/tests/Composer/Test/IO/ConsoleIOTest.php @@ -149,22 +149,22 @@ class ConsoleIOTest extends TestCase $consoleIO->askAndValidate('Why?', 'validator', 10, 'default'); } - public function testSetAndGetAuthorization() + public function testSetAndgetAuthentication() { $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); - $consoleIO->setAuthorization('repoName', 'l3l0', 'passwd'); + $consoleIO->setAuthentication('repoName', 'l3l0', 'passwd'); $this->assertEquals( array('username' => 'l3l0', 'password' => 'passwd'), - $consoleIO->getAuthorization('repoName') + $consoleIO->getAuthentication('repoName') ); } - public function testGetAuthorizationWhenDidNotSet() + public function testgetAuthenticationWhenDidNotSet() { $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); @@ -174,20 +174,20 @@ class ConsoleIOTest extends TestCase $this->assertEquals( array('username' => null, 'password' => null), - $consoleIO->getAuthorization('repoName') + $consoleIO->getAuthentication('repoName') ); } - public function testHasAuthorization() + public function testhasAuthentication() { $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); - $consoleIO->setAuthorization('repoName', 'l3l0', 'passwd'); + $consoleIO->setAuthentication('repoName', 'l3l0', 'passwd'); - $this->assertTrue($consoleIO->hasAuthorization('repoName')); - $this->assertFalse($consoleIO->hasAuthorization('repoName2')); + $this->assertTrue($consoleIO->hasAuthentication('repoName')); + $this->assertFalse($consoleIO->hasAuthentication('repoName2')); } } diff --git a/tests/Composer/Test/IO/NullIOTest.php b/tests/Composer/Test/IO/NullIOTest.php index 07577d5a1..cb2023d49 100644 --- a/tests/Composer/Test/IO/NullIOTest.php +++ b/tests/Composer/Test/IO/NullIOTest.php @@ -24,11 +24,11 @@ class NullIOTest extends TestCase $this->assertFalse($io->isInteractive()); } - public function testHasAuthorization() + public function testhasAuthentication() { $io = new NullIO(); - $this->assertFalse($io->hasAuthorization('foo')); + $this->assertFalse($io->hasAuthentication('foo')); } public function testAskAndHideAnswer() @@ -38,13 +38,13 @@ class NullIOTest extends TestCase $this->assertNull($io->askAndHideAnswer('foo')); } - public function testGetAuthorizations() + public function testgetAuthentications() { $io = new NullIO(); - $this->assertInternalType('array', $io->getAuthorizations()); - $this->assertEmpty($io->getAuthorizations()); - $this->assertEquals(array('username' => null, 'password' => null), $io->getAuthorization('foo')); + $this->assertInternalType('array', $io->getAuthentications()); + $this->assertEmpty($io->getAuthentications()); + $this->assertEquals(array('username' => null, 'password' => null), $io->getAuthentication('foo')); } public function testAsk() diff --git a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php index 1598a1826..3ea549556 100644 --- a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php @@ -69,7 +69,7 @@ class GitHubDriverTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue('somepassword')); $io->expects($this->any()) - ->method('setAuthorization') + ->method('setAuthentication') ->with($this->equalTo('github.com'), $this->matchesRegularExpression('{someuser|abcdef}'), $this->matchesRegularExpression('{somepassword|x-oauth-basic}')); $remoteFilesystem->expects($this->at(1)) diff --git a/tests/Composer/Test/Util/RemoteFilesystemTest.php b/tests/Composer/Test/Util/RemoteFilesystemTest.php index 90362c8f4..f9c1d398b 100644 --- a/tests/Composer/Test/Util/RemoteFilesystemTest.php +++ b/tests/Composer/Test/Util/RemoteFilesystemTest.php @@ -21,7 +21,7 @@ class RemoteFilesystemTest extends \PHPUnit_Framework_TestCase $io = $this->getMock('Composer\IO\IOInterface'); $io ->expects($this->once()) - ->method('hasAuthorization') + ->method('hasAuthentication') ->will($this->returnValue(false)) ; @@ -42,12 +42,12 @@ class RemoteFilesystemTest extends \PHPUnit_Framework_TestCase $io = $this->getMock('Composer\IO\IOInterface'); $io ->expects($this->once()) - ->method('hasAuthorization') + ->method('hasAuthentication') ->will($this->returnValue(true)) ; $io ->expects($this->once()) - ->method('getAuthorization') + ->method('getAuthentication') ->will($this->returnValue(array('username' => 'login', 'password' => 'password'))) ; @@ -67,7 +67,7 @@ class RemoteFilesystemTest extends \PHPUnit_Framework_TestCase $io = $this->getMock('Composer\IO\IOInterface'); $io ->expects($this->once()) - ->method('hasAuthorization') + ->method('hasAuthentication') ->will($this->returnValue(true)) ; @@ -84,7 +84,7 @@ class RemoteFilesystemTest extends \PHPUnit_Framework_TestCase $io = $this->getMock('Composer\IO\IOInterface'); $io ->expects($this->once()) - ->method('hasAuthorization') + ->method('hasAuthentication') ->will($this->returnValue(true)) ;