Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/updater.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-08-09 12:29:26 +0300
committerGitHub <noreply@github.com>2017-08-09 12:29:26 +0300
commit4372aebd622ba6edbc20ff6eec92d2cb1c97f57c (patch)
tree66e0bea5b1ce4c1bd0fa5c95326700b2798de2b4
parent647c9912715133ded36e9df1482f9580bf5fdfdd (diff)
parent194a67f68f9cd818d275ac7bb2966684613aa8ab (diff)
Merge pull request #130 from nextcloud/stable12-fix-tests
[stable12] ignore custom app folders and fix tests
-rw-r--r--.drone.yml43
-rw-r--r--Makefile3
-rw-r--r--index.php23
-rw-r--r--lib/Updater.php23
-rw-r--r--tests/features/bootstrap/FeatureContext.php70
-rw-r--r--tests/features/cli.feature74
-rw-r--r--tests/features/master.feature2
-rw-r--r--tests/features/stable10.feature2
-rw-r--r--tests/features/stable11.feature27
-rw-r--r--tests/features/stable12.feature40
-rw-r--r--tests/features/stable9.feature2
11 files changed, 245 insertions, 64 deletions
diff --git a/.drone.yml b/.drone.yml
index a207dfa..6a8ba6c 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -23,13 +23,6 @@ pipeline:
when:
matrix:
TESTS: check-same-code-base
- php54-cli:
- image: nextcloudci/php5.4:php5.4-5
- commands:
- - make test-cli
- when:
- matrix:
- TESTS: php54-cli
php55-cli:
image: nextcloudci/php5.5:php5.5-5
commands:
@@ -58,13 +51,6 @@ pipeline:
when:
matrix:
TESTS: php71-cli
- php54-stable9:
- image: nextcloudci/php5.4:php5.4-5
- commands:
- - make test-stable9
- when:
- matrix:
- TESTS: php54-stable9
php55-stable9:
image: nextcloudci/php5.5:php5.5-5
commands:
@@ -128,6 +114,27 @@ pipeline:
when:
matrix:
TESTS: php71-stable11
+ php56-stable12:
+ image: nextcloudci/php5.6:php5.6-7
+ commands:
+ - make test-stable12
+ when:
+ matrix:
+ TESTS: php56-stable12
+ php70-stable12:
+ image: nextcloudci/php7.0:php7.0-6
+ commands:
+ - make test-stable12
+ when:
+ matrix:
+ TESTS: php70-stable12
+ php71-stable12:
+ image: nextcloudci/php7.1:php7.1-9
+ commands:
+ - make test-stable12
+ when:
+ matrix:
+ TESTS: php71-stable12
php56-master:
image: nextcloudci/php5.6:php5.6-7
commands:
@@ -151,12 +158,9 @@ pipeline:
TESTS: php71-master
matrix:
include:
- #- TESTS: php54-cli # TODO currently the php built in server can't be used
- - TESTS: php55-cli
- TESTS: php56-cli
- TESTS: php70-cli
- #- TESTS: php71-cli - not supported on Nextcloud up to 10
- #- TESTS: php54-stable9 # TODO currently the php built in server can't be used
+ - TESTS: php71-cli
- TESTS: php55-stable9
- TESTS: php56-stable9
- TESTS: php70-stable9
@@ -165,6 +169,9 @@ matrix:
- TESTS: php56-stable11
- TESTS: php70-stable11
- TESTS: php71-stable11
+ - TESTS: php56-stable12
+ - TESTS: php70-stable12
+ - TESTS: php71-stable12
- TESTS: php56-master
- TESTS: php70-master
- TESTS: php71-master
diff --git a/Makefile b/Makefile
index c97ebf8..ab770db 100644
--- a/Makefile
+++ b/Makefile
@@ -32,6 +32,9 @@ test-stable10: updater.phar test/vendor
test-stable11: updater.phar test/vendor
cd tests && vendor/behat/behat/bin/behat features/stable11.feature
+test-stable12: updater.phar test/vendor
+ cd tests && vendor/behat/behat/bin/behat features/stable12.feature
+
test-master: updater.phar test/vendor
cd tests && vendor/behat/behat/bin/behat features/master.feature
diff --git a/index.php b/index.php
index 245a583..552e262 100644
--- a/index.php
+++ b/index.php
@@ -289,7 +289,7 @@ class Updater {
* @return array
*/
private function getExpectedElementsList() {
- return [
+ $expected = [
// Generic
'.',
'..',
@@ -327,6 +327,26 @@ class Updater {
'occ',
'db_structure.xml',
];
+ return array_merge($expected, $this->getAppDirectories());
+ }
+
+ /**
+ * Returns app directories specified in config.php
+ *
+ * @return array
+ */
+ private function getAppDirectories() {
+ $expected = [];
+ if($appsPaths = $this->getConfigOption('apps_paths')) {
+ foreach ($appsPaths as $appsPath) {
+ $parentDir = realpath($this->baseDir . '/../');
+ $appDir = basename($appsPath['path']);
+ if(strpos($appsPath['path'], $parentDir) === 0 && $appDir !== 'apps') {
+ $expected[] = $appDir;
+ }
+ }
+ }
+ return $expected;
}
/**
@@ -873,6 +893,7 @@ EOF;
'apps',
'updater',
];
+ $excludedElements = array_merge($excludedElements, $this->getAppDirectories());
/**
* @var string $path
* @var \SplFileInfo $fileInfo
diff --git a/lib/Updater.php b/lib/Updater.php
index 822b760..5d0b480 100644
--- a/lib/Updater.php
+++ b/lib/Updater.php
@@ -174,7 +174,7 @@ class Updater {
* @return array
*/
private function getExpectedElementsList() {
- return [
+ $expected = [
// Generic
'.',
'..',
@@ -212,6 +212,26 @@ class Updater {
'occ',
'db_structure.xml',
];
+ return array_merge($expected, $this->getAppDirectories());
+ }
+
+ /**
+ * Returns app directories specified in config.php
+ *
+ * @return array
+ */
+ private function getAppDirectories() {
+ $expected = [];
+ if($appsPaths = $this->getConfigOption('apps_paths')) {
+ foreach ($appsPaths as $appsPath) {
+ $parentDir = realpath($this->baseDir . '/../');
+ $appDir = basename($appsPath['path']);
+ if(strpos($appsPath['path'], $parentDir) === 0 && $appDir !== 'apps') {
+ $expected[] = $appDir;
+ }
+ }
+ }
+ return $expected;
}
/**
@@ -758,6 +778,7 @@ EOF;
'apps',
'updater',
];
+ $excludedElements = array_merge($excludedElements, $this->getAppDirectories());
/**
* @var string $path
* @var \SplFileInfo $fileInfo
diff --git a/tests/features/bootstrap/FeatureContext.php b/tests/features/bootstrap/FeatureContext.php
index 7d8ef5a..4de6da9 100644
--- a/tests/features/bootstrap/FeatureContext.php
+++ b/tests/features/bootstrap/FeatureContext.php
@@ -212,6 +212,42 @@ S6riPZk2uRmx5W2XZ+IUHSTVlAOKOQaflTlo3xConuKfcyojJ3PGsO8x7awtRNA7
QYwN9zVszIoWo31nlVz7QSzUZ4iyEVnbY4gT5EVPKfflI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paHSLtKrUCHGgyQZO
+0APf4QTMn+Jlw40JD3vbQSPkxWb7dcQEE6gGg6htN7iLHRRVXf8sJWFrLGotCHCH
+RVY+A9o0d/+e49hXBsqNA03y1ZETQkVle1X7618aFj+Rfekq+yANXG1w2yD69Erv
+DB8RQvd5QS/1Igt4LyTdMw==',
];
if(isset($signatures[$version])) {
@@ -423,4 +459,38 @@ jFSE6+KKI+HAE132eaXY5A==',
$content = preg_replace("!'version'\s*=>\s*'(\d+\.\d+\.\d+)\.\d+!", "'version' => '$1", $content);
file_put_contents($configFile, $content);
}
+
+ /**
+ * @Given there is a folder called :name
+ */
+ public function thereIsAFolderCalled($name)
+ {
+ mkdir($this->serverDir . 'nextcloud/' . $name);
+ }
+
+ /**
+ * @Given there is a config for a secondary apps directory called :name
+ */
+ public function thereIsAConfigForASecondaryAppsDirectoryCalled($name)
+ {
+ $configFile = $this->serverDir . 'nextcloud/config/config.php';
+ $content = file_get_contents($configFile);
+ $appsPaths = <<<EOF
+ 'apps_paths' => [
+ [
+ 'path'=> dirname(__DIR__) . '/apps',
+ 'url' => '/apps',
+ 'writable' => true,
+ ],
+ [
+ 'path'=> dirname(__DIR__) . '/%s',
+ 'url' => '/%s',
+ 'writable' => true,
+ ],
+ ],
+EOF;
+ $appsPaths = sprintf($appsPaths, $name, $name);
+ $content = preg_replace("!\);!", $appsPaths . ');', $content);
+ file_put_contents($configFile, $content);
+ }
}
diff --git a/tests/features/cli.feature b/tests/features/cli.feature
index 99af2f1..3ba08e6 100644
--- a/tests/features/cli.feature
+++ b/tests/features/cli.feature
@@ -1,71 +1,93 @@
Feature: CLI updater
- Scenario: No update is available - 10.0.0
- Given the current version is 10.0.0
+ Scenario: No update is available - 12.0.0
+ Given the current version is 12.0.0
When the CLI updater is run
Then the output should contain "Could not find config.php. Is this file in the "updater" subfolder of Nextcloud?"
- Scenario: No update is available - 10.0.0
- Given the current installed version is 10.0.0
+ Scenario: No update is available - 12.0.0
+ Given the current installed version is 12.0.0
And there is no update available
When the CLI updater is run successfully
- Then the installed version should be 10.0.0
+ Then the installed version should be 12.0.0
And maintenance mode should be off
And upgrade is not required
- Scenario: Update is available - 10.0.0 to 10.0.1
- Given the current installed version is 10.0.0
- And there is an update to version 10.0.1 available
+ Scenario: Update is available - 12.0.0 to 12.0.1
+ Given the current installed version is 12.0.0
+ And there is an update to version 12.0.1 available
When the CLI updater is run successfully
- Then the installed version should be 10.0.1
+ Then the installed version should be 12.0.1
And maintenance mode should be off
And upgrade is not required
- Scenario: Invalid update is available - 10.0.0 to 10.0.503
- Given the current installed version is 10.0.0
- And there is an update to version 10.0.503 available
+ Scenario: Invalid update is available - 12.0.0 to 12.0.503
+ Given the current installed version is 12.0.0
+ And there is an update to version 12.0.503 available
When the CLI updater is run
Then the return code should not be 0
And the output should contain "Download failed - Not Found (HTTP 404)"
- And the installed version should be 10.0.0
+ And the installed version should be 12.0.0
# known issue:
And maintenance mode should be on
# TODO - it should be:
#And maintenance mode should be off
And upgrade is not required
- Scenario: Update without valid signature is being offered - 10.0.0 to 10.0.2
- Given the current installed version is 10.0.0
- # This works because 10.0.2 is not in the signature list
- And there is an update to version 10.0.2 available
+ Scenario: Update without valid signature is being offered - 11.0.0 to 11.0.1
+ Given the current installed version is 11.0.0
+ # This works because 11.0.1 is not in the signature list
+ And there is an update to version 11.0.1 available
When the CLI updater is run
Then the return code should not be 0
And the output should contain "Signature of update is not valid"
- And the installed version should be 10.0.0
+ And the installed version should be 11.0.0
# known issue:
And maintenance mode should be on
# TODO - it should be:
#And maintenance mode should be off
And upgrade is not required
- Scenario: Update to older version - 10.0.0 to 9.0.54
- Given the current installed version is 10.0.0
- And there is an update to version 9.0.54 available
+ Scenario: Update to older version - 12.0.0 to 11.0.2
+ Given the current installed version is 12.0.0
+ And there is an update to version 11.0.2 available
When the CLI updater is run
Then the return code should not be 0
And the output should contain "Downloaded version is lower than installed version"
- And the installed version should be 10.0.0
+ And the installed version should be 12.0.0
# known issue:
And maintenance mode should be on
# TODO - it should be:
#And maintenance mode should be off
And upgrade is not required
- Scenario: Update is available but autoupdate is disabled - 10.0.0 to 10.0.1
- Given the current installed version is 10.0.0
+ Scenario: Update is available but autoupdate is disabled - 12.0.0 to 12.0.1
+ Given the current installed version is 12.0.0
And the autoupdater is disabled
- And there is an update to version 10.0.1 available
+ And there is an update to version 12.0.1 available
When the CLI updater is run
- Then the installed version should be 10.0.0
+ Then the installed version should be 12.0.0
+ And maintenance mode should be off
+ And upgrade is not required
+
+ Scenario: Update is available and apps2 folder is there and configured - 12.0.0 to 12.0.1
+ Given the current installed version is 12.0.0
+ And there is an update to version 12.0.1 available
+ And there is a folder called "apps2"
+ And there is a config for a secondary apps directory called "apps2"
+ When the CLI updater is run successfully
+ Then the installed version should be 12.0.1
+ And maintenance mode should be off
+ And upgrade is not required
+
+ Scenario: Update is available and apps2 folder is there and not configured - 12.0.0 to 12.0.1
+ Given the current installed version is 12.0.0
+ And there is an update to version 12.0.1 available
+ And there is a folder called "apps2"
+ When the CLI updater is run
+ Then the return code should not be 0
+ And the output should contain "The following extra files have been found"
+ And the output should contain "apps2"
+ And the installed version should be 12.0.0
And maintenance mode should be off
And upgrade is not required
diff --git a/tests/features/master.feature b/tests/features/master.feature
index 5fd4817..486f8f1 100644
--- a/tests/features/master.feature
+++ b/tests/features/master.feature
@@ -7,6 +7,6 @@ Feature: CLI updater - master base
And the version number is decreased in the config.php to enforce upgrade
When the CLI updater is run successfully
And the output should contain "Update successful"
- Then the installed version should be 12.0
+ Then the installed version should be 13.0
And maintenance mode should be off
And upgrade is not required
diff --git a/tests/features/stable10.feature b/tests/features/stable10.feature
index bcc5367..bb65144 100644
--- a/tests/features/stable10.feature
+++ b/tests/features/stable10.feature
@@ -106,7 +106,7 @@ Feature: CLI updater - stable10 base
Scenario: Update is available - 10.0.2 RC1 to 10.0.2RC1 to check if the updater will run on the RC onwards
Given the current installed version is 10.0.2RC1
- And there is an update to prerelease version of 10.0.2RC1 available
+ And there is an update to prerelease version "10.0.2RC1" available
And the version number is decreased in the config.php to enforce upgrade
When the CLI updater is run successfully
And the output should contain "Update successful"
diff --git a/tests/features/stable11.feature b/tests/features/stable11.feature
index c96f1dc..c30f434 100644
--- a/tests/features/stable11.feature
+++ b/tests/features/stable11.feature
@@ -1,31 +1,28 @@
Feature: CLI updater - stable11 base
- Scenario: Update is available - 11.0.0 beta to 11.0.0 beta 2
- Given the current installed version is 11.0.0beta
- And there is an update to prerelease version "11.0.0beta2" available
- And the version number is decreased in the config.php to enforce upgrade
+ Scenario: Update is available - 11.0.3 to 11.0.4
+ Given the current installed version is 11.0.3
+ And there is an update to version 11.0.4 available
When the CLI updater is run successfully
And the output should contain "Update successful"
- Then the installed version should be 11.0.0.5
+ Then the installed version should be 11.0.4
And maintenance mode should be off
And upgrade is not required
- Scenario: Update is available - 11.0.2 to master daily
- Given the current installed version is 11.0.2
- And the current channel is "daily"
- And there is an update to daily version of master available
+ Scenario: Update is available - 11.0.3 to 12.0.1
+ Given the current installed version is 11.0.3
+ And there is an update to version 12.0.1 available
When the CLI updater is run successfully
And the output should contain "Update successful"
- Then the installed version should be 12.0
+ Then the installed version should be 12.0.1
And maintenance mode should be off
And upgrade is not required
- Scenario: Update is available - 11.0.2 to master daily
- Given the current installed version is 11.0.2
- And the current channel is "daily"
- And there is an update to daily version of master available
+ Scenario: Update is available - 11.0.4 to 12.0.1
+ Given the current installed version is 11.0.4
+ And there is an update to version 12.0.1 available
When the CLI updater is run successfully
And the output should contain "Update successful"
- Then the installed version should be 12.0
+ Then the installed version should be 12.0.1
And maintenance mode should be off
And upgrade is not required
diff --git a/tests/features/stable12.feature b/tests/features/stable12.feature
new file mode 100644
index 0000000..d9b67e7
--- /dev/null
+++ b/tests/features/stable12.feature
@@ -0,0 +1,40 @@
+Feature: CLI updater - stable12 base
+
+ Scenario: Update is available - 12.0.0 beta 1 to 12.0.0 beta 2
+ Given the current installed version is 12.0.0beta1
+ And there is an update to prerelease version "12.0.0beta2" available
+ And the version number is decreased in the config.php to enforce upgrade
+ When the CLI updater is run successfully
+ And the output should contain "Update successful"
+ Then the installed version should be 12.0
+ And maintenance mode should be off
+ And upgrade is not required
+
+ Scenario: Update is available - 12.0.0 to 12.0.1
+ Given the current installed version is 12.0.0
+ And there is an update to version 12.0.1 available
+ When the CLI updater is run successfully
+ And the output should contain "Update successful"
+ Then the installed version should be 12.0.1
+ And maintenance mode should be off
+ And upgrade is not required
+
+ Scenario: Update is available - 12.0.1 to master daily
+ Given the current installed version is 12.0.1
+ And the current channel is "daily"
+ And there is an update to daily version of master available
+ When the CLI updater is run successfully
+ And the output should contain "Update successful"
+ Then the installed version should be 13.0
+ And maintenance mode should be off
+ And upgrade is not required
+
+ Scenario: Update is available - 12.0.1 to master daily
+ Given the current installed version is 12.0.1
+ And the current channel is "daily"
+ And there is an update to daily version of master available
+ When the CLI updater is run successfully
+ And the output should contain "Update successful"
+ Then the installed version should be 13.0
+ And maintenance mode should be off
+ And upgrade is not required
diff --git a/tests/features/stable9.feature b/tests/features/stable9.feature
index a23ce5a..e5009a4 100644
--- a/tests/features/stable9.feature
+++ b/tests/features/stable9.feature
@@ -48,7 +48,7 @@ Feature: CLI updater - stable9 base
Scenario: Update is available - 9.0.53 to 9.0.55 RC1
Given the current installed version is 9.0.53
- And there is an update to prerelease version 9.0.55RC1 available
+ And there is an update to prerelease version "9.0.55RC1" available
When the CLI updater is run successfully
And the output should contain "Update successful"
Then the installed version should be 9.0.55