Replace references of a11n with a12n where appropriate

Authorization => Authentication.
main
Igor Wiedler 12 years ago
parent a2c2652695
commit 4959c2bdc6

@ -52,11 +52,11 @@ class GitDownloader extends VcsDownloader
$this->io->write(" Checking out ".$ref); $this->io->write(" Checking out ".$ref);
$command = 'cd %s && git remote set-url composer %s && git fetch composer && git fetch --tags composer'; $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 // capture username/password from github URL if there is one
$this->process->execute(sprintf('cd %s && git remote -v', escapeshellarg($path)), $output); $this->process->execute(sprintf('cd %s && git remote -v', escapeshellarg($path)), $output);
if (preg_match('{^composer\s+https://(.+):(.+)@github.com/}im', $output, $match)) { 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)) { if (0 !== $this->process->execute($command, $handler)) {
// private github repository without git access, try https with auth // private github repository without git access, try https with auth
if (preg_match('{^git@(github.com):(.+?)\.git$}i', $url, $match)) { 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); $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'; $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])) { if ($this->io->hasAuthentication($match[1])) {
$auth = $this->io->getAuthorization($match[1]); $auth = $this->io->getAuthentication($match[1]);
$url = 'https://'.$auth['username'] . ':' . $auth['password'] . '@'.$match[1].'/'.$match[2].'.git'; $url = 'https://'.$auth['username'] . ':' . $auth['password'] . '@'.$match[1].'/'.$match[2].'.git';
$command = call_user_func($commandCallable, $url); $command = call_user_func($commandCallable, $url);

@ -152,7 +152,7 @@ class Factory
// reload oauth token from config if available // reload oauth token from config if available
if ($tokens = $config->get('github-oauth')) { if ($tokens = $config->get('github-oauth')) {
foreach ($tokens as $domain => $token) { foreach ($tokens as $domain => $token) {
$io->setAuthorization($domain, $token, 'x-oauth-basic'); $io->setAuthentication($domain, $token, 'x-oauth-basic');
} }
} }

@ -27,7 +27,7 @@ class ConsoleIO implements IOInterface
protected $input; protected $input;
protected $output; protected $output;
protected $helperSet; protected $helperSet;
protected $authorizations = array(); protected $authentications = array();
protected $lastMessage; protected $lastMessage;
/** /**
@ -189,17 +189,17 @@ class ConsoleIO implements IOInterface
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getAuthorizations() public function getAuthentications()
{ {
return $this->authorizations; return $this->authentications;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function hasAuthorization($repositoryName) public function hasAuthentication($repositoryName)
{ {
$auths = $this->getAuthorizations(); $auths = $this->getAuthentications();
return isset($auths[$repositoryName]); return isset($auths[$repositoryName]);
} }
@ -207,9 +207,9 @@ class ConsoleIO implements IOInterface
/** /**
* {@inheritDoc} * {@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); return isset($auths[$repositoryName]) ? $auths[$repositoryName] : array('username' => null, 'password' => null);
} }
@ -217,8 +217,8 @@ class ConsoleIO implements IOInterface
/** /**
* {@inheritDoc} * {@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);
} }
} }

@ -109,20 +109,20 @@ interface IOInterface
public function askAndHideAnswer($question); 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 * @param string $repositoryName The unique name of repository
* *
* @return boolean * @return boolean
*/ */
public function hasAuthorization($repositoryName); public function hasAuthentication($repositoryName);
/** /**
* Get the username and password of repository. * Get the username and password of repository.
@ -131,14 +131,14 @@ interface IOInterface
* *
* @return array The 'username' and 'password' * @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 $repositoryName The unique name of repository
* @param string $username The username * @param string $username The username
* @param string $password The password * @param string $password The password
*/ */
public function setAuthorization($repositoryName, $username, $password = null); public function setAuthentication($repositoryName, $username, $password = null);
} }

