diff options
Diffstat (limited to 'apps/files_external/tests/backends')
-rw-r--r-- | apps/files_external/tests/backends/amazons3.php | 52 | ||||
-rw-r--r-- | apps/files_external/tests/backends/dropbox.php | 49 | ||||
-rw-r--r-- | apps/files_external/tests/backends/ftp.php | 68 | ||||
-rw-r--r-- | apps/files_external/tests/backends/google.php | 49 | ||||
-rw-r--r-- | apps/files_external/tests/backends/owncloud.php | 35 | ||||
-rw-r--r-- | apps/files_external/tests/backends/sftp.php | 48 | ||||
-rw-r--r-- | apps/files_external/tests/backends/smb.php | 47 | ||||
-rw-r--r-- | apps/files_external/tests/backends/swift.php | 56 | ||||
-rw-r--r-- | apps/files_external/tests/backends/webdav.php | 38 |
9 files changed, 442 insertions, 0 deletions
diff --git a/apps/files_external/tests/backends/amazons3.php b/apps/files_external/tests/backends/amazons3.php new file mode 100644 index 00000000000..fbb8744bd8d --- /dev/null +++ b/apps/files_external/tests/backends/amazons3.php @@ -0,0 +1,52 @@ +<?php + +/** + * ownCloud + * + * @author Michael Gapczynski + * @author Christian Berendt + * @copyright 2012 Michael Gapczynski mtgap@owncloud.com + * @copyright 2013 Christian Berendt berendt@b1-systems.de + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library 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 along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace Test\Files\Storage; + +class AmazonS3 extends Storage { + + private $config; + + protected function setUp() { + parent::setUp(); + + $this->config = include('files_external/tests/config.php'); + if ( ! is_array($this->config) or ! isset($this->config['amazons3']) or ! $this->config['amazons3']['run']) { + $this->markTestSkipped('AmazonS3 backend not configured'); + } + $this->instance = new \OC\Files\Storage\AmazonS3($this->config['amazons3']); + } + + protected function tearDown() { + if ($this->instance) { + $this->instance->rmdir(''); + } + + parent::tearDown(); + } + + public function testStat() { + $this->markTestSkipped('S3 doesn\'t update the parents folder mtime'); + } +} diff --git a/apps/files_external/tests/backends/dropbox.php b/apps/files_external/tests/backends/dropbox.php new file mode 100644 index 00000000000..3f25d5a31e8 --- /dev/null +++ b/apps/files_external/tests/backends/dropbox.php @@ -0,0 +1,49 @@ +<?php +/** + * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace Test\Files\Storage; + +class Dropbox extends Storage { + private $config; + + protected function setUp() { + parent::setUp(); + + $id = $this->getUniqueID(); + $this->config = include('files_external/tests/config.php'); + if ( ! is_array($this->config) or ! isset($this->config['dropbox']) or ! $this->config['dropbox']['run']) { + $this->markTestSkipped('Dropbox backend not configured'); + } + $this->config['dropbox']['root'] .= '/' . $id; //make sure we have an new empty folder to work in + $this->instance = new \OC\Files\Storage\Dropbox($this->config['dropbox']); + } + + protected function tearDown() { + if ($this->instance) { + $this->instance->unlink('/'); + } + + parent::tearDown(); + } + + public function directoryProvider() { + // doesn't support leading/trailing spaces + return array(array('folder')); + } + + public function testDropboxTouchReturnValue() { + $this->assertFalse($this->instance->file_exists('foo')); + + // true because succeeded + $this->assertTrue($this->instance->touch('foo')); + $this->assertTrue($this->instance->file_exists('foo')); + + // false because not supported + $this->assertFalse($this->instance->touch('foo')); + } +} diff --git a/apps/files_external/tests/backends/ftp.php b/apps/files_external/tests/backends/ftp.php new file mode 100644 index 00000000000..842b7f43fa8 --- /dev/null +++ b/apps/files_external/tests/backends/ftp.php @@ -0,0 +1,68 @@ +<?php +/** + * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace Test\Files\Storage; + +class FTP extends Storage { + private $config; + + protected function setUp() { + parent::setUp(); + + $id = $this->getUniqueID(); + $this->config = include('files_external/tests/config.php'); + if ( ! is_array($this->config) or ! isset($this->config['ftp']) or ! $this->config['ftp']['run']) { + $this->markTestSkipped('FTP backend not configured'); + } + $this->config['ftp']['root'] .= '/' . $id; //make sure we have an new empty folder to work in + $this->instance = new \OC\Files\Storage\FTP($this->config['ftp']); + $this->instance->mkdir('/'); + } + + protected function tearDown() { + if ($this->instance) { + \OCP\Files::rmdirr($this->instance->constructUrl('')); + } + + parent::tearDown(); + } + + public function testConstructUrl(){ + $config = array ( 'host' => 'localhost', + 'user' => 'ftp', + 'password' => 'ftp', + 'root' => '/', + 'secure' => false ); + $instance = new \OC\Files\Storage\FTP($config); + $this->assertEquals('ftp://ftp:ftp@localhost/', $instance->constructUrl('')); + + $config['secure'] = true; + $instance = new \OC\Files\Storage\FTP($config); + $this->assertEquals('ftps://ftp:ftp@localhost/', $instance->constructUrl('')); + + $config['secure'] = 'false'; + $instance = new \OC\Files\Storage\FTP($config); + $this->assertEquals('ftp://ftp:ftp@localhost/', $instance->constructUrl('')); + + $config['secure'] = 'true'; + $instance = new \OC\Files\Storage\FTP($config); + $this->assertEquals('ftps://ftp:ftp@localhost/', $instance->constructUrl('')); + + $config['root'] = ''; + $instance = new \OC\Files\Storage\FTP($config); + $this->assertEquals('ftps://ftp:ftp@localhost/somefile.txt', $instance->constructUrl('somefile.txt')); + + $config['root'] = '/abc'; + $instance = new \OC\Files\Storage\FTP($config); + $this->assertEquals('ftps://ftp:ftp@localhost/abc/somefile.txt', $instance->constructUrl('somefile.txt')); + + $config['root'] = '/abc/'; + $instance = new \OC\Files\Storage\FTP($config); + $this->assertEquals('ftps://ftp:ftp@localhost/abc/somefile.txt', $instance->constructUrl('somefile.txt')); + } +} diff --git a/apps/files_external/tests/backends/google.php b/apps/files_external/tests/backends/google.php new file mode 100644 index 00000000000..79023fac9e1 --- /dev/null +++ b/apps/files_external/tests/backends/google.php @@ -0,0 +1,49 @@ +<?php +/** + * ownCloud + * + * @author Michael Gapczynski + * @copyright 2012 Michael Gapczynski mtgap@owncloud.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library 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 along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace Test\Files\Storage; + +require_once 'files_external/lib/google.php'; + +class Google extends Storage { + + private $config; + + protected function setUp() { + parent::setUp(); + + $this->config = include('files_external/tests/config.php'); + if (!is_array($this->config) || !isset($this->config['google']) + || !$this->config['google']['run'] + ) { + $this->markTestSkipped('Google Drive backend not configured'); + } + $this->instance = new \OC\Files\Storage\Google($this->config['google']); + } + + protected function tearDown() { + if ($this->instance) { + $this->instance->rmdir('/'); + } + + parent::tearDown(); + } +} diff --git a/apps/files_external/tests/backends/owncloud.php b/apps/files_external/tests/backends/owncloud.php new file mode 100644 index 00000000000..ab9101cfe5f --- /dev/null +++ b/apps/files_external/tests/backends/owncloud.php @@ -0,0 +1,35 @@ +<?php +/** + * Copyright (c) 2013 Vincent Petry <pvince81@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace Test\Files\Storage; + +class OwnCloud extends Storage { + + private $config; + + protected function setUp() { + parent::setUp(); + + $id = $this->getUniqueID(); + $this->config = include('files_external/tests/config.php'); + if ( ! is_array($this->config) or ! isset($this->config['owncloud']) or ! $this->config['owncloud']['run']) { + $this->markTestSkipped('ownCloud backend not configured'); + } + $this->config['owncloud']['root'] .= '/' . $id; //make sure we have an new empty folder to work in + $this->instance = new \OC\Files\Storage\OwnCloud($this->config['owncloud']); + $this->instance->mkdir('/'); + } + + protected function tearDown() { + if ($this->instance) { + $this->instance->rmdir('/'); + } + + parent::tearDown(); + } +} diff --git a/apps/files_external/tests/backends/sftp.php b/apps/files_external/tests/backends/sftp.php new file mode 100644 index 00000000000..703b37d93f1 --- /dev/null +++ b/apps/files_external/tests/backends/sftp.php @@ -0,0 +1,48 @@ +<?php + +/** + * ownCloud + * + * @author Henrik Kjölhede + * @copyright 2013 Henrik Kjölhede hkjolhede@gmail.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library 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 along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace Test\Files\Storage; + +class SFTP extends Storage { + private $config; + + protected function setUp() { + parent::setUp(); + + $id = $this->getUniqueID(); + $this->config = include('files_external/tests/config.php'); + if ( ! is_array($this->config) or ! isset($this->config['sftp']) or ! $this->config['sftp']['run']) { + $this->markTestSkipped('SFTP backend not configured'); + } + $this->config['sftp']['root'] .= '/' . $id; //make sure we have an new empty folder to work in + $this->instance = new \OC\Files\Storage\SFTP($this->config['sftp']); + $this->instance->mkdir('/'); + } + + protected function tearDown() { + if ($this->instance) { + $this->instance->rmdir('/'); + } + + parent::tearDown(); + } +} diff --git a/apps/files_external/tests/backends/smb.php b/apps/files_external/tests/backends/smb.php new file mode 100644 index 00000000000..9e5ab2b331f --- /dev/null +++ b/apps/files_external/tests/backends/smb.php @@ -0,0 +1,47 @@ +<?php +/** + * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace Test\Files\Storage; + +class SMB extends Storage { + + private $config; + + protected function setUp() { + parent::setUp(); + + $id = $this->getUniqueID(); + $this->config = include('files_external/tests/config.php'); + if (!is_array($this->config) or !isset($this->config['smb']) or !$this->config['smb']['run']) { + $this->markTestSkipped('Samba backend not configured'); + } + $this->config['smb']['root'] .= $id; //make sure we have an new empty folder to work in + $this->instance = new \OC\Files\Storage\SMB($this->config['smb']); + $this->instance->mkdir('/'); + } + + protected function tearDown() { + if ($this->instance) { + \OCP\Files::rmdirr($this->instance->constructUrl('')); + } + + parent::tearDown(); + } + + public function directoryProvider() { + // doesn't support leading/trailing spaces + return array(array('folder')); + } + + public function testRenameWithSpaces() { + $this->instance->mkdir('with spaces'); + $result = $this->instance->rename('with spaces', 'foo bar'); + $this->assertTrue($result); + $this->assertTrue($this->instance->is_dir('foo bar')); + } +} diff --git a/apps/files_external/tests/backends/swift.php b/apps/files_external/tests/backends/swift.php new file mode 100644 index 00000000000..d2c884a8b4c --- /dev/null +++ b/apps/files_external/tests/backends/swift.php @@ -0,0 +1,56 @@ +<?php + +/** + * ownCloud + * + * @author Christian Berendt + * @copyright 2013 Christian Berendt berendt@b1-systems.de + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library 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 along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace Test\Files\Storage; + +class Swift extends Storage { + + private $config; + + protected function setUp() { + parent::setUp(); + + $this->config = include('files_external/tests/config.php'); + if (!is_array($this->config) or !isset($this->config['swift']) + or !$this->config['swift']['run']) { + $this->markTestSkipped('OpenStack Object Storage backend not configured'); + } + $this->instance = new \OC\Files\Storage\Swift($this->config['swift']); + } + + protected function tearDown() { + if ($this->instance) { + $connection = $this->instance->getConnection(); + $container = $connection->getContainer($this->config['swift']['bucket']); + + $objects = $container->objectList(); + while($object = $objects->next()) { + $object->setName(str_replace('#','%23',$object->getName())); + $object->delete(); + } + + $container->delete(); + } + + parent::tearDown(); + } +} diff --git a/apps/files_external/tests/backends/webdav.php b/apps/files_external/tests/backends/webdav.php new file mode 100644 index 00000000000..c390612810d --- /dev/null +++ b/apps/files_external/tests/backends/webdav.php @@ -0,0 +1,38 @@ +<?php +/** + * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace Test\Files\Storage; + +class DAV extends Storage { + + private $config; + + protected function setUp() { + parent::setUp(); + + $id = $this->getUniqueID(); + $config = include('files_external/tests/config.webdav.php'); + if ( ! is_array($config) or !$config['run']) { + $this->markTestSkipped('WebDAV backend not configured'); + } + if (isset($config['wait'])) { + $this->waitDelay = $config['wait']; + } + $config['root'] .= '/' . $id; //make sure we have an new empty folder to work in + $this->instance = new \OC\Files\Storage\DAV($config); + $this->instance->mkdir('/'); + } + + protected function tearDown() { + if ($this->instance) { + $this->instance->rmdir('/'); + } + + parent::tearDown(); + } +} |