2015-02-07 02:07:53 -05:00
|
|
|
<?php
|
2025-06-30 09:04:05 -04:00
|
|
|
|
2015-02-07 02:07:53 -05:00
|
|
|
/**
|
2024-06-06 13:48:28 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2015-02-26 02:35:41 -05:00
|
|
|
*/
|
2015-02-07 02:07:53 -05:00
|
|
|
namespace OCA\Files_Sharing\Tests;
|
|
|
|
|
|
2021-11-05 05:44:51 -04:00
|
|
|
use OC\KnownUser\KnownUserService;
|
2021-04-23 11:29:34 -04:00
|
|
|
use OC\Share20\Manager;
|
2023-08-15 12:21:04 -04:00
|
|
|
use OC\Share20\ShareDisableChecker;
|
2015-02-07 02:07:53 -05:00
|
|
|
use OCA\Files_Sharing\Capabilities;
|
2025-08-07 01:14:40 -04:00
|
|
|
use OCP\App\IAppManager;
|
2021-04-23 11:29:34 -04:00
|
|
|
use OCP\EventDispatcher\IEventDispatcher;
|
|
|
|
|
use OCP\Files\IRootFolder;
|
|
|
|
|
use OCP\Files\Mount\IMountManager;
|
2025-01-09 17:52:33 -05:00
|
|
|
use OCP\IAppConfig;
|
2017-10-24 09:26:53 -04:00
|
|
|
use OCP\IConfig;
|
2024-02-07 06:06:12 -05:00
|
|
|
use OCP\IDateTimeZone;
|
2021-04-23 11:29:34 -04:00
|
|
|
use OCP\IGroupManager;
|
|
|
|
|
use OCP\IURLGenerator;
|
|
|
|
|
use OCP\IUserManager;
|
|
|
|
|
use OCP\IUserSession;
|
|
|
|
|
use OCP\L10N\IFactory;
|
|
|
|
|
use OCP\Mail\IMailer;
|
|
|
|
|
use OCP\Security\IHasher;
|
|
|
|
|
use OCP\Security\ISecureRandom;
|
|
|
|
|
use OCP\Share\IProviderFactory;
|
2022-03-21 07:41:58 -04:00
|
|
|
use Psr\Log\LoggerInterface;
|
2017-07-24 01:44:09 -04:00
|
|
|
|
2015-02-07 02:07:53 -05:00
|
|
|
/**
|
2016-05-17 05:42:03 -04:00
|
|
|
* Class CapabilitiesTest
|
2015-11-02 19:52:41 -05:00
|
|
|
*
|
|
|
|
|
* @group DB
|
2015-02-07 02:07:53 -05:00
|
|
|
*/
|
2016-05-17 05:42:03 -04:00
|
|
|
class CapabilitiesTest extends \Test\TestCase {
|
2015-02-07 02:07:53 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test for the general part in each return statement and assert.
|
|
|
|
|
* Strip of the general part on the way.
|
|
|
|
|
*
|
|
|
|
|
* @param string[] $data Capabilities
|
|
|
|
|
* @return string[]
|
|
|
|
|
*/
|
2015-03-11 11:30:54 -04:00
|
|
|
private function getFilesSharingPart(array $data) {
|
2015-03-21 15:12:55 -04:00
|
|
|
$this->assertArrayHasKey('files_sharing', $data);
|
|
|
|
|
return $data['files_sharing'];
|
2015-02-07 02:07:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2017-03-30 10:29:34 -04:00
|
|
|
* Create a mock config object and insert the values in $map to the getAppValue
|
2015-02-07 02:07:53 -05:00
|
|
|
* function. Then obtain the capabilities and extract the first few
|
|
|
|
|
* levels in the array
|
|
|
|
|
*
|
|
|
|
|
* @param (string[])[] $map Map of arguments to return types for the getAppValue function in the mock
|
|
|
|
|
* @return string[]
|
|
|
|
|
*/
|
2025-08-07 09:58:35 -04:00
|
|
|
private function getResults(array $map, array $typedMap = [], bool $federationEnabled = true) {
|
2017-10-24 09:26:53 -04:00
|
|
|
$config = $this->getMockBuilder(IConfig::class)->disableOriginalConstructor()->getMock();
|
2025-08-07 01:14:40 -04:00
|
|
|
$appManager = $this->getMockBuilder(IAppManager::class)->disableOriginalConstructor()->getMock();
|
2020-03-25 17:21:27 -04:00
|
|
|
$config->method('getAppValue')->willReturnMap($map);
|
2025-08-07 01:14:40 -04:00
|
|
|
$appManager->method('isEnabledForAnyone')->with('federation')->willReturn($federationEnabled);
|
2025-08-07 09:58:35 -04:00
|
|
|
|
|
|
|
|
if (empty($typedMap)) {
|
|
|
|
|
$appConfig = $this->createMock(IAppConfig::class);
|
|
|
|
|
} else {
|
|
|
|
|
// hack to help transition from old IConfig to new IAppConfig
|
|
|
|
|
$appConfig = $this->getMockBuilder(IAppConfig::class)->disableOriginalConstructor()->getMock();
|
|
|
|
|
$appConfig->expects($this->any())->method('getValueBool')->willReturnCallback(function (...$args) use ($typedMap): bool {
|
|
|
|
|
foreach ($typedMap as $entry) {
|
|
|
|
|
if ($entry[0] !== $args[0] || $entry[1] !== $args[1]) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $entry[2];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-23 11:29:34 -04:00
|
|
|
$shareManager = new Manager(
|
2022-03-21 07:41:58 -04:00
|
|
|
$this->createMock(LoggerInterface::class),
|
2021-04-23 11:29:34 -04:00
|
|
|
$config,
|
|
|
|
|
$this->createMock(ISecureRandom::class),
|
|
|
|
|
$this->createMock(IHasher::class),
|
|
|
|
|
$this->createMock(IMountManager::class),
|
|
|
|
|
$this->createMock(IGroupManager::class),
|
|
|
|
|
$this->createMock(IFactory::class),
|
|
|
|
|
$this->createMock(IProviderFactory::class),
|
|
|
|
|
$this->createMock(IUserManager::class),
|
|
|
|
|
$this->createMock(IRootFolder::class),
|
|
|
|
|
$this->createMock(IMailer::class),
|
|
|
|
|
$this->createMock(IURLGenerator::class),
|
|
|
|
|
$this->createMock(\OC_Defaults::class),
|
|
|
|
|
$this->createMock(IEventDispatcher::class),
|
2021-11-05 05:44:51 -04:00
|
|
|
$this->createMock(IUserSession::class),
|
2023-08-15 12:21:04 -04:00
|
|
|
$this->createMock(KnownUserService::class),
|
2024-02-07 06:06:12 -05:00
|
|
|
$this->createMock(ShareDisableChecker::class),
|
|
|
|
|
$this->createMock(IDateTimeZone::class),
|
2025-08-07 09:58:35 -04:00
|
|
|
$appConfig,
|
2021-04-23 11:29:34 -04:00
|
|
|
);
|
2025-08-07 09:58:35 -04:00
|
|
|
|
|
|
|
|
$cap = new Capabilities($config, $appConfig, $shareManager, $appManager);
|
2015-03-21 15:12:55 -04:00
|
|
|
$result = $this->getFilesSharingPart($cap->getCapabilities());
|
2015-02-07 02:07:53 -05:00
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-25 05:24:23 -04:00
|
|
|
public function testEnabledSharingAPI(): void {
|
|
|
|
|
$map = [
|
|
|
|
|
['core', 'shareapi_enabled', 'yes', 'yes'],
|
|
|
|
|
];
|
|
|
|
|
$result = $this->getResults($map);
|
|
|
|
|
$this->assertTrue($result['api_enabled']);
|
2020-12-03 10:38:25 -05:00
|
|
|
$this->assertArrayHasKey('public', $result);
|
|
|
|
|
$this->assertArrayHasKey('user', $result);
|
|
|
|
|
$this->assertArrayHasKey('resharing', $result);
|
2015-09-25 05:24:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testDisabledSharingAPI(): void {
|
|
|
|
|
$map = [
|
|
|
|
|
['core', 'shareapi_enabled', 'yes', 'no'],
|
|
|
|
|
];
|
|
|
|
|
$result = $this->getResults($map);
|
|
|
|
|
$this->assertFalse($result['api_enabled']);
|
2020-12-03 10:38:25 -05:00
|
|
|
$this->assertFalse($result['public']['enabled']);
|
|
|
|
|
$this->assertFalse($result['user']['send_mail']);
|
|
|
|
|
$this->assertFalse($result['resharing']);
|
2015-09-25 05:24:23 -04:00
|
|
|
}
|
|
|
|
|
|
2015-02-07 02:07:53 -05:00
|
|
|
public function testNoLinkSharing(): void {
|
2015-02-26 02:39:55 -05:00
|
|
|
$map = [
|
2015-09-25 05:24:23 -04:00
|
|
|
['core', 'shareapi_enabled', 'yes', 'yes'],
|
2015-02-26 02:39:55 -05:00
|
|
|
['core', 'shareapi_allow_links', 'yes', 'no'],
|
|
|
|
|
];
|
2015-02-07 02:07:53 -05:00
|
|
|
$result = $this->getResults($map);
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsArray($result['public']);
|
2015-02-09 08:26:49 -05:00
|
|
|
$this->assertFalse($result['public']['enabled']);
|
2015-02-07 02:07:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testOnlyLinkSharing(): void {
|
2015-02-26 02:39:55 -05:00
|
|
|
$map = [
|
2015-09-25 05:24:23 -04:00
|
|
|
['core', 'shareapi_enabled', 'yes', 'yes'],
|
2015-02-26 02:39:55 -05:00
|
|
|
['core', 'shareapi_allow_links', 'yes', 'yes'],
|
2022-02-15 11:45:09 -05:00
|
|
|
['core', 'shareapi_enforce_links_password_excluded_groups', '', ''],
|
2015-02-26 02:39:55 -05:00
|
|
|
];
|
2015-02-07 02:07:53 -05:00
|
|
|
$result = $this->getResults($map);
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsArray($result['public']);
|
2015-02-09 08:26:49 -05:00
|
|
|
$this->assertTrue($result['public']['enabled']);
|
2015-02-07 02:07:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testLinkPassword(): void {
|
2015-02-26 02:39:55 -05:00
|
|
|
$map = [
|
2015-09-25 05:24:23 -04:00
|
|
|
['core', 'shareapi_enabled', 'yes', 'yes'],
|
2015-02-26 02:39:55 -05:00
|
|
|
['core', 'shareapi_allow_links', 'yes', 'yes'],
|
2022-02-15 11:45:09 -05:00
|
|
|
['core', 'shareapi_enforce_links_password_excluded_groups', '', ''],
|
2015-02-26 02:39:55 -05:00
|
|
|
];
|
2025-08-07 09:58:35 -04:00
|
|
|
$typedMap = [
|
|
|
|
|
['core', 'shareapi_enforce_links_password', true],
|
|
|
|
|
];
|
|
|
|
|
$result = $this->getResults($map, $typedMap);
|
2015-03-11 10:11:50 -04:00
|
|
|
$this->assertArrayHasKey('password', $result['public']);
|
|
|
|
|
$this->assertArrayHasKey('enforced', $result['public']['password']);
|
|
|
|
|
$this->assertTrue($result['public']['password']['enforced']);
|
2015-02-07 02:07:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testLinkNoPassword(): void {
|
2015-02-26 02:39:55 -05:00
|
|
|
$map = [
|
2015-09-25 05:24:23 -04:00
|
|
|
['core', 'shareapi_enabled', 'yes', 'yes'],
|
2015-02-26 02:39:55 -05:00
|
|
|
['core', 'shareapi_allow_links', 'yes', 'yes'],
|
2022-02-15 11:45:09 -05:00
|
|
|
['core', 'shareapi_enforce_links_password_excluded_groups', '', ''],
|
2015-08-13 07:07:49 -04:00
|
|
|
['core', 'shareapi_enforce_links_password', 'no', 'no'],
|
2015-02-26 02:39:55 -05:00
|
|
|
];
|
2015-02-07 02:07:53 -05:00
|
|
|
$result = $this->getResults($map);
|
2015-03-11 10:11:50 -04:00
|
|
|
$this->assertArrayHasKey('password', $result['public']);
|
|
|
|
|
$this->assertArrayHasKey('enforced', $result['public']['password']);
|
|
|
|
|
$this->assertFalse($result['public']['password']['enforced']);
|
2015-02-07 02:07:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testLinkNoExpireDate(): void {
|
2015-02-26 02:39:55 -05:00
|
|
|
$map = [
|
2015-09-25 05:24:23 -04:00
|
|
|
['core', 'shareapi_enabled', 'yes', 'yes'],
|
2015-02-26 02:39:55 -05:00
|
|
|
['core', 'shareapi_allow_links', 'yes', 'yes'],
|
2015-08-13 07:07:49 -04:00
|
|
|
['core', 'shareapi_default_expire_date', 'no', 'no'],
|
2022-02-15 11:45:09 -05:00
|
|
|
['core', 'shareapi_enforce_links_password_excluded_groups', '', ''],
|
2015-02-26 02:39:55 -05:00
|
|
|
];
|
2015-02-07 02:07:53 -05:00
|
|
|
$result = $this->getResults($map);
|
|
|
|
|
$this->assertArrayHasKey('expire_date', $result['public']);
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsArray($result['public']['expire_date']);
|
2015-02-09 08:26:49 -05:00
|
|
|
$this->assertFalse($result['public']['expire_date']['enabled']);
|
2015-02-07 02:07:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testLinkExpireDate(): void {
|
2015-02-26 02:39:55 -05:00
|
|
|
$map = [
|
2015-09-25 05:24:23 -04:00
|
|
|
['core', 'shareapi_enabled', 'yes', 'yes'],
|
2015-02-26 02:39:55 -05:00
|
|
|
['core', 'shareapi_allow_links', 'yes', 'yes'],
|
|
|
|
|
['core', 'shareapi_expire_after_n_days', '7', '7'],
|
2022-02-15 11:45:09 -05:00
|
|
|
['core', 'shareapi_enforce_links_password_excluded_groups', '', ''],
|
2015-02-26 02:39:55 -05:00
|
|
|
];
|
2025-08-13 08:03:25 -04:00
|
|
|
|
|
|
|
|
$typedMap = [
|
|
|
|
|
['core', 'shareapi_default_expire_date', true],
|
|
|
|
|
['core', 'shareapi_enforce_expire_date', false],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$result = $this->getResults($map, $typedMap);
|
2015-02-07 02:07:53 -05:00
|
|
|
$this->assertArrayHasKey('expire_date', $result['public']);
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsArray($result['public']['expire_date']);
|
2015-02-09 08:26:49 -05:00
|
|
|
$this->assertTrue($result['public']['expire_date']['enabled']);
|
2015-02-07 02:07:53 -05:00
|
|
|
$this->assertArrayHasKey('days', $result['public']['expire_date']);
|
2015-03-11 10:11:50 -04:00
|
|
|
$this->assertFalse($result['public']['expire_date']['enforced']);
|
2015-02-07 02:07:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testLinkExpireDateEnforced(): void {
|
2015-02-26 02:39:55 -05:00
|
|
|
$map = [
|
2015-09-25 05:24:23 -04:00
|
|
|
['core', 'shareapi_enabled', 'yes', 'yes'],
|
2015-02-26 02:39:55 -05:00
|
|
|
['core', 'shareapi_allow_links', 'yes', 'yes'],
|
2022-02-15 11:45:09 -05:00
|
|
|
['core', 'shareapi_enforce_links_password_excluded_groups', '', ''],
|
2015-02-26 02:39:55 -05:00
|
|
|
];
|
2025-08-13 08:03:25 -04:00
|
|
|
|
|
|
|
|
$typedMap = [
|
|
|
|
|
['core', 'shareapi_default_expire_date', true],
|
|
|
|
|
['core', 'shareapi_enforce_expire_date', true],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$result = $this->getResults($map, $typedMap);
|
2015-02-07 02:07:53 -05:00
|
|
|
$this->assertArrayHasKey('expire_date', $result['public']);
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsArray($result['public']['expire_date']);
|
2015-03-11 10:11:50 -04:00
|
|
|
$this->assertTrue($result['public']['expire_date']['enforced']);
|
2015-02-07 02:07:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testLinkSendMail(): void {
|
2015-02-26 02:39:55 -05:00
|
|
|
$map = [
|
2015-09-25 05:24:23 -04:00
|
|
|
['core', 'shareapi_enabled', 'yes', 'yes'],
|
2015-02-26 02:39:55 -05:00
|
|
|
['core', 'shareapi_allow_links', 'yes', 'yes'],
|
2015-08-13 07:07:49 -04:00
|
|
|
['core', 'shareapi_allow_public_notification', 'no', 'yes'],
|
2022-02-15 11:45:09 -05:00
|
|
|
['core', 'shareapi_enforce_links_password_excluded_groups', '', ''],
|
2015-02-26 02:39:55 -05:00
|
|
|
];
|
2015-02-07 02:07:53 -05:00
|
|
|
$result = $this->getResults($map);
|
|
|
|
|
$this->assertTrue($result['public']['send_mail']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testLinkNoSendMail(): void {
|
2015-02-26 02:39:55 -05:00
|
|
|
$map = [
|
2015-09-25 05:24:23 -04:00
|
|
|
['core', 'shareapi_enabled', 'yes', 'yes'],
|
2015-02-26 02:39:55 -05:00
|
|
|
['core', 'shareapi_allow_links', 'yes', 'yes'],
|
2015-08-13 07:07:49 -04:00
|
|
|
['core', 'shareapi_allow_public_notification', 'no', 'no'],
|
2022-02-15 11:45:09 -05:00
|
|
|
['core', 'shareapi_enforce_links_password_excluded_groups', '', ''],
|
2015-02-26 02:39:55 -05:00
|
|
|
];
|
2015-02-07 02:07:53 -05:00
|
|
|
$result = $this->getResults($map);
|
|
|
|
|
$this->assertFalse($result['public']['send_mail']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testResharing(): void {
|
2015-02-26 02:39:55 -05:00
|
|
|
$map = [
|
2015-09-25 05:24:23 -04:00
|
|
|
['core', 'shareapi_enabled', 'yes', 'yes'],
|
2015-02-26 02:39:55 -05:00
|
|
|
['core', 'shareapi_allow_resharing', 'yes', 'yes'],
|
2022-02-15 11:45:09 -05:00
|
|
|
['core', 'shareapi_enforce_links_password_excluded_groups', '', ''],
|
2015-02-26 02:39:55 -05:00
|
|
|
];
|
2015-02-07 02:07:53 -05:00
|
|
|
$result = $this->getResults($map);
|
|
|
|
|
$this->assertTrue($result['resharing']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testNoResharing(): void {
|
2015-02-26 02:39:55 -05:00
|
|
|
$map = [
|
2015-09-25 05:24:23 -04:00
|
|
|
['core', 'shareapi_enabled', 'yes', 'yes'],
|
2015-02-26 02:39:55 -05:00
|
|
|
['core', 'shareapi_allow_resharing', 'yes', 'no'],
|
2022-02-15 11:45:09 -05:00
|
|
|
['core', 'shareapi_enforce_links_password_excluded_groups', '', ''],
|
2015-02-26 02:39:55 -05:00
|
|
|
];
|
2015-02-07 02:07:53 -05:00
|
|
|
$result = $this->getResults($map);
|
|
|
|
|
$this->assertFalse($result['resharing']);
|
|
|
|
|
}
|
2015-08-14 14:00:04 -04:00
|
|
|
|
|
|
|
|
public function testLinkPublicUpload(): void {
|
|
|
|
|
$map = [
|
2015-09-25 05:24:23 -04:00
|
|
|
['core', 'shareapi_enabled', 'yes', 'yes'],
|
2015-08-14 14:00:04 -04:00
|
|
|
['core', 'shareapi_allow_links', 'yes', 'yes'],
|
|
|
|
|
['core', 'shareapi_allow_public_upload', 'yes', 'yes'],
|
2022-02-15 11:45:09 -05:00
|
|
|
['core', 'shareapi_enforce_links_password_excluded_groups', '', ''],
|
2015-08-14 14:00:04 -04:00
|
|
|
];
|
|
|
|
|
$result = $this->getResults($map);
|
|
|
|
|
$this->assertTrue($result['public']['upload']);
|
2016-08-13 08:00:44 -04:00
|
|
|
$this->assertTrue($result['public']['upload_files_drop']);
|
2015-08-14 14:00:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testLinkNoPublicUpload(): void {
|
|
|
|
|
$map = [
|
2015-09-25 05:24:23 -04:00
|
|
|
['core', 'shareapi_enabled', 'yes', 'yes'],
|
2015-08-14 14:00:04 -04:00
|
|
|
['core', 'shareapi_allow_links', 'yes', 'yes'],
|
|
|
|
|
['core', 'shareapi_allow_public_upload', 'yes', 'no'],
|
2022-02-15 11:45:09 -05:00
|
|
|
['core', 'shareapi_enforce_links_password_excluded_groups', '', ''],
|
2015-08-14 14:00:04 -04:00
|
|
|
];
|
|
|
|
|
$result = $this->getResults($map);
|
|
|
|
|
$this->assertFalse($result['public']['upload']);
|
2016-08-13 08:00:44 -04:00
|
|
|
$this->assertFalse($result['public']['upload_files_drop']);
|
2015-08-14 14:00:04 -04:00
|
|
|
}
|
|
|
|
|
|
2016-03-31 03:27:38 -04:00
|
|
|
public function testNoGroupSharing(): void {
|
|
|
|
|
$map = [
|
|
|
|
|
['core', 'shareapi_enabled', 'yes', 'yes'],
|
|
|
|
|
['core', 'shareapi_allow_group_sharing', 'yes', 'no'],
|
|
|
|
|
];
|
|
|
|
|
$result = $this->getResults($map);
|
|
|
|
|
$this->assertFalse($result['group_sharing']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGroupSharing(): void {
|
|
|
|
|
$map = [
|
|
|
|
|
['core', 'shareapi_enabled', 'yes', 'yes'],
|
|
|
|
|
['core', 'shareapi_allow_group_sharing', 'yes', 'yes'],
|
|
|
|
|
];
|
|
|
|
|
$result = $this->getResults($map);
|
|
|
|
|
$this->assertTrue($result['group_sharing']);
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-05 05:27:38 -05:00
|
|
|
public function testFederatedSharingIncoming(): void {
|
2015-09-12 10:25:23 -04:00
|
|
|
$map = [
|
|
|
|
|
['files_sharing', 'incoming_server2server_share_enabled', 'yes', 'yes'],
|
|
|
|
|
];
|
|
|
|
|
$result = $this->getResults($map);
|
|
|
|
|
$this->assertArrayHasKey('federation', $result);
|
|
|
|
|
$this->assertTrue($result['federation']['incoming']);
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-05 05:27:38 -05:00
|
|
|
public function testFederatedSharingNoIncoming(): void {
|
2015-09-12 10:25:23 -04:00
|
|
|
$map = [
|
|
|
|
|
['files_sharing', 'incoming_server2server_share_enabled', 'yes', 'no'],
|
|
|
|
|
];
|
|
|
|
|
$result = $this->getResults($map);
|
|
|
|
|
$this->assertArrayHasKey('federation', $result);
|
|
|
|
|
$this->assertFalse($result['federation']['incoming']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testFederatedSharingOutgoing(): void {
|
|
|
|
|
$map = [
|
|
|
|
|
['files_sharing', 'outgoing_server2server_share_enabled', 'yes', 'yes'],
|
|
|
|
|
];
|
|
|
|
|
$result = $this->getResults($map);
|
|
|
|
|
$this->assertArrayHasKey('federation', $result);
|
|
|
|
|
$this->assertTrue($result['federation']['outgoing']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testFederatedSharingNoOutgoing(): void {
|
|
|
|
|
$map = [
|
|
|
|
|
['files_sharing', 'outgoing_server2server_share_enabled', 'yes', 'no'],
|
|
|
|
|
];
|
|
|
|
|
$result = $this->getResults($map);
|
|
|
|
|
$this->assertArrayHasKey('federation', $result);
|
|
|
|
|
$this->assertFalse($result['federation']['outgoing']);
|
|
|
|
|
}
|
2021-03-24 12:50:56 -04:00
|
|
|
|
|
|
|
|
public function testFederatedSharingExpirationDate(): void {
|
|
|
|
|
$result = $this->getResults([]);
|
|
|
|
|
$this->assertArrayHasKey('federation', $result);
|
|
|
|
|
$this->assertEquals(['enabled' => true], $result['federation']['expire_date']);
|
|
|
|
|
$this->assertEquals(['enabled' => true], $result['federation']['expire_date_supported']);
|
|
|
|
|
}
|
2025-08-07 01:14:40 -04:00
|
|
|
|
|
|
|
|
public function testFederatedSharingDisabled(): void {
|
2025-08-07 09:58:35 -04:00
|
|
|
$result = $this->getResults([], federationEnabled: false);
|
2025-08-07 01:14:40 -04:00
|
|
|
$this->assertArrayHasKey('federation', $result);
|
|
|
|
|
$this->assertFalse($result['federation']['incoming']);
|
|
|
|
|
$this->assertFalse($result['federation']['outgoing']);
|
|
|
|
|
$this->assertEquals(['enabled' => false], $result['federation']['expire_date']);
|
|
|
|
|
$this->assertEquals(['enabled' => false], $result['federation']['expire_date_supported']);
|
|
|
|
|
}
|
2015-02-07 02:07:53 -05:00
|
|
|
}
|