@ -92,7 +92,7 @@ class NullIO implements IOInterface
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getAuthorizations() public function getAuthentications()
{ {
return array(); return array();
} }
@ -100,7 +100,7 @@ class NullIO implements IOInterface
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function hasAuthorization($repositoryName) public function hasAuthentication($repositoryName)
{ {
return false; return false;
} }
@ -108,7 +108,7 @@ class NullIO implements IOInterface
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getAuthorization($repositoryName) public function getAuthentication($repositoryName)
{ {
return array('username' => null, 'password' => null); return array('username' => null, 'password' => null);
} }
@ -116,7 +116,7 @@ class NullIO implements IOInterface
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function setAuthorization($repositoryName, $username, $password = null) public function setAuthentication($repositoryName, $username, $password = null)
{ {
} }
} }

@ -267,7 +267,7 @@ class GitHubDriver extends VcsDriver
return parent::getContents($url); return parent::getContents($url);
case 403: 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); 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()) { if (!$this->io->isInteractive()) {
$this->io->write('<error>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</error>'); $this->io->write('<error>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</error>');
throw $e; throw $e;

@ -19,7 +19,7 @@ use Composer\Util\ProcessExecutor;
use Composer\Util\RemoteFilesystem; use Composer\Util\RemoteFilesystem;
/** /**
* A driver implementation for driver with authorization interaction. * A driver implementation for driver with authentication interaction.
* *
* @author François Pluchino <francois.pluchino@opendisplay.com> * @author François Pluchino <francois.pluchino@opendisplay.com>
*/ */

@ -57,7 +57,7 @@ class GitHub
// if available use token from git config // if available use token from git config
if (0 === $this->process->execute('git config github.accesstoken', $output)) { 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; return true;
} }
@ -85,7 +85,7 @@ class GitHub
try { try {
$username = $this->io->ask('Username: '); $username = $this->io->ask('Username: ');
$password = $this->io->askAndHideAnswer('Password: '); $password = $this->io->askAndHideAnswer('Password: ');
$this->io->setAuthorization($originUrl, $username, $password); $this->io->setAuthentication($originUrl, $username, $password);
// build up OAuth app name // build up OAuth app name
$appName = 'Composer'; $appName = 'Composer';
@ -114,7 +114,7 @@ class GitHub
throw $e; 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 // store value in user config
$githubTokens = $this->config->get('github-oauth') ?: array(); $githubTokens = $this->config->get('github-oauth') ?: array();

@ -221,7 +221,7 @@ class RemoteFilesystem
$this->io->overwrite(' Authentication required (<info>'.parse_url($this->fileUrl, PHP_URL_HOST).'</info>):'); $this->io->overwrite(' Authentication required (<info>'.parse_url($this->fileUrl, PHP_URL_HOST).'</info>):');
$username = $this->io->ask(' Username: '); $username = $this->io->ask(' Username: ');
$password = $this->io->askAndHideAnswer(' Password: '); $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); $this->get($this->originUrl, $this->fileUrl, $this->fileName, $this->progress);
} }
@ -277,8 +277,8 @@ class RemoteFilesystem
$headers[] = 'Accept-Encoding: gzip'; $headers[] = 'Accept-Encoding: gzip';
} }
if ($this->io->hasAuthorization($originUrl)) { if ($this->io->hasAuthentication($originUrl)) {
$auth = $this->io->getAuthorization($originUrl); $auth = $this->io->getAuthentication($originUrl);
$authStr = base64_encode($auth['username'] . ':' . $auth['password']); $authStr = base64_encode($auth['username'] . ':' . $auth['password']);
$headers[] = 'Authorization: Basic '.$authStr; $headers[] = 'Authorization: Basic '.$authStr;
} }

@ -149,22 +149,22 @@ class ConsoleIOTest extends TestCase
$consoleIO->askAndValidate('Why?', 'validator', 10, 'default'); $consoleIO->askAndValidate('Why?', 'validator', 10, 'default');
} }
public function testSetAndGetAuthorization() public function testSetAndgetAuthentication()
{ {
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); $helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet');
$consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
$consoleIO->setAuthorization('repoName', 'l3l0', 'passwd'); $consoleIO->setAuthentication('repoName', 'l3l0', 'passwd');
$this->assertEquals( $this->assertEquals(
array('username' => 'l3l0', 'password' => 'passwd'), 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'); $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
@ -174,20 +174,20 @@ class ConsoleIOTest extends TestCase
$this->assertEquals( $this->assertEquals(
array('username' => null, 'password' => null), 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'); $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); $helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet');
$consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
$consoleIO->setAuthorization('repoName', 'l3l0', 'passwd'); $consoleIO->setAuthentication('repoName', 'l3l0', 'passwd');
$this->assertTrue($consoleIO->hasAuthorization('repoName')); $this->assertTrue($consoleIO->hasAuthentication('repoName'));
$this->assertFalse($consoleIO->hasAuthorization('repoName2')); $this->assertFalse($consoleIO->hasAuthentication('repoName2'));
} }
} }

