Display warning in security & setup warnings if php version is EOL
This commit is contained in:
parent
e77b2e5317
commit
72ba67815e
|
@ -72,6 +72,11 @@
|
||||||
if(data.isUsedTlsLibOutdated) {
|
if(data.isUsedTlsLibOutdated) {
|
||||||
messages.push(data.isUsedTlsLibOutdated);
|
messages.push(data.isUsedTlsLibOutdated);
|
||||||
}
|
}
|
||||||
|
if(data.phpSupported && data.phpSupported.eol) {
|
||||||
|
messages.push(
|
||||||
|
t('core', 'Your PHP version ({version}) is no longer <a href="{phpLink}">supported by PHP</a>. We encourage you to upgrade your PHP version to take advantage of performance and security updates provided by PHP.', {version: data.phpSupported.version, phpLink: 'https://secure.php.net/supported-versions.php'})
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
messages.push(t('core', 'Error occurred while checking server setup'));
|
messages.push(t('core', 'Error occurred while checking server setup'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,6 +142,23 @@ describe('OC.SetupChecks tests', function() {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return an error if the php version is no longer supported', function(done) {
|
||||||
|
var async = OC.SetupChecks.checkSetup();
|
||||||
|
|
||||||
|
suite.server.requests[0].respond(
|
||||||
|
200,
|
||||||
|
{
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
JSON.stringify({isUrandomAvailable: true, securityDocs: 'https://docs.owncloud.org/myDocs.html', serverHasInternetConnection: true, dataDirectoryProtected: true, isMemcacheConfigured: true, phpSupported: {eol: true, version: '5.4.0'}})
|
||||||
|
);
|
||||||
|
|
||||||
|
async.done(function( data, s, x ){
|
||||||
|
expect(data).toEqual(['Your PHP version (5.4.0) is no longer <a href="https://secure.php.net/supported-versions.php">supported by PHP</a>. We encourage you to upgrade your PHP version to take advantage of performance and security updates provided by PHP.']);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('checkGeneric', function() {
|
describe('checkGeneric', function() {
|
||||||
|
|
|
@ -175,6 +175,23 @@ class CheckSetupController extends Controller {
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Whether the php version is still supported (at time of release)
|
||||||
|
* according to: https://secure.php.net/supported-versions.php
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function isPhpSupported() {
|
||||||
|
$eol = false;
|
||||||
|
|
||||||
|
//PHP 5.4 is EOL on 14 Sep 2015
|
||||||
|
if (version_compare(PHP_VERSION, '5.5.0') === -1) {
|
||||||
|
$eol = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['eol' => $eol, 'version' => PHP_VERSION];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return DataResponse
|
* @return DataResponse
|
||||||
|
@ -189,6 +206,7 @@ class CheckSetupController extends Controller {
|
||||||
'isUrandomAvailable' => $this->isUrandomAvailable(),
|
'isUrandomAvailable' => $this->isUrandomAvailable(),
|
||||||
'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'),
|
'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'),
|
||||||
'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(),
|
'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(),
|
||||||
|
'phpSupported' => $this->isPhpSupported(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,12 +30,25 @@ use OCP\IURLGenerator;
|
||||||
use OC_Util;
|
use OC_Util;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mock version_compare
|
||||||
|
* @param string $version1
|
||||||
|
* @param string $version2
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
function version_compare($version1, $version2) {
|
||||||
|
return CheckSetupControllerTest::$version_compare;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CheckSetupControllerTest
|
* Class CheckSetupControllerTest
|
||||||
*
|
*
|
||||||
* @package OC\Settings\Controller
|
* @package OC\Settings\Controller
|
||||||
*/
|
*/
|
||||||
class CheckSetupControllerTest extends TestCase {
|
class CheckSetupControllerTest extends TestCase {
|
||||||
|
/** @var int */
|
||||||
|
public static $version_compare;
|
||||||
|
|
||||||
/** @var CheckSetupController */
|
/** @var CheckSetupController */
|
||||||
private $checkSetupController;
|
private $checkSetupController;
|
||||||
/** @var IRequest */
|
/** @var IRequest */
|
||||||
|
@ -209,6 +222,33 @@ class CheckSetupControllerTest extends TestCase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testIsPhpSupportedFalse() {
|
||||||
|
self::$version_compare = -1;
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
['eol' => true, 'version' => PHP_VERSION],
|
||||||
|
self::invokePrivate($this->checkSetupController, 'isPhpSupported')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testIsPhpSupportedTrue() {
|
||||||
|
self::$version_compare = 0;
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
['eol' => false, 'version' => PHP_VERSION],
|
||||||
|
self::invokePrivate($this->checkSetupController, 'isPhpSupported')
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
self::$version_compare = 1;
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
['eol' => false, 'version' => PHP_VERSION],
|
||||||
|
self::invokePrivate($this->checkSetupController, 'isPhpSupported')
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function testCheck() {
|
public function testCheck() {
|
||||||
$this->config->expects($this->at(0))
|
$this->config->expects($this->at(0))
|
||||||
->method('getSystemValue')
|
->method('getSystemValue')
|
||||||
|
@ -244,6 +284,7 @@ class CheckSetupControllerTest extends TestCase {
|
||||||
->method('linkToDocs')
|
->method('linkToDocs')
|
||||||
->with('admin-security')
|
->with('admin-security')
|
||||||
->willReturn('https://doc.owncloud.org/server/8.1/admin_manual/configuration_server/hardening.html');
|
->willReturn('https://doc.owncloud.org/server/8.1/admin_manual/configuration_server/hardening.html');
|
||||||
|
self::$version_compare = -1;
|
||||||
|
|
||||||
$expected = new DataResponse(
|
$expected = new DataResponse(
|
||||||
[
|
[
|
||||||
|
@ -254,6 +295,10 @@ class CheckSetupControllerTest extends TestCase {
|
||||||
'isUrandomAvailable' => self::invokePrivate($this->checkSetupController, 'isUrandomAvailable'),
|
'isUrandomAvailable' => self::invokePrivate($this->checkSetupController, 'isUrandomAvailable'),
|
||||||
'securityDocs' => 'https://doc.owncloud.org/server/8.1/admin_manual/configuration_server/hardening.html',
|
'securityDocs' => 'https://doc.owncloud.org/server/8.1/admin_manual/configuration_server/hardening.html',
|
||||||
'isUsedTlsLibOutdated' => '',
|
'isUsedTlsLibOutdated' => '',
|
||||||
|
'phpSupported' => [
|
||||||
|
'eol' => true,
|
||||||
|
'version' => PHP_VERSION
|
||||||
|
]
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertEquals($expected, $this->checkSetupController->check());
|
$this->assertEquals($expected, $this->checkSetupController->check());
|
||||||
|
|
Loading…
Reference in New Issue