Skip to content

Commit

Permalink
Merge pull request #991 from phpbrew/feature/https
Browse files Browse the repository at this point in the history
move to https
close #953
  • Loading branch information
jhdxr committed Dec 24, 2018
2 parents 0140224 + af58d8d commit ceb31b5
Show file tree
Hide file tree
Showing 8 changed files with 1,424 additions and 637 deletions.
3 changes: 2 additions & 1 deletion src/PhpBrew/Command/DownloadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ public function execute($version)
throw new \Exception("Version $version not found.");
}
$version = $versionInfo['version'];
$distUrl = 'http://www.php.net/get/'.$versionInfo['filename'].'/from/this/mirror';
$distUrl = 'https://secure.php.net/get/'.$versionInfo['filename'].'/from/this/mirror';
if ($mirrorSite = $this->options->mirror) {
//fixme mirror sites usually doesn't support https, maybe need a warning here
// http://tw1.php.net/distributions/php-5.3.29.tar.bz2
$distUrl = $mirrorSite.'/distributions/'.$versionInfo['filename'];
}
Expand Down
4 changes: 2 additions & 2 deletions src/PhpBrew/Distribution/DistributionUrlPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function buildUrl($version, $filename, $museum = false)
{
//the historic releases only available at museum
if ($museum || $this->isDistributedAtMuseum($version)) {
return 'http://museum.php.net/php5/'.$filename;
return 'https://museum.php.net/php5/'.$filename;
}

if (!is_null($this->mirrorSite)) {
Expand All @@ -29,7 +29,7 @@ public function buildUrl($version, $filename, $museum = false)
}

// http://tw1.php.net/distributions/php-5.3.29.tar.bz2.
return 'http://www.php.net/get/'.$filename.'/from/this/mirror';
return 'https://secure.php.net/get/'.$filename.'/from/this/mirror';
}

private function isDistributedAtMuseum($version)
Expand Down
2 changes: 1 addition & 1 deletion src/PhpBrew/Extension/Provider/PeclProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function isBundled($name)

public function buildKnownReleasesUrl()
{
return sprintf('http://pecl.php.net/rest/r/%s/allreleases.xml', $this->getPackageName());
return sprintf('https://pecl.php.net/rest/r/%s/allreleases.xml', $this->getPackageName());
}

public function parseKnownReleasesResponse($content)
Expand Down
2 changes: 1 addition & 1 deletion src/PhpBrew/ReleaseList.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public static function buildReleaseListFromOfficialSite(OptionResult $options =
list($o, $major, $minor) = $matches;
$release = array('version' => $k);
if (isset($v['announcement']['English'])) {
$release['announcement'] = 'http://php.net'.$v['announcement']['English'];
$release['announcement'] = 'https://php.net'.$v['announcement']['English'];
}

if (isset($v['date'])) {
Expand Down
11 changes: 6 additions & 5 deletions tests/PhpBrew/Distribution/DistributionUrlPolicyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,19 @@ public function testBuildUrlWhenMirrorSiteIsUsed()
$mirror = 'http://ja.php.net';
$this->policy->setMirrorSite($mirror);
$this->assertSame(
//mirrors should remain http since they don't have https support
'http://ja.php.net/distributions/php-5.6.23.tar.bz2',
$this->policy->buildUrl('5.6.23', 'php-5.6.23.tar.bz2')
);
}

public function versionDataProvider() {
return array(
array("5.3.29", "php-5.3.29.tar.bz2", "http://museum.php.net/php5/php-5.3.29.tar.bz2", true),
array("5.4.7", "php-5.4.7.tar.bz2", "http://museum.php.net/php5/php-5.4.7.tar.bz2", true),
array("5.4.21", "php-5.4.21.tar.bz2", "http://museum.php.net/php5/php-5.4.21.tar.bz2", true),
array("5.4.22", "php-5.4.22.tar.bz2", "http://www.php.net/get/php-5.4.22.tar.bz2/from/this/mirror", false),
array("5.6.23", "php-5.6.23.tar.bz2", "http://www.php.net/get/php-5.6.23.tar.bz2/from/this/mirror", false),
array("5.3.29", "php-5.3.29.tar.bz2", "https://museum.php.net/php5/php-5.3.29.tar.bz2", true),
array("5.4.7", "php-5.4.7.tar.bz2", "https://museum.php.net/php5/php-5.4.7.tar.bz2", true),
array("5.4.21", "php-5.4.21.tar.bz2", "https://museum.php.net/php5/php-5.4.21.tar.bz2", true),
array("5.4.22", "php-5.4.22.tar.bz2", "https://secure.php.net/get/php-5.4.22.tar.bz2/from/this/mirror", false),
array("5.6.23", "php-5.6.23.tar.bz2", "https://secure.php.net/get/php-5.6.23.tar.bz2/from/this/mirror", false),
);
}
}
27 changes: 14 additions & 13 deletions tests/PhpBrew/ReleaseListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,32 @@ class ReleaseListTest extends \PHPUnit\Framework\TestCase
public function setUp()
{
$this->releaseList = new ReleaseList;
$this->releaseList->loadJsonFile('tests/fixtures/php-releases.json');
$this->releaseList->loadJsonFile(__DIR__.'/../fixtures/php-releases.json');
}

public function testGetVersions()
{
$versions = $this->releaseList->getVersions("5.3");
$versions = $this->releaseList->getVersions("7.2");
$this->assertSame(
$versions['5.3.0'],
$versions['7.2.0'],
array(
'version' => "5.3.0",
'announcement' => "http://php.net/releases/5_3_0.php",
'date' => "30 June 2009",
'filename' => "php-5.3.0.tar.bz2",
'md5' => "846760cd655c98dfd86d6d97c3d964b0",
'name' => "PHP 5.3.0 (tar.bz2)",
'version' => "7.2.0",
'announcement' => "https://php.net/releases/7_2_0.php",
'date' => "30 Nov 2017",
'filename' => "php-7.2.0.tar.bz2",
'name' => "PHP 7.2.0 (tar.bz2)",
'sha256' => "2bfefae4226b9b97879c9d33078e50bdb5c17f45ff6e255951062a529720c64a",
'museum' => false
)
);
}

public function versionDataProvider() {
return array(
array("5.3", "5.3.29"),
array("5.4", "5.4.35"),
array("5.5", "5.5.19"),
array("5.6", "5.6.3"),
array("7.3", "7.3.0"),
array("7.2", "7.2.13"),
array("5.4", "5.4.45"),
array("5.6", "5.6.39"),
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
require __DIR__ . '/../vendor/autoload.php';

VCR::configure()
->setCassettePath('tests/fixtures/vcr_cassettes')
->setCassettePath(__DIR__.'/fixtures/vcr_cassettes')
->enableLibraryHooks(array('curl'))
->setStorage('json');
Loading

0 comments on commit ceb31b5

Please sign in to comment.