@ -24,11 +24,11 @@ class NullIOTest extends TestCase
$this->assertFalse($io->isInteractive()); $this->assertFalse($io->isInteractive());
} }
public function testHasAuthorization() public function testhasAuthentication()
{ {
$io = new NullIO(); $io = new NullIO();
$this->assertFalse($io->hasAuthorization('foo')); $this->assertFalse($io->hasAuthentication('foo'));
} }
public function testAskAndHideAnswer() public function testAskAndHideAnswer()
@ -38,13 +38,13 @@ class NullIOTest extends TestCase
$this->assertNull($io->askAndHideAnswer('foo')); $this->assertNull($io->askAndHideAnswer('foo'));
} }
public function testGetAuthorizations() public function testgetAuthentications()
{ {
$io = new NullIO(); $io = new NullIO();
$this->assertInternalType('array', $io->getAuthorizations()); $this->assertInternalType('array', $io->getAuthentications());
$this->assertEmpty($io->getAuthorizations()); $this->assertEmpty($io->getAuthentications());
$this->assertEquals(array('username' => null, 'password' => null), $io->getAuthorization('foo')); $this->assertEquals(array('username' => null, 'password' => null), $io->getAuthentication('foo'));
} }
public function testAsk() public function testAsk()

@ -69,7 +69,7 @@ class GitHubDriverTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue('somepassword')); ->will($this->returnValue('somepassword'));
$io->expects($this->any()) $io->expects($this->any())
->method('setAuthorization') ->method('setAuthentication')
->with($this->equalTo('github.com'), $this->matchesRegularExpression('{someuser|abcdef}'), $this->matchesRegularExpression('{somepassword|x-oauth-basic}')); ->with($this->equalTo('github.com'), $this->matchesRegularExpression('{someuser|abcdef}'), $this->matchesRegularExpression('{somepassword|x-oauth-basic}'));
$remoteFilesystem->expects($this->at(1)) $remoteFilesystem->expects($this->at(1))

@ -21,7 +21,7 @@ class RemoteFilesystemTest extends \PHPUnit_Framework_TestCase
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMock('Composer\IO\IOInterface');
$io $io
->expects($this->once()) ->expects($this->once())
->method('hasAuthorization') ->method('hasAuthentication')
->will($this->returnValue(false)) ->will($this->returnValue(false))
; ;
@ -42,12 +42,12 @@ class RemoteFilesystemTest extends \PHPUnit_Framework_TestCase
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMock('Composer\IO\IOInterface');
$io $io
->expects($this->once()) ->expects($this->once())
->method('hasAuthorization') ->method('hasAuthentication')
->will($this->returnValue(true)) ->will($this->returnValue(true))
; ;
$io $io
->expects($this->once()) ->expects($this->once())
->method('getAuthorization') ->method('getAuthentication')
->will($this->returnValue(array('username' => 'login', 'password' => 'password'))) ->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 = $this->getMock('Composer\IO\IOInterface');
$io $io
->expects($this->once()) ->expects($this->once())
->method('hasAuthorization') ->method('hasAuthentication')
->will($this->returnValue(true)) ->will($this->returnValue(true))
; ;
@ -84,7 +84,7 @@ class RemoteFilesystemTest extends \PHPUnit_Framework_TestCase
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMock('Composer\IO\IOInterface');
$io $io
->expects($this->once()) ->expects($this->once())
->method('hasAuthorization') ->method('hasAuthentication')
->will($this->returnValue(true)) ->will($this->returnValue(true))
; ;

Loading…
Cancel
Save