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

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-12-19 23:40:08 +0300
committerLukas Reschke <lukas@statuscode.ch>2016-12-21 00:05:33 +0300
commit1c80307537ea6e8542c5afda6b2ddb2d4ddf4dc3 (patch)
tree1397000e6d9568f36b306f5da1925014c2124df2
parentd7b340264321008ccbf7fe057c0a9107cabc7085 (diff)
Add SMB tests and execute files_external tests
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
-rw-r--r--.drone.yml20
-rw-r--r--apps/files_external/tests/AmazonS3MigrationTest.php146
-rw-r--r--apps/files_external/tests/Command/ListCommandTest.php9
-rw-r--r--apps/files_external/tests/Settings/AdminTest.php20
-rwxr-xr-xapps/files_external/tests/env/start-smb-linux.sh42
-rwxr-xr-xapps/files_external/tests/env/start-smb-silvershell.sh67
-rwxr-xr-xapps/files_external/tests/env/stop-smb-linux.sh21
-rwxr-xr-xapps/files_external/tests/env/stop-smb-silvershell.sh37
-rwxr-xr-xautotest-external.sh7
9 files changed, 105 insertions, 264 deletions
diff --git a/.drone.yml b/.drone.yml
index 0b930aef501..65717641f29 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -104,6 +104,22 @@ pipeline:
when:
matrix:
TESTS: carddavtester
+ sqlite-php7.0-samba-native:
+ image: nextcloudci/samba-native-php7.0:samba-native-php7.0-1
+ commands:
+ - smbd -D -FS &
+ - NOCOVERAGE=true ./autotest-external.sh sqlite smb-linux
+ when:
+ matrix:
+ TESTS: sqlite-php7.0-samba-native
+ sqlite-php7.0-samba-non-native:
+ image: nextcloudci/samba-non-native-php7.0:samba-non-native-php7.0-2
+ commands:
+ - smbd -D -FS &
+ - NOCOVERAGE=true ./autotest-external.sh sqlite smb-linux
+ when:
+ matrix:
+ TESTS: sqlite-php7.0-samba-non-native
nodb-php5.6:
image: nextcloudci/php5.6:php5.6-7
commands:
@@ -381,7 +397,7 @@ matrix:
- TESTS: signed-off-check
- TESTS: htaccess-checker
- TESTS: nodb-codecov
- - TESTS: db-codecov
+ - TESTS: db-codecov
- TESTS: integration-capabilities_features
- TESTS: integration-federation_features
- TESTS: integration-auth
@@ -412,6 +428,8 @@ matrix:
- TESTS: litmus-v2
- TESTS: caldavtester
- TESTS: carddavtester
+ - TESTS: sqlite-php7.0-samba-native
+ - TESTS: sqlite-php7.0-samba-non-native
- DB: NODB
PHP: 5.6
- DB: NODB
diff --git a/apps/files_external/tests/AmazonS3MigrationTest.php b/apps/files_external/tests/AmazonS3MigrationTest.php
deleted file mode 100644
index 2788ef6cbb4..00000000000
--- a/apps/files_external/tests/AmazonS3MigrationTest.php
+++ /dev/null
@@ -1,146 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Joas Schilling <coding@schilljs.com>
- * @author Jörn Friedrich Dreyer <jfd@butonic.de>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-
-namespace OCA\Files_External\Tests;
-
-use OCA\Files_External\Lib\Storage\AmazonS3;
-
-/**
- * Class AmazonS3Migration
- *
- * @group DB
- *
- * @package OCA\Files_External\Tests
- */
-class AmazonS3MigrationTest extends \Test\TestCase {
-
- /**
- * @var \OC\Files\Storage\Storage instance
- */
- protected $instance;
-
- /** @var array */
- protected $params;
-
- /** @var string */
- protected $oldId;
-
- /** @var string */
- protected $newId;
-
- protected function setUp() {
- parent::setUp();
-
- $uuid = $this->getUniqueID();
-
- $this->params['key'] = 'key'.$uuid;
- $this->params['secret'] = 'secret'.$uuid;
- $this->params['bucket'] = 'bucket'.$uuid;
-
- $this->oldId = 'amazon::' . $this->params['key'] . md5($this->params['secret']);
- $this->newId = 'amazon::' . $this->params['bucket'];
- }
-
- protected function tearDown() {
- $this->deleteStorage($this->oldId);
- $this->deleteStorage($this->newId);
-
- parent::tearDown();
- }
-
- public function testUpdateLegacyOnlyId () {
- // add storage ids
- $oldCache = new \OC\Files\Cache\Cache($this->oldId);
-
- // add file to old cache
- $fileId = $oldCache->put('foobar', array('size' => 0, 'mtime' => time(), 'mimetype' => 'httpd/directory'));
-
- try {
- $this->instance = new AmazonS3($this->params);
- } catch (\Exception $e) {
- //ignore
- }
- $storages = $this->getStorages();
-
- $this->assertTrue(isset($storages[$this->newId]));
- $this->assertFalse(isset($storages[$this->oldId]));
- $this->assertSame((int)$oldCache->getNumericStorageId(), (int)$storages[$this->newId]);
-
- list($storageId, $path) = \OC\Files\Cache\Cache::getById($fileId);
-
- $this->assertSame($this->newId, $storageId);
- $this->assertSame('foobar', $path);
- }
-
- public function testUpdateLegacyAndNewId () {
- // add storage ids
-
- $oldCache = new \OC\Files\Cache\Cache($this->oldId);
- new \OC\Files\Cache\Cache($this->newId);
-
- // add file to old cache
- $fileId = $oldCache->put('/', array('size' => 0, 'mtime' => time(), 'mimetype' => 'httpd/directory'));
-
- try {
- $this->instance = new AmazonS3($this->params);
- } catch (\Exception $e) {
- //ignore
- }
- $storages = $this->getStorages();
-
- $this->assertTrue(isset($storages[$this->newId]));
- $this->assertFalse(isset($storages[$this->oldId]));
-
- $this->assertNull(\OC\Files\Cache\Cache::getById($fileId), 'old filecache has not been cleared');
- }
-
- /**
- * @param $storages
- * @return array
- */
- public function getStorages() {
- $storages = array();
- $stmt = \OC::$server->getDatabaseConnection()->prepare(
- 'SELECT `numeric_id`, `id` FROM `*PREFIX*storages` WHERE `id` IN (?, ?)'
- );
- $stmt->execute(array($this->oldId, $this->newId));
- while ($row = $stmt->fetch()) {
- $storages[$row['id']] = $row['numeric_id'];
- }
- return $storages;
- }
-
- /**
- * @param string $id
- */
- public function deleteStorage($id) {
- $stmt = \OC::$server->getDatabaseConnection()->prepare(
- 'DELETE FROM `*PREFIX*storages` WHERE `id` = ?'
- );
- $stmt->execute(array($id));
- }
-}
diff --git a/apps/files_external/tests/Command/ListCommandTest.php b/apps/files_external/tests/Command/ListCommandTest.php
index f2f9fa94c02..5563b19c7a8 100644
--- a/apps/files_external/tests/Command/ListCommandTest.php
+++ b/apps/files_external/tests/Command/ListCommandTest.php
@@ -29,6 +29,9 @@ use OCA\Files_External\Lib\Auth\Password\Password;
use OCA\Files_External\Lib\Auth\Password\SessionCredentials;
use OCA\Files_External\Lib\Backend\Local;
use OCA\Files_External\Lib\StorageConfig;
+use OCA\Files_External\Service\GlobalStoragesService;
+use OCA\Files_External\Service\UserStoragesService;
+use OCP\IL10N;
use OCP\ISession;
use OCP\IUserManager;
use OCP\IUserSession;
@@ -41,9 +44,9 @@ class ListCommandTest extends CommandTest {
*/
private function getInstance() {
/** @var \OCA\Files_External\Service\GlobalStoragesService|\PHPUnit_Framework_MockObject_MockObject $globalService */
- $globalService = $this->getMock('\OCA\Files_External\Service\GlobalStoragesService', null, [], '', false);
+ $globalService = $this->createMock(GlobalStoragesService::class);
/** @var \OCA\Files_External\Service\UserStoragesService|\PHPUnit_Framework_MockObject_MockObject $userService */
- $userService = $this->getMock('\OCA\Files_External\Service\UserStoragesService', null, [], '', false);
+ $userService = $this->createMock(UserStoragesService::class);
/** @var \OCP\IUserManager|\PHPUnit_Framework_MockObject_MockObject $userManager */
$userManager = $this->createMock(IUserManager::class);
/** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject $userSession */
@@ -53,7 +56,7 @@ class ListCommandTest extends CommandTest {
}
public function testListAuthIdentifier() {
- $l10n = $this->getMock('\OPC\IL10N', null, [], '', false);
+ $l10n = $this->createMock(IL10N::class);
$session = $this->createMock(ISession::class);
$crypto = $this->createMock(ICrypto::class);
$instance = $this->getInstance();
diff --git a/apps/files_external/tests/Settings/AdminTest.php b/apps/files_external/tests/Settings/AdminTest.php
index fdf9680e7c3..6236f2d416a 100644
--- a/apps/files_external/tests/Settings/AdminTest.php
+++ b/apps/files_external/tests/Settings/AdminTest.php
@@ -34,21 +34,21 @@ use Test\TestCase;
class AdminTest extends TestCase {
/** @var Admin */
private $admin;
- /** @var IManager */
+ /** @var IManager|\PHPUnit_Framework_MockObject_MockObject */
private $encryptionManager;
- /** @var GlobalStoragesService */
+ /** @var GlobalStoragesService|\PHPUnit_Framework_MockObject_MockObject */
private $globalStoragesService;
- /** @var BackendService */
+ /** @var BackendService|\PHPUnit_Framework_MockObject_MockObject */
private $backendService;
- /** @var GlobalAuth */
+ /** @var GlobalAuth|\PHPUnit_Framework_MockObject_MockObject */
private $globalAuth;
public function setUp() {
parent::setUp();
- $this->encryptionManager = $this->getMockBuilder('\OCP\Encryption\IManager')->getMock();
- $this->globalStoragesService = $this->getMockBuilder('\OCA\Files_External\Service\GlobalStoragesService')->disableOriginalConstructor()->getMock();
- $this->backendService = $this->getMockBuilder('\OCA\Files_External\Service\BackendService')->disableOriginalConstructor()->getMock();
- $this->globalAuth = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\Password\GlobalAuth')->disableOriginalConstructor()->getMock();
+ $this->encryptionManager = $this->createMock(IManager::class);
+ $this->globalStoragesService = $this->createMock(GlobalStoragesService::class);
+ $this->backendService = $this->createMock(BackendService::class);
+ $this->globalAuth = $this->createMock(GlobalAuth::class);
$this->admin = new Admin(
$this->encryptionManager,
@@ -79,6 +79,10 @@ class AdminTest extends TestCase {
->expects($this->once())
->method('isUserMountingAllowed')
->willReturn(true);
+ $this->backendService
+ ->expects($this->exactly(2))
+ ->method('getBackends')
+ ->willReturn([]);
$this->globalAuth
->expects($this->once())
->method('getAuth')
diff --git a/apps/files_external/tests/env/start-smb-linux.sh b/apps/files_external/tests/env/start-smb-linux.sh
new file mode 100755
index 00000000000..173dd25ebb9
--- /dev/null
+++ b/apps/files_external/tests/env/start-smb-linux.sh
@@ -0,0 +1,42 @@
+#!/usr/bin/env bash
+#
+# ownCloud
+#
+# This script start a docker container to test the files_external tests
+# against. It will also change the files_external config to use the docker
+# container as testing environment. This is reverted in the stop step.W
+#
+# Set environment variable DEBUG to print config file
+#
+# @author Morris Jobke
+# @copyright 2015 Morris Jobke <hey@morrisjobke.de>
+#
+
+# retrieve current folder to place the config in the parent folder
+thisFolder=`echo $0 | sed 's#env/start-smb-linux\.sh##'`
+
+if [ -z "$thisFolder" ]; then
+ thisFolder="."
+fi;
+
+cat > $thisFolder/config.smb.php <<DELIM
+<?php
+
+return array(
+ 'run'=>true,
+ 'host'=>'127.0.0.1',
+ 'user'=>'test',
+ 'password'=>'test',
+ 'root'=>'',
+ 'share'=>'public',
+);
+
+DELIM
+
+echo -n "Waiting for samba initialization"
+if ! "$thisFolder"/env/wait-for-connection 127.0.0.1 445 60; then
+ echo "[ERROR] Waited 60 seconds, no response" >&2
+ exit 1
+fi
+
+sleep 1
diff --git a/apps/files_external/tests/env/start-smb-silvershell.sh b/apps/files_external/tests/env/start-smb-silvershell.sh
deleted file mode 100755
index a7ff3f71eb1..00000000000
--- a/apps/files_external/tests/env/start-smb-silvershell.sh
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/env bash
-#
-# ownCloud
-#
-# This script start a docker container to test the files_external tests
-# against. It will also change the files_external config to use the docker
-# container as testing environment. This is reverted in the stop step.W
-#
-# Set environment variable DEBUG to print config file
-#
-# @author Morris Jobke
-# @copyright 2015 Morris Jobke <hey@morrisjobke.de>
-#
-
-if ! command -v docker >/dev/null 2>&1; then
- echo "No docker executable found - skipped docker setup"
- exit 0;
-fi
-
-echo "Docker executable found - setup docker"
-
-echo "Fetch recent silvershell/samba docker image"
-docker pull silvershell/samba
-
-# retrieve current folder to place the config in the parent folder
-thisFolder=`echo $0 | sed 's#env/start-smb-silvershell\.sh##'`
-
-if [ -z "$thisFolder" ]; then
- thisFolder="."
-fi;
-
-container=`docker run -d -e SMB_USER=test -e SMB_PWD=test silvershell/samba`
-
-host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container`
-
-cat > $thisFolder/config.smb.php <<DELIM
-<?php
-
-return array(
- 'run'=>true,
- 'host'=>'$host',
- 'user'=>'test',
- 'password'=>'test',
- 'root'=>'',
- 'share'=>'public',
-);
-
-DELIM
-
-echo "samba container: $container"
-
-# put container IDs into a file to drop them after the test run (keep in mind that multiple tests run in parallel on the same host)
-echo $container >> $thisFolder/dockerContainerSilvershell.$EXECUTOR_NUMBER.smb
-
-echo -n "Waiting for samba initialization"
-if ! "$thisFolder"/env/wait-for-connection ${host} 445 60; then
- echo "[ERROR] Waited 60 seconds, no response" >&2
- exit 1
-fi
-sleep 1
-
-if [ -n "$DEBUG" ]; then
- cat $thisFolder/config.smb.php
- cat $thisFolder/dockerContainerSilvershell.$EXECUTOR_NUMBER.smb
-fi
-
-
diff --git a/apps/files_external/tests/env/stop-smb-linux.sh b/apps/files_external/tests/env/stop-smb-linux.sh
new file mode 100755
index 00000000000..434d3e166b1
--- /dev/null
+++ b/apps/files_external/tests/env/stop-smb-linux.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+#
+# ownCloud
+#
+# This script stops the docker container the files_external tests were run
+# against. It will also revert the config changes done in start step.
+#
+# @author Morris Jobke
+# @copyright 2015 Morris Jobke <hey@morrisjobke.de>
+#
+
+# retrieve current folder to remove the config from the parent folder
+thisFolder=`echo $0 | sed 's#env/stop-smb-linux\.sh##'`
+
+if [ -z "$thisFolder" ]; then
+ thisFolder="."
+fi;
+
+# cleanup
+rm $thisFolder/config.smb.php
+
diff --git a/apps/files_external/tests/env/stop-smb-silvershell.sh b/apps/files_external/tests/env/stop-smb-silvershell.sh
deleted file mode 100755
index 56866f13b1f..00000000000
--- a/apps/files_external/tests/env/stop-smb-silvershell.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/env bash
-#
-# ownCloud
-#
-# This script stops the docker container the files_external tests were run
-# against. It will also revert the config changes done in start step.
-#
-# @author Morris Jobke
-# @copyright 2015 Morris Jobke <hey@morrisjobke.de>
-#
-
-if ! command -v docker >/dev/null 2>&1; then
- echo "No docker executable found - skipped docker stop"
- exit 0;
-fi
-
-echo "Docker executable found - stop and remove docker containers"
-
-# retrieve current folder to remove the config from the parent folder
-thisFolder=`echo $0 | sed 's#env/stop-smb-silvershell\.sh##'`
-
-if [ -z "$thisFolder" ]; then
- thisFolder="."
-fi;
-
-# stopping and removing docker containers
-for container in `cat $thisFolder/dockerContainerSilvershell.$EXECUTOR_NUMBER.smb`; do
- echo "Stopping and removing docker container $container"
- # kills running container and removes it
- docker stop $container
- docker rm -f $container
-done;
-
-# cleanup
-rm $thisFolder/config.smb.php
-rm $thisFolder/dockerContainerSilvershell.$EXECUTOR_NUMBER.smb
-
diff --git a/autotest-external.sh b/autotest-external.sh
index 7d2e506ae98..a6ca077ebb0 100755
--- a/autotest-external.sh
+++ b/autotest-external.sh
@@ -167,11 +167,14 @@ EOF
fi
if [ -z "$NOCOVERAGE" ]; then
"$PHPUNIT" --configuration phpunit-autotest-external.xml --log-junit "autotest-external-results-$1.xml" --coverage-clover "autotest-external-clover-$1.xml" --coverage-html "coverage-external-html-$1"
- RESULT=$?
else
echo "No coverage"
"$PHPUNIT" --configuration phpunit-autotest-external.xml --log-junit "autotest-external-results-$1.xml"
- RESULT=$?
+ fi
+
+ if [[ $? -ne 0 ]]; then
+ echo "Error during phpunit execution ... terminating"
+ exit 1
fi
if [ -n "$2" -a "$2" == "common-tests" ]; then