VcsDrivers now send proper originUrl for authentication
parent
c754f96677
commit
7bfe031768
|
@ -35,6 +35,7 @@ class GitBitbucketDriver extends VcsDriver implements VcsDriverInterface
|
||||||
preg_match('#^https://bitbucket\.org/([^/]+)/(.+?)\.git$#', $this->url, $match);
|
preg_match('#^https://bitbucket\.org/([^/]+)/(.+?)\.git$#', $this->url, $match);
|
||||||
$this->owner = $match[1];
|
$this->owner = $match[1];
|
||||||
$this->repository = $match[2];
|
$this->repository = $match[2];
|
||||||
|
$this->originUrl = 'bitbucket.org';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -46,6 +46,7 @@ class GitHubDriver extends VcsDriver
|
||||||
preg_match('#^(?:https?|git)://github\.com/([^/]+)/(.+?)(?:\.git)?$#', $this->url, $match);
|
preg_match('#^(?:https?|git)://github\.com/([^/]+)/(.+?)(?:\.git)?$#', $this->url, $match);
|
||||||
$this->owner = $match[1];
|
$this->owner = $match[1];
|
||||||
$this->repository = $match[2];
|
$this->repository = $match[2];
|
||||||
|
$this->originUrl = 'github.com';
|
||||||
|
|
||||||
$this->fetchRootIdentifier();
|
$this->fetchRootIdentifier();
|
||||||
}
|
}
|
||||||
|
@ -245,7 +246,7 @@ class GitHubDriver extends VcsDriver
|
||||||
$this->io->write('Authentication required (<info>'.$this->url.'</info>):');
|
$this->io->write('Authentication required (<info>'.$this->url.'</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->url, $username, $password);
|
$this->io->setAuthorization($this->originUrl, $username, $password);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -35,6 +35,7 @@ class HgBitbucketDriver extends VcsDriver
|
||||||
preg_match('#^https://bitbucket\.org/([^/]+)/([^/]+)/?$#', $this->url, $match);
|
preg_match('#^https://bitbucket\.org/([^/]+)/([^/]+)/?$#', $this->url, $match);
|
||||||
$this->owner = $match[1];
|
$this->owner = $match[1];
|
||||||
$this->repository = $match[2];
|
$this->repository = $match[2];
|
||||||
|
$this->originUrl = 'bitbucket.org';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -26,6 +26,7 @@ use Composer\Util\RemoteFilesystem;
|
||||||
abstract class VcsDriver implements VcsDriverInterface
|
abstract class VcsDriver implements VcsDriverInterface
|
||||||
{
|
{
|
||||||
protected $url;
|
protected $url;
|
||||||
|
protected $originUrl;
|
||||||
protected $io;
|
protected $io;
|
||||||
protected $config;
|
protected $config;
|
||||||
protected $process;
|
protected $process;
|
||||||
|
@ -43,6 +44,7 @@ abstract class VcsDriver implements VcsDriverInterface
|
||||||
final public function __construct($url, IOInterface $io, Config $config, ProcessExecutor $process = null, $remoteFilesystem = null)
|
final public function __construct($url, IOInterface $io, Config $config, ProcessExecutor $process = null, $remoteFilesystem = null)
|
||||||
{
|
{
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
|
$this->originUrl = $url;
|
||||||
$this->io = $io;
|
$this->io = $io;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->process = $process ?: new ProcessExecutor;
|
$this->process = $process ?: new ProcessExecutor;
|
||||||
|
@ -86,7 +88,7 @@ abstract class VcsDriver implements VcsDriverInterface
|
||||||
*/
|
*/
|
||||||
protected function getContents($url)
|
protected function getContents($url)
|
||||||
{
|
{
|
||||||
return $this->remoteFilesystem->getContents($this->url, $url, false);
|
return $this->remoteFilesystem->getContents($this->originUrl, $url, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function isLocalUrl($url)
|
protected static function isLocalUrl($url)
|
||||||
|
|
|
@ -40,7 +40,7 @@ class GitHubDriverTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$remoteFilesystem->expects($this->at(0))
|
$remoteFilesystem->expects($this->at(0))
|
||||||
->method('getContents')
|
->method('getContents')
|
||||||
->with($this->equalTo($repoUrl), $this->equalTo($repoApiUrl), $this->equalTo(false))
|
->with($this->equalTo('github.com'), $this->equalTo($repoApiUrl), $this->equalTo(false))
|
||||||
->will($this->throwException(new TransportException('HTTP/1.1 404 Not Found', 404)));
|
->will($this->throwException(new TransportException('HTTP/1.1 404 Not Found', 404)));
|
||||||
|
|
||||||
$io->expects($this->once())
|
$io->expects($this->once())
|
||||||
|
@ -55,11 +55,11 @@ class GitHubDriverTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$io->expects($this->once())
|
$io->expects($this->once())
|
||||||
->method('setAuthorization')
|
->method('setAuthorization')
|
||||||
->with($this->equalTo($repoUrl), 'someuser', 'somepassword');
|
->with($this->equalTo('github.com'), 'someuser', 'somepassword');
|
||||||
|
|
||||||
$remoteFilesystem->expects($this->at(1))
|
$remoteFilesystem->expects($this->at(1))
|
||||||
->method('getContents')
|
->method('getContents')
|
||||||
->with($this->equalTo($repoUrl), $this->equalTo($repoApiUrl), $this->equalTo(false))
|
->with($this->equalTo('github.com'), $this->equalTo($repoApiUrl), $this->equalTo(false))
|
||||||
->will($this->returnValue('{"master_branch": "test_master"}'));
|
->will($this->returnValue('{"master_branch": "test_master"}'));
|
||||||
|
|
||||||
$gitHubDriver = new GitHubDriver($repoUrl, $io, new Config(), null, $remoteFilesystem);
|
$gitHubDriver = new GitHubDriver($repoUrl, $io, new Config(), null, $remoteFilesystem);
|
||||||
|
@ -109,7 +109,7 @@ class GitHubDriverTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$remoteFilesystem->expects($this->at(0))
|
$remoteFilesystem->expects($this->at(0))
|
||||||
->method('getContents')
|
->method('getContents')
|
||||||
->with($this->equalTo($repoUrl), $this->equalTo($repoApiUrl), $this->equalTo(false))
|
->with($this->equalTo('github.com'), $this->equalTo($repoApiUrl), $this->equalTo(false))
|
||||||
->will($this->returnValue('{"master_branch": "test_master"}'));
|
->will($this->returnValue('{"master_branch": "test_master"}'));
|
||||||
|
|
||||||
$gitHubDriver = new GitHubDriver($repoUrl, $io, new Config(), null, $remoteFilesystem);
|
$gitHubDriver = new GitHubDriver($repoUrl, $io, new Config(), null, $remoteFilesystem);
|
||||||
|
@ -164,7 +164,7 @@ class GitHubDriverTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$remoteFilesystem->expects($this->at(0))
|
$remoteFilesystem->expects($this->at(0))
|
||||||
->method('getContents')
|
->method('getContents')
|
||||||
->with($this->equalTo($repoUrl), $this->equalTo($repoApiUrl), $this->equalTo(false))
|
->with($this->equalTo('github.com'), $this->equalTo($repoApiUrl), $this->equalTo(false))
|
||||||
->will($this->throwException(new TransportException('HTTP/1.1 404 Not Found', 404)));
|
->will($this->throwException(new TransportException('HTTP/1.1 404 Not Found', 404)));
|
||||||
|
|
||||||
// clean local clone if present
|
// clean local clone if present
|
||||||
|
|
Loading…
Reference in New Issue