diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2016-05-13 11:46:36 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2016-05-24 08:41:22 +0200 |
commit | 4576891f10aa41cc146dc6ed421384269eca283a (patch) | |
tree | 0b3f8696b880fc0867c885af6ca9c2be14e3c372 /apps/files_external/tests/Storage | |
parent | b9fd7d4cc7834fd0fff01c1c6aa478a62a905bb1 (diff) | |
download | nextcloud-server-4576891f10aa41cc146dc6ed421384269eca283a.tar.gz nextcloud-server-4576891f10aa41cc146dc6ed421384269eca283a.zip |
Move Lib\Storage to PSR-4
Diffstat (limited to 'apps/files_external/tests/Storage')
-rw-r--r-- | apps/files_external/tests/Storage/AmazonS3Test.php | 63 | ||||
-rw-r--r-- | apps/files_external/tests/Storage/DropboxTest.php | 76 | ||||
-rw-r--r-- | apps/files_external/tests/Storage/FTPTest.php | 95 | ||||
-rw-r--r-- | apps/files_external/tests/Storage/GoogleTest.php | 62 | ||||
-rw-r--r-- | apps/files_external/tests/Storage/OwnCloudTest.php | 60 | ||||
-rw-r--r-- | apps/files_external/tests/Storage/SFTPTest.php | 156 | ||||
-rw-r--r-- | apps/files_external/tests/Storage/SFTP_KeyTest.php | 97 | ||||
-rw-r--r-- | apps/files_external/tests/Storage/SMBTest.php | 86 | ||||
-rw-r--r-- | apps/files_external/tests/Storage/SwiftTest.php | 76 | ||||
-rw-r--r-- | apps/files_external/tests/Storage/WebDAVTest.php | 62 |
10 files changed, 833 insertions, 0 deletions
diff --git a/apps/files_external/tests/Storage/AmazonS3Test.php b/apps/files_external/tests/Storage/AmazonS3Test.php new file mode 100644 index 00000000000..eb0e410764c --- /dev/null +++ b/apps/files_external/tests/Storage/AmazonS3Test.php @@ -0,0 +1,63 @@ +<?php +/** + * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Michael Gapczynski <GapczynskiM@gmail.com> + * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> + * @author Robin McCorkell <robin@mccorkell.me.uk> + * @author Thomas Müller <thomas.mueller@tmit.eu> + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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\Storage; + +use \OCA\Files_External\Lib\Storage\AmazonS3; + +/** + * Class AmazonS3Test + * + * @group DB + * + * @package OCA\Files_External\Tests\Storage + */ +class AmazonS3Test extends \Test\Files\Storage\Storage { + + private $config; + + protected function setUp() { + parent::setUp(); + + $this->config = include('files_external/tests/config.amazons3.php'); + if ( ! is_array($this->config) or ! $this->config['run']) { + $this->markTestSkipped('AmazonS3 backend not configured'); + } + $this->instance = new AmazonS3($this->config); + } + + 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/Storage/DropboxTest.php b/apps/files_external/tests/Storage/DropboxTest.php new file mode 100644 index 00000000000..d466d4b1b44 --- /dev/null +++ b/apps/files_external/tests/Storage/DropboxTest.php @@ -0,0 +1,76 @@ +<?php +/** + * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Jörn Friedrich Dreyer <jfd@butonic.de> + * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> + * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Vincent Petry <pvince81@owncloud.com> + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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\Storage; + +use \OCA\Files_External\Lib\Storage\Dropbox; + +/** + * Class DropboxTest + * + * @group DB + * + * @package OCA\Files_External\Tests\Storage + */ +class DropboxTest extends \Test\Files\Storage\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 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/Storage/FTPTest.php b/apps/files_external/tests/Storage/FTPTest.php new file mode 100644 index 00000000000..9af9ccff012 --- /dev/null +++ b/apps/files_external/tests/Storage/FTPTest.php @@ -0,0 +1,95 @@ +<?php +/** + * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Jörn Friedrich Dreyer <jfd@butonic.de> + * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> + * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Vincent Petry <pvince81@owncloud.com> + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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\Storage; + +use \OCA\Files_External\Lib\Storage\FTP; + +/** + * Class FTPTest + * + * @group DB + * + * @package OCA\Files_External\Tests\Storage + */ +class FTPTest extends \Test\Files\Storage\Storage { + private $config; + + protected function setUp() { + parent::setUp(); + + $id = $this->getUniqueID(); + $this->config = include('files_external/tests/config.ftp.php'); + if ( ! is_array($this->config) or ! $this->config['run']) { + $this->markTestSkipped('FTP backend not configured'); + } + $this->config['root'] .= '/' . $id; //make sure we have an new empty folder to work in + $this->instance = new FTP($this->config); + $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 FTP($config); + $this->assertEquals('ftp://ftp:ftp@localhost/', $instance->constructUrl('')); + + $config['secure'] = true; + $instance = new FTP($config); + $this->assertEquals('ftps://ftp:ftp@localhost/', $instance->constructUrl('')); + + $config['secure'] = 'false'; + $instance = new FTP($config); + $this->assertEquals('ftp://ftp:ftp@localhost/', $instance->constructUrl('')); + + $config['secure'] = 'true'; + $instance = new FTP($config); + $this->assertEquals('ftps://ftp:ftp@localhost/', $instance->constructUrl('')); + + $config['root'] = ''; + $instance = new FTP($config); + $this->assertEquals('ftps://ftp:ftp@localhost/somefile.txt', $instance->constructUrl('somefile.txt')); + + $config['root'] = '/abc'; + $instance = new FTP($config); + $this->assertEquals('ftps://ftp:ftp@localhost/abc/somefile.txt', $instance->constructUrl('somefile.txt')); + + $config['root'] = '/abc/'; + $instance = new FTP($config); + $this->assertEquals('ftps://ftp:ftp@localhost/abc/somefile.txt', $instance->constructUrl('somefile.txt')); + } +} diff --git a/apps/files_external/tests/Storage/GoogleTest.php b/apps/files_external/tests/Storage/GoogleTest.php new file mode 100644 index 00000000000..46aa4555b12 --- /dev/null +++ b/apps/files_external/tests/Storage/GoogleTest.php @@ -0,0 +1,62 @@ +<?php +/** + * @author Bart Visscher <bartv@thisnet.nl> + * @author Christopher Schäpers <kondou@ts.unde.re> + * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Michael Gapczynski <GapczynskiM@gmail.com> + * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> + * @author Thomas Müller <thomas.mueller@tmit.eu> + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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\Storage; + +use \OCA\Files_External\Lib\Storage\Google; + +/** + * Class GoogleTest + * + * @group DB + * + * @package OCA\Files_External\Tests\Storage + */ +class GoogleTest extends \Test\Files\Storage\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 Google($this->config['google']); + } + + protected function tearDown() { + if ($this->instance) { + $this->instance->rmdir('/'); + } + + parent::tearDown(); + } +} diff --git a/apps/files_external/tests/Storage/OwnCloudTest.php b/apps/files_external/tests/Storage/OwnCloudTest.php new file mode 100644 index 00000000000..cbc25e46fa0 --- /dev/null +++ b/apps/files_external/tests/Storage/OwnCloudTest.php @@ -0,0 +1,60 @@ +<?php +/** + * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Morris Jobke <hey@morrisjobke.de> + * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Vincent Petry <pvince81@owncloud.com> + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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\Storage; + +use \OCA\Files_External\Lib\Storage\OwnCloud; + +/** + * Class OwnCloudTest + * + * @group DB + * + * @package OCA\Files_External\Tests\Storage + */ +class OwnCloudTest extends \Test\Files\Storage\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 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/Storage/SFTPTest.php b/apps/files_external/tests/Storage/SFTPTest.php new file mode 100644 index 00000000000..329e93819fc --- /dev/null +++ b/apps/files_external/tests/Storage/SFTPTest.php @@ -0,0 +1,156 @@ +<?php +/** + * @author hkjolhede <hkjolhede@gmail.com> + * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> + * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Vincent Petry <pvince81@owncloud.com> + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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\Storage; + +use \OCA\Files_External\Lib\Storage\SFTP; + +/** + * Class SFTPTest + * + * @group DB + * + * @package OCA\Files_External\Tests\Storage + */ +class SFTPTest extends \Test\Files\Storage\Storage { + /** + * @var SFTP instance + */ + protected $instance; + + private $config; + + protected function setUp() { + parent::setUp(); + + $id = $this->getUniqueID(); + $this->config = include('files_external/tests/config.sftp.php'); + if (!is_array($this->config) or !$this->config['run']) { + $this->markTestSkipped('SFTP backend not configured'); + } + $this->config['root'] .= '/' . $id; //make sure we have an new empty folder to work in + $this->instance = new SFTP($this->config); + $this->instance->mkdir('/'); + } + + protected function tearDown() { + if ($this->instance) { + $this->instance->rmdir('/'); + } + + parent::tearDown(); + } + + /** + * @dataProvider configProvider + */ + public function testStorageId($config, $expectedStorageId) { + $instance = new SFTP($config); + $this->assertEquals($expectedStorageId, $instance->getId()); + } + + public function configProvider() { + return [ + [ + // no root path + [ + 'run' => true, + 'host' => 'somehost', + 'user' => 'someuser', + 'password' => 'somepassword', + 'root' => '', + ], + 'sftp::someuser@somehost//', + ], + [ + // without leading nor trailing slash + [ + 'run' => true, + 'host' => 'somehost', + 'user' => 'someuser', + 'password' => 'somepassword', + 'root' => 'remotedir/subdir', + ], + 'sftp::someuser@somehost//remotedir/subdir/', + ], + [ + // regular path + [ + 'run' => true, + 'host' => 'somehost', + 'user' => 'someuser', + 'password' => 'somepassword', + 'root' => '/remotedir/subdir/', + ], + 'sftp::someuser@somehost//remotedir/subdir/', + ], + [ + // different port + [ + 'run' => true, + 'host' => 'somehost:8822', + 'user' => 'someuser', + 'password' => 'somepassword', + 'root' => 'remotedir/subdir/', + ], + 'sftp::someuser@somehost:8822//remotedir/subdir/', + ], + [ + // ipv6 with port + [ + 'run' => true, + 'host' => 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329', + 'user' => 'someuser', + 'password' => 'somepassword', + 'root' => 'remotedir/subdir/', + ], + 'sftp::someuser@FE80:0000:0000:0000:0202:B3FF:FE1E:8329//remotedir/subdir/', + ], + [ + // ipv6 without port + [ + 'run' => true, + 'host' => 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329:8822', + 'user' => 'someuser', + 'password' => 'somepassword', + 'root' => 'remotedir/subdir/', + ], + 'sftp::someuser@FE80:0000:0000:0000:0202:B3FF:FE1E:8329:8822//remotedir/subdir/', + ], + [ + // collapsed ipv6 with port + [ + 'run' => true, + 'host' => 'FE80::0202:B3FF:FE1E:8329:8822', + 'user' => 'someuser', + 'password' => 'somepassword', + 'root' => 'remotedir/subdir/', + ], + 'sftp::someuser@FE80::0202:B3FF:FE1E:8329:8822//remotedir/subdir/', + ], + ]; + } +} diff --git a/apps/files_external/tests/Storage/SFTP_KeyTest.php b/apps/files_external/tests/Storage/SFTP_KeyTest.php new file mode 100644 index 00000000000..b974f88555f --- /dev/null +++ b/apps/files_external/tests/Storage/SFTP_KeyTest.php @@ -0,0 +1,97 @@ +<?php +/** + * @author Morris Jobke <hey@morrisjobke.de> + * @author Ross Nicoll <jrn@jrn.me.uk> + * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Viktor Szépe <viktor@szepe.net> + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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\Storage; + +use \OCA\Files_External\Lib\Storage\SFTP_Key; + +/** + * Class SFTP_KeyTest + * + * @group DB + * + * @package OCA\Files_External\Tests\Storage + */ +class SFTP_KeyTest extends \Test\Files\Storage\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_key']) or ! $this->config['sftp_key']['run']) { + $this->markTestSkipped('SFTP with key backend not configured'); + } + // Make sure we have an new empty folder to work in + $this->config['sftp_key']['root'] .= '/' . $id; + $this->instance = new SFTP_Key($this->config['sftp_key']); + $this->instance->mkdir('/'); + } + + protected function tearDown() { + if ($this->instance) { + $this->instance->rmdir('/'); + } + + parent::tearDown(); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testInvalidAddressShouldThrowException() { + // I'd use example.com for this, but someone decided to break the spec and make it resolve + $this->instance->assertHostAddressValid('notarealaddress...'); + } + + public function testValidAddressShouldPass() { + $this->assertTrue($this->instance->assertHostAddressValid('localhost')); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testNegativePortNumberShouldThrowException() { + $this->instance->assertPortNumberValid('-1'); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testNonNumericalPortNumberShouldThrowException() { + $this->instance->assertPortNumberValid('a'); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testHighPortNumberShouldThrowException() { + $this->instance->assertPortNumberValid('65536'); + } + + public function testValidPortNumberShouldPass() { + $this->assertTrue($this->instance->assertPortNumberValid('22222')); + } +} diff --git a/apps/files_external/tests/Storage/SMBTest.php b/apps/files_external/tests/Storage/SMBTest.php new file mode 100644 index 00000000000..fc2795702c6 --- /dev/null +++ b/apps/files_external/tests/Storage/SMBTest.php @@ -0,0 +1,86 @@ +<?php +/** + * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> + * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Vincent Petry <pvince81@owncloud.com> + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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\Storage; + +use \OCA\Files_External\Lib\Storage\SMB; + +/** + * Class SMBTest + * + * @group DB + * + * @package OCA\Files_External\Tests\Storage + */ +class SMBTest extends \Test\Files\Storage\Storage { + + protected function setUp() { + parent::setUp(); + + $id = $this->getUniqueID(); + $config = include('files_external/tests/config.smb.php'); + if (!is_array($config) or !$config['run']) { + $this->markTestSkipped('Samba backend not configured'); + } + if (substr($config['root'], -1, 1) != '/') { + $config['root'] .= '/'; + } + $config['root'] .= $id; //make sure we have an new empty folder to work in + $this->instance = new SMB($config); + $this->instance->mkdir('/'); + } + + protected function tearDown() { + if ($this->instance) { + $this->instance->rmdir(''); + } + + 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')); + } + + public function testStorageId() { + $this->instance = new SMB([ + 'host' => 'testhost', + 'user' => 'testuser', + 'password' => 'somepass', + 'share' => 'someshare', + 'root' => 'someroot', + ]); + $this->assertEquals('smb::testuser@testhost//someshare//someroot/', $this->instance->getId()); + $this->instance = null; + } +} diff --git a/apps/files_external/tests/Storage/SwiftTest.php b/apps/files_external/tests/Storage/SwiftTest.php new file mode 100644 index 00000000000..1bcbb815067 --- /dev/null +++ b/apps/files_external/tests/Storage/SwiftTest.php @@ -0,0 +1,76 @@ +<?php +/** + * @author Christian Berendt <berendt@b1-systems.de> + * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> + * @author Robin McCorkell <robin@mccorkell.me.uk> + * @author Thomas Müller <thomas.mueller@tmit.eu> + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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\Storage; + +use \OCA\Files_External\Lib\Storage\Swift; + +/** + * Class SwiftTest + * + * @group DB + * + * @package OCA\Files_External\Tests\Storage + */ +class SwiftTest extends \Test\Files\Storage\Storage { + + private $config; + + protected function setUp() { + parent::setUp(); + + $this->config = include('files_external/tests/config.swift.php'); + if (!is_array($this->config) or !$this->config['run']) { + $this->markTestSkipped('OpenStack Object Storage backend not configured'); + } + $this->instance = new Swift($this->config); + } + + protected function tearDown() { + if ($this->instance) { + try { + $connection = $this->instance->getConnection(); + $container = $connection->getContainer($this->config['bucket']); + + $objects = $container->objectList(); + while($object = $objects->next()) { + $object->setName(str_replace('#','%23',$object->getName())); + $object->delete(); + } + + $container->delete(); + } catch (\Guzzle\Http\Exception\ClientErrorResponseException $e) { + // container didn't exist, so we don't need to delete it + } + } + + parent::tearDown(); + } + + public function testStat() { + $this->markTestSkipped('Swift doesn\'t update the parents folder mtime'); + } +} diff --git a/apps/files_external/tests/Storage/WebDAVTest.php b/apps/files_external/tests/Storage/WebDAVTest.php new file mode 100644 index 00000000000..f8c5b19e04f --- /dev/null +++ b/apps/files_external/tests/Storage/WebDAVTest.php @@ -0,0 +1,62 @@ +<?php +/** + * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> + * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Vincent Petry <pvince81@owncloud.com> + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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\Storage; + +use \OC\Files\Storage\DAV; + +/** + * Class WebDAVTest + * + * @group DB + * + * @package OCA\Files_External\Tests\Storage + */ +class WebDAVTest extends \Test\Files\Storage\Storage { + + 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 DAV($config); + $this->instance->mkdir('/'); + } + + protected function tearDown() { + if ($this->instance) { + $this->instance->rmdir('/'); + } + + parent::tearDown(); + } +} |