commit
796c4c57d0
11 changed files with 676 additions and 566 deletions
|
@ -3,6 +3,8 @@ dist: trusty
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
|
- language: php
|
||||||
|
php: 7.4
|
||||||
- language: php
|
- language: php
|
||||||
php: 7.3
|
php: 7.3
|
||||||
- language: php
|
- language: php
|
||||||
|
|
|
@ -150,6 +150,8 @@ public static function checkUpdate(
|
||||||
* @param string $minVersion minimum PHP required version
|
* @param string $minVersion minimum PHP required version
|
||||||
* @param string $curVersion current PHP version (use PHP_VERSION)
|
* @param string $curVersion current PHP version (use PHP_VERSION)
|
||||||
*
|
*
|
||||||
|
* @return bool true on success
|
||||||
|
*
|
||||||
* @throws Exception the PHP version is not supported
|
* @throws Exception the PHP version is not supported
|
||||||
*/
|
*/
|
||||||
public static function checkPHPVersion($minVersion, $curVersion)
|
public static function checkPHPVersion($minVersion, $curVersion)
|
||||||
|
@ -163,6 +165,7 @@ public static function checkPHPVersion($minVersion, $curVersion)
|
||||||
);
|
);
|
||||||
throw new Exception(sprintf($msg, $minVersion));
|
throw new Exception(sprintf($msg, $minVersion));
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,6 +15,8 @@ class ApiUtils
|
||||||
* @param string $token JWT token extracted from the headers.
|
* @param string $token JWT token extracted from the headers.
|
||||||
* @param string $secret API secret set in the settings.
|
* @param string $secret API secret set in the settings.
|
||||||
*
|
*
|
||||||
|
* @return bool true on success
|
||||||
|
*
|
||||||
* @throws ApiAuthorizationException the token is not valid.
|
* @throws ApiAuthorizationException the token is not valid.
|
||||||
*/
|
*/
|
||||||
public static function validateJwtToken($token, $secret)
|
public static function validateJwtToken($token, $secret)
|
||||||
|
@ -45,6 +47,8 @@ public static function validateJwtToken($token, $secret)
|
||||||
) {
|
) {
|
||||||
throw new ApiAuthorizationException('Invalid JWT issued time');
|
throw new ApiAuthorizationException('Invalid JWT issued time');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,15 +21,15 @@
|
||||||
"shaarli/netscape-bookmark-parser": "^2.1",
|
"shaarli/netscape-bookmark-parser": "^2.1",
|
||||||
"erusev/parsedown": "^1.6",
|
"erusev/parsedown": "^1.6",
|
||||||
"slim/slim": "^3.0",
|
"slim/slim": "^3.0",
|
||||||
"arthurhoaro/web-thumbnailer": "^1.1",
|
"arthurhoaro/web-thumbnailer": "^2.0",
|
||||||
"pubsubhubbub/publisher": "dev-master",
|
"pubsubhubbub/publisher": "dev-master",
|
||||||
"gettext/gettext": "^4.4"
|
"gettext/gettext": "^4.4"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"roave/security-advisories": "dev-master",
|
"roave/security-advisories": "dev-master",
|
||||||
"phpunit/phpcov": "*",
|
"phpunit/phpcov": "*",
|
||||||
"phpunit/phpunit": "^5.0",
|
"phpunit/phpunit": "^7.5",
|
||||||
"squizlabs/php_codesniffer": "2.*"
|
"squizlabs/php_codesniffer": "3.*"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-curl": "Allows fetching web pages and thumbnails in a more robust way",
|
"ext-curl": "Allows fetching web pages and thumbnails in a more robust way",
|
||||||
|
|
1201
composer.lock
generated
1201
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -253,9 +253,9 @@ public function testCheckUpdateNewVersionTwiceOutdated()
|
||||||
public function testCheckSupportedPHPVersion()
|
public function testCheckSupportedPHPVersion()
|
||||||
{
|
{
|
||||||
$minVersion = '5.3';
|
$minVersion = '5.3';
|
||||||
ApplicationUtils::checkPHPVersion($minVersion, '5.4.32');
|
$this->assertTrue(ApplicationUtils::checkPHPVersion($minVersion, '5.4.32'));
|
||||||
ApplicationUtils::checkPHPVersion($minVersion, '5.5');
|
$this->assertTrue(ApplicationUtils::checkPHPVersion($minVersion, '5.5'));
|
||||||
ApplicationUtils::checkPHPVersion($minVersion, '5.6.10');
|
$this->assertTrue(ApplicationUtils::checkPHPVersion($minVersion, '5.6.10'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -265,7 +265,7 @@ public function testCheckSupportedPHPVersion()
|
||||||
*/
|
*/
|
||||||
public function testCheckSupportedPHPVersion51()
|
public function testCheckSupportedPHPVersion51()
|
||||||
{
|
{
|
||||||
ApplicationUtils::checkPHPVersion('5.3', '5.1.0');
|
$this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.1.0'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -275,7 +275,7 @@ public function testCheckSupportedPHPVersion51()
|
||||||
*/
|
*/
|
||||||
public function testCheckSupportedPHPVersion52()
|
public function testCheckSupportedPHPVersion52()
|
||||||
{
|
{
|
||||||
ApplicationUtils::checkPHPVersion('5.3', '5.2');
|
$this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.2'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -58,13 +58,12 @@ public function testPlugin()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test missing plugin loading.
|
* Test missing plugin loading.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function testPluginNotFound()
|
public function testPluginNotFound()
|
||||||
{
|
{
|
||||||
$this->pluginManager->load(array());
|
$this->pluginManager->load(array());
|
||||||
$this->pluginManager->load(array('nope', 'renope'));
|
$this->pluginManager->load(array('nope', 'renope'));
|
||||||
|
$this->addToAssertionCount(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -60,7 +60,7 @@ public static function generateCustomJwtToken($header, $payload, $secret)
|
||||||
public function testValidateJwtTokenValid()
|
public function testValidateJwtTokenValid()
|
||||||
{
|
{
|
||||||
$secret = 'WarIsPeace';
|
$secret = 'WarIsPeace';
|
||||||
ApiUtils::validateJwtToken(self::generateValidJwtToken($secret), $secret);
|
$this->assertTrue(ApiUtils::validateJwtToken(self::generateValidJwtToken($secret), $secret));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ConfigPhpTest
|
* Class ConfigPhpTest
|
||||||
|
*
|
||||||
|
* We run tests in separate processes due to the usage for $GLOBALS
|
||||||
|
* which are kept between tests.
|
||||||
|
* @runTestsInSeparateProcesses
|
||||||
*/
|
*/
|
||||||
class ConfigPhpTest extends \PHPUnit\Framework\TestCase
|
class ConfigPhpTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,6 +44,7 @@ public function testConstruct()
|
||||||
new CachedPage(self::$testCacheDir, '', false);
|
new CachedPage(self::$testCacheDir, '', false);
|
||||||
new CachedPage(self::$testCacheDir, 'http://shaar.li/?do=rss', true);
|
new CachedPage(self::$testCacheDir, 'http://shaar.li/?do=rss', true);
|
||||||
new CachedPage(self::$testCacheDir, 'http://shaar.li/?do=atom', false);
|
new CachedPage(self::$testCacheDir, 'http://shaar.li/?do=atom', false);
|
||||||
|
$this->addToAssertionCount(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -724,6 +724,9 @@ public function testUpdateMethodWebThumbnailerEnabled()
|
||||||
*/
|
*/
|
||||||
public function testUpdateMethodWebThumbnailerDisabled()
|
public function testUpdateMethodWebThumbnailerDisabled()
|
||||||
{
|
{
|
||||||
|
if (isset($_SESSION['warnings'])) {
|
||||||
|
unset($_SESSION['warnings']);
|
||||||
|
}
|
||||||
$this->conf->remove('thumbnails');
|
$this->conf->remove('thumbnails');
|
||||||
$this->conf->set('thumbnail.enable_thumbnails', false);
|
$this->conf->set('thumbnail.enable_thumbnails', false);
|
||||||
$updater = new Updater([], [], $this->conf, true, $_SESSION);
|
$updater = new Updater([], [], $this->conf, true, $_SESSION);
|
||||||
|
@ -740,6 +743,9 @@ public function testUpdateMethodWebThumbnailerDisabled()
|
||||||
*/
|
*/
|
||||||
public function testUpdateMethodWebThumbnailerNothingToDo()
|
public function testUpdateMethodWebThumbnailerNothingToDo()
|
||||||
{
|
{
|
||||||
|
if (isset($_SESSION['warnings'])) {
|
||||||
|
unset($_SESSION['warnings']);
|
||||||
|
}
|
||||||
$updater = new Updater([], [], $this->conf, true, $_SESSION);
|
$updater = new Updater([], [], $this->conf, true, $_SESSION);
|
||||||
$this->assertTrue($updater->updateMethodWebThumbnailer());
|
$this->assertTrue($updater->updateMethodWebThumbnailer());
|
||||||
$this->assertFalse($this->conf->exists('thumbnail'));
|
$this->assertFalse($this->conf->exists('thumbnail'));
|
||||||
|
|
Loading…
Reference in a new issue