aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/tests
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/tests')
-rw-r--r--apps/files_external/tests/Auth/AuthMechanismTest.php46
-rw-r--r--apps/files_external/tests/Auth/Password/GlobalAuthTest.php (renamed from apps/files_external/tests/Auth/Password/GlobalAuth.php)61
-rw-r--r--apps/files_external/tests/Backend/BackendTest.php42
-rw-r--r--apps/files_external/tests/Backend/LegacyBackendTest.php48
-rw-r--r--apps/files_external/tests/Command/ApplicableTest.php49
-rw-r--r--apps/files_external/tests/Command/CommandTestCase.php (renamed from apps/files_external/tests/Command/CommandTest.php)43
-rw-r--r--apps/files_external/tests/Command/ListCommandTest.php50
-rw-r--r--apps/files_external/tests/Config/UserPlaceholderHandlerTest.php68
-rw-r--r--apps/files_external/tests/Controller/AjaxControllerTest.php91
-rw-r--r--apps/files_external/tests/Controller/GlobalStoragesControllerTest.php37
-rw-r--r--apps/files_external/tests/Controller/StoragesControllerTestCase.php (renamed from apps/files_external/tests/Controller/StoragesControllerTest.php)142
-rw-r--r--apps/files_external/tests/Controller/UserStoragesControllerTest.php48
-rw-r--r--apps/files_external/tests/DefinitionParameterTest.php46
-rw-r--r--apps/files_external/tests/FrontendDefinitionTraitTest.php44
-rw-r--r--apps/files_external/tests/LegacyDependencyCheckPolyfillTest.php33
-rw-r--r--apps/files_external/tests/Listener/StorePasswordListenerTest.php42
-rw-r--r--apps/files_external/tests/OwnCloudFunctionsTest.php39
-rw-r--r--apps/files_external/tests/PersonalMountTest.php42
-rw-r--r--apps/files_external/tests/README.md5
-rw-r--r--apps/files_external/tests/Service/BackendServiceTest.php125
-rw-r--r--apps/files_external/tests/Service/DBConfigServiceTest.php97
-rw-r--r--apps/files_external/tests/Service/GlobalStoragesServiceTest.php160
-rw-r--r--apps/files_external/tests/Service/StoragesServiceTestCase.php (renamed from apps/files_external/tests/Service/StoragesServiceTest.php)162
-rw-r--r--apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php110
-rw-r--r--apps/files_external/tests/Service/UserStoragesServiceTest.php76
-rw-r--r--apps/files_external/tests/Settings/AdminTest.php51
-rw-r--r--apps/files_external/tests/Settings/SectionTest.php46
-rw-r--r--apps/files_external/tests/Storage/Amazons3MultiPartTest.php35
-rw-r--r--apps/files_external/tests/Storage/Amazons3Test.php40
-rw-r--r--apps/files_external/tests/Storage/FtpTest.php34
-rw-r--r--apps/files_external/tests/Storage/OwncloudTest.php29
-rw-r--r--apps/files_external/tests/Storage/SFTP_KeyTest.php50
-rw-r--r--apps/files_external/tests/Storage/SftpTest.php38
-rw-r--r--apps/files_external/tests/Storage/SmbTest.php93
-rw-r--r--apps/files_external/tests/Storage/SwiftTest.php31
-rw-r--r--apps/files_external/tests/Storage/VersionedAmazonS3Test.php28
-rw-r--r--apps/files_external/tests/Storage/WebdavTest.php35
-rw-r--r--apps/files_external/tests/StorageConfigTest.php41
-rw-r--r--apps/files_external/tests/appSpec.js102
-rw-r--r--apps/files_external/tests/config.php25
-rwxr-xr-xapps/files_external/tests/env/start-amazons3-ceph.sh6
-rwxr-xr-xapps/files_external/tests/env/start-ftp-morrisjobke.sh6
-rwxr-xr-xapps/files_external/tests/env/start-sftp-atmoz.sh6
-rwxr-xr-xapps/files_external/tests/env/start-smb-linux.sh6
-rwxr-xr-xapps/files_external/tests/env/start-smb-windows.sh6
-rwxr-xr-xapps/files_external/tests/env/start-swift-ceph.sh6
-rwxr-xr-xapps/files_external/tests/env/start-webdav-apache.sh16
-rwxr-xr-xapps/files_external/tests/env/start-webdav-apachedrone.sh26
-rwxr-xr-xapps/files_external/tests/env/start-webdav-ownCloud.sh9
-rwxr-xr-xapps/files_external/tests/env/stop-amazons3-ceph.sh6
-rwxr-xr-xapps/files_external/tests/env/stop-ftp-morrisjobke.sh6
-rwxr-xr-xapps/files_external/tests/env/stop-sftp-atmoz.sh6
-rwxr-xr-xapps/files_external/tests/env/stop-smb-linux.sh6
-rwxr-xr-xapps/files_external/tests/env/stop-smb-windows.sh6
-rwxr-xr-xapps/files_external/tests/env/stop-swift-ceph.sh6
-rwxr-xr-xapps/files_external/tests/env/stop-webdav-apache.sh10
-rwxr-xr-xapps/files_external/tests/env/stop-webdav-apachedrone.sh14
-rwxr-xr-xapps/files_external/tests/env/stop-webdav-ownCloud.sh9
-rwxr-xr-xapps/files_external/tests/env/wait-for-connection5
-rw-r--r--apps/files_external/tests/js/mountsfilelistSpec.js166
-rw-r--r--apps/files_external/tests/js/settingsSpec.js471
-rw-r--r--apps/files_external/tests/sso-setup/apps.config.php18
-rwxr-xr-xapps/files_external/tests/sso-setup/client-cmd.sh4
-rwxr-xr-xapps/files_external/tests/sso-setup/setup-sso-nc.sh5
-rwxr-xr-xapps/files_external/tests/sso-setup/start-apache.sh8
-rwxr-xr-xapps/files_external/tests/sso-setup/start-dc.sh5
-rwxr-xr-xapps/files_external/tests/sso-setup/test-sso-smb.sh12
67 files changed, 852 insertions, 2382 deletions
diff --git a/apps/files_external/tests/Auth/AuthMechanismTest.php b/apps/files_external/tests/Auth/AuthMechanismTest.php
index 7e1d2a84ae4..e999cecf181 100644
--- a/apps/files_external/tests/Auth/AuthMechanismTest.php
+++ b/apps/files_external/tests/Auth/AuthMechanismTest.php
@@ -1,24 +1,10 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Auth;
@@ -27,9 +13,9 @@ use OCA\Files_External\Lib\Backend\Backend;
use OCA\Files_External\Lib\StorageConfig;
class AuthMechanismTest extends \Test\TestCase {
- public function testJsonSerialization() {
+ public function testJsonSerialization(): void {
$mechanism = $this->getMockBuilder(AuthMechanism::class)
- ->setMethods(['jsonSerializeDefinition'])
+ ->onlyMethods(['jsonSerializeDefinition'])
->getMock();
$mechanism->expects($this->once())
->method('jsonSerializeDefinition')
@@ -42,7 +28,7 @@ class AuthMechanismTest extends \Test\TestCase {
$this->assertEquals('scheme', $json['scheme']);
}
- public function validateStorageProvider() {
+ public static function validateStorageProvider(): array {
return [
[true, 'scheme', true],
[false, 'scheme', false],
@@ -51,12 +37,10 @@ class AuthMechanismTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider validateStorageProvider
- */
- public function testValidateStorage($expectedSuccess, $scheme, $definitionSuccess) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('validateStorageProvider')]
+ public function testValidateStorage(bool $expectedSuccess, string $scheme, bool $definitionSuccess): void {
$mechanism = $this->getMockBuilder(AuthMechanism::class)
- ->setMethods(['validateStorageDefinition'])
+ ->onlyMethods(['validateStorageDefinition'])
->getMock();
$mechanism->expects($this->atMost(1))
->method('validateStorageDefinition')
@@ -64,16 +48,12 @@ class AuthMechanismTest extends \Test\TestCase {
$mechanism->setScheme($scheme);
- $backend = $this->getMockBuilder(Backend::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $backend = $this->createMock(Backend::class);
$backend->expects($this->once())
->method('getAuthSchemes')
->willReturn(['scheme' => true, 'foobar' => true]);
- $storageConfig = $this->getMockBuilder(StorageConfig::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $storageConfig = $this->createMock(StorageConfig::class);
$storageConfig->expects($this->once())
->method('getBackend')
->willReturn($backend);
diff --git a/apps/files_external/tests/Auth/Password/GlobalAuth.php b/apps/files_external/tests/Auth/Password/GlobalAuthTest.php
index 611efd3a8eb..6d83655403e 100644
--- a/apps/files_external/tests/Auth/Password/GlobalAuth.php
+++ b/apps/files_external/tests/Auth/Password/GlobalAuthTest.php
@@ -1,50 +1,25 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Auth\Password;
use OCA\Files_External\Lib\Auth\Password\GlobalAuth;
-use OCA\Files_external\Lib\StorageConfig;
+use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
+use OCA\Files_External\Lib\StorageConfig;
use OCP\IL10N;
use OCP\Security\ICredentialsManager;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class GlobalAuthTest extends TestCase {
- /**
- * @var \OCP\IL10N|\PHPUnit\Framework\MockObject\MockObject
- */
- private $l10n;
-
- /**
- * @var \OCP\Security\ICredentialsManager|\PHPUnit\Framework\MockObject\MockObject
- */
- private $credentialsManager;
-
- /**
- * @var GlobalAuth
- */
- private $instance;
+ private IL10N&MockObject $l10n;
+ private ICredentialsManager&MockObject $credentialsManager;
+ private GlobalAuth $instance;
protected function setUp(): void {
parent::setUp();
@@ -54,7 +29,7 @@ class GlobalAuthTest extends TestCase {
}
private function getStorageConfig($type, $config = []) {
- /** @var \OCA\Files_External\Lib\StorageConfig|\PHPUnit\Framework\MockObject\MockObject $storageConfig */
+ /** @var StorageConfig&MockObject $storageConfig */
$storageConfig = $this->createMock(StorageConfig::class);
$storageConfig->expects($this->any())
->method('getType')
@@ -71,14 +46,14 @@ class GlobalAuthTest extends TestCase {
});
$storageConfig->expects($this->any())
->method('setBackendOption')
- ->willReturnCallback(function ($key, $value) use (&$config) {
+ ->willReturnCallback(function ($key, $value) use (&$config): void {
$config[$key] = $value;
});
return $storageConfig;
}
- public function testNoCredentials() {
+ public function testNoCredentials(): void {
$this->credentialsManager->expects($this->once())
->method('retrieve')
->willReturn(null);
@@ -89,7 +64,7 @@ class GlobalAuthTest extends TestCase {
$this->assertEquals([], $storage->getBackendOptions());
}
- public function testSavedCredentials() {
+ public function testSavedCredentials(): void {
$this->credentialsManager->expects($this->once())
->method('retrieve')
->willReturn([
@@ -107,13 +82,13 @@ class GlobalAuthTest extends TestCase {
}
- public function testNoCredentialsPersonal() {
- $this->expectException(\OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException::class);
+ public function testNoCredentialsPersonal(): void {
+ $this->expectException(InsufficientDataForMeaningfulAnswerException::class);
$this->credentialsManager->expects($this->never())
->method('retrieve');
- $storage = $this->getStorageConfig(StorageConfig::MOUNT_TYPE_PERSONAl);
+ $storage = $this->getStorageConfig(StorageConfig::MOUNT_TYPE_PERSONAL);
$this->instance->manipulateStorageConfig($storage);
$this->assertEquals([], $storage->getBackendOptions());
diff --git a/apps/files_external/tests/Backend/BackendTest.php b/apps/files_external/tests/Backend/BackendTest.php
index 066aab0ff31..1653c354e16 100644
--- a/apps/files_external/tests/Backend/BackendTest.php
+++ b/apps/files_external/tests/Backend/BackendTest.php
@@ -1,26 +1,10 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Backend;
@@ -28,9 +12,9 @@ use OCA\Files_External\Lib\Backend\Backend;
use OCA\Files_External\Lib\StorageConfig;
class BackendTest extends \Test\TestCase {
- public function testJsonSerialization() {
+ public function testJsonSerialization(): void {
$backend = $this->getMockBuilder(Backend::class)
- ->setMethods(['jsonSerializeDefinition'])
+ ->onlyMethods(['jsonSerializeDefinition'])
->getMock();
$backend->expects($this->once())
->method('jsonSerializeDefinition')
@@ -50,19 +34,17 @@ class BackendTest extends \Test\TestCase {
$this->assertContains('barauth', array_keys($json['authSchemes']));
}
- public function validateStorageProvider() {
+ public static function validateStorageProvider(): array {
return [
[true, true],
[false, false],
];
}
- /**
- * @dataProvider validateStorageProvider
- */
- public function testValidateStorage($expectedSuccess, $definitionSuccess) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('validateStorageProvider')]
+ public function testValidateStorage(bool $expectedSuccess, bool $definitionSuccess): void {
$backend = $this->getMockBuilder(Backend::class)
- ->setMethods(['validateStorageDefinition'])
+ ->onlyMethods(['validateStorageDefinition'])
->getMock();
$backend->expects($this->atMost(1))
->method('validateStorageDefinition')
@@ -75,7 +57,7 @@ class BackendTest extends \Test\TestCase {
$this->assertEquals($expectedSuccess, $backend->validateStorage($storageConfig));
}
- public function testLegacyAuthMechanismCallback() {
+ public function testLegacyAuthMechanismCallback(): void {
$backend = new Backend();
$backend->setLegacyAuthMechanismCallback(function (array $params) {
if (isset($params['ping'])) {
diff --git a/apps/files_external/tests/Backend/LegacyBackendTest.php b/apps/files_external/tests/Backend/LegacyBackendTest.php
index 2a69ab9e355..c4ddfedf6e2 100644
--- a/apps/files_external/tests/Backend/LegacyBackendTest.php
+++ b/apps/files_external/tests/Backend/LegacyBackendTest.php
@@ -1,27 +1,13 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Backend;
+use OCA\Files_External\Lib\Auth\Builtin;
use OCA\Files_External\Lib\Backend\LegacyBackend;
use OCA\Files_External\Lib\DefinitionParameter;
use OCA\Files_External\Lib\MissingDependency;
@@ -31,24 +17,21 @@ class LegacyBackendTest extends \Test\TestCase {
/**
* @return MissingDependency[]
*/
- public static function checkDependencies() {
+ public static function checkDependencies(): array {
return [
(new MissingDependency('abc'))->setMessage('foobar')
];
}
- public function testConstructor() {
- $auth = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\Builtin')
- ->disableOriginalConstructor()
- ->getMock();
+ public function testConstructor(): void {
+ $auth = $this->createMock(Builtin::class);
- $class = '\OCA\Files_External\Tests\Backend\LegacyBackendTest';
+ $class = self::class;
$definition = [
'configuration' => [
'textfield' => 'Text field',
'passwordfield' => '*Password field',
'checkbox' => '!Checkbox',
- 'hiddenfield' => '#Hidden field',
'optionaltext' => '&Optional text field',
'optionalpassword' => '&*Optional password field',
],
@@ -60,7 +43,7 @@ class LegacyBackendTest extends \Test\TestCase {
$backend = new LegacyBackend($class, $definition, $auth);
- $this->assertEquals('\OCA\Files_External\Tests\Backend\LegacyBackendTest', $backend->getStorageClass());
+ $this->assertEquals(self::class, $backend->getStorageClass());
$this->assertEquals('Backend text', $backend->getText());
$this->assertEquals(123, $backend->getPriority());
$this->assertContains('foo/bar.js', $backend->getCustomJs());
@@ -82,9 +65,6 @@ class LegacyBackendTest extends \Test\TestCase {
$this->assertEquals('Checkbox', $parameters['checkbox']->getText());
$this->assertEquals(DefinitionParameter::VALUE_BOOLEAN, $parameters['checkbox']->getType());
$this->assertEquals(DefinitionParameter::FLAG_NONE, $parameters['checkbox']->getFlags());
- $this->assertEquals('Hidden field', $parameters['hiddenfield']->getText());
- $this->assertEquals(DefinitionParameter::VALUE_HIDDEN, $parameters['hiddenfield']->getType());
- $this->assertEquals(DefinitionParameter::FLAG_NONE, $parameters['hiddenfield']->getFlags());
$this->assertEquals('Optional text field', $parameters['optionaltext']->getText());
$this->assertEquals(DefinitionParameter::VALUE_TEXT, $parameters['optionaltext']->getType());
$this->assertEquals(DefinitionParameter::FLAG_OPTIONAL, $parameters['optionaltext']->getFlags());
@@ -93,12 +73,10 @@ class LegacyBackendTest extends \Test\TestCase {
$this->assertEquals(DefinitionParameter::FLAG_OPTIONAL, $parameters['optionalpassword']->getFlags());
}
- public function testNoDependencies() {
- $auth = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\Builtin')
- ->disableOriginalConstructor()
- ->getMock();
+ public function testNoDependencies(): void {
+ $auth = $this->createMock(Builtin::class);
- $class = '\OCA\Files_External\Tests\Backend\LegacyBackendTest';
+ $class = self::class;
$definition = [
'configuration' => [
],
diff --git a/apps/files_external/tests/Command/ApplicableTest.php b/apps/files_external/tests/Command/ApplicableTest.php
index fb4326354fa..59db18a42de 100644
--- a/apps/files_external/tests/Command/ApplicableTest.php
+++ b/apps/files_external/tests/Command/ApplicableTest.php
@@ -1,38 +1,23 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Command;
use OCA\Files_External\Command\Applicable;
use OCP\IGroupManager;
use OCP\IUserManager;
+use PHPUnit\Framework\MockObject\MockObject;
-class ApplicableTest extends CommandTest {
- private function getInstance($storageService) {
- /** @var \OCP\IUserManager|\PHPUnit\Framework\MockObject\MockObject $userManager */
+class ApplicableTest extends CommandTestCase {
+ private function getInstance($storageService): Applicable {
+ /** @var IUserManager&MockObject $userManager */
$userManager = $this->createMock(IUserManager::class);
- /** @var \OCP\IGroupManager|\PHPUnit\Framework\MockObject\MockObject $groupManager */
+ /** @var IGroupManager&MockObject $groupManager */
$groupManager = $this->createMock(IGroupManager::class);
$userManager->expects($this->any())
@@ -46,7 +31,7 @@ class ApplicableTest extends CommandTest {
return new Applicable($storageService, $userManager, $groupManager);
}
- public function testListEmpty() {
+ public function testListEmpty(): void {
$mount = $this->getMount(1, '', '');
$storageService = $this->getGlobalStorageService([$mount]);
@@ -63,7 +48,7 @@ class ApplicableTest extends CommandTest {
$this->assertEquals(['users' => [], 'groups' => []], $result);
}
- public function testList() {
+ public function testList(): void {
$mount = $this->getMount(1, '', '', '', [], [], ['test', 'asd']);
$storageService = $this->getGlobalStorageService([$mount]);
@@ -80,7 +65,7 @@ class ApplicableTest extends CommandTest {
$this->assertEquals(['users' => ['test', 'asd'], 'groups' => []], $result);
}
- public function testAddSingle() {
+ public function testAddSingle(): void {
$mount = $this->getMount(1, '', '', '', [], [], []);
$storageService = $this->getGlobalStorageService([$mount]);
@@ -98,7 +83,7 @@ class ApplicableTest extends CommandTest {
$this->assertEquals(['foo'], $mount->getApplicableUsers());
}
- public function testAddDuplicate() {
+ public function testAddDuplicate(): void {
$mount = $this->getMount(1, '', '', '', [], [], ['foo']);
$storageService = $this->getGlobalStorageService([$mount]);
@@ -116,7 +101,7 @@ class ApplicableTest extends CommandTest {
$this->assertEquals(['foo', 'bar'], $mount->getApplicableUsers());
}
- public function testRemoveSingle() {
+ public function testRemoveSingle(): void {
$mount = $this->getMount(1, '', '', '', [], [], ['foo', 'bar']);
$storageService = $this->getGlobalStorageService([$mount]);
@@ -134,7 +119,7 @@ class ApplicableTest extends CommandTest {
$this->assertEquals(['foo'], $mount->getApplicableUsers());
}
- public function testRemoveNonExisting() {
+ public function testRemoveNonExisting(): void {
$mount = $this->getMount(1, '', '', '', [], [], ['foo', 'bar']);
$storageService = $this->getGlobalStorageService([$mount]);
@@ -152,7 +137,7 @@ class ApplicableTest extends CommandTest {
$this->assertEquals(['foo'], $mount->getApplicableUsers());
}
- public function testRemoveAddRemove() {
+ public function testRemoveAddRemove(): void {
$mount = $this->getMount(1, '', '', '', [], [], ['foo', 'bar']);
$storageService = $this->getGlobalStorageService([$mount]);
diff --git a/apps/files_external/tests/Command/CommandTest.php b/apps/files_external/tests/Command/CommandTestCase.php
index 952ca2a0307..e42ad9cd68a 100644
--- a/apps/files_external/tests/Command/CommandTest.php
+++ b/apps/files_external/tests/Command/CommandTestCase.php
@@ -1,46 +1,29 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Command;
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\NotFoundException;
+use OCA\Files_External\Service\GlobalStoragesService;
+use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\Input;
use Symfony\Component\Console\Output\BufferedOutput;
use Test\TestCase;
-abstract class CommandTest extends TestCase {
+abstract class CommandTestCase extends TestCase {
/**
* @param StorageConfig[] $mounts
- * @return \OCA\Files_External\Service\GlobalStoragesService|\PHPUnit\Framework\MockObject\MockObject
+ * @return GlobalStoragesService&MockObject
*/
protected function getGlobalStorageService(array $mounts = []) {
- $mock = $this->getMockBuilder('OCA\Files_External\Service\GlobalStoragesService')
- ->disableOriginalConstructor()
- ->getMock();
+ $mock = $this->createMock(GlobalStoragesService::class);
$this->bindMounts($mock, $mounts);
@@ -48,10 +31,10 @@ abstract class CommandTest extends TestCase {
}
/**
- * @param \PHPUnit\Framework\MockObject\MockObject $mock
+ * @param MockObject $mock
* @param StorageConfig[] $mounts
*/
- protected function bindMounts(\PHPUnit\Framework\MockObject\MockObject $mock, array $mounts) {
+ protected function bindMounts(MockObject $mock, array $mounts) {
$mock->expects($this->any())
->method('getStorage')
->willReturnCallback(function ($id) use ($mounts) {
@@ -87,7 +70,7 @@ abstract class CommandTest extends TestCase {
return $mount;
}
- protected function getInput(Command $command, array $arguments = [], array $options = []) {
+ protected function getInput(Command $command, array $arguments = [], array $options = []): ArrayInput {
$input = new ArrayInput([]);
$input->bind($command->getDefinition());
foreach ($arguments as $key => $value) {
@@ -99,7 +82,7 @@ abstract class CommandTest extends TestCase {
return $input;
}
- protected function executeCommand(Command $command, Input $input) {
+ protected function executeCommand(Command $command, Input $input): string {
$output = new BufferedOutput();
$this->invokePrivate($command, 'execute', [$input, $output]);
return $output->fetch();
diff --git a/apps/files_external/tests/Command/ListCommandTest.php b/apps/files_external/tests/Command/ListCommandTest.php
index e9cd3496d71..5b84e500e3f 100644
--- a/apps/files_external/tests/Command/ListCommandTest.php
+++ b/apps/files_external/tests/Command/ListCommandTest.php
@@ -1,28 +1,10 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Command;
@@ -36,33 +18,27 @@ use OCA\Files_External\Service\GlobalStoragesService;
use OCA\Files_External\Service\UserStoragesService;
use OCP\Authentication\LoginCredentials\IStore;
use OCP\IL10N;
-use OCP\ISession;
use OCP\IUserManager;
use OCP\IUserSession;
-use OCP\Security\ICrypto;
+use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\Console\Output\BufferedOutput;
-class ListCommandTest extends CommandTest {
- /**
- * @return ListCommand|\PHPUnit\Framework\MockObject\MockObject
- */
- private function getInstance() {
- /** @var GlobalStoragesService|\PHPUnit\Framework\MockObject\MockObject $globalService */
+class ListCommandTest extends CommandTestCase {
+ private function getInstance(): ListCommand {
+ /** @var GlobalStoragesService&MockObject $globalService */
$globalService = $this->createMock(GlobalStoragesService::class);
- /** @var UserStoragesService|\PHPUnit\Framework\MockObject\MockObject $userService */
+ /** @var UserStoragesService&MockObject $userService */
$userService = $this->createMock(UserStoragesService::class);
- /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject $userManager */
+ /** @var IUserManager&MockObject $userManager */
$userManager = $this->createMock(IUserManager::class);
- /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject $userSession */
+ /** @var IUserSession&MockObject $userSession */
$userSession = $this->createMock(IUserSession::class);
return new ListCommand($globalService, $userService, $userSession, $userManager);
}
- public function testListAuthIdentifier() {
+ public function testListAuthIdentifier(): void {
$l10n = $this->createMock(IL10N::class);
- $session = $this->createMock(ISession::class);
- $crypto = $this->createMock(ICrypto::class);
$instance = $this->getInstance();
$mount1 = new StorageConfig();
$mount1->setAuthMechanism(new Password($l10n));
diff --git a/apps/files_external/tests/Config/UserPlaceholderHandlerTest.php b/apps/files_external/tests/Config/UserPlaceholderHandlerTest.php
index 48474a82331..13d25ce5075 100644
--- a/apps/files_external/tests/Config/UserPlaceholderHandlerTest.php
+++ b/apps/files_external/tests/Config/UserPlaceholderHandlerTest.php
@@ -1,29 +1,11 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Julius Härtl <jus@bitgrid.net>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
-namespace OCA\files_external\tests\Config;
+namespace OCA\Files_External\Tests\Config;
use OCA\Files_External\Config\UserPlaceholderHandler;
use OCP\IRequest;
@@ -32,25 +14,15 @@ use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager;
+use PHPUnit\Framework\MockObject\MockObject;
class UserPlaceholderHandlerTest extends \Test\TestCase {
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject */
- protected $user;
-
- /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
- protected $session;
-
- /** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
- private $shareManager;
-
- /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
- private $request;
-
- /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
- private $userManager;
-
- /** @var UserPlaceholderHandler */
- protected $handler;
+ protected IUser&MockObject $user;
+ protected IUserSession&MockObject $session;
+ protected IManager&MockObject $shareManager;
+ protected IRequest&MockObject $request;
+ protected IUserManager&MockObject $userManager;
+ protected UserPlaceholderHandler $handler;
protected function setUp(): void {
parent::setUp();
@@ -67,13 +39,13 @@ class UserPlaceholderHandlerTest extends \Test\TestCase {
$this->handler = new UserPlaceholderHandler($this->session, $this->shareManager, $this->request, $this->userManager);
}
- protected function setUser() {
+ protected function setUser(): void {
$this->session->expects($this->any())
->method('getUser')
->willReturn($this->user);
}
- public function optionProvider() {
+ public static function optionProvider(): array {
return [
['/foo/bar/$user/foobar', '/foo/bar/alice/foobar'],
[['/foo/bar/$user/foobar'], ['/foo/bar/alice/foobar']],
@@ -81,18 +53,14 @@ class UserPlaceholderHandlerTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider optionProvider
- */
- public function testHandle($option, $expected) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('optionProvider')]
+ public function testHandle(string|array $option, string|array $expected): void {
$this->setUser();
$this->assertSame($expected, $this->handler->handle($option));
}
- /**
- * @dataProvider optionProvider
- */
- public function testHandleNoUser($option) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('optionProvider')]
+ public function testHandleNoUser(string|array $option): void {
$this->shareManager->expects($this->once())
->method('getShareByToken')
->willThrowException(new ShareNotFound());
diff --git a/apps/files_external/tests/Controller/AjaxControllerTest.php b/apps/files_external/tests/Controller/AjaxControllerTest.php
index 304a1807931..b1ea7a2b1b1 100644
--- a/apps/files_external/tests/Controller/AjaxControllerTest.php
+++ b/apps/files_external/tests/Controller/AjaxControllerTest.php
@@ -1,26 +1,9 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Files_External\Tests\Controller;
@@ -29,35 +12,29 @@ use OCA\Files_External\Lib\Auth\Password\GlobalAuth;
use OCA\Files_External\Lib\Auth\PublicKey\RSA;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IGroupManager;
+use OCP\IL10N;
use OCP\IRequest;
use OCP\IUser;
use OCP\IUserSession;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class AjaxControllerTest extends TestCase {
- /** @var IRequest */
- private $request;
- /** @var RSA */
- private $rsa;
- /** @var GlobalAuth */
- private $globalAuth;
- /** @var IUserSession */
- private $userSession;
- /** @var IGroupManager */
- private $groupManager;
- /** @var AjaxController */
- private $ajaxController;
+ private IRequest&MockObject $request;
+ private RSA&MockObject $rsa;
+ private GlobalAuth&MockObject $globalAuth;
+ private IUserSession&MockObject $userSession;
+ private IGroupManager&MockObject $groupManager;
+ private IL10N&MockObject $l10n;
+ private AjaxController $ajaxController;
protected function setUp(): void {
$this->request = $this->createMock(IRequest::class);
- $this->rsa = $this->getMockBuilder('\\OCA\\Files_External\\Lib\\Auth\\PublicKey\\RSA')
- ->disableOriginalConstructor()
- ->getMock();
- $this->globalAuth = $this->getMockBuilder('\\OCA\\Files_External\\Lib\\Auth\\Password\GlobalAuth')
- ->disableOriginalConstructor()
- ->getMock();
+ $this->rsa = $this->createMock(RSA::class);
+ $this->globalAuth = $this->createMock(GlobalAuth::class);
$this->userSession = $this->createMock(IUserSession::class);
$this->groupManager = $this->createMock(IGroupManager::class);
+ $this->l10n = $this->createMock(IL10N::class);
$this->ajaxController = new AjaxController(
'files_external',
@@ -65,13 +42,23 @@ class AjaxControllerTest extends TestCase {
$this->rsa,
$this->globalAuth,
$this->userSession,
- $this->groupManager
+ $this->groupManager,
+ $this->l10n,
);
+ $this->l10n->expects($this->any())
+ ->method('t')
+ ->willReturnCallback(function ($string, $args) {
+ if (!is_array($args)) {
+ $args = [$args];
+ }
+ return vsprintf($string, $args);
+ });
+
parent::setUp();
}
- public function testGetSshKeys() {
+ public function testGetSshKeys(): void {
$this->rsa
->expects($this->once())
->method('createKey')
@@ -92,7 +79,7 @@ class AjaxControllerTest extends TestCase {
$this->assertEquals($expected, $this->ajaxController->getSshKeys());
}
- public function testSaveGlobalCredentialsAsAdminForAnotherUser() {
+ public function testSaveGlobalCredentialsAsAdminForAnotherUser(): void {
$user = $this->createMock(IUser::class);
$user
->expects($this->once())
@@ -106,10 +93,12 @@ class AjaxControllerTest extends TestCase {
->expects($this->never())
->method('saveAuth');
- $this->assertSame(false, $this->ajaxController->saveGlobalCredentials('UidOfTestUser', 'test', 'password'));
+ $response = $this->ajaxController->saveGlobalCredentials('UidOfTestUser', 'test', 'password');
+ $this->assertSame($response->getStatus(), 403);
+ $this->assertSame('Permission denied', $response->getData()['message']);
}
- public function testSaveGlobalCredentialsAsAdminForSelf() {
+ public function testSaveGlobalCredentialsAsAdminForSelf(): void {
$user = $this->createMock(IUser::class);
$user
->expects($this->once())
@@ -124,10 +113,11 @@ class AjaxControllerTest extends TestCase {
->method('saveAuth')
->with('MyAdminUid', 'test', 'password');
- $this->assertSame(true, $this->ajaxController->saveGlobalCredentials('MyAdminUid', 'test', 'password'));
+ $response = $this->ajaxController->saveGlobalCredentials('MyAdminUid', 'test', 'password');
+ $this->assertSame($response->getStatus(), 200);
}
- public function testSaveGlobalCredentialsAsNormalUserForSelf() {
+ public function testSaveGlobalCredentialsAsNormalUserForSelf(): void {
$user = $this->createMock(IUser::class);
$user
->method('getUID')
@@ -139,10 +129,11 @@ class AjaxControllerTest extends TestCase {
->method('saveAuth')
->with('MyUserUid', 'test', 'password');
- $this->assertSame(true, $this->ajaxController->saveGlobalCredentials('MyUserUid', 'test', 'password'));
+ $response = $this->ajaxController->saveGlobalCredentials('MyUserUid', 'test', 'password');
+ $this->assertSame($response->getStatus(), 200);
}
- public function testSaveGlobalCredentialsAsNormalUserForAnotherUser() {
+ public function testSaveGlobalCredentialsAsNormalUserForAnotherUser(): void {
$user = $this->createMock(IUser::class);
$user
->method('getUID')
@@ -154,6 +145,8 @@ class AjaxControllerTest extends TestCase {
->expects($this->never())
->method('saveAuth');
- $this->assertSame(false, $this->ajaxController->saveGlobalCredentials('AnotherUserUid', 'test', 'password'));
+ $response = $this->ajaxController->saveGlobalCredentials('AnotherUserUid', 'test', 'password');
+ $this->assertSame($response->getStatus(), 403);
+ $this->assertSame('Permission denied', $response->getData()['message']);
}
}
diff --git a/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php b/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php
index a3c1a7b0dae..74a27eb15e4 100644
--- a/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php
+++ b/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php
@@ -1,33 +1,16 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Joas Schilling <coding@schilljs.com>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Controller;
use OC\User\User;
use OCA\Files_External\Controller\GlobalStoragesController;
use OCA\Files_External\Service\BackendService;
+use OCA\Files_External\Service\GlobalStoragesService;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IGroupManager;
@@ -36,13 +19,11 @@ use OCP\IRequest;
use OCP\IUserSession;
use Psr\Log\LoggerInterface;
-class GlobalStoragesControllerTest extends StoragesControllerTest {
+class GlobalStoragesControllerTest extends StoragesControllerTestCase {
protected function setUp(): void {
parent::setUp();
- $this->service = $this->getMockBuilder('\OCA\Files_External\Service\GlobalStoragesService')
- ->disableOriginalConstructor()
- ->getMock();
+ $this->service = $this->createMock(GlobalStoragesService::class);
$this->service->method('getVisibilityType')
->willReturn(BackendService::VISIBILITY_ADMIN);
@@ -50,7 +31,7 @@ class GlobalStoragesControllerTest extends StoragesControllerTest {
$this->controller = $this->createController(true);
}
- private function createController($allowCreateLocal = true) {
+ private function createController(bool $allowCreateLocal = true): GlobalStoragesController {
$session = $this->createMock(IUserSession::class);
$session->method('getUser')
->willReturn(new User('test', null, $this->createMock(IEventDispatcher::class)));
@@ -72,7 +53,7 @@ class GlobalStoragesControllerTest extends StoragesControllerTest {
);
}
- public function testAddLocalStorageWhenDisabled() {
+ public function testAddLocalStorageWhenDisabled(): void {
$this->controller = $this->createController(false);
parent::testAddLocalStorageWhenDisabled();
}
diff --git a/apps/files_external/tests/Controller/StoragesControllerTest.php b/apps/files_external/tests/Controller/StoragesControllerTestCase.php
index fdaf6e2261f..1eb52f9b459 100644
--- a/apps/files_external/tests/Controller/StoragesControllerTest.php
+++ b/apps/files_external/tests/Controller/StoragesControllerTestCase.php
@@ -1,97 +1,71 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Controller;
use OCA\Files_External\Controller\GlobalStoragesController;
+use OCA\Files_External\Controller\UserStoragesController;
use OCA\Files_External\Lib\Auth\AuthMechanism;
+use OCA\Files_External\Lib\Auth\NullMechanism;
use OCA\Files_External\Lib\Backend\Backend;
-
+use OCA\Files_External\Lib\Backend\SMB;
use OCA\Files_External\Lib\StorageConfig;
+use OCA\Files_External\MountConfig;
use OCA\Files_External\NotFoundException;
use OCA\Files_External\Service\GlobalStoragesService;
use OCA\Files_External\Service\UserStoragesService;
use OCP\AppFramework\Http;
use PHPUnit\Framework\MockObject\MockObject;
-abstract class StoragesControllerTest extends \Test\TestCase {
-
- /**
- * @var GlobalStoragesController
- */
- protected $controller;
-
- /**
- * @var GlobalStoragesService|UserStoragesService|MockObject
- */
- protected $service;
+abstract class StoragesControllerTestCase extends \Test\TestCase {
+ protected GlobalStoragesController|UserStoragesController $controller;
+ protected GlobalStoragesService|UserStoragesService|MockObject $service;
protected function setUp(): void {
- \OCA\Files_External\MountConfig::$skipTest = true;
+ parent::setUp();
+ MountConfig::$skipTest = true;
}
protected function tearDown(): void {
- \OCA\Files_External\MountConfig::$skipTest = false;
+ MountConfig::$skipTest = false;
+ parent::tearDown();
}
/**
- * @return \OCA\Files_External\Lib\Backend\Backend|MockObject
+ * @return \OCA\Files_External\Lib\Backend\Backend&MockObject
*/
- protected function getBackendMock($class = '\OCA\Files_External\Lib\Backend\SMB', $storageClass = '\OCA\Files_External\Lib\Storage\SMB') {
- $backend = $this->getMockBuilder(Backend::class)
- ->disableOriginalConstructor()
- ->getMock();
+ protected function getBackendMock($class = SMB::class, $storageClass = \OCA\Files_External\Lib\Storage\SMB::class) {
+ $backend = $this->createMock(Backend::class);
$backend->method('getStorageClass')
->willReturn($storageClass);
$backend->method('getIdentifier')
- ->willReturn('identifier:'.$class);
+ ->willReturn('identifier:' . $class);
$backend->method('getParameters')
->willReturn([]);
return $backend;
}
/**
- * @return \OCA\Files_External\Lib\Auth\AuthMechanism|MockObject
+ * @return AuthMechanism|MockObject
*/
- protected function getAuthMechMock($scheme = 'null', $class = '\OCA\Files_External\Lib\Auth\NullMechanism') {
- $authMech = $this->getMockBuilder(AuthMechanism::class)
- ->disableOriginalConstructor()
- ->getMock();
+ protected function getAuthMechMock($scheme = 'null', $class = NullMechanism::class) {
+ $authMech = $this->createMock(AuthMechanism::class);
$authMech->method('getScheme')
->willReturn($scheme);
$authMech->method('getIdentifier')
- ->willReturn('identifier:'.$class);
+ ->willReturn('identifier:' . $class);
$authMech->method('getParameters')
->willReturn([]);
return $authMech;
}
- public function testAddStorage() {
+ public function testAddStorage(): void {
$authMech = $this->getAuthMechMock();
$authMech->method('validateStorage')
->willReturn(true);
@@ -118,8 +92,8 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$response = $this->controller->create(
'mount',
- '\OCA\Files_External\Lib\Storage\SMB',
- '\OCA\Files_External\Lib\Auth\NullMechanism',
+ \OCA\Files_External\Lib\Storage\SMB::class,
+ NullMechanism::class,
[],
[],
[],
@@ -132,7 +106,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->assertEquals($storageConfig->jsonSerialize(), $data);
}
- public function testAddLocalStorageWhenDisabled() {
+ public function testAddLocalStorageWhenDisabled(): void {
$authMech = $this->getAuthMechMock();
$backend = $this->getBackendMock();
@@ -150,7 +124,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$response = $this->controller->create(
'mount',
'local',
- '\OCA\Files_External\Lib\Auth\NullMechanism',
+ NullMechanism::class,
[],
[],
[],
@@ -162,7 +136,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->assertEquals(Http::STATUS_FORBIDDEN, $response->getStatus());
}
- public function testUpdateStorage() {
+ public function testUpdateStorage(): void {
$authMech = $this->getAuthMechMock();
$authMech->method('validateStorage')
->willReturn(true);
@@ -190,8 +164,8 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$response = $this->controller->update(
1,
'mount',
- '\OCA\Files_External\Lib\Storage\SMB',
- '\OCA\Files_External\Lib\Auth\NullMechanism',
+ \OCA\Files_External\Lib\Storage\SMB::class,
+ NullMechanism::class,
[],
[],
[],
@@ -204,7 +178,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->assertEquals($storageConfig->jsonSerialize(), $data);
}
- public function mountPointNamesProvider() {
+ public static function mountPointNamesProvider(): array {
return [
[''],
['/'],
@@ -212,10 +186,8 @@ abstract class StoragesControllerTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider mountPointNamesProvider
- */
- public function testAddOrUpdateStorageInvalidMountPoint($mountPoint) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('mountPointNamesProvider')]
+ public function testAddOrUpdateStorageInvalidMountPoint($mountPoint): void {
$storageConfig = new StorageConfig(1);
$storageConfig->setMountPoint($mountPoint);
$storageConfig->setBackend($this->getBackendMock());
@@ -232,8 +204,8 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$response = $this->controller->create(
$mountPoint,
- '\OCA\Files_External\Lib\Storage\SMB',
- '\OCA\Files_External\Lib\Auth\NullMechanism',
+ \OCA\Files_External\Lib\Storage\SMB::class,
+ NullMechanism::class,
[],
[],
[],
@@ -246,8 +218,8 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$response = $this->controller->update(
1,
$mountPoint,
- '\OCA\Files_External\Lib\Storage\SMB',
- '\OCA\Files_External\Lib\Auth\NullMechanism',
+ \OCA\Files_External\Lib\Storage\SMB::class,
+ NullMechanism::class,
[],
[],
[],
@@ -258,10 +230,10 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->assertEquals(Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus());
}
- public function testAddOrUpdateStorageInvalidBackend() {
+ public function testAddOrUpdateStorageInvalidBackend(): void {
$this->service->expects($this->exactly(2))
->method('createStorage')
- ->will($this->throwException(new \InvalidArgumentException()));
+ ->willThrowException(new \InvalidArgumentException());
$this->service->expects($this->never())
->method('addStorage');
$this->service->expects($this->never())
@@ -270,7 +242,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$response = $this->controller->create(
'mount',
'\OC\Files\Storage\InvalidStorage',
- '\OCA\Files_External\Lib\Auth\NullMechanism',
+ NullMechanism::class,
[],
[],
[],
@@ -284,7 +256,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
1,
'mount',
'\OC\Files\Storage\InvalidStorage',
- '\OCA\Files_External\Lib\Auth\NullMechanism',
+ NullMechanism::class,
[],
[],
[],
@@ -295,7 +267,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->assertEquals(Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus());
}
- public function testUpdateStorageNonExisting() {
+ public function testUpdateStorageNonExisting(): void {
$authMech = $this->getAuthMechMock();
$authMech->method('validateStorage')
->willReturn(true);
@@ -318,13 +290,13 @@ abstract class StoragesControllerTest extends \Test\TestCase {
->willReturn($storageConfig);
$this->service->expects($this->once())
->method('updateStorage')
- ->will($this->throwException(new NotFoundException()));
+ ->willThrowException(new NotFoundException());
$response = $this->controller->update(
255,
'mount',
- '\OCA\Files_External\Lib\Storage\SMB',
- '\OCA\Files_External\Lib\Auth\NullMechanism',
+ \OCA\Files_External\Lib\Storage\SMB::class,
+ NullMechanism::class,
[],
[],
[],
@@ -335,7 +307,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus());
}
- public function testDeleteStorage() {
+ public function testDeleteStorage(): void {
$this->service->expects($this->once())
->method('removeStorage');
@@ -343,16 +315,16 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->assertEquals(Http::STATUS_NO_CONTENT, $response->getStatus());
}
- public function testDeleteStorageNonExisting() {
+ public function testDeleteStorageNonExisting(): void {
$this->service->expects($this->once())
->method('removeStorage')
- ->will($this->throwException(new NotFoundException()));
+ ->willThrowException(new NotFoundException());
$response = $this->controller->destroy(255);
$this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus());
}
- public function testGetStorage() {
+ public function testGetStorage(): void {
$backend = $this->getBackendMock();
$authMech = $this->getAuthMechMock();
$storageConfig = new StorageConfig(1);
@@ -374,7 +346,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$this->assertEquals($expected, $response->getData());
}
- public function validateStorageProvider() {
+ public static function validateStorageProvider(): array {
return [
[true, true, true],
[false, true, false],
@@ -383,10 +355,8 @@ abstract class StoragesControllerTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider validateStorageProvider
- */
- public function testValidateStorage($backendValidate, $authMechValidate, $expectSuccess) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('validateStorageProvider')]
+ public function testValidateStorage(bool $backendValidate, bool $authMechValidate, bool $expectSuccess): void {
$backend = $this->getBackendMock();
$backend->method('validateStorage')
->willReturn($backendValidate);
@@ -421,8 +391,8 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$response = $this->controller->create(
'mount',
- '\OCA\Files_External\Lib\Storage\SMB',
- '\OCA\Files_External\Lib\Auth\NullMechanism',
+ \OCA\Files_External\Lib\Storage\SMB::class,
+ NullMechanism::class,
[],
[],
[],
diff --git a/apps/files_external/tests/Controller/UserStoragesControllerTest.php b/apps/files_external/tests/Controller/UserStoragesControllerTest.php
index 793a90c527b..3e8d89ec060 100644
--- a/apps/files_external/tests/Controller/UserStoragesControllerTest.php
+++ b/apps/files_external/tests/Controller/UserStoragesControllerTest.php
@@ -1,35 +1,19 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Controller;
use OC\User\User;
use OCA\Files_External\Controller\UserStoragesController;
+use OCA\Files_External\Lib\Storage\SMB;
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\Service\BackendService;
+use OCA\Files_External\Service\UserStoragesService;
use OCP\AppFramework\Http;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
@@ -39,18 +23,16 @@ use OCP\IRequest;
use OCP\IUserSession;
use Psr\Log\LoggerInterface;
-class UserStoragesControllerTest extends StoragesControllerTest {
+class UserStoragesControllerTest extends StoragesControllerTestCase {
/**
* @var array
*/
- private $oldAllowedBackends;
+ private array $oldAllowedBackends;
protected function setUp(): void {
parent::setUp();
- $this->service = $this->getMockBuilder('\OCA\Files_External\Service\UserStoragesService')
- ->disableOriginalConstructor()
- ->getMock();
+ $this->service = $this->createMock(UserStoragesService::class);
$this->service->method('getVisibilityType')
->willReturn(BackendService::VISIBILITY_PERSONAL);
@@ -58,7 +40,7 @@ class UserStoragesControllerTest extends StoragesControllerTest {
$this->controller = $this->createController(true);
}
- private function createController($allowCreateLocal = true) {
+ private function createController(bool $allowCreateLocal = true) {
$session = $this->createMock(IUserSession::class);
$session->method('getUser')
->willReturn(new User('test', null, $this->createMock(IEventDispatcher::class)));
@@ -80,12 +62,12 @@ class UserStoragesControllerTest extends StoragesControllerTest {
);
}
- public function testAddLocalStorageWhenDisabled() {
+ public function testAddLocalStorageWhenDisabled(): void {
$this->controller = $this->createController(false);
parent::testAddLocalStorageWhenDisabled();
}
- public function testAddOrUpdateStorageDisallowedBackend() {
+ public function testAddOrUpdateStorageDisallowedBackend(): void {
$backend = $this->getBackendMock();
$backend->method('isVisibleFor')
->with(BackendService::VISIBILITY_PERSONAL)
@@ -108,7 +90,7 @@ class UserStoragesControllerTest extends StoragesControllerTest {
$response = $this->controller->create(
'mount',
- '\OCA\Files_External\Lib\Storage\SMB',
+ SMB::class,
'\Auth\Mechanism',
[],
[],
@@ -122,7 +104,7 @@ class UserStoragesControllerTest extends StoragesControllerTest {
$response = $this->controller->update(
1,
'mount',
- '\OCA\Files_External\Lib\Storage\SMB',
+ SMB::class,
'\Auth\Mechanism',
[],
[],
diff --git a/apps/files_external/tests/DefinitionParameterTest.php b/apps/files_external/tests/DefinitionParameterTest.php
index 04d5f6762c5..c535481bf66 100644
--- a/apps/files_external/tests/DefinitionParameterTest.php
+++ b/apps/files_external/tests/DefinitionParameterTest.php
@@ -1,32 +1,17 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests;
use OCA\Files_External\Lib\DefinitionParameter as Param;
class DefinitionParameterTest extends \Test\TestCase {
- public function testJsonSerialization() {
+ public function testJsonSerialization(): void {
$param = new Param('foo', 'bar');
$this->assertEquals([
'value' => 'bar',
@@ -55,21 +40,22 @@ class DefinitionParameterTest extends \Test\TestCase {
'tooltip' => '',
], $param->jsonSerialize());
- $param->setType(Param::VALUE_HIDDEN);
- $param->setFlags(Param::FLAG_NONE);
+ $param->setType(Param::VALUE_TEXT);
+ $param->setFlags(Param::FLAG_HIDDEN);
$this->assertEquals([
'value' => 'bar',
- 'flags' => Param::FLAG_NONE,
- 'type' => Param::VALUE_HIDDEN,
+ 'flags' => Param::FLAG_HIDDEN,
+ 'type' => Param::VALUE_TEXT,
'tooltip' => '',
], $param->jsonSerialize());
}
- public function validateValueProvider() {
+ public static function validateValueProvider(): array {
return [
[Param::VALUE_TEXT, Param::FLAG_NONE, 'abc', true],
[Param::VALUE_TEXT, Param::FLAG_NONE, '', false],
[Param::VALUE_TEXT, Param::FLAG_OPTIONAL, '', true],
+ [Param::VALUE_TEXT, Param::FLAG_HIDDEN, '', false],
[Param::VALUE_BOOLEAN, Param::FLAG_NONE, false, true],
[Param::VALUE_BOOLEAN, Param::FLAG_NONE, 123, false],
@@ -79,15 +65,11 @@ class DefinitionParameterTest extends \Test\TestCase {
[Param::VALUE_PASSWORD, Param::FLAG_NONE, 'foobar', true],
[Param::VALUE_PASSWORD, Param::FLAG_NONE, '', false],
-
- [Param::VALUE_HIDDEN, Param::FLAG_NONE, '', false]
];
}
- /**
- * @dataProvider validateValueProvider
- */
- public function testValidateValue($type, $flags, $value, $success, $expectedValue = null) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('validateValueProvider')]
+ public function testValidateValue($type, $flags, $value, $success, $expectedValue = null): void {
$param = new Param('foo', 'bar');
$param->setType($type);
$param->setFlags($flags);
diff --git a/apps/files_external/tests/FrontendDefinitionTraitTest.php b/apps/files_external/tests/FrontendDefinitionTraitTest.php
index 22593a81afa..e0bf066e70a 100644
--- a/apps/files_external/tests/FrontendDefinitionTraitTest.php
+++ b/apps/files_external/tests/FrontendDefinitionTraitTest.php
@@ -1,40 +1,24 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests;
use OCA\Files_External\Lib\DefinitionParameter;
+use OCA\Files_External\Lib\FrontendDefinitionTrait;
use OCA\Files_External\Lib\StorageConfig;
class FrontendDefinitionTraitTest extends \Test\TestCase {
- public function testJsonSerialization() {
+ public function testJsonSerialization(): void {
$param = $this->getMockBuilder(DefinitionParameter::class)
->disableOriginalConstructor()
->getMock();
$param->method('getName')->willReturn('foo');
- $trait = $this->getMockForTrait('\OCA\Files_External\Lib\FrontendDefinitionTrait');
+ $trait = $this->getMockForTrait(FrontendDefinitionTrait::class);
$trait->setText('test');
$trait->addParameters([$param]);
$trait->addCustomJs('foo/bar.js');
@@ -50,17 +34,15 @@ class FrontendDefinitionTraitTest extends \Test\TestCase {
$this->assertArrayHasKey('foo', $configuration);
}
- public function validateStorageProvider() {
+ public static function validateStorageProvider(): array {
return [
[true, ['foo' => true, 'bar' => true, 'baz' => true]],
[false, ['foo' => true, 'bar' => false]]
];
}
- /**
- * @dataProvider validateStorageProvider
- */
- public function testValidateStorage($expectedSuccess, $params) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('validateStorageProvider')]
+ public function testValidateStorage(bool $expectedSuccess, array $params): void {
$backendParams = [];
foreach ($params as $name => $valid) {
$param = $this->getMockBuilder(DefinitionParameter::class)
@@ -85,14 +67,14 @@ class FrontendDefinitionTraitTest extends \Test\TestCase {
$storageConfig->expects($this->any())
->method('setBackendOption');
- $trait = $this->getMockForTrait('\OCA\Files_External\Lib\FrontendDefinitionTrait');
+ $trait = $this->getMockForTrait(FrontendDefinitionTrait::class);
$trait->setText('test');
$trait->addParameters($backendParams);
$this->assertEquals($expectedSuccess, $trait->validateStorageDefinition($storageConfig));
}
- public function testValidateStorageSet() {
+ public function testValidateStorageSet(): void {
$param = $this->getMockBuilder(DefinitionParameter::class)
->disableOriginalConstructor()
->getMock();
@@ -116,7 +98,7 @@ class FrontendDefinitionTraitTest extends \Test\TestCase {
->method('setBackendOption')
->with('param', 'foobar');
- $trait = $this->getMockForTrait('\OCA\Files_External\Lib\FrontendDefinitionTrait');
+ $trait = $this->getMockForTrait(FrontendDefinitionTrait::class);
$trait->setText('test');
$trait->addParameter($param);
diff --git a/apps/files_external/tests/LegacyDependencyCheckPolyfillTest.php b/apps/files_external/tests/LegacyDependencyCheckPolyfillTest.php
index b905f24fb1a..d26aa752ea1 100644
--- a/apps/files_external/tests/LegacyDependencyCheckPolyfillTest.php
+++ b/apps/files_external/tests/LegacyDependencyCheckPolyfillTest.php
@@ -1,27 +1,14 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests;
+use OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
use OCA\Files_External\Lib\MissingDependency;
class LegacyDependencyCheckPolyfillTest extends \Test\TestCase {
@@ -29,18 +16,18 @@ class LegacyDependencyCheckPolyfillTest extends \Test\TestCase {
/**
* @return MissingDependency[]
*/
- public static function checkDependencies() {
+ public static function checkDependencies(): array {
return [
(new MissingDependency('dependency'))->setMessage('missing dependency'),
(new MissingDependency('program'))->setMessage('cannot find program'),
];
}
- public function testCheckDependencies() {
- $trait = $this->getMockForTrait('\OCA\Files_External\Lib\LegacyDependencyCheckPolyfill');
+ public function testCheckDependencies(): void {
+ $trait = $this->getMockForTrait(LegacyDependencyCheckPolyfill::class);
$trait->expects($this->once())
->method('getStorageClass')
- ->willReturn('\OCA\Files_External\Tests\LegacyDependencyCheckPolyfillTest');
+ ->willReturn(self::class);
$dependencies = $trait->checkDependencies();
$this->assertCount(2, $dependencies);
diff --git a/apps/files_external/tests/Listener/StorePasswordListenerTest.php b/apps/files_external/tests/Listener/StorePasswordListenerTest.php
index f6521b39410..04635b7dafd 100644
--- a/apps/files_external/tests/Listener/StorePasswordListenerTest.php
+++ b/apps/files_external/tests/Listener/StorePasswordListenerTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2023, Louis Chmn <louis@chmn.me>
- *
- * @author Louis Chmn <louis@chmn.me>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Files_External\Tests\Listener;
@@ -39,15 +22,12 @@ use Test\TestCase;
* @group DB
*/
class StorePasswordListenerTest extends TestCase {
- /** @var MockObject|IUser */
- protected $mockedUser;
+ protected IUser&MockObject $mockedUser;
protected function setUp(): void {
parent::setUp();
$this->mockedUser = $this->createMock(IUser::class);
- $this->mockedUser
- ->expects($this->any())
- ->method('getUID')
+ $this->mockedUser->method('getUID')
->willReturn('test');
}
@@ -93,7 +73,7 @@ class StorePasswordListenerTest extends TestCase {
$storePasswordListener->handle($event);
}
- public function testClassicLoginSameCredentials() {
+ public function testClassicLoginSameCredentials(): void {
$this->getMockedCredentialManager(
[
'user' => 'test',
@@ -104,7 +84,7 @@ class StorePasswordListenerTest extends TestCase {
);
}
- public function testClassicLoginNewPassword() {
+ public function testClassicLoginNewPassword(): void {
$this->getMockedCredentialManager(
[
'user' => 'test',
@@ -118,7 +98,7 @@ class StorePasswordListenerTest extends TestCase {
);
}
- public function testClassicLoginNewUser() {
+ public function testClassicLoginNewUser(): void {
$this->getMockedCredentialManager(
[
'user' => 'test',
@@ -132,7 +112,7 @@ class StorePasswordListenerTest extends TestCase {
);
}
- public function testSSOLogin() {
+ public function testSSOLogin(): void {
$this->getMockedCredentialManager(
[
'user' => 'test',
@@ -143,7 +123,7 @@ class StorePasswordListenerTest extends TestCase {
);
}
- public function testPasswordUpdated() {
+ public function testPasswordUpdated(): void {
$this->getMockedCredentialManager(
[
'user' => 'test',
@@ -157,7 +137,7 @@ class StorePasswordListenerTest extends TestCase {
);
}
- public function testUserLoginWithToken() {
+ public function testUserLoginWithToken(): void {
$this->getMockedCredentialManager(
null,
new UserLoggedInEvent($this->mockedUser, 'test', 'password', true),
@@ -165,7 +145,7 @@ class StorePasswordListenerTest extends TestCase {
);
}
- public function testNoInitialCredentials() {
+ public function testNoInitialCredentials(): void {
$this->getMockedCredentialManager(
false,
new PasswordUpdatedEvent($this->mockedUser, 'test', 'password'),
diff --git a/apps/files_external/tests/OwnCloudFunctionsTest.php b/apps/files_external/tests/OwnCloudFunctionsTest.php
index 0564fa6a727..2e052cb86b0 100644
--- a/apps/files_external/tests/OwnCloudFunctionsTest.php
+++ b/apps/files_external/tests/OwnCloudFunctionsTest.php
@@ -1,30 +1,15 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests;
+use OCA\Files_External\Lib\Storage\OwnCloud;
+
/**
* Class OwnCloudFunctions
*
@@ -33,7 +18,7 @@ namespace OCA\Files_External\Tests;
* @package OCA\Files_External\Tests
*/
class OwnCloudFunctionsTest extends \Test\TestCase {
- public function configUrlProvider() {
+ public static function configUrlProvider(): array {
return [
[
[
@@ -102,13 +87,11 @@ class OwnCloudFunctionsTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider configUrlProvider
- */
- public function testConfig($config, $expectedUri) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('configUrlProvider')]
+ public function testConfig(array $config, string $expectedUri): void {
$config['user'] = 'someuser';
$config['password'] = 'somepassword';
- $instance = new \OCA\Files_External\Lib\Storage\OwnCloud($config);
+ $instance = new OwnCloud($config);
$this->assertEquals($expectedUri, $instance->createBaseUri());
}
}
diff --git a/apps/files_external/tests/PersonalMountTest.php b/apps/files_external/tests/PersonalMountTest.php
index f2b270f087f..618048c3335 100644
--- a/apps/files_external/tests/PersonalMountTest.php
+++ b/apps/files_external/tests/PersonalMountTest.php
@@ -1,46 +1,28 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Julius Härtl <jus@bitgrid.net>
- * @author Robin Appelman <robin@icewind.nl>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests;
use OC\Files\Mount\Manager;
use OC\Files\SetupManagerFactory;
+use OC\Files\Storage\Storage;
use OCA\Files_External\Lib\PersonalMount;
use OCA\Files_External\Lib\StorageConfig;
+use OCA\Files_External\Service\UserStoragesService;
use Test\TestCase;
class PersonalMountTest extends TestCase {
- public function testFindByStorageId() {
+ public function testFindByStorageId(): void {
$storageConfig = $this->createMock(StorageConfig::class);
- /** @var \OCA\Files_External\Service\UserStoragesService $storageService */
- $storageService = $this->getMockBuilder('\OCA\Files_External\Service\UserStoragesService')
- ->disableOriginalConstructor()
- ->getMock();
-
- $storage = $this->getMockBuilder('\OC\Files\Storage\Storage')
- ->disableOriginalConstructor()
- ->getMock();
+ /** @var UserStoragesService $storageService */
+ $storageService = $this->createMock(UserStoragesService::class);
+
+ $storage = $this->createMock(Storage::class);
$storage->expects($this->any())
->method('getId')
diff --git a/apps/files_external/tests/README.md b/apps/files_external/tests/README.md
index 202ae8eee9a..4af03516860 100644
--- a/apps/files_external/tests/README.md
+++ b/apps/files_external/tests/README.md
@@ -1,3 +1,8 @@
+<!--
+ - SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ - SPDX-FileCopyrightText: 2015 ownCloud, Inc.
+ - SPDX-License-Identifier: AGPL-3.0-only
+-->
# How to run the files external unit tests
## Components
diff --git a/apps/files_external/tests/Service/BackendServiceTest.php b/apps/files_external/tests/Service/BackendServiceTest.php
index 9190b63b5d8..ef545688040 100644
--- a/apps/files_external/tests/Service/BackendServiceTest.php
+++ b/apps/files_external/tests/Service/BackendServiceTest.php
@@ -1,27 +1,9 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Service;
@@ -31,54 +13,45 @@ use OCA\Files_External\Lib\Backend\Backend;
use OCA\Files_External\Lib\Config\IAuthMechanismProvider;
use OCA\Files_External\Lib\Config\IBackendProvider;
use OCA\Files_External\Service\BackendService;
-use OCP\IConfig;
+use OCP\IAppConfig;
+use PHPUnit\Framework\MockObject\MockObject;
class BackendServiceTest extends \Test\TestCase {
-
- /** @var \OCP\IConfig|\PHPUnit\Framework\MockObject\MockObject */
- protected $config;
+ protected IAppConfig&MockObject $appConfig;
protected function setUp(): void {
- $this->config = $this->createMock(IConfig::class);
+ $this->appConfig = $this->createMock(IAppConfig::class);
}
/**
- * @param string $class
- *
- * @return \OCA\Files_External\Lib\Backend\Backend|\PHPUnit\Framework\MockObject\MockObject
+ * @return \OCA\Files_External\Lib\Backend\Backend&MockObject
*/
- protected function getBackendMock($class) {
- $backend = $this->getMockBuilder(Backend::class)
- ->disableOriginalConstructor()
- ->getMock();
- $backend->method('getIdentifier')->willReturn('identifier:'.$class);
- $backend->method('getIdentifierAliases')->willReturn(['identifier:'.$class]);
+ protected function getBackendMock(string $class) {
+ $backend = $this->createMock(Backend::class);
+ $backend->method('getIdentifier')->willReturn('identifier:' . $class);
+ $backend->method('getIdentifierAliases')->willReturn(['identifier:' . $class]);
return $backend;
}
/**
* @param string $class
*
- * @return \OCA\Files_External\Lib\Auth\AuthMechanism|\PHPUnit\Framework\MockObject\MockObject
+ * @return AuthMechanism&MockObject
*/
protected function getAuthMechanismMock($class) {
- $backend = $this->getMockBuilder(AuthMechanism::class)
- ->disableOriginalConstructor()
- ->getMock();
- $backend->method('getIdentifier')->willReturn('identifier:'.$class);
- $backend->method('getIdentifierAliases')->willReturn(['identifier:'.$class]);
+ $backend = $this->createMock(AuthMechanism::class);
+ $backend->method('getIdentifier')->willReturn('identifier:' . $class);
+ $backend->method('getIdentifierAliases')->willReturn(['identifier:' . $class]);
return $backend;
}
- public function testRegisterBackend() {
- $service = new BackendService($this->config);
+ public function testRegisterBackend(): void {
+ $service = new BackendService($this->appConfig);
$backend = $this->getBackendMock('\Foo\Bar');
- /** @var \OCA\Files_External\Lib\Backend\Backend|\PHPUnit\Framework\MockObject\MockObject $backendAlias */
- $backendAlias = $this->getMockBuilder(Backend::class)
- ->disableOriginalConstructor()
- ->getMock();
+ /** @var \OCA\Files_External\Lib\Backend\Backend&MockObject $backendAlias */
+ $backendAlias = $this->createMock(Backend::class);
$backendAlias->method('getIdentifierAliases')
->willReturn(['identifier_real', 'identifier_alias']);
$backendAlias->method('getIdentifier')
@@ -98,13 +71,13 @@ class BackendServiceTest extends \Test\TestCase {
$this->assertArrayNotHasKey('identifier_alias', $backends);
}
- public function testBackendProvider() {
- $service = new BackendService($this->config);
+ public function testBackendProvider(): void {
+ $service = new BackendService($this->appConfig);
$backend1 = $this->getBackendMock('\Foo\Bar');
$backend2 = $this->getBackendMock('\Bar\Foo');
- /** @var IBackendProvider|\PHPUnit\Framework\MockObject\MockObject $providerMock */
+ /** @var IBackendProvider&MockObject $providerMock */
$providerMock = $this->createMock(IBackendProvider::class);
$providerMock->expects($this->once())
->method('getBackends')
@@ -117,13 +90,13 @@ class BackendServiceTest extends \Test\TestCase {
$this->assertCount(2, $service->getBackends());
}
- public function testAuthMechanismProvider() {
- $service = new BackendService($this->config);
+ public function testAuthMechanismProvider(): void {
+ $service = new BackendService($this->appConfig);
$backend1 = $this->getAuthMechanismMock('\Foo\Bar');
$backend2 = $this->getAuthMechanismMock('\Bar\Foo');
- /** @var IAuthMechanismProvider|\PHPUnit\Framework\MockObject\MockObject $providerMock */
+ /** @var IAuthMechanismProvider&MockObject $providerMock */
$providerMock = $this->createMock(IAuthMechanismProvider::class);
$providerMock->expects($this->once())
->method('getAuthMechanisms')
@@ -136,21 +109,21 @@ class BackendServiceTest extends \Test\TestCase {
$this->assertCount(2, $service->getAuthMechanisms());
}
- public function testMultipleBackendProviders() {
- $service = new BackendService($this->config);
+ public function testMultipleBackendProviders(): void {
+ $service = new BackendService($this->appConfig);
$backend1a = $this->getBackendMock('\Foo\Bar');
$backend1b = $this->getBackendMock('\Bar\Foo');
$backend2 = $this->getBackendMock('\Dead\Beef');
- /** @var IBackendProvider|\PHPUnit\Framework\MockObject\MockObject $provider1Mock */
+ /** @var IBackendProvider&MockObject $provider1Mock */
$provider1Mock = $this->createMock(IBackendProvider::class);
$provider1Mock->expects($this->once())
->method('getBackends')
->willReturn([$backend1a, $backend1b]);
$service->registerBackendProvider($provider1Mock);
- /** @var IBackendProvider|\PHPUnit\Framework\MockObject\MockObject $provider2Mock */
+ /** @var IBackendProvider&MockObject $provider2Mock */
$provider2Mock = $this->createMock(IBackendProvider::class);
$provider2Mock->expects($this->once())
->method('getBackends')
@@ -164,15 +137,17 @@ class BackendServiceTest extends \Test\TestCase {
$this->assertCount(3, $service->getBackends());
}
- public function testUserMountingBackends() {
- $this->config->expects($this->exactly(2))
- ->method('getAppValue')
- ->willReturnMap([
- ['files_external', 'allow_user_mounting', 'yes', 'yes'],
- ['files_external', 'user_mounting_backends', '', 'identifier:\User\Mount\Allowed,identifier_alias']
- ]);
+ public function testUserMountingBackends(): void {
+ $this->appConfig->expects($this->once())
+ ->method('getValueString')
+ ->with('files_external', 'user_mounting_backends')
+ ->willReturn('identifier:\User\Mount\Allowed,identifier_alias');
+ $this->appConfig->expects($this->once())
+ ->method('getValueBool')
+ ->with('files_external', 'allow_user_mounting')
+ ->willReturn(true);
- $service = new BackendService($this->config);
+ $service = new BackendService($this->appConfig);
$backendAllowed = $this->getBackendMock('\User\Mount\Allowed');
$backendAllowed->expects($this->never())
@@ -195,8 +170,8 @@ class BackendServiceTest extends \Test\TestCase {
$service->registerBackend($backendAlias);
}
- public function testGetAvailableBackends() {
- $service = new BackendService($this->config);
+ public function testGetAvailableBackends(): void {
+ $service = new BackendService($this->appConfig);
$backendAvailable = $this->getBackendMock('\Backend\Available');
$backendAvailable->expects($this->once())
@@ -219,7 +194,7 @@ class BackendServiceTest extends \Test\TestCase {
$this->assertArrayNotHasKey('identifier:\Backend\NotAvailable', $availableBackends);
}
- public function invalidConfigPlaceholderProvider() {
+ public static function invalidConfigPlaceholderProvider(): array {
return [
[['@user']],
[['$user']],
@@ -233,13 +208,11 @@ class BackendServiceTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider invalidConfigPlaceholderProvider
- */
- public function testRegisterConfigHandlerInvalid(array $placeholders) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('invalidConfigPlaceholderProvider')]
+ public function testRegisterConfigHandlerInvalid(array $placeholders): void {
$this->expectException(\RuntimeException::class);
- $service = new BackendService($this->config);
+ $service = new BackendService($this->appConfig);
$mock = $this->createMock(IConfigHandler::class);
$cb = function () use ($mock) {
return $mock;
@@ -249,8 +222,8 @@ class BackendServiceTest extends \Test\TestCase {
}
}
- public function testConfigHandlers() {
- $service = new BackendService($this->config);
+ public function testConfigHandlers(): void {
+ $service = new BackendService($this->appConfig);
$mock = $this->createMock(IConfigHandler::class);
$mock->expects($this->exactly(3))
->method('handle');
diff --git a/apps/files_external/tests/Service/DBConfigServiceTest.php b/apps/files_external/tests/Service/DBConfigServiceTest.php
index f5a93435a1d..85d8b70fda7 100644
--- a/apps/files_external/tests/Service/DBConfigServiceTest.php
+++ b/apps/files_external/tests/Service/DBConfigServiceTest.php
@@ -1,52 +1,32 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Service;
use OCA\Files_External\Service\DBConfigService;
use OCP\IDBConnection;
+use OCP\Security\ICrypto;
+use OCP\Server;
use Test\TestCase;
/**
* @group DB
*/
class DBConfigServiceTest extends TestCase {
- /**
- * @var DBConfigService
- */
- private $dbConfig;
-
- /**
- * @var IDBConnection
- */
- private $connection;
+ private IDBConnection $connection;
+ private DBConfigService $dbConfig;
- private $mounts = [];
+ private array $mounts = [];
protected function setUp(): void {
parent::setUp();
- $this->connection = \OC::$server->getDatabaseConnection();
- $this->dbConfig = new DBConfigService($this->connection, \OC::$server->getCrypto());
+ $this->connection = Server::get(IDBConnection::class);
+ $this->dbConfig = new DBConfigService($this->connection, Server::get(ICrypto::class));
}
protected function tearDown(): void {
@@ -54,15 +34,16 @@ class DBConfigServiceTest extends TestCase {
$this->dbConfig->removeMount($mount);
}
$this->mounts = [];
+ parent::tearDown();
}
- private function addMount($mountPoint, $storageBackend, $authBackend, $priority, $type) {
+ private function addMount(string $mountPoint, string $storageBackend, string $authBackend, int $priority, int $type) {
$id = $this->dbConfig->addMount($mountPoint, $storageBackend, $authBackend, $priority, $type);
$this->mounts[] = $id;
return $id;
}
- public function testAddSimpleMount() {
+ public function testAddSimpleMount(): void {
$id = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$mount = $this->dbConfig->getMountById($id);
@@ -76,7 +57,7 @@ class DBConfigServiceTest extends TestCase {
$this->assertEquals([], $mount['options']);
}
- public function testAddApplicable() {
+ public function testAddApplicable(): void {
$id = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$this->dbConfig->addApplicable($id, DBConfigService::APPLICABLE_TYPE_USER, 'test');
@@ -89,14 +70,14 @@ class DBConfigServiceTest extends TestCase {
$this->dbConfig->addApplicable($id, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
$mount = $this->dbConfig->getMountById($id);
- $this->assertEquals([
+ $this->assertEqualsCanonicalizing([
['type' => DBConfigService::APPLICABLE_TYPE_USER, 'value' => 'test', 'mount_id' => $id],
['type' => DBConfigService::APPLICABLE_TYPE_GROUP, 'value' => 'bar', 'mount_id' => $id],
['type' => DBConfigService::APPLICABLE_TYPE_GLOBAL, 'value' => null, 'mount_id' => $id]
], $mount['applicable']);
}
- public function testAddApplicableDouble() {
+ public function testAddApplicableDouble(): void {
$id = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$this->dbConfig->addApplicable($id, DBConfigService::APPLICABLE_TYPE_USER, 'test');
$this->dbConfig->addApplicable($id, DBConfigService::APPLICABLE_TYPE_USER, 'test');
@@ -107,7 +88,7 @@ class DBConfigServiceTest extends TestCase {
], $mount['applicable']);
}
- public function testDeleteMount() {
+ public function testDeleteMount(): void {
$id = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$this->dbConfig->removeMount($id);
@@ -116,7 +97,7 @@ class DBConfigServiceTest extends TestCase {
$this->assertEquals(null, $mount);
}
- public function testRemoveApplicable() {
+ public function testRemoveApplicable(): void {
$id = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$this->dbConfig->addApplicable($id, DBConfigService::APPLICABLE_TYPE_USER, 'test');
$this->dbConfig->removeApplicable($id, DBConfigService::APPLICABLE_TYPE_USER, 'test');
@@ -125,7 +106,7 @@ class DBConfigServiceTest extends TestCase {
$this->assertEquals([], $mount['applicable']);
}
- public function testRemoveApplicableGlobal() {
+ public function testRemoveApplicableGlobal(): void {
$id = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$this->dbConfig->addApplicable($id, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
$this->dbConfig->removeApplicable($id, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
@@ -137,7 +118,7 @@ class DBConfigServiceTest extends TestCase {
], $mount['applicable']);
}
- public function testSetConfig() {
+ public function testSetConfig(): void {
$id = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$this->dbConfig->setConfig($id, 'foo', 'bar');
@@ -150,7 +131,7 @@ class DBConfigServiceTest extends TestCase {
$this->assertEquals(['foo' => 'bar', 'foo2' => 'bar2'], $mount['config']);
}
- public function testSetConfigOverwrite() {
+ public function testSetConfigOverwrite(): void {
$id = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$this->dbConfig->setConfig($id, 'foo', 'bar');
$this->dbConfig->setConfig($id, 'asd', '1');
@@ -160,7 +141,7 @@ class DBConfigServiceTest extends TestCase {
$this->assertEquals(['foo' => 'qwerty', 'asd' => '1'], $mount['config']);
}
- public function testSetOption() {
+ public function testSetOption(): void {
$id = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$this->dbConfig->setOption($id, 'foo', 'bar');
@@ -173,7 +154,7 @@ class DBConfigServiceTest extends TestCase {
$this->assertEquals(['foo' => 'bar', 'foo2' => 'bar2'], $mount['options']);
}
- public function testSetOptionOverwrite() {
+ public function testSetOptionOverwrite(): void {
$id = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$this->dbConfig->setOption($id, 'foo', 'bar');
$this->dbConfig->setOption($id, 'asd', '1');
@@ -183,7 +164,7 @@ class DBConfigServiceTest extends TestCase {
$this->assertEquals(['foo' => 'qwerty', 'asd' => '1'], $mount['options']);
}
- public function testGetMountsFor() {
+ public function testGetMountsFor(): void {
$mounts = $this->dbConfig->getMountsFor(DBConfigService::APPLICABLE_TYPE_USER, 'test');
$this->assertEquals([], $mounts);
@@ -196,19 +177,19 @@ class DBConfigServiceTest extends TestCase {
$this->assertEquals([['type' => DBConfigService::APPLICABLE_TYPE_USER, 'value' => 'test', 'mount_id' => $id]], $mounts[0]['applicable']);
}
- public function testGetAdminMounts() {
+ public function testGetAdminMounts(): void {
$id1 = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
- $this->addMount('/test2', 'foo2', 'bar2', 100, DBConfigService::MOUNT_TYPE_PERSONAl);
+ $this->addMount('/test2', 'foo2', 'bar2', 100, DBConfigService::MOUNT_TYPE_PERSONAL);
$mounts = $this->dbConfig->getAdminMounts();
$this->assertCount(1, $mounts);
$this->assertEquals($id1, $mounts[0]['mount_id']);
}
- public function testGetAdminMountsFor() {
+ public function testGetAdminMountsFor(): void {
$id1 = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$this->addMount('/test2', 'foo2', 'bar2', 100, DBConfigService::MOUNT_TYPE_ADMIN);
- $id3 = $this->addMount('/test3', 'foo3', 'bar3', 100, DBConfigService::MOUNT_TYPE_PERSONAl);
+ $id3 = $this->addMount('/test3', 'foo3', 'bar3', 100, DBConfigService::MOUNT_TYPE_PERSONAL);
$this->dbConfig->addApplicable($id1, DBConfigService::APPLICABLE_TYPE_USER, 'test');
$this->dbConfig->addApplicable($id3, DBConfigService::APPLICABLE_TYPE_USER, 'test');
@@ -219,10 +200,10 @@ class DBConfigServiceTest extends TestCase {
$this->assertEquals([['type' => DBConfigService::APPLICABLE_TYPE_USER, 'value' => 'test', 'mount_id' => $id1]], $mounts[0]['applicable']);
}
- public function testGetUserMountsFor() {
+ public function testGetUserMountsFor(): void {
$id1 = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
- $this->addMount('/test2', 'foo2', 'bar2', 100, DBConfigService::MOUNT_TYPE_PERSONAl);
- $id3 = $this->addMount('/test3', 'foo3', 'bar3', 100, DBConfigService::MOUNT_TYPE_PERSONAl);
+ $this->addMount('/test2', 'foo2', 'bar2', 100, DBConfigService::MOUNT_TYPE_PERSONAL);
+ $id3 = $this->addMount('/test3', 'foo3', 'bar3', 100, DBConfigService::MOUNT_TYPE_PERSONAL);
$this->dbConfig->addApplicable($id1, DBConfigService::APPLICABLE_TYPE_USER, 'test');
$this->dbConfig->addApplicable($id3, DBConfigService::APPLICABLE_TYPE_USER, 'test');
@@ -233,7 +214,7 @@ class DBConfigServiceTest extends TestCase {
$this->assertEquals([['type' => DBConfigService::APPLICABLE_TYPE_USER, 'value' => 'test', 'mount_id' => $id3]], $mounts[0]['applicable']);
}
- public function testGetAdminMountsForGlobal() {
+ public function testGetAdminMountsForGlobal(): void {
$id1 = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$this->dbConfig->addApplicable($id1, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
@@ -244,7 +225,7 @@ class DBConfigServiceTest extends TestCase {
$this->assertEquals([['type' => DBConfigService::APPLICABLE_TYPE_GLOBAL, 'value' => null, 'mount_id' => $id1]], $mounts[0]['applicable']);
}
- public function testSetMountPoint() {
+ public function testSetMountPoint(): void {
$id1 = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$id2 = $this->addMount('/foo', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
@@ -258,7 +239,7 @@ class DBConfigServiceTest extends TestCase {
$this->assertEquals('/foo', $mount['mount_point']);
}
- public function testSetAuthBackend() {
+ public function testSetAuthBackend(): void {
$id1 = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$id2 = $this->addMount('/foo', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
@@ -272,7 +253,7 @@ class DBConfigServiceTest extends TestCase {
$this->assertEquals('bar', $mount['auth_backend']);
}
- public function testGetMountsForDuplicateByGroup() {
+ public function testGetMountsForDuplicateByGroup(): void {
$id1 = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$this->dbConfig->addApplicable($id1, DBConfigService::APPLICABLE_TYPE_GROUP, 'group1');
@@ -283,9 +264,9 @@ class DBConfigServiceTest extends TestCase {
$this->assertEquals($id1, $mounts[0]['mount_id']);
}
- public function testGetAllMounts() {
+ public function testGetAllMounts(): void {
$id1 = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
- $id2 = $this->addMount('/test2', 'foo2', 'bar2', 100, DBConfigService::MOUNT_TYPE_PERSONAl);
+ $id2 = $this->addMount('/test2', 'foo2', 'bar2', 100, DBConfigService::MOUNT_TYPE_PERSONAL);
$mounts = $this->dbConfig->getAllMounts();
$this->assertCount(2, $mounts);
diff --git a/apps/files_external/tests/Service/GlobalStoragesServiceTest.php b/apps/files_external/tests/Service/GlobalStoragesServiceTest.php
index 7d77ea971f3..0a3749981c8 100644
--- a/apps/files_external/tests/Service/GlobalStoragesServiceTest.php
+++ b/apps/files_external/tests/Service/GlobalStoragesServiceTest.php
@@ -1,40 +1,22 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Service;
use OC\Files\Filesystem;
+use OCA\Files_External\MountConfig;
use OCA\Files_External\Service\GlobalStoragesService;
/**
* @group DB
*/
-class GlobalStoragesServiceTest extends StoragesServiceTest {
+class GlobalStoragesServiceTest extends StoragesServiceTestCase {
protected function setUp(): void {
parent::setUp();
$this->service = new GlobalStoragesService($this->backendService, $this->dbConfig, $this->mountCache, $this->eventDispatcher);
@@ -64,7 +46,7 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
]);
}
- public function storageDataProvider() {
+ public static function storageDataProvider(): array {
return [
// all users
[
@@ -133,10 +115,8 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
];
}
- /**
- * @dataProvider storageDataProvider
- */
- public function testAddStorage($storageParams) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('storageDataProvider')]
+ public function testAddStorage($storageParams): void {
$storage = $this->makeStorageConfig($storageParams);
$newStorage = $this->service->addStorage($storage);
@@ -157,10 +137,8 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
$this->assertEquals($baseId + 1, $nextStorage->getId());
}
- /**
- * @dataProvider storageDataProvider
- */
- public function testUpdateStorage($updatedStorageParams) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('storageDataProvider')]
+ public function testUpdateStorage($updatedStorageParams): void {
$updatedStorage = $this->makeStorageConfig($updatedStorageParams);
$storage = $this->makeStorageConfig([
'mountPoint' => 'mountpoint',
@@ -186,13 +164,13 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
$this->assertEquals($updatedStorage->getMountPoint(), $newStorage->getMountPoint());
$this->assertEquals($updatedStorage->getBackendOptions()['password'], $newStorage->getBackendOptions()['password']);
- $this->assertEquals($updatedStorage->getApplicableUsers(), $newStorage->getApplicableUsers());
+ $this->assertEqualsCanonicalizing($updatedStorage->getApplicableUsers(), $newStorage->getApplicableUsers());
$this->assertEquals($updatedStorage->getApplicableGroups(), $newStorage->getApplicableGroups());
$this->assertEquals($updatedStorage->getPriority(), $newStorage->getPriority());
$this->assertEquals(0, $newStorage->getStatus());
}
- public function hooksAddStorageDataProvider() {
+ public static function hooksAddStorageDataProvider(): array {
return [
// applicable all
[
@@ -202,7 +180,7 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
[
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'all'
],
],
@@ -215,7 +193,7 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
[
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user1',
],
],
@@ -228,7 +206,7 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
[
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group1',
],
],
@@ -240,12 +218,12 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
[
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user1',
],
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user2',
],
],
@@ -258,12 +236,12 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
[
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group1'
],
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group2'
],
],
@@ -276,22 +254,22 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
[
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user1',
],
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user2',
],
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group1'
],
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group2'
],
],
@@ -299,10 +277,8 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
];
}
- /**
- * @dataProvider hooksAddStorageDataProvider
- */
- public function testHooksAddStorage($applicableUsers, $applicableGroups, $expectedCalls) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('hooksAddStorageDataProvider')]
+ public function testHooksAddStorage($applicableUsers, $applicableGroups, $expectedCalls): void {
$storage = $this->makeTestStorageData();
$storage->setApplicableUsers($applicableUsers);
$storage->setApplicableGroups($applicableGroups);
@@ -321,7 +297,7 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
}
}
- public function hooksUpdateStorageDataProvider() {
+ public static function hooksUpdateStorageDataProvider(): array {
return [
[
// nothing to multiple users and groups
@@ -334,27 +310,27 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
// delete the "all entry"
[
Filesystem::signal_delete_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'all',
],
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user1',
],
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user2',
],
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group1'
],
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group2'
],
],
@@ -369,12 +345,12 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
[
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user2',
],
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group2'
],
],
@@ -389,12 +365,12 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
[
[
Filesystem::signal_delete_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user2',
],
[
Filesystem::signal_delete_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group2'
],
],
@@ -409,18 +385,18 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
[
[
Filesystem::signal_delete_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user1',
],
[
Filesystem::signal_delete_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group1'
],
// create the "all" entry
[
Filesystem::signal_create_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'all'
],
],
@@ -437,15 +413,14 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
];
}
- /**
- * @dataProvider hooksUpdateStorageDataProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('hooksUpdateStorageDataProvider')]
public function testHooksUpdateStorage(
- $sourceApplicableUsers,
- $sourceApplicableGroups,
- $updatedApplicableUsers,
- $updatedApplicableGroups,
- $expectedCalls) {
+ array $sourceApplicableUsers,
+ array $sourceApplicableGroups,
+ array $updatedApplicableUsers,
+ array $updatedApplicableGroups,
+ array $expectedCalls,
+ ): void {
$storage = $this->makeTestStorageData();
$storage->setApplicableUsers($sourceApplicableUsers);
$storage->setApplicableGroups($sourceApplicableGroups);
@@ -473,7 +448,7 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
}
- public function testHooksRenameMountPoint() {
+ public function testHooksRenameMountPoint(): void {
$storage = $this->makeTestStorageData();
$storage->setApplicableUsers(['user1', 'user2']);
$storage->setApplicableGroups(['group1', 'group2']);
@@ -491,50 +466,50 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
[
Filesystem::signal_delete_mount,
'/mountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user1',
],
[
Filesystem::signal_delete_mount,
'/mountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user2',
],
[
Filesystem::signal_delete_mount,
'/mountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group1',
],
[
Filesystem::signal_delete_mount,
'/mountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group2',
],
// creates new one
[
Filesystem::signal_create_mount,
'/renamedMountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user1',
],
[
Filesystem::signal_create_mount,
'/renamedMountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user2',
],
[
Filesystem::signal_create_mount,
'/renamedMountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group1',
],
[
Filesystem::signal_create_mount,
'/renamedMountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group2',
],
];
@@ -552,7 +527,7 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
}
}
- public function hooksDeleteStorageDataProvider() {
+ public static function hooksDeleteStorageDataProvider(): array {
return [
[
['user1', 'user2'],
@@ -561,22 +536,22 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
[
[
Filesystem::signal_delete_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user1',
],
[
Filesystem::signal_delete_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'user2',
],
[
Filesystem::signal_delete_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group1'
],
[
Filesystem::signal_delete_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP,
+ MountConfig::MOUNT_TYPE_GROUP,
'group2'
],
],
@@ -588,7 +563,7 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
[
[
Filesystem::signal_delete_mount,
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
'all',
],
],
@@ -596,13 +571,12 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
];
}
- /**
- * @dataProvider hooksDeleteStorageDataProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('hooksDeleteStorageDataProvider')]
public function testHooksDeleteStorage(
- $sourceApplicableUsers,
- $sourceApplicableGroups,
- $expectedCalls) {
+ array $sourceApplicableUsers,
+ array $sourceApplicableGroups,
+ array $expectedCalls,
+ ): void {
$storage = $this->makeTestStorageData();
$storage->setApplicableUsers($sourceApplicableUsers);
$storage->setApplicableGroups($sourceApplicableGroups);
diff --git a/apps/files_external/tests/Service/StoragesServiceTest.php b/apps/files_external/tests/Service/StoragesServiceTestCase.php
index 4eaf70a8e84..b41eb409468 100644
--- a/apps/files_external/tests/Service/StoragesServiceTest.php
+++ b/apps/files_external/tests/Service/StoragesServiceTestCase.php
@@ -1,39 +1,23 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Service;
+use OC\Files\Cache\Storage;
use OC\Files\Filesystem;
-
use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCA\Files_External\Lib\Auth\InvalidAuth;
+use OCA\Files_External\Lib\Auth\NullMechanism;
use OCA\Files_External\Lib\Backend\Backend;
use OCA\Files_External\Lib\Backend\InvalidBackend;
+use OCA\Files_External\Lib\Backend\SMB;
use OCA\Files_External\Lib\StorageConfig;
+use OCA\Files_External\MountConfig;
use OCA\Files_External\NotFoundException;
use OCA\Files_External\Service\BackendService;
use OCA\Files_External\Service\DBConfigService;
@@ -44,10 +28,16 @@ use OCP\Files\Cache\ICache;
use OCP\Files\Config\IUserMountCache;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\Storage\IStorage;
+use OCP\IConfig;
+use OCP\IDBConnection;
use OCP\IUser;
+use OCP\Security\ICrypto;
+use OCP\Server;
+use OCP\Util;
+use PHPUnit\Framework\MockObject\MockObject;
class CleaningDBConfig extends DBConfigService {
- private $mountIds = [];
+ private array $mountIds = [];
public function addMount($mountPoint, $storageBackend, $authBackend, $priority, $type) {
$id = parent::addMount($mountPoint, $storageBackend, $authBackend, $priority, $type); // TODO: Change the autogenerated stub
@@ -65,62 +55,31 @@ class CleaningDBConfig extends DBConfigService {
/**
* @group DB
*/
-abstract class StoragesServiceTest extends \Test\TestCase {
-
- /**
- * @var StoragesService
- */
- protected $service;
-
- /** @var BackendService */
- protected $backendService;
-
- /**
- * Data directory
- *
- * @var string
- */
- protected $dataDir;
-
- /** @var CleaningDBConfig */
- protected $dbConfig;
-
- /**
- * Hook calls
- *
- * @var array
- */
- protected static $hookCalls;
-
- /**
- * @var \PHPUnit\Framework\MockObject\MockObject|\OCP\Files\Config\IUserMountCache
- */
- protected $mountCache;
-
- /**
- * @var \PHPUnit\Framework\MockObject\MockObject|IEventDispatcher
- */
- protected IEventDispatcher $eventDispatcher;
+abstract class StoragesServiceTestCase extends \Test\TestCase {
+ protected StoragesService $service;
+ protected BackendService $backendService;
+ protected string $dataDir;
+ protected CleaningDBConfig $dbConfig;
+ protected static array $hookCalls;
+ protected IUserMountCache&MockObject $mountCache;
+ protected IEventDispatcher&MockObject $eventDispatcher;
protected function setUp(): void {
parent::setUp();
- $this->dbConfig = new CleaningDBConfig(\OC::$server->getDatabaseConnection(), \OC::$server->getCrypto());
+ $this->dbConfig = new CleaningDBConfig(Server::get(IDBConnection::class), Server::get(ICrypto::class));
self::$hookCalls = [];
- $config = \OC::$server->getConfig();
+ $config = Server::get(IConfig::class);
$this->dataDir = $config->getSystemValue(
'datadirectory',
\OC::$SERVERROOT . '/data/'
);
- \OCA\Files_External\MountConfig::$skipTest = true;
+ MountConfig::$skipTest = true;
$this->mountCache = $this->createMock(IUserMountCache::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
// prepare BackendService mock
- $this->backendService =
- $this->getMockBuilder('\OCA\Files_External\Service\BackendService')
- ->disableOriginalConstructor()
- ->getMock();
+ $this->backendService = $this->createMock(BackendService::class);
$authMechanisms = [
'identifier:\Auth\Mechanism' => $this->getAuthMechMock('null', '\Auth\Mechanism'),
@@ -163,11 +122,11 @@ abstract class StoragesServiceTest extends \Test\TestCase {
->willReturn($backends);
$this->overwriteService(BackendService::class, $this->backendService);
- \OCP\Util::connectHook(
+ Util::connectHook(
Filesystem::CLASSNAME,
Filesystem::signal_create_mount,
get_class($this), 'createHookCallback');
- \OCP\Util::connectHook(
+ Util::connectHook(
Filesystem::CLASSNAME,
Filesystem::signal_delete_mount,
get_class($this), 'deleteHookCallback');
@@ -182,17 +141,16 @@ abstract class StoragesServiceTest extends \Test\TestCase {
}
protected function tearDown(): void {
- \OCA\Files_External\MountConfig::$skipTest = false;
+ MountConfig::$skipTest = false;
self::$hookCalls = [];
if ($this->dbConfig) {
$this->dbConfig->clean();
}
+ parent::tearDown();
}
- protected function getBackendMock($class = '\OCA\Files_External\Lib\Backend\SMB', $storageClass = '\OCA\Files_External\Lib\Storage\SMB') {
- $backend = $this->getMockBuilder(Backend::class)
- ->disableOriginalConstructor()
- ->getMock();
+ protected function getBackendMock($class = SMB::class, $storageClass = \OCA\Files_External\Lib\Storage\SMB::class) {
+ $backend = $this->createMock(Backend::class);
$backend->method('getStorageClass')
->willReturn($storageClass);
$backend->method('getIdentifier')
@@ -200,10 +158,8 @@ abstract class StoragesServiceTest extends \Test\TestCase {
return $backend;
}
- protected function getAuthMechMock($scheme = 'null', $class = '\OCA\Files_External\Lib\Auth\NullMechanism') {
- $authMech = $this->getMockBuilder(AuthMechanism::class)
- ->disableOriginalConstructor()
- ->getMock();
+ protected function getAuthMechMock($scheme = 'null', $class = NullMechanism::class) {
+ $authMech = $this->createMock(AuthMechanism::class);
$authMech->method('getScheme')
->willReturn($scheme);
$authMech->method('getIdentifier')
@@ -214,12 +170,8 @@ abstract class StoragesServiceTest extends \Test\TestCase {
/**
* Creates a StorageConfig instance based on array data
- *
- * @param array $data
- *
- * @return StorageConfig storage config instance
*/
- protected function makeStorageConfig($data) {
+ protected function makeStorageConfig(array $data): StorageConfig {
$storage = new StorageConfig();
if (isset($data['id'])) {
$storage->setId($data['id']);
@@ -268,13 +220,13 @@ abstract class StoragesServiceTest extends \Test\TestCase {
$this->service->updateStorage($storage);
}
- public function testNonExistingStorage() {
- $this->expectException(\OCA\Files_External\NotFoundException::class);
+ public function testNonExistingStorage(): void {
+ $this->expectException(NotFoundException::class);
$this->ActualNonExistingStorageTest();
}
- public function deleteStorageDataProvider() {
+ public static function deleteStorageDataProvider(): array {
return [
// regular case, can properly delete the oc_storages entry
[
@@ -298,10 +250,8 @@ abstract class StoragesServiceTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider deleteStorageDataProvider
- */
- public function testDeleteStorage($backendOptions, $rustyStorageId) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('deleteStorageDataProvider')]
+ public function testDeleteStorage(array $backendOptions, string $rustyStorageId): void {
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\DAV');
$authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism');
$storage = new StorageConfig(255);
@@ -315,10 +265,10 @@ abstract class StoragesServiceTest extends \Test\TestCase {
// manually trigger storage entry because normally it happens on first
// access, which isn't possible within this test
- $storageCache = new \OC\Files\Cache\Storage($rustyStorageId);
+ $storageCache = new Storage($rustyStorageId, true, Server::get(IDBConnection::class));
/** @var IUserMountCache $mountCache */
- $mountCache = \OC::$server->get(IUserMountCache::class);
+ $mountCache = Server::get(IUserMountCache::class);
$mountCache->clear();
$user = $this->createMock(IUser::class);
$user->method('getUID')->willReturn('test');
@@ -357,7 +307,7 @@ abstract class StoragesServiceTest extends \Test\TestCase {
$this->assertTrue($caught);
// storage id was removed from oc_storages
- $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+ $qb = Server::get(IDBConnection::class)->getQueryBuilder();
$storageCheckQuery = $qb->select('*')
->from('storages')
->where($qb->expr()->eq('numeric_id', $qb->expr()->literal($numericId)));
@@ -365,20 +315,20 @@ abstract class StoragesServiceTest extends \Test\TestCase {
$result = $storageCheckQuery->execute();
$storages = $result->fetchAll();
$result->closeCursor();
- $this->assertCount(0, $storages, "expected 0 storages, got " . json_encode($storages));
+ $this->assertCount(0, $storages, 'expected 0 storages, got ' . json_encode($storages));
}
protected function actualDeletedUnexistingStorageTest() {
$this->service->removeStorage(255);
}
- public function testDeleteUnexistingStorage() {
- $this->expectException(\OCA\Files_External\NotFoundException::class);
+ public function testDeleteUnexistingStorage(): void {
+ $this->expectException(NotFoundException::class);
$this->actualDeletedUnexistingStorageTest();
}
- public function testCreateStorage() {
+ public function testCreateStorage(): void {
$mountPoint = 'mount';
$backendIdentifier = 'identifier:\OCA\Files_External\Lib\Backend\SMB';
$authMechanismIdentifier = 'identifier:\Auth\Mechanism';
@@ -412,7 +362,7 @@ abstract class StoragesServiceTest extends \Test\TestCase {
$this->assertEquals($priority, $storage->getPriority());
}
- public function testCreateStorageInvalidClass() {
+ public function testCreateStorageInvalidClass(): void {
$storage = $this->service->createStorage(
'mount',
'identifier:\OC\Not\A\Backend',
@@ -422,7 +372,7 @@ abstract class StoragesServiceTest extends \Test\TestCase {
$this->assertInstanceOf(InvalidBackend::class, $storage->getBackend());
}
- public function testCreateStorageInvalidAuthMechanismClass() {
+ public function testCreateStorageInvalidAuthMechanismClass(): void {
$storage = $this->service->createStorage(
'mount',
'identifier:\OCA\Files_External\Lib\Backend\SMB',
@@ -432,7 +382,7 @@ abstract class StoragesServiceTest extends \Test\TestCase {
$this->assertInstanceOf(InvalidAuth::class, $storage->getAuthMechanism());
}
- public function testGetStoragesBackendNotVisible() {
+ public function testGetStoragesBackendNotVisible(): void {
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
$backend->expects($this->once())
->method('isVisibleFor')
@@ -455,7 +405,7 @@ abstract class StoragesServiceTest extends \Test\TestCase {
$this->assertEmpty($this->service->getStorages());
}
- public function testGetStoragesAuthMechanismNotVisible() {
+ public function testGetStoragesAuthMechanismNotVisible(): void {
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
$backend->method('isVisibleFor')
->with($this->service->getVisibilityType())
@@ -478,14 +428,14 @@ abstract class StoragesServiceTest extends \Test\TestCase {
$this->assertEmpty($this->service->getStorages());
}
- public static function createHookCallback($params) {
+ public static function createHookCallback($params): void {
self::$hookCalls[] = [
'signal' => Filesystem::signal_create_mount,
'params' => $params
];
}
- public static function deleteHookCallback($params) {
+ public static function deleteHookCallback($params): void {
self::$hookCalls[] = [
'signal' => Filesystem::signal_delete_mount,
'params' => $params
@@ -518,7 +468,7 @@ abstract class StoragesServiceTest extends \Test\TestCase {
);
}
- public function testUpdateStorageMountPoint() {
+ public function testUpdateStorageMountPoint(): void {
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
$authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism');
diff --git a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
index 5e54e8acb30..2a2f4596fda 100644
--- a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
+++ b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
@@ -1,32 +1,13 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Service;
+use OC\User\User;
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\NotFoundException;
use OCA\Files_External\Service\StoragesService;
@@ -35,6 +16,8 @@ use OCP\EventDispatcher\IEventDispatcher;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserSession;
+use OCP\Server;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\Traits\UserTrait;
/**
@@ -43,20 +26,9 @@ use Test\Traits\UserTrait;
class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
use UserTrait;
- /** @var \OCP\IGroupManager|\PHPUnit\Framework\MockObject\MockObject groupManager */
- protected $groupManager;
-
- /**
- * @var StoragesService
- */
- protected $globalStoragesService;
-
- /**
- * @var UserGlobalStoragesService
- */
- protected $service;
-
- protected $user;
+ protected IGroupManager&MockObject $groupManager;
+ protected StoragesService $globalStoragesService;
+ protected User $user;
public const USER_ID = 'test_user';
public const GROUP_ID = 'test_group';
@@ -67,8 +39,8 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
$this->globalStoragesService = $this->service;
- $this->user = new \OC\User\User(self::USER_ID, null, \OC::$server->get(IEventDispatcher::class));
- /** @var \OCP\IUserSession|\PHPUnit\Framework\MockObject\MockObject $userSession */
+ $this->user = new User(self::USER_ID, null, Server::get(IEventDispatcher::class));
+ /** @var IUserSession&MockObject $userSession */
$userSession = $this->createMock(IUserSession::class);
$userSession
->expects($this->any())
@@ -106,7 +78,7 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
);
}
- public function applicableStorageProvider() {
+ public static function applicableStorageProvider(): array {
return [
[[], [], true],
@@ -126,10 +98,8 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
];
}
- /**
- * @dataProvider applicableStorageProvider
- */
- public function testGetStorageWithApplicable($applicableUsers, $applicableGroups, $isVisible) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('applicableStorageProvider')]
+ public function testGetStorageWithApplicable($applicableUsers, $applicableGroups, $isVisible): void {
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
$authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism');
@@ -160,7 +130,7 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
}
- public function testAddStorage($storageParams = null) {
+ public function testAddStorage($storageParams = null): void {
$this->expectException(\DomainException::class);
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
@@ -176,7 +146,7 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
}
- public function testUpdateStorage($storageParams = null) {
+ public function testUpdateStorage($storageParams = null): void {
$this->expectException(\DomainException::class);
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
@@ -196,16 +166,14 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
}
- public function testNonExistingStorage() {
+ public function testNonExistingStorage(): void {
$this->expectException(\DomainException::class);
$this->ActualNonExistingStorageTest();
}
- /**
- * @dataProvider deleteStorageDataProvider
- */
- public function testDeleteStorage($backendOptions, $rustyStorageId) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('deleteStorageDataProvider')]
+ public function testDeleteStorage($backendOptions, $rustyStorageId): void {
$this->expectException(\DomainException::class);
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
@@ -224,13 +192,13 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
}
- public function testDeleteUnexistingStorage() {
+ public function testDeleteUnexistingStorage(): void {
$this->expectException(\DomainException::class);
$this->actualDeletedUnexistingStorageTest();
}
- public function getUniqueStoragesProvider() {
+ public static function getUniqueStoragesProvider(): array {
return [
// 'all' vs group
[100, [], [], 100, [], [self::GROUP_ID], 2],
@@ -258,14 +226,12 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
];
}
- /**
- * @dataProvider getUniqueStoragesProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('getUniqueStoragesProvider')]
public function testGetUniqueStorages(
$priority1, $applicableUsers1, $applicableGroups1,
$priority2, $applicableUsers2, $applicableGroups2,
- $expectedPrecedence
- ) {
+ $expectedPrecedence,
+ ): void {
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
$backend->method('isVisibleFor')
->willReturn(true);
@@ -305,67 +271,67 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
}
}
- public function testGetStoragesBackendNotVisible() {
+ public function testGetStoragesBackendNotVisible(): void {
// we don't test this here
$this->addToAssertionCount(1);
}
- public function testGetStoragesAuthMechanismNotVisible() {
+ public function testGetStoragesAuthMechanismNotVisible(): void {
// we don't test this here
$this->addToAssertionCount(1);
}
- public function testHooksAddStorage($a = null, $b = null, $c = null) {
+ public function testHooksAddStorage($a = null, $b = null, $c = null): void {
// we don't test this here
$this->addToAssertionCount(1);
}
- public function testHooksUpdateStorage($a = null, $b = null, $c = null, $d = null, $e = null) {
+ public function testHooksUpdateStorage($a = null, $b = null, $c = null, $d = null, $e = null): void {
// we don't test this here
$this->addToAssertionCount(1);
}
- public function testHooksRenameMountPoint() {
+ public function testHooksRenameMountPoint(): void {
// we don't test this here
$this->addToAssertionCount(1);
}
- public function testHooksDeleteStorage($a = null, $b = null, $c = null) {
+ public function testHooksDeleteStorage($a = null, $b = null, $c = null): void {
// we don't test this here
$this->addToAssertionCount(1);
}
- public function testLegacyConfigConversionApplicableAll() {
+ public function testLegacyConfigConversionApplicableAll(): void {
// we don't test this here
$this->addToAssertionCount(1);
}
- public function testLegacyConfigConversionApplicableUserAndGroup() {
+ public function testLegacyConfigConversionApplicableUserAndGroup(): void {
// we don't test this here
$this->addToAssertionCount(1);
}
- public function testReadLegacyConfigAndGenerateConfigId() {
+ public function testReadLegacyConfigAndGenerateConfigId(): void {
// we don't test this here
$this->addToAssertionCount(1);
}
- public function testReadLegacyConfigNoAuthMechanism() {
+ public function testReadLegacyConfigNoAuthMechanism(): void {
// we don't test this here
$this->addToAssertionCount(1);
}
- public function testReadLegacyConfigClass() {
+ public function testReadLegacyConfigClass(): void {
// we don't test this here
$this->addToAssertionCount(1);
}
- public function testReadEmptyMountPoint() {
+ public function testReadEmptyMountPoint(): void {
// we don't test this here
$this->addToAssertionCount(1);
}
- public function testUpdateStorageMountPoint() {
+ public function testUpdateStorageMountPoint(): void {
// we don't test this here
$this->addToAssertionCount(1);
}
diff --git a/apps/files_external/tests/Service/UserStoragesServiceTest.php b/apps/files_external/tests/Service/UserStoragesServiceTest.php
index cda1dd0a27f..0a2f291f6e4 100644
--- a/apps/files_external/tests/Service/UserStoragesServiceTest.php
+++ b/apps/files_external/tests/Service/UserStoragesServiceTest.php
@@ -1,55 +1,37 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Service;
use OC\Files\Filesystem;
-
+use OC\User\User;
use OCA\Files_External\Lib\StorageConfig;
+use OCA\Files_External\MountConfig;
+use OCA\Files_External\NotFoundException;
use OCA\Files_External\Service\GlobalStoragesService;
+
use OCA\Files_External\Service\StoragesService;
use OCA\Files_External\Service\UserStoragesService;
+use OCP\IUserManager;
use OCP\IUserSession;
+use OCP\Server;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\Traits\UserTrait;
/**
* @group DB
*/
-class UserStoragesServiceTest extends StoragesServiceTest {
+class UserStoragesServiceTest extends StoragesServiceTestCase {
use UserTrait;
- private $user;
-
- private $userId;
+ protected User $user;
- /**
- * @var StoragesService
- */
- protected $globalStoragesService;
+ protected string $userId;
+ protected StoragesService $globalStoragesService;
protected function setUp(): void {
parent::setUp();
@@ -58,9 +40,9 @@ class UserStoragesServiceTest extends StoragesServiceTest {
$this->userId = $this->getUniqueID('user_');
$this->createUser($this->userId, $this->userId);
- $this->user = \OC::$server->getUserManager()->get($this->userId);
+ $this->user = Server::get(IUserManager::class)->get($this->userId);
- /** @var \OCP\IUserSession|\PHPUnit\Framework\MockObject\MockObject $userSession */
+ /** @var IUserSession&MockObject $userSession */
$userSession = $this->createMock(IUserSession::class);
$userSession
->expects($this->any())
@@ -86,7 +68,7 @@ class UserStoragesServiceTest extends StoragesServiceTest {
]);
}
- public function testAddStorage() {
+ public function testAddStorage(): void {
$storage = $this->makeTestStorageData();
$newStorage = $this->service->addStorage($storage);
@@ -106,7 +88,7 @@ class UserStoragesServiceTest extends StoragesServiceTest {
current(self::$hookCalls),
Filesystem::signal_create_mount,
$storage->getMountPoint(),
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
$this->userId
);
@@ -114,7 +96,7 @@ class UserStoragesServiceTest extends StoragesServiceTest {
$this->assertEquals($id + 1, $nextStorage->getId());
}
- public function testUpdateStorage() {
+ public function testUpdateStorage(): void {
$storage = $this->makeStorageConfig([
'mountPoint' => 'mountpoint',
'backendIdentifier' => 'identifier:\OCA\Files_External\Lib\Backend\SMB',
@@ -146,10 +128,8 @@ class UserStoragesServiceTest extends StoragesServiceTest {
$this->assertEmpty(self::$hookCalls);
}
- /**
- * @dataProvider deleteStorageDataProvider
- */
- public function testDeleteStorage($backendOptions, $rustyStorageId) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('deleteStorageDataProvider')]
+ public function testDeleteStorage($backendOptions, $rustyStorageId): void {
parent::testDeleteStorage($backendOptions, $rustyStorageId);
// hook called once for user (first one was during test creation)
@@ -157,12 +137,12 @@ class UserStoragesServiceTest extends StoragesServiceTest {
self::$hookCalls[1],
Filesystem::signal_delete_mount,
'/mountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
$this->userId
);
}
- public function testHooksRenameMountPoint() {
+ public function testHooksRenameMountPoint(): void {
$storage = $this->makeTestStorageData();
$storage = $this->service->addStorage($storage);
@@ -178,21 +158,21 @@ class UserStoragesServiceTest extends StoragesServiceTest {
self::$hookCalls[0],
Filesystem::signal_delete_mount,
'/mountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
$this->userId
);
$this->assertHookCall(
self::$hookCalls[1],
Filesystem::signal_create_mount,
'/renamedMountpoint',
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
$this->userId
);
}
- public function testGetAdminStorage() {
- $this->expectException(\OCA\Files_External\NotFoundException::class);
+ public function testGetAdminStorage(): void {
+ $this->expectException(NotFoundException::class);
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
$authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism');
diff --git a/apps/files_external/tests/Settings/AdminTest.php b/apps/files_external/tests/Settings/AdminTest.php
index bad5da8516d..fd4a1949760 100644
--- a/apps/files_external/tests/Settings/AdminTest.php
+++ b/apps/files_external/tests/Settings/AdminTest.php
@@ -1,49 +1,28 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Files_External\Tests\Settings;
use OCA\Files_External\Lib\Auth\Password\GlobalAuth;
+use OCA\Files_External\MountConfig;
use OCA\Files_External\Service\BackendService;
use OCA\Files_External\Service\GlobalStoragesService;
use OCA\Files_External\Settings\Admin;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Encryption\IManager;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class AdminTest extends TestCase {
- /** @var Admin */
- private $admin;
- /** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
- private $encryptionManager;
- /** @var GlobalStoragesService|\PHPUnit\Framework\MockObject\MockObject */
- private $globalStoragesService;
- /** @var BackendService|\PHPUnit\Framework\MockObject\MockObject */
- private $backendService;
- /** @var GlobalAuth|\PHPUnit\Framework\MockObject\MockObject */
- private $globalAuth;
+ private IManager&MockObject $encryptionManager;
+ private GlobalStoragesService&MockObject $globalStoragesService;
+ private BackendService&MockObject $backendService;
+ private GlobalAuth&MockObject $globalAuth;
+ private Admin $admin;
protected function setUp(): void {
parent::setUp();
@@ -60,7 +39,7 @@ class AdminTest extends TestCase {
);
}
- public function testGetForm() {
+ public function testGetForm(): void {
$this->encryptionManager
->expects($this->once())
->method('isEnabled')
@@ -96,7 +75,7 @@ class AdminTest extends TestCase {
'storages' => ['a', 'b', 'c'],
'backends' => ['d', 'e', 'f'],
'authMechanisms' => ['g', 'h', 'i'],
- 'dependencies' => \OCA\Files_External\MountConfig::dependencyMessage($this->backendService->getBackends()),
+ 'dependencies' => MountConfig::dependencyMessage($this->backendService->getBackends()),
'allowUserMounting' => true,
'globalCredentials' => 'asdf:asdf',
'globalCredentialsUid' => '',
@@ -105,11 +84,11 @@ class AdminTest extends TestCase {
$this->assertEquals($expected, $this->admin->getForm());
}
- public function testGetSection() {
+ public function testGetSection(): void {
$this->assertSame('externalstorages', $this->admin->getSection());
}
- public function testGetPriority() {
+ public function testGetPriority(): void {
$this->assertSame(40, $this->admin->getPriority());
}
}
diff --git a/apps/files_external/tests/Settings/SectionTest.php b/apps/files_external/tests/Settings/SectionTest.php
index cfe97896358..c64849ff7ba 100644
--- a/apps/files_external/tests/Settings/SectionTest.php
+++ b/apps/files_external/tests/Settings/SectionTest.php
@@ -1,47 +1,27 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
- *
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author szaimen <szaimen@e.mail.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Files_External\Tests\Settings;
use OCA\Files_External\Settings\Section;
use OCP\IL10N;
use OCP\IURLGenerator;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class SectionTest extends TestCase {
- /** @var IL10N */
- private $l;
- /** @var IURLGenerator */
- private $urlGenerator;
- /** @var Section */
- private $section;
+ private IL10N&MockObject $l;
+ private IURLGenerator&MockObject $urlGenerator;
+ private Section $section;
protected function setUp(): void {
parent::setUp();
- $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)->disableOriginalConstructor()->getMock();
- $this->l = $this->getMockBuilder(IL10N::class)->disableOriginalConstructor()->getMock();
+ $this->urlGenerator = $this->createMock(IURLGenerator::class);
+ $this->l = $this->createMock(IL10N::class);
$this->section = new Section(
$this->urlGenerator,
@@ -49,11 +29,11 @@ class SectionTest extends TestCase {
);
}
- public function testGetID() {
+ public function testGetID(): void {
$this->assertSame('externalstorages', $this->section->getID());
}
- public function testGetName() {
+ public function testGetName(): void {
$this->l
->expects($this->once())
->method('t')
@@ -63,7 +43,7 @@ class SectionTest extends TestCase {
$this->assertSame('External storage', $this->section->getName());
}
- public function testGetPriority() {
+ public function testGetPriority(): void {
$this->assertSame(10, $this->section->getPriority());
}
}
diff --git a/apps/files_external/tests/Storage/Amazons3MultiPartTest.php b/apps/files_external/tests/Storage/Amazons3MultiPartTest.php
index d102a2a064e..aa3925899f3 100644
--- a/apps/files_external/tests/Storage/Amazons3MultiPartTest.php
+++ b/apps/files_external/tests/Storage/Amazons3MultiPartTest.php
@@ -1,27 +1,11 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2023 Robin Appelman <robin@icewind.nl>
- *
- * @author Maxence Lange <maxence@artificial-owl.com>
- * @author Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
-namespace OCA\files_external\tests\Storage;
+namespace OCA\Files_External\Tests\Storage;
use OCA\Files_External\Lib\Storage\AmazonS3;
@@ -29,6 +13,7 @@ use OCA\Files_External\Lib\Storage\AmazonS3;
* Class Amazons3Test
*
* @group DB
+ * @group S3
*
* @package OCA\Files_External\Tests\Storage
*/
@@ -41,7 +26,7 @@ class Amazons3MultiPartTest extends \Test\Files\Storage\Storage {
parent::setUp();
$this->config = include('files_external/tests/config.amazons3.php');
- if (! is_array($this->config) or ! $this->config['run']) {
+ if (!is_array($this->config) || !$this->config['run']) {
$this->markTestSkipped('AmazonS3 backend not configured');
}
$this->instance = new AmazonS3($this->config + [
@@ -58,11 +43,7 @@ class Amazons3MultiPartTest extends \Test\Files\Storage\Storage {
parent::tearDown();
}
- public function testStat() {
+ public function testStat(): void {
$this->markTestSkipped('S3 doesn\'t update the parents folder mtime');
}
-
- public function testHashInFileName() {
- $this->markTestSkipped('Localstack has a bug with hashes in filename');
- }
}
diff --git a/apps/files_external/tests/Storage/Amazons3Test.php b/apps/files_external/tests/Storage/Amazons3Test.php
index d231539fb54..d02dec0230c 100644
--- a/apps/files_external/tests/Storage/Amazons3Test.php
+++ b/apps/files_external/tests/Storage/Amazons3Test.php
@@ -1,29 +1,10 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Michael Gapczynski <GapczynskiM@gmail.com>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Storage;
@@ -33,11 +14,12 @@ use OCA\Files_External\Lib\Storage\AmazonS3;
* Class Amazons3Test
*
* @group DB
+ * @group S3
*
* @package OCA\Files_External\Tests\Storage
*/
class Amazons3Test extends \Test\Files\Storage\Storage {
- private $config;
+ protected $config;
/** @var AmazonS3 */
protected $instance;
@@ -45,7 +27,7 @@ class Amazons3Test extends \Test\Files\Storage\Storage {
parent::setUp();
$this->config = include('files_external/tests/config.amazons3.php');
- if (! is_array($this->config) or ! $this->config['run']) {
+ if (!is_array($this->config) || !$this->config['run']) {
$this->markTestSkipped('AmazonS3 backend not configured');
}
$this->instance = new AmazonS3($this->config);
@@ -59,11 +41,7 @@ class Amazons3Test extends \Test\Files\Storage\Storage {
parent::tearDown();
}
- public function testStat() {
+ public function testStat(): void {
$this->markTestSkipped('S3 doesn\'t update the parents folder mtime');
}
-
- public function testHashInFileName() {
- $this->markTestSkipped('Localstack has a bug with hashes in filename');
- }
}
diff --git a/apps/files_external/tests/Storage/FtpTest.php b/apps/files_external/tests/Storage/FtpTest.php
index 9ca06f15112..095a5236049 100644
--- a/apps/files_external/tests/Storage/FtpTest.php
+++ b/apps/files_external/tests/Storage/FtpTest.php
@@ -1,30 +1,10 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Storage;
@@ -67,7 +47,7 @@ class FtpTest extends \Test\Files\Storage\Storage {
/**
* ftp has no proper way to handle spaces at the end of file names
*/
- public function directoryProvider() {
+ public static function directoryProvider(): array {
return array_filter(parent::directoryProvider(), function ($item) {
return substr($item[0], -1) !== ' ';
});
@@ -77,7 +57,7 @@ class FtpTest extends \Test\Files\Storage\Storage {
/**
* mtime for folders is only with a minute resolution
*/
- public function testStat() {
+ public function testStat(): void {
$textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt';
$ctimeStart = time();
$this->instance->file_put_contents('/lorem.txt', file_get_contents($textFile));
diff --git a/apps/files_external/tests/Storage/OwncloudTest.php b/apps/files_external/tests/Storage/OwncloudTest.php
index 88f6277c06a..ab6cd443dba 100644
--- a/apps/files_external/tests/Storage/OwncloudTest.php
+++ b/apps/files_external/tests/Storage/OwncloudTest.php
@@ -1,29 +1,10 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Storage;
diff --git a/apps/files_external/tests/Storage/SFTP_KeyTest.php b/apps/files_external/tests/Storage/SFTP_KeyTest.php
index 558b24f0914..17e2087f91b 100644
--- a/apps/files_external/tests/Storage/SFTP_KeyTest.php
+++ b/apps/files_external/tests/Storage/SFTP_KeyTest.php
@@ -1,28 +1,10 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Ross Nicoll <jrn@jrn.me.uk>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Viktor Szépe <viktor@szepe.net>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Storage;
@@ -60,40 +42,40 @@ class SFTP_KeyTest extends \Test\Files\Storage\Storage {
parent::tearDown();
}
-
- public function testInvalidAddressShouldThrowException() {
+
+ public function testInvalidAddressShouldThrowException(): void {
$this->expectException(\InvalidArgumentException::class);
// 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() {
+ public function testValidAddressShouldPass(): void {
$this->assertTrue($this->instance->assertHostAddressValid('localhost'));
}
-
- public function testNegativePortNumberShouldThrowException() {
+
+ public function testNegativePortNumberShouldThrowException(): void {
$this->expectException(\InvalidArgumentException::class);
$this->instance->assertPortNumberValid('-1');
}
-
- public function testNonNumericalPortNumberShouldThrowException() {
+
+ public function testNonNumericalPortNumberShouldThrowException(): void {
$this->expectException(\InvalidArgumentException::class);
$this->instance->assertPortNumberValid('a');
}
-
- public function testHighPortNumberShouldThrowException() {
+
+ public function testHighPortNumberShouldThrowException(): void {
$this->expectException(\InvalidArgumentException::class);
-
+
$this->instance->assertPortNumberValid('65536');
}
- public function testValidPortNumberShouldPass() {
+ public function testValidPortNumberShouldPass(): void {
$this->assertTrue($this->instance->assertPortNumberValid('22222'));
}
}
diff --git a/apps/files_external/tests/Storage/SftpTest.php b/apps/files_external/tests/Storage/SftpTest.php
index 70e93ada2f2..ebfc8ab3c1f 100644
--- a/apps/files_external/tests/Storage/SftpTest.php
+++ b/apps/files_external/tests/Storage/SftpTest.php
@@ -1,30 +1,10 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author hkjolhede <hkjolhede@gmail.com>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Storage;
@@ -66,15 +46,13 @@ class SftpTest extends \Test\Files\Storage\Storage {
parent::tearDown();
}
- /**
- * @dataProvider configProvider
- */
- public function testStorageId($config, $expectedStorageId) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('configProvider')]
+ public function testStorageId($config, $expectedStorageId): void {
$instance = new SFTP($config);
$this->assertEquals($expectedStorageId, $instance->getId());
}
- public function configProvider() {
+ public static function configProvider(): array {
return [
[
// no root path
diff --git a/apps/files_external/tests/Storage/SmbTest.php b/apps/files_external/tests/Storage/SmbTest.php
index 30040e499c8..afcb5c1034f 100644
--- a/apps/files_external/tests/Storage/SmbTest.php
+++ b/apps/files_external/tests/Storage/SmbTest.php
@@ -1,31 +1,10 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Juan Pablo Villafáñez <jvillafanez@solidgear.es>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Storage;
@@ -33,6 +12,7 @@ use OC\Files\Notify\Change;
use OC\Files\Notify\RenameChange;
use OCA\Files_External\Lib\Storage\SMB;
use OCP\Files\Notify\IChange;
+use PHPUnit\Framework\ExpectationFailedException;
/**
* Class SmbTest
@@ -71,19 +51,19 @@ class SmbTest extends \Test\Files\Storage\Storage {
parent::tearDown();
}
- public function directoryProvider() {
+ public static function directoryProvider(): array {
// doesn't support leading/trailing spaces
return [['folder']];
}
- public function testRenameWithSpaces() {
+ public function testRenameWithSpaces(): void {
$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() {
+ public function testStorageId(): void {
$this->instance = new SMB([
'host' => 'testhost',
'user' => 'testuser',
@@ -95,7 +75,23 @@ class SmbTest extends \Test\Files\Storage\Storage {
$this->instance = null;
}
- public function testNotifyGetChanges() {
+ public function testNotifyGetChanges(): void {
+ $lastError = null;
+ for ($i = 0; $i < 5; $i++) {
+ try {
+ $this->tryTestNotifyGetChanges();
+ return;
+ } catch (ExpectationFailedException $e) {
+ $lastError = $e;
+ $this->tearDown();
+ $this->setUp();
+ sleep(1);
+ }
+ }
+ throw $lastError;
+ }
+
+ private function tryTestNotifyGetChanges(): void {
$notifyHandler = $this->instance->notify('');
sleep(1); //give time for the notify to start
$this->instance->file_put_contents('/newfile.txt', 'test content');
@@ -105,6 +101,7 @@ class SmbTest extends \Test\Files\Storage\Storage {
$this->instance->unlink('/renamed.txt');
sleep(1); //time for all changes to be processed
+ /** @var IChange[] $changes */
$changes = [];
$count = 0;
// wait up to 10 seconds for incoming changes
@@ -115,18 +112,27 @@ class SmbTest extends \Test\Files\Storage\Storage {
}
$notifyHandler->stop();
- $expected = [
- new Change(IChange::ADDED, 'newfile.txt'),
- new RenameChange(IChange::RENAMED, 'newfile.txt', 'renamed.txt'),
- new Change(IChange::REMOVED, 'renamed.txt')
- ];
+ // depending on the server environment, the initial create might be detected as a change instead
+ if ($changes[0]->getType() === IChange::MODIFIED) {
+ $expected = [
+ new Change(IChange::MODIFIED, 'newfile.txt'),
+ new RenameChange(IChange::RENAMED, 'newfile.txt', 'renamed.txt'),
+ new Change(IChange::REMOVED, 'renamed.txt')
+ ];
+ } else {
+ $expected = [
+ new Change(IChange::ADDED, 'newfile.txt'),
+ new RenameChange(IChange::RENAMED, 'newfile.txt', 'renamed.txt'),
+ new Change(IChange::REMOVED, 'renamed.txt')
+ ];
+ }
foreach ($expected as $expectedChange) {
- $this->assertTrue(in_array($expectedChange, $changes), 'Actual changes are:' . PHP_EOL . print_r($changes, true) . PHP_EOL . 'Expected to find: ' . PHP_EOL . print_r($expectedChange, true));
+ $this->assertTrue(in_array($expectedChange, $changes), "Expected changes are:\n" . print_r($expected, true) . PHP_EOL . 'Expected to find: ' . PHP_EOL . print_r($expectedChange, true) . "\nGot:\n" . print_r($changes, true));
}
}
- public function testNotifyListen() {
+ public function testNotifyListen(): void {
$notifyHandler = $this->instance->notify('');
usleep(100 * 1000); //give time for the notify to start
$this->instance->file_put_contents('/newfile.txt', 'test content');
@@ -141,10 +147,15 @@ class SmbTest extends \Test\Files\Storage\Storage {
return false;//stop listening
});
- $this->assertEquals(new Change(IChange::ADDED, 'newfile.txt'), $result);
+ // depending on the server environment, the initial create might be detected as a change instead
+ if ($result->getType() === IChange::ADDED) {
+ $this->assertEquals(new Change(IChange::ADDED, 'newfile.txt'), $result);
+ } else {
+ $this->assertEquals(new Change(IChange::MODIFIED, 'newfile.txt'), $result);
+ }
}
- public function testRenameRoot() {
+ public function testRenameRoot(): void {
// root can't be renamed
$this->assertFalse($this->instance->rename('', 'foo1'));
@@ -153,12 +164,12 @@ class SmbTest extends \Test\Files\Storage\Storage {
$this->instance->rmdir('foo2');
}
- public function testUnlinkRoot() {
+ public function testUnlinkRoot(): void {
// root can't be deleted
$this->assertFalse($this->instance->unlink(''));
}
- public function testRmdirRoot() {
+ public function testRmdirRoot(): void {
// root can't be deleted
$this->assertFalse($this->instance->rmdir(''));
}
diff --git a/apps/files_external/tests/Storage/SwiftTest.php b/apps/files_external/tests/Storage/SwiftTest.php
index 98a184f37b5..17037e76ee3 100644
--- a/apps/files_external/tests/Storage/SwiftTest.php
+++ b/apps/files_external/tests/Storage/SwiftTest.php
@@ -1,29 +1,10 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christian Berendt <berendt@b1-systems.de>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Storage;
@@ -74,7 +55,7 @@ class SwiftTest extends \Test\Files\Storage\Storage {
parent::tearDown();
}
- public function testStat() {
+ public function testStat(): void {
$this->markTestSkipped('Swift doesn\'t update the parents folder mtime');
}
}
diff --git a/apps/files_external/tests/Storage/VersionedAmazonS3Test.php b/apps/files_external/tests/Storage/VersionedAmazonS3Test.php
index a16a9944d57..9d413620292 100644
--- a/apps/files_external/tests/Storage/VersionedAmazonS3Test.php
+++ b/apps/files_external/tests/Storage/VersionedAmazonS3Test.php
@@ -2,29 +2,15 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2021 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Files_External\Tests\Storage;
/**
* @group DB
+ * @group S3
*/
class VersionedAmazonS3Test extends Amazons3Test {
protected function setUp(): void {
@@ -40,4 +26,12 @@ class VersionedAmazonS3Test extends Amazons3Test {
$this->markTestSkipped("s3 backend doesn't seem to support versioning");
}
}
+
+ public function testCopyOverWriteDirectory(): void {
+ if (isset($this->config['minio'])) {
+ $this->markTestSkipped('MinIO has a bug with batch deletion on versioned storages, see https://github.com/minio/minio/issues/21366');
+ }
+
+ parent::testCopyOverWriteDirectory();
+ }
}
diff --git a/apps/files_external/tests/Storage/WebdavTest.php b/apps/files_external/tests/Storage/WebdavTest.php
index bf3eb64a63c..a8de178effd 100644
--- a/apps/files_external/tests/Storage/WebdavTest.php
+++ b/apps/files_external/tests/Storage/WebdavTest.php
@@ -1,34 +1,17 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Storage;
use OC\Files\Storage\DAV;
use OC\Files\Type\Detection;
+use OCP\Files\IMimeTypeDetector;
+use OCP\Server;
/**
* Class WebdavTest
@@ -62,11 +45,11 @@ class WebdavTest extends \Test\Files\Storage\Storage {
parent::tearDown();
}
- public function testMimetypeFallback() {
+ public function testMimetypeFallback(): void {
$this->instance->file_put_contents('foo.bar', 'asd');
/** @var Detection $mimeDetector */
- $mimeDetector = \OC::$server->getMimeTypeDetector();
+ $mimeDetector = Server::get(IMimeTypeDetector::class);
$mimeDetector->registerType('bar', 'application/x-bar');
$this->assertEquals('application/x-bar', $this->instance->getMimeType('foo.bar'));
diff --git a/apps/files_external/tests/StorageConfigTest.php b/apps/files_external/tests/StorageConfigTest.php
index 6f5d8066f92..b3024cb228c 100644
--- a/apps/files_external/tests/StorageConfigTest.php
+++ b/apps/files_external/tests/StorageConfigTest.php
@@ -1,27 +1,10 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Joas Schilling <coding@schilljs.com>
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests;
@@ -31,13 +14,9 @@ use OCA\Files_External\Lib\DefinitionParameter;
use OCA\Files_External\Lib\StorageConfig;
class StorageConfigTest extends \Test\TestCase {
- public function testJsonSerialization() {
- $backend = $this->getMockBuilder(Backend::class)
- ->disableOriginalConstructor()
- ->getMock();
- $parameter = $this->getMockBuilder(DefinitionParameter::class)
- ->disableOriginalConstructor()
- ->getMock();
+ public function testJsonSerialization(): void {
+ $backend = $this->createMock(Backend::class);
+ $parameter = $this->createMock(DefinitionParameter::class);
$parameter
->expects($this->once())
->method('getType')
@@ -49,9 +28,7 @@ class StorageConfigTest extends \Test\TestCase {
$backend->method('getIdentifier')
->willReturn('storage::identifier');
- $authMech = $this->getMockBuilder(AuthMechanism::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $authMech = $this->createMock(AuthMechanism::class);
$authMech->method('getIdentifier')
->willReturn('auth::identifier');
diff --git a/apps/files_external/tests/appSpec.js b/apps/files_external/tests/appSpec.js
deleted file mode 100644
index 8e5ab5b8d98..00000000000
--- a/apps/files_external/tests/appSpec.js
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
-* @copyright 2014 Vincent Petry <pvince81@owncloud.com>
- *
- * @author Joas Schilling <coding@schilljs.com>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-describe('OCA.Files_External.App tests', function() {
- const App = OCA.Files_External.App
- let fileList
-
- beforeEach(function() {
- $('#testArea').append(
- '<div id="app-navigation">'
- + '<ul><li data-id="files"><a>Files</a></li>'
- + '<li data-id="sharingin"><a></a></li>'
- + '<li data-id="sharingout"><a></a></li>'
- + '</ul></div>'
- + '<div id="app-content">'
- + '<div id="app-content-files" class="hidden">'
- + '</div>'
- + '<div id="app-content-extstoragemounts" class="hidden">'
- + '</div>'
- + '</div>'
- + '</div>'
- )
- fileList = App.initList($('#app-content-extstoragemounts'))
- })
- afterEach(function() {
- App.fileList = null
- fileList.destroy()
- fileList = null
- })
-
- describe('initialization', function() {
- it('inits external mounts list on show', function() {
- expect(App.fileList).toBeDefined()
- })
- })
- describe('file actions', function() {
- it('provides default file actions', function() {
- const fileActions = fileList.fileActions
-
- expect(fileActions.actions.all).toBeDefined()
- expect(fileActions.actions.all.Delete).toBeDefined()
- expect(fileActions.actions.all.Rename).toBeDefined()
- expect(fileActions.actions.all.Download).toBeDefined()
-
- expect(fileActions.defaults.dir).toEqual('Open')
- })
- it('redirects to files app when opening a directory', function() {
- const oldList = OCA.Files.App.fileList
- // dummy new list to make sure it exists
- OCA.Files.App.fileList = new OCA.Files.FileList($('<table><thead></thead><tbody></tbody></table>'))
-
- const setActiveViewStub = sinon.stub(OCA.Files.App, 'setActiveView')
- // create dummy table so we can click the dom
- const $table = '<table><thead></thead><tbody class="files-fileList"></tbody></table>'
- $('#app-content-extstoragemounts').append($table)
-
- App._inFileList = null
- fileList = App.initList($('#app-content-extstoragemounts'))
-
- fileList.setFiles([{
- name: 'testdir',
- type: 'dir',
- path: '/somewhere/inside/subdir',
- counterParts: ['user2'],
- shareOwner: 'user2',
- }])
-
- fileList.findFileEl('testdir').find('td a.name').click()
-
- expect(OCA.Files.App.fileList.getCurrentDirectory()).toEqual('/somewhere/inside/subdir/testdir')
-
- expect(setActiveViewStub.calledOnce).toEqual(true)
- expect(setActiveViewStub.calledWith('files')).toEqual(true)
-
- setActiveViewStub.restore()
-
- // restore old list
- OCA.Files.App.fileList = oldList
- })
- })
-})
diff --git a/apps/files_external/tests/config.php b/apps/files_external/tests/config.php
index a00308e6d07..ec860cf05a4 100644
--- a/apps/files_external/tests/config.php
+++ b/apps/files_external/tests/config.php
@@ -1,26 +1,9 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christian Berendt <berendt@b1-systems.de>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2012-2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
// in case there are private configurations in the users home -> use them
$privateConfigFile = $_SERVER['HOME'] . '/owncloud-extfs-test-config.php';
diff --git a/apps/files_external/tests/env/start-amazons3-ceph.sh b/apps/files_external/tests/env/start-amazons3-ceph.sh
index 1aa14ac990d..ecaa6e0ff46 100755
--- a/apps/files_external/tests/env/start-amazons3-ceph.sh
+++ b/apps/files_external/tests/env/start-amazons3-ceph.sh
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
#
-# ownCloud
+# SPDX-FileCopyrightText: 2015-2016 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
#
# 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
@@ -8,9 +9,6 @@
#
# Set environment variable DEBUG to print config file
#
-# @author Morris Jobke
-# @author Robin McCorkell
-# @copyright 2015 ownCloud
if ! command -v docker >/dev/null 2>&1; then
echo "No docker executable found - skipped docker setup"
diff --git a/apps/files_external/tests/env/start-ftp-morrisjobke.sh b/apps/files_external/tests/env/start-ftp-morrisjobke.sh
index 3a5f6ffcb67..3074bedce74 100755
--- a/apps/files_external/tests/env/start-ftp-morrisjobke.sh
+++ b/apps/files_external/tests/env/start-ftp-morrisjobke.sh
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
#
-# ownCloud
+# SPDX-FileCopyrightText: 2015-2016 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
#
# 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
@@ -8,9 +9,6 @@
#
# 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"
diff --git a/apps/files_external/tests/env/start-sftp-atmoz.sh b/apps/files_external/tests/env/start-sftp-atmoz.sh
index 0fc0c5c427f..9d444515a8a 100755
--- a/apps/files_external/tests/env/start-sftp-atmoz.sh
+++ b/apps/files_external/tests/env/start-sftp-atmoz.sh
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
#
-# ownCloud
+# SPDX-FileCopyrightText: 2015 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
#
# 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
@@ -8,9 +9,6 @@
#
# 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"
diff --git a/apps/files_external/tests/env/start-smb-linux.sh b/apps/files_external/tests/env/start-smb-linux.sh
index 173dd25ebb9..ca303b521f4 100755
--- a/apps/files_external/tests/env/start-smb-linux.sh
+++ b/apps/files_external/tests/env/start-smb-linux.sh
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
#
-# ownCloud
+# SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+# SPDX-License-Identifier: AGPL-3.0-or-later
#
# 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
@@ -8,9 +9,6 @@
#
# 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##'`
diff --git a/apps/files_external/tests/env/start-smb-windows.sh b/apps/files_external/tests/env/start-smb-windows.sh
index a23c879dd96..3c5570a2f80 100755
--- a/apps/files_external/tests/env/start-smb-windows.sh
+++ b/apps/files_external/tests/env/start-smb-windows.sh
@@ -1,12 +1,10 @@
#!/usr/bin/env bash
#
-# ownCloud
+# SPDX-FileCopyrightText: 2015 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
#
# Set environment variable DEBUG to print config file
#
-# @author Thomas Müller
-# @copyright 2015 Thomas Müller <deepdiver@owncloud.com>
-#
# retrieve current folder to place the config in the parent folder
thisFolder=`echo $0 | sed 's#env/start-smb-windows\.sh##'`
diff --git a/apps/files_external/tests/env/start-swift-ceph.sh b/apps/files_external/tests/env/start-swift-ceph.sh
index 3a299a6fa85..c646b9eef28 100755
--- a/apps/files_external/tests/env/start-swift-ceph.sh
+++ b/apps/files_external/tests/env/start-swift-ceph.sh
@@ -1,6 +1,7 @@
#!/bin/bash
#
-# ownCloud
+# SPDX-FileCopyrightText: 2015-2016 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
#
# 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
@@ -8,9 +9,6 @@
#
# Set environment variable DEBUG to print config file
#
-# @author Morris Jobke
-# @author Robin McCorkell
-# @copyright 2015 ownCloud
if ! command -v docker >/dev/null 2>&1; then
echo "No docker executable found - skipped docker setup"
diff --git a/apps/files_external/tests/env/start-webdav-apache.sh b/apps/files_external/tests/env/start-webdav-apache.sh
index a5464c9cfab..517f278a366 100755
--- a/apps/files_external/tests/env/start-webdav-apache.sh
+++ b/apps/files_external/tests/env/start-webdav-apache.sh
@@ -1,6 +1,8 @@
#!/bin/bash
#
-# ownCloud
+# SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+# SPDX-FileCopyrightText: 2015 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
#
# 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
@@ -11,10 +13,6 @@
#
# Set environment variable DEBUG to print config file
#
-# @author Morris Jobke
-# @copyright 2014 Morris Jobke <hey@morrisjobke.de>
-# @copyright 2016 Vincent Petry <pvince81@owncloud.com>
-#
if ! command -v docker >/dev/null 2>&1; then
echo "No docker executable found - skipped docker setup"
@@ -23,8 +21,8 @@ fi
echo "Docker executable found - setup docker"
-echo "Fetch recent morrisjobke/webdav docker image"
-docker pull morrisjobke/webdav
+echo "Fetch recent webdav docker image"
+docker pull ghcr.io/nextcloud/continuous-integration-webdav-apache:latest
# retrieve current folder to place the config in the parent folder
thisFolder=`echo $0 | sed 's#env/start-webdav-apache\.sh##'`
@@ -45,7 +43,7 @@ if [ -n "$RUN_DOCKER_MYSQL" ]; then
parameter="--link $containerName:db"
fi
-container=`docker run -P $parameter -d -e USERNAME=test -e PASSWORD=test morrisjobke/webdav`
+container=`docker run -P $parameter -d --rm ghcr.io/nextcloud/continuous-integration-webdav-apache:latest`
host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container`
echo -n "Waiting for Apache initialization on ${host}:${port}"
@@ -64,7 +62,7 @@ return array(
'run'=>true,
'host'=>'${host}:80/webdav/',
'user'=>'test',
- 'password'=>'test',
+ 'password'=>'pass',
'root'=>'',
// wait delay in seconds after write operations
// (only in tests)
diff --git a/apps/files_external/tests/env/start-webdav-apachedrone.sh b/apps/files_external/tests/env/start-webdav-apachedrone.sh
deleted file mode 100755
index 9887cea5eee..00000000000
--- a/apps/files_external/tests/env/start-webdav-apachedrone.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env bash
-#
-# Nextcloud
-#
-
-# retrieve current folder to place the config in the parent folder
-thisFolder=`echo $0 | sed 's#env/start-webdav-apachedrone\.sh##'`
-
-if [ -z "$thisFolder" ]; then
- thisFolder="."
-fi;
-
-cat > $thisFolder/config.webdav.php <<DELIM
-<?php
-
-return array(
- 'run'=>true,
- 'host'=>'127.0.0.1:80/webdav/',
- 'user'=>'test',
- 'password'=>'pass',
- 'root'=>'',
- 'wait'=> 0
-);
-
-DELIM
-
diff --git a/apps/files_external/tests/env/start-webdav-ownCloud.sh b/apps/files_external/tests/env/start-webdav-ownCloud.sh
index 870bd5bcdf8..9d833330205 100755
--- a/apps/files_external/tests/env/start-webdav-ownCloud.sh
+++ b/apps/files_external/tests/env/start-webdav-ownCloud.sh
@@ -1,6 +1,10 @@
#!/usr/bin/env bash
#
-# ownCloud
+#!/bin/bash
+#
+# SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+# SPDX-FileCopyrightText: 2014-2015 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
#
# 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
@@ -11,9 +15,6 @@
#
# Set environment variable DEBUG to print config file
#
-# @author Morris Jobke
-# @copyright 2014 Morris Jobke <hey@morrisjobke.de>
-#
if ! command -v docker >/dev/null 2>&1; then
echo "No docker executable found - skipped docker setup"
diff --git a/apps/files_external/tests/env/stop-amazons3-ceph.sh b/apps/files_external/tests/env/stop-amazons3-ceph.sh
index f559f8f9058..5e7aac5d5e7 100755
--- a/apps/files_external/tests/env/stop-amazons3-ceph.sh
+++ b/apps/files_external/tests/env/stop-amazons3-ceph.sh
@@ -1,13 +1,11 @@
#!/usr/bin/env bash
#
-# ownCloud
+# SPDX-FileCopyrightText: 2015-2016 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
#
# 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
-# @author Robin McCorkell
-# @copyright 2015 ownCloud
if ! command -v docker >/dev/null 2>&1; then
echo "No docker executable found - skipped docker stop"
diff --git a/apps/files_external/tests/env/stop-ftp-morrisjobke.sh b/apps/files_external/tests/env/stop-ftp-morrisjobke.sh
index eedf8f82a50..cb6c8ee9d94 100755
--- a/apps/files_external/tests/env/stop-ftp-morrisjobke.sh
+++ b/apps/files_external/tests/env/stop-ftp-morrisjobke.sh
@@ -1,13 +1,11 @@
#!/usr/bin/env bash
#
-# ownCloud
+# SPDX-FileCopyrightText: 2015-2016 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
#
# 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"
diff --git a/apps/files_external/tests/env/stop-sftp-atmoz.sh b/apps/files_external/tests/env/stop-sftp-atmoz.sh
index 44380152340..0dcdcebf96d 100755
--- a/apps/files_external/tests/env/stop-sftp-atmoz.sh
+++ b/apps/files_external/tests/env/stop-sftp-atmoz.sh
@@ -1,13 +1,11 @@
#!/usr/bin/env bash
#
-# ownCloud
+# SPDX-FileCopyrightText: 2015-2016 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
#
# 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"
diff --git a/apps/files_external/tests/env/stop-smb-linux.sh b/apps/files_external/tests/env/stop-smb-linux.sh
index 434d3e166b1..dd9e78d2811 100755
--- a/apps/files_external/tests/env/stop-smb-linux.sh
+++ b/apps/files_external/tests/env/stop-smb-linux.sh
@@ -1,13 +1,11 @@
#!/usr/bin/env bash
#
-# ownCloud
+# SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+# SPDX-License-Identifier: AGPL-3.0-or-later
#
# 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##'`
diff --git a/apps/files_external/tests/env/stop-smb-windows.sh b/apps/files_external/tests/env/stop-smb-windows.sh
index 39c49e2c505..268b531e145 100755
--- a/apps/files_external/tests/env/stop-smb-windows.sh
+++ b/apps/files_external/tests/env/stop-smb-windows.sh
@@ -1,9 +1,7 @@
#!/usr/bin/env bash
#
-# ownCloud
-#
-# @author Thomas Müller
-# @copyright 2015 Thomas Müller <deepdiver@owncloud.com>
+# SPDX-FileCopyrightText: 2015 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
#
# retrieve current folder to remove the config from the parent folder
diff --git a/apps/files_external/tests/env/stop-swift-ceph.sh b/apps/files_external/tests/env/stop-swift-ceph.sh
index 418f96e63f6..d23ca2f13dc 100755
--- a/apps/files_external/tests/env/stop-swift-ceph.sh
+++ b/apps/files_external/tests/env/stop-swift-ceph.sh
@@ -1,13 +1,11 @@
#!/bin/bash
#
-# ownCloud
+# SPDX-FileCopyrightText: 2015-2016 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
#
# 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
-# @author Robin McCorkell
-# @copyright 2015 ownCloud
if ! command -v docker >/dev/null 2>&1; then
echo "No docker executable found - skipped docker stop"
diff --git a/apps/files_external/tests/env/stop-webdav-apache.sh b/apps/files_external/tests/env/stop-webdav-apache.sh
index e898a65cc36..825f39470b1 100755
--- a/apps/files_external/tests/env/stop-webdav-apache.sh
+++ b/apps/files_external/tests/env/stop-webdav-apache.sh
@@ -1,13 +1,7 @@
#!/bin/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 2014 Morris Jobke <hey@morrisjobke.de>
-# @copyright 2016 Vincent Petry <pvince81@owncloud.com>
+# SPDX-FileCopyrightText: 2015-2016 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
#
if ! command -v docker >/dev/null 2>&1; then
diff --git a/apps/files_external/tests/env/stop-webdav-apachedrone.sh b/apps/files_external/tests/env/stop-webdav-apachedrone.sh
deleted file mode 100755
index 3c4b0492dd0..00000000000
--- a/apps/files_external/tests/env/stop-webdav-apachedrone.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env bash
-#
-# Nextcloud
-
-# retrieve current folder to remove the config from the parent folder
-thisFolder=`echo $0 | sed 's#env/stop-webdav-apachedrone\.sh##'`
-
-if [ -z "$thisFolder" ]; then
- thisFolder="."
-fi;
-
-# cleanup
-rm $thisFolder/config.webdav.php
-
diff --git a/apps/files_external/tests/env/stop-webdav-ownCloud.sh b/apps/files_external/tests/env/stop-webdav-ownCloud.sh
index 613a22efb8c..140e7cce23b 100755
--- a/apps/files_external/tests/env/stop-webdav-ownCloud.sh
+++ b/apps/files_external/tests/env/stop-webdav-ownCloud.sh
@@ -1,12 +1,7 @@
#!/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 2014 Morris Jobke <hey@morrisjobke.de>
+# SPDX-FileCopyrightText: 2014-2016 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
#
if ! command -v docker >/dev/null 2>&1; then
diff --git a/apps/files_external/tests/env/wait-for-connection b/apps/files_external/tests/env/wait-for-connection
index 2c480fb733e..a3ff5591122 100755
--- a/apps/files_external/tests/env/wait-for-connection
+++ b/apps/files_external/tests/env/wait-for-connection
@@ -1,6 +1,11 @@
#!/usr/bin/php
<?php
+/**
+ * SPDX-FileCopyrightText: 2015 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
$timeout = 60;
switch ($argc) {
diff --git a/apps/files_external/tests/js/mountsfilelistSpec.js b/apps/files_external/tests/js/mountsfilelistSpec.js
deleted file mode 100644
index 389b76550b7..00000000000
--- a/apps/files_external/tests/js/mountsfilelistSpec.js
+++ /dev/null
@@ -1,166 +0,0 @@
-/**
- * Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-describe('OCA.Files_External.FileList tests', function() {
- var testFiles, alertStub, notificationStub, fileList;
-
- beforeEach(function() {
- alertStub = sinon.stub(OC.dialogs, 'alert');
- notificationStub = sinon.stub(OC.Notification, 'show');
-
- // init parameters and test table elements
- $('#testArea').append(
- '<div id="app-content">' +
- // init horrible parameters
- '<input type="hidden" id="permissions" value="31"></input>' +
- // dummy controls
- '<div class="files-controls">' +
- ' <div class="actions creatable"></div>' +
- ' <div class="notCreatable"></div>' +
- '</div>' +
- // dummy table
- // TODO: at some point this will be rendered by the fileList class itself!
- '<table class="files-filestable">' +
- '<thead><tr>' +
- '<th class="hidden column-name">' +
- ' <div id="column-name-container">' +
- ' <a class="name sort columntitle" data-sort="name"><span>Name</span><span class="sort-indicator"></span></a>' +
- ' </div>' +
- '</th>' +
- '<th id="headerBackend" class="hidden column-backend">' +
- ' <a class="backend sort columntitle" data-sort="backend"><span>Storage type</span><span class="sort-indicator"></span></a>' +
- '</th>' +
- '<th id="headerScope" class="hidden column-scope column-last">' +
- ' <a class="scope sort columntitle" data-sort="scope"><span>Scope</span><span class="sort-indicator"></span></a>' +
- '</th>' +
- '</tr></thead>' +
- '<tbody class="files-fileList"></tbody>' +
- '<tfoot></tfoot>' +
- '</table>' +
- '<div class="emptyfilelist emptycontent">Empty content message</div>' +
- '</div>'
- );
- });
- afterEach(function() {
- testFiles = undefined;
- fileList.destroy();
- fileList = undefined;
-
- notificationStub.restore();
- alertStub.restore();
- });
-
- describe('loading file list for external storage', function() {
- var ocsResponse;
- var reloading;
-
- beforeEach(function() {
- fileList = new OCA.Files_External.FileList(
- $('#app-content')
- );
-
- reloading = fileList.reload();
-
- /* jshint camelcase: false */
- ocsResponse = {
- ocs: {
- meta: {
- status: 'ok',
- statuscode: 100,
- message: null
- },
- data: [{
- name: 'smb mount',
- path: '/mount points',
- type: 'dir',
- backend: 'SMB',
- scope: 'personal',
- permissions: OC.PERMISSION_READ | OC.PERMISSION_DELETE
- }, {
- name: 'sftp mount',
- path: '/another mount points',
- type: 'dir',
- backend: 'SFTP',
- scope: 'system',
- permissions: OC.PERMISSION_READ
- }]
- }
- };
- });
- it('render storage list', function(done) {
- var request;
- var $rows;
- var $tr;
-
- expect(fakeServer.requests.length).toEqual(1);
- request = fakeServer.requests[0];
- expect(request.url).toEqual(
- OC.linkToOCS('apps/files_external/api/v1') + 'mounts?format=json'
- );
-
- fakeServer.requests[0].respond(
- 200,
- { 'Content-Type': 'application/json' },
- JSON.stringify(ocsResponse)
- );
-
- return reloading.then(function() {
- $rows = fileList.$el.find('tbody tr');
- expect($rows.length).toEqual(2);
-
- $tr = $rows.eq(0);
- expect($tr.attr('data-id')).not.toBeDefined();
- expect($tr.attr('data-type')).toEqual('dir');
- expect($tr.attr('data-file')).toEqual('sftp mount');
- expect($tr.attr('data-path')).toEqual('/another mount points');
- expect($tr.attr('data-size')).not.toBeDefined();
- expect($tr.attr('data-permissions')).toEqual('1'); // read only
- expect($tr.find('a.name').attr('href')).toEqual(
- OC.getRootPath() +
- '/index.php/apps/files' +
- '?dir=/another%20mount%20points/sftp%20mount'
- );
- expect($tr.find('.nametext').text().trim()).toEqual('sftp mount');
- expect($tr.find('.column-scope > span').text().trim()).toEqual('System');
- expect($tr.find('.column-backend').text().trim()).toEqual('SFTP');
-
- $tr = $rows.eq(1);
- expect($tr.attr('data-id')).not.toBeDefined();
- expect($tr.attr('data-type')).toEqual('dir');
- expect($tr.attr('data-file')).toEqual('smb mount');
- expect($tr.attr('data-path')).toEqual('/mount points');
- expect($tr.attr('data-size')).not.toBeDefined();
- expect($tr.attr('data-permissions')).toEqual('9'); // read and delete
- expect($tr.find('a.name').attr('href')).toEqual(
- OC.getRootPath() +
- '/index.php/apps/files' +
- '?dir=/mount%20points/smb%20mount'
- );
- expect($tr.find('.nametext').text().trim()).toEqual('smb mount');
- expect($tr.find('.column-scope > span').text().trim()).toEqual('Personal');
- expect($tr.find('.column-backend').text().trim()).toEqual('SMB');
- }).then(done, done);
- });
- });
-});
diff --git a/apps/files_external/tests/js/settingsSpec.js b/apps/files_external/tests/js/settingsSpec.js
deleted file mode 100644
index 4032f6f6a37..00000000000
--- a/apps/files_external/tests/js/settingsSpec.js
+++ /dev/null
@@ -1,471 +0,0 @@
-/**
- * Copyright (c) 2015 Vincent Petry <pvince81@owncloud.com>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- * @author Juan Pablo Villafáñez <jvillafanez@solidgear.es>
- * @author Julius Härtl <jus@bitgrid.net>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-describe('OCA.Files_External.Settings tests', function() {
- var clock;
- var select2Stub;
- var select2ApplicableUsers;
-
- beforeEach(function() {
- clock = sinon.useFakeTimers();
- select2ApplicableUsers = [];
- select2Stub = sinon.stub($.fn, 'select2').callsFake(function(args) {
- if (args === 'val') {
- return select2ApplicableUsers;
- }
- return {
- on: function() { return this; }
- };
- });
-
- // view still requires an existing DOM table
- $('#testArea').append(
- '<table id="externalStorage" data-admin="true">' +
- '<thead></thead>' +
- '<tbody>' +
- '<tr id="addMountPoint" data-id="">' +
- '<td class="status"></td>' +
- '<td class="mountPoint"><input type="text" name="mountPoint"/></td>' +
- '<td class="backend">' +
- '<select class="selectBackend">' +
- '<option disable selected>Add storage</option>' +
- '<option value="\\OC\\TestBackend">Test Backend</option>' +
- '<option value="\\OC\\AnotherTestBackend">Another Test Backend</option>' +
- '<option value="\\OC\\InputsTestBackend">Inputs test backend</option>' +
- '</select>' +
- '</td>' +
- '<td class="authentication"></td>' +
- '<td class="configuration"></td>' +
- '<td class="applicable">' +
- '<input type="checkbox" class="applicableToAllUsers">' +
- '<input type="hidden" class="applicableUsers">' +
- '</td>' +
- '<td class="mountOptionsToggle">'+
- '<div class="icon-more" title="Advanced settings" deluminate_imagetype="unknown"></div>'+
- '<input type="hidden" class="mountOptions"/>'+
- '</td>'+
- '<td class="save">'+
- '<div class="icon-checkmark" title="Save" deluminate_imagetype="unknown"></div>'+
- '</td>'+
- '</tr>' +
- '</tbody>' +
- '</table>'
- );
- // these are usually appended into the data attribute
- // within the DOM by the server template
- $('#externalStorage .selectBackend:first').data('configurations', {
- '\\OC\\TestBackend': {
- 'identifier': '\\OC\\TestBackend',
- 'name': 'Test Backend',
- 'configuration': {
- 'field1': {
- 'value': 'Display Name 1'
- },
- 'field2': {
- 'value': 'Display Name 2',
- 'flags': 1
- }
- },
- 'authSchemes': {
- 'builtin': true,
- },
- 'priority': 11
- },
- '\\OC\\AnotherTestBackend': {
- 'identifier': '\\OC\\AnotherTestBackend',
- 'name': 'Another Test Backend',
- 'configuration': {
- 'field1': {
- 'value': 'Display Name 1'
- },
- 'field2': {
- 'value': 'Display Name 2',
- 'flags': 1
- }
- },
- 'authSchemes': {
- 'builtin': true,
- },
- 'priority': 12
- },
- '\\OC\\InputsTestBackend': {
- 'identifier': '\\OC\\InputsTestBackend',
- 'name': 'Inputs test backend',
- 'configuration': {
- 'field_text': {
- 'value': 'Text field'
- },
- 'field_password': {
- 'value': ',Password field',
- 'type': 2
- },
- 'field_bool': {
- 'value': 'Boolean field',
- 'type': 1
- },
- 'field_hidden': {
- 'value': 'Hidden field',
- 'type': 3
- },
- 'field_text_optional': {
- 'value': 'Text field optional',
- 'flags': 1
- },
- 'field_password_optional': {
- 'value': 'Password field optional',
- 'flags': 1,
- 'type': 2
- }
- },
- 'authSchemes': {
- 'builtin': true,
- },
- 'priority': 13
- }
- }
- );
-
- $('#externalStorage #addMountPoint .authentication:first').data('mechanisms', {
- 'mechanism1': {
- 'identifier': 'mechanism1',
- 'name': 'Mechanism 1',
- 'configuration': {
- },
- 'scheme': 'builtin',
- 'visibility': 3
- },
- });
-
- });
- afterEach(function() {
- select2Stub.restore();
- clock.restore();
- });
-
- describe('storage configuration', function() {
- var view;
-
- function selectBackend(backendName) {
- view.$el.find('.selectBackend:first').val(backendName).trigger('change');
- view.$el.find('.applicableToAllUsers').prop('checked', true).trigger('change');
- }
-
- beforeEach(function() {
- var $el = $('#externalStorage');
- view = new OCA.Files_External.Settings.MountConfigListView($el, {encryptionEnabled: false});
- });
- afterEach(function() {
- view = null;
- });
- describe('selecting backend', function() {
- it('populates the row and creates a new empty one', function() {
- selectBackend('\\OC\\TestBackend');
- var $firstRow = view.$el.find('tr:first');
- expect($firstRow.find('.backend').text()).toEqual('Test Backend');
- expect($firstRow.find('.selectBackend').length).toEqual(0);
-
- // TODO: check "remove" button visibility
-
- // the suggested mount point name
- expect($firstRow.find('[name=mountPoint]').val()).toEqual('TestBackend');
-
- // TODO: check that the options have been created
-
- // TODO: check select2 call on the ".applicableUsers" element
-
- var $emptyRow = $firstRow.next('tr');
- expect($emptyRow.length).toEqual(1);
- expect($emptyRow.find('.selectBackend').length).toEqual(1);
- expect($emptyRow.find('.applicable select').length).toEqual(0);
-
- // TODO: check "remove" button visibility
- });
- it('shows row even if selection row is hidden', function() {
- selectBackend('\\OC\\TestBackend');
- view.$el.find('tr#addMountPoint').hide();
- expect(view.$el.find('tr:first').is(':visible')).toBe(true);
- expect(view.$el.find('tr#addMountPoint').is(':visible')).toBe(false);
- });
- // TODO: test with personal mounts (no applicable fields)
- // TODO: test suggested mount point logic
- });
- describe('saving storages', function() {
- var $tr;
-
- beforeEach(function() {
- selectBackend('\\OC\\TestBackend');
- $tr = view.$el.find('tr:first');
- });
- it('saves storage after clicking the save button', function() {
- var $field1 = $tr.find('input[data-parameter=field1]');
- expect($field1.length).toEqual(1);
- $field1.val('test');
- $field1.trigger(new $.Event('keyup', {keyCode: 97}));
-
- var $mountOptionsField = $tr.find('input.mountOptions');
- expect($mountOptionsField.length).toEqual(1);
- $mountOptionsField.val(JSON.stringify({previews:true}));
-
- var $saveButton = $tr.find('td.save .icon-checkmark');
- $saveButton.click();
-
- expect(fakeServer.requests.length).toEqual(1);
- var request = fakeServer.requests[0];
- expect(request.url).toEqual(OC.getRootPath() + '/index.php/apps/files_external/globalstorages');
- expect(JSON.parse(request.requestBody)).toEqual({
- backend: '\\OC\\TestBackend',
- authMechanism: 'mechanism1',
- backendOptions: {
- 'field1': 'test',
- 'field2': ''
- },
- mountPoint: 'TestBackend',
- priority: 11,
- applicableUsers: [],
- applicableGroups: [],
- mountOptions: {
- 'previews': true
- },
- testOnly: true
- });
-
- // TODO: respond and check data-id
- });
- it('saves storage with applicable users', function() {
- var $field1 = $tr.find('input[data-parameter=field1]');
- expect($field1.length).toEqual(1);
- $field1.val('test');
- $field1.trigger(new $.Event('keyup', {keyCode: 97}));
-
- $tr.find('.applicableToAllUsers').prop('checked', false).trigger('change');
- select2ApplicableUsers = ['user1', 'user2', 'group1(group)', 'group2(group)'];
-
- var $saveButton = $tr.find('td.save .icon-checkmark');
- $saveButton.click();
-
- expect(fakeServer.requests.length).toEqual(1);
- var request = fakeServer.requests[0];
- expect(request.url).toEqual(OC.getRootPath() + '/index.php/apps/files_external/globalstorages');
- expect(JSON.parse(request.requestBody)).toEqual({
- backend: '\\OC\\TestBackend',
- authMechanism: 'mechanism1',
- backendOptions: {
- 'field1': 'test',
- 'field2': ''
- },
- mountPoint: 'TestBackend',
- priority: 11,
- applicableUsers: ['user1', 'user2'],
- applicableGroups: ['group1', 'group2'],
- mountOptions: {
- encrypt: true,
- previews: true,
- enable_sharing: false,
- filesystem_check_changes: 1,
- encoding_compatibility: false,
- readonly: false,
- },
- testOnly: true
- });
-
- // TODO: respond and check data-id
- });
- it('does not saves storage without applicable users and unchecked all users checkbox', function() {
- var $field1 = $tr.find('input[data-parameter=field1]');
- expect($field1.length).toEqual(1);
- $field1.val('test');
- $field1.trigger(new $.Event('keyup', {keyCode: 97}));
-
- $tr.find('.applicableToAllUsers').prop('checked', false).trigger('change');
-
- var $saveButton = $tr.find('td.save .icon-checkmark');
- $saveButton.click();
-
- expect(fakeServer.requests.length).toEqual(0);
- });
-
- it('saves storage after closing mount options popovermenu', function() {
- $tr.find('.mountOptionsToggle .icon-more').click();
- $tr.find('[name=previews]').trigger(new $.Event('keyup', {keyCode: 97}));
- $tr.find('input[data-parameter=field1]').val('test');
-
- // does not save inside the popovermenu
- expect(fakeServer.requests.length).toEqual(0);
-
- $('body').mouseup();
-
- // but after closing the popovermenu
- expect(fakeServer.requests.length).toEqual(1);
- });
- // TODO: status indicator
- });
- describe('validate storage configuration', function() {
- var $tr;
-
- beforeEach(function() {
- selectBackend('\\OC\\InputsTestBackend');
- $tr = view.$el.find('tr:first');
- });
-
- it('lists missing fields in storage errors', function() {
- $tr.find('.applicableToAllUsers').prop('checked', false).trigger('change');
- var storage = view.getStorageConfig($tr);
-
- expect(storage.errors).toEqual({
- backendOptions: ['field_text', 'field_password'],
- requiredApplicable: true,
- });
- });
-
- it('does not list applicable when all users checkbox is ticked', function() {
- var storage = view.getStorageConfig($tr);
-
- expect(storage.errors).toEqual({
- backendOptions: ['field_text', 'field_password']
- });
- });
-
- it('highlights missing non-optional fields', function() {
- _.each([
- 'field_text',
- 'field_password'
- ], function(param) {
- expect($tr.find('input[data-parameter='+param+']').hasClass('warning-input')).toBe(true);
- });
- _.each([
- 'field_bool',
- 'field_hidden',
- 'field_text_optional',
- 'field_password_optional'
- ], function(param) {
- expect($tr.find('input[data-parameter='+param+']').hasClass('warning-input')).toBe(false);
- });
- });
-
- it('validates correct storage', function() {
- $tr.find('[name=mountPoint]').val('mountpoint');
-
- $tr.find('input[data-parameter=field_text]').val('foo');
- $tr.find('input[data-parameter=field_password]').val('bar');
- $tr.find('input[data-parameter=field_text_optional]').val('foobar');
- // don't set field_password_optional
- $tr.find('input[data-parameter=field_hidden]').val('baz');
-
- var storage = view.getStorageConfig($tr);
-
- expect(storage.validate()).toBe(true);
- });
-
- it('checks missing mount point', function() {
- $tr.find('[name=mountPoint]').val('');
-
- $tr.find('input[data-parameter=field_text]').val('foo');
- $tr.find('input[data-parameter=field_password]').val('bar');
-
- var storage = view.getStorageConfig($tr);
-
- expect(storage.validate()).toBe(false);
- });
- });
- describe('update storage', function() {
- // TODO
- });
- describe('delete storage', function() {
- // TODO
- });
- describe('recheck storages', function() {
- // TODO
- });
- describe('mount options popovermenu', function() {
- var $tr;
- var $td;
-
- beforeEach(function() {
- selectBackend('\\OC\\TestBackend');
- $tr = view.$el.find('tr:first');
- $td = $tr.find('.mountOptionsToggle');
- });
-
- it('shows popovermenu when clicking on toggle button, hides when clicking outside', function() {
- $td.find('.icon-more').click();
-
- expect($td.find('.popovermenu.open').length).toEqual(1);
-
- $('body').mouseup();
-
- expect($td.find('.popovermenu.open').length).toEqual(0);
- });
-
- it('doesnt show the encryption option when encryption is disabled', function () {
- view._encryptionEnabled = false;
- $td.find('.icon-more').click();
-
- expect($td.find('.popovermenu [name=encrypt]:visible').length).toEqual(0);
-
- $('body').mouseup();
-
- expect($td.find('.popovermenu.open').length).toEqual(0);
- });
-
- it('reads config from mountOptions field', function() {
- $tr.find('input.mountOptions').val(JSON.stringify({previews:false}));
-
- $td.find('.icon-more').click();
- expect($td.find('.popovermenu [name=previews]').prop('checked')).toEqual(false);
- $('body').mouseup();
-
- $tr.find('input.mountOptions').val(JSON.stringify({previews:true}));
- $td.find('.icon-more').click();
- expect($td.find('.popovermenu [name=previews]').prop('checked')).toEqual(true);
- });
-
- it('writes config into mountOptions field', function() {
- $td.find('.icon-more').click();
- // defaults to true
- var $field = $td.find('.popovermenu [name=previews]');
- expect($field.prop('checked')).toEqual(true);
- $td.find('.popovermenu [name=filesystem_check_changes]').val(0);
- $('body').mouseup();
-
- expect(JSON.parse($tr.find('input.mountOptions').val())).toEqual({
- encrypt: true,
- previews: true,
- enable_sharing: false,
- filesystem_check_changes: 0,
- encoding_compatibility: false,
- readonly: false
- });
- });
- });
- });
- describe('allow user mounts section', function() {
- // TODO: test allowUserMounting section
- });
-});
diff --git a/apps/files_external/tests/sso-setup/apps.config.php b/apps/files_external/tests/sso-setup/apps.config.php
index 08f1288bd3d..b3889956a53 100644
--- a/apps/files_external/tests/sso-setup/apps.config.php
+++ b/apps/files_external/tests/sso-setup/apps.config.php
@@ -1,16 +1,20 @@
<?php
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
$CONFIG = [
- "apps_paths" => [
+ 'apps_paths' => [
[
- "path" => "/var/www/html/apps",
- "url" => "/apps",
- "writable" => false,
+ 'path' => '/var/www/html/apps',
+ 'url' => '/apps',
+ 'writable' => false,
],
[
- "path" => "/var/www/html/extra-apps",
- "url" => "/extra-apps",
- "writable" => true,
+ 'path' => '/var/www/html/extra-apps',
+ 'url' => '/extra-apps',
+ 'writable' => true,
],
],
];
diff --git a/apps/files_external/tests/sso-setup/client-cmd.sh b/apps/files_external/tests/sso-setup/client-cmd.sh
index c97045bea4c..38b50bada67 100755
--- a/apps/files_external/tests/sso-setup/client-cmd.sh
+++ b/apps/files_external/tests/sso-setup/client-cmd.sh
@@ -1,4 +1,8 @@
#!/usr/bin/env bash
+#
+# SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+# SPDX-License-Identifier: AGPL-3.0-or-later
+#
DC_IP=$1
shift
diff --git a/apps/files_external/tests/sso-setup/setup-sso-nc.sh b/apps/files_external/tests/sso-setup/setup-sso-nc.sh
index 60cc51ff68d..d0029ea684e 100755
--- a/apps/files_external/tests/sso-setup/setup-sso-nc.sh
+++ b/apps/files_external/tests/sso-setup/setup-sso-nc.sh
@@ -1,4 +1,9 @@
#!/usr/bin/env bash
+#
+# SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+# SPDX-License-Identifier: AGPL-3.0-or-later
+#
+
set -e
docker exec --user 33 apache ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
diff --git a/apps/files_external/tests/sso-setup/start-apache.sh b/apps/files_external/tests/sso-setup/start-apache.sh
index b483c73fa4f..58ad71e3a3a 100755
--- a/apps/files_external/tests/sso-setup/start-apache.sh
+++ b/apps/files_external/tests/sso-setup/start-apache.sh
@@ -1,4 +1,9 @@
#!/usr/bin/env bash
+#
+# SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+# SPDX-License-Identifier: AGPL-3.0-or-later
+#
+
set -e
SCRIPT_DIR="${0%/*}"
@@ -10,6 +15,9 @@ APACHE_IP=$(docker inspect apache --format '{{.NetworkSettings.IPAddress}}')
docker exec apache chown 33 /var/www/html/config /var/www/html/data /var/www/html/extra-apps
docker cp "$SCRIPT_DIR/apps.config.php" apache:/var/www/html/config/apps.config.php
+# ensure that samba is started (see https://github.com/icewind1991/samba-krb-test/pull/8)
+docker exec dc service samba-ad-dc status || docker exec dc service samba-ad-dc start
+
# add the dns record for apache
docker exec dc samba-tool dns add krb.domain.test domain.test httpd A $APACHE_IP -U administrator --password=passwOrd1 1>&2
diff --git a/apps/files_external/tests/sso-setup/start-dc.sh b/apps/files_external/tests/sso-setup/start-dc.sh
index df8b02318df..c08b49477b3 100755
--- a/apps/files_external/tests/sso-setup/start-dc.sh
+++ b/apps/files_external/tests/sso-setup/start-dc.sh
@@ -1,4 +1,9 @@
#!/usr/bin/env bash
+#
+# SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+# SPDX-License-Identifier: AGPL-3.0-or-later
+#
+
set -e
function getContainerHealth {
diff --git a/apps/files_external/tests/sso-setup/test-sso-smb.sh b/apps/files_external/tests/sso-setup/test-sso-smb.sh
index b0f0a2c7af9..46955ae0d3c 100755
--- a/apps/files_external/tests/sso-setup/test-sso-smb.sh
+++ b/apps/files_external/tests/sso-setup/test-sso-smb.sh
@@ -1,15 +1,22 @@
#!/usr/bin/env bash
+#
+# SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+# SPDX-License-Identifier: AGPL-3.0-or-later
+#
+
set -e
DC_IP="$1"
SCRIPT_DIR="${0%/*}"
echo -n "Checking that we can authenticate using kerberos: "
-LOGIN_CONTENT=$("$SCRIPT_DIR/client-cmd.sh" $DC_IP curl -i -s --negotiate -u testuser@DOMAIN.TEST: --delegation always http://httpd.domain.test/index.php/apps/user_saml/saml/login?originalUrl=success)
-if [[ "$LOGIN_CONTENT" =~ "Location: success" ]]; then
+LOGIN_CONTENT=$("$SCRIPT_DIR/client-cmd.sh" $DC_IP curl -i -s --negotiate -u testuser@DOMAIN.TEST: --delegation always http://httpd.domain.test/index.php/apps/user_saml/saml/login?originalUrl=http://localhost/success)
+
+if [[ "$LOGIN_CONTENT" =~ "Location: http://localhost/success" ]]; then
echo "✔️"
else
echo "❌"
+ echo "$CONTENT"
exit 1
fi
echo -n "Getting test file: "
@@ -20,5 +27,6 @@ if [[ $CONTENT == "testfile" ]]; then
echo "✔️"
else
echo "❌"
+ echo "$CONTENT"
exit 1
fi