aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests/CapabilitiesTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/tests/CapabilitiesTest.php')
-rw-r--r--apps/files_sharing/tests/CapabilitiesTest.php63
1 files changed, 39 insertions, 24 deletions
diff --git a/apps/files_sharing/tests/CapabilitiesTest.php b/apps/files_sharing/tests/CapabilitiesTest.php
index 69911100f56..2fe221703a5 100644
--- a/apps/files_sharing/tests/CapabilitiesTest.php
+++ b/apps/files_sharing/tests/CapabilitiesTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -10,9 +11,11 @@ use OC\KnownUser\KnownUserService;
use OC\Share20\Manager;
use OC\Share20\ShareDisableChecker;
use OCA\Files_Sharing\Capabilities;
+use OCP\App\IAppManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountManager;
+use OCP\IAppConfig;
use OCP\IConfig;
use OCP\IDateTimeZone;
use OCP\IGroupManager;
@@ -53,9 +56,11 @@ class CapabilitiesTest extends \Test\TestCase {
* @param (string[])[] $map Map of arguments to return types for the getAppValue function in the mock
* @return string[]
*/
- private function getResults(array $map) {
+ private function getResults(array $map, bool $federationEnabled = true) {
$config = $this->getMockBuilder(IConfig::class)->disableOriginalConstructor()->getMock();
+ $appManager = $this->getMockBuilder(IAppManager::class)->disableOriginalConstructor()->getMock();
$config->method('getAppValue')->willReturnMap($map);
+ $appManager->method('isEnabledForAnyone')->with('federation')->willReturn($federationEnabled);
$shareManager = new Manager(
$this->createMock(LoggerInterface::class),
$config,
@@ -75,13 +80,14 @@ class CapabilitiesTest extends \Test\TestCase {
$this->createMock(KnownUserService::class),
$this->createMock(ShareDisableChecker::class),
$this->createMock(IDateTimeZone::class),
+ $this->createMock(IAppConfig::class),
);
- $cap = new Capabilities($config, $shareManager);
+ $cap = new Capabilities($config, $shareManager, $appManager);
$result = $this->getFilesSharingPart($cap->getCapabilities());
return $result;
}
- public function testEnabledSharingAPI() {
+ public function testEnabledSharingAPI(): void {
$map = [
['core', 'shareapi_enabled', 'yes', 'yes'],
];
@@ -92,7 +98,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertArrayHasKey('resharing', $result);
}
- public function testDisabledSharingAPI() {
+ public function testDisabledSharingAPI(): void {
$map = [
['core', 'shareapi_enabled', 'yes', 'no'],
];
@@ -103,7 +109,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertFalse($result['resharing']);
}
- public function testNoLinkSharing() {
+ public function testNoLinkSharing(): void {
$map = [
['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'no'],
@@ -113,7 +119,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertFalse($result['public']['enabled']);
}
- public function testOnlyLinkSharing() {
+ public function testOnlyLinkSharing(): void {
$map = [
['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
@@ -124,7 +130,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertTrue($result['public']['enabled']);
}
- public function testLinkPassword() {
+ public function testLinkPassword(): void {
$map = [
['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
@@ -137,7 +143,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertTrue($result['public']['password']['enforced']);
}
- public function testLinkNoPassword() {
+ public function testLinkNoPassword(): void {
$map = [
['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
@@ -150,7 +156,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertFalse($result['public']['password']['enforced']);
}
- public function testLinkNoExpireDate() {
+ public function testLinkNoExpireDate(): void {
$map = [
['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
@@ -163,7 +169,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertFalse($result['public']['expire_date']['enabled']);
}
- public function testLinkExpireDate() {
+ public function testLinkExpireDate(): void {
$map = [
['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
@@ -180,7 +186,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertFalse($result['public']['expire_date']['enforced']);
}
- public function testLinkExpireDateEnforced() {
+ public function testLinkExpireDateEnforced(): void {
$map = [
['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
@@ -194,7 +200,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertTrue($result['public']['expire_date']['enforced']);
}
- public function testLinkSendMail() {
+ public function testLinkSendMail(): void {
$map = [
['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
@@ -205,7 +211,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertTrue($result['public']['send_mail']);
}
- public function testLinkNoSendMail() {
+ public function testLinkNoSendMail(): void {
$map = [
['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
@@ -216,7 +222,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertFalse($result['public']['send_mail']);
}
- public function testResharing() {
+ public function testResharing(): void {
$map = [
['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_resharing', 'yes', 'yes'],
@@ -226,7 +232,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertTrue($result['resharing']);
}
- public function testNoResharing() {
+ public function testNoResharing(): void {
$map = [
['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_resharing', 'yes', 'no'],
@@ -236,7 +242,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertFalse($result['resharing']);
}
- public function testLinkPublicUpload() {
+ public function testLinkPublicUpload(): void {
$map = [
['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
@@ -248,7 +254,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertTrue($result['public']['upload_files_drop']);
}
- public function testLinkNoPublicUpload() {
+ public function testLinkNoPublicUpload(): void {
$map = [
['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
@@ -260,7 +266,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertFalse($result['public']['upload_files_drop']);
}
- public function testNoGroupSharing() {
+ public function testNoGroupSharing(): void {
$map = [
['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_group_sharing', 'yes', 'no'],
@@ -269,7 +275,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertFalse($result['group_sharing']);
}
- public function testGroupSharing() {
+ public function testGroupSharing(): void {
$map = [
['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_group_sharing', 'yes', 'yes'],
@@ -278,7 +284,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertTrue($result['group_sharing']);
}
- public function testFederatedSharingIncoming() {
+ public function testFederatedSharingIncoming(): void {
$map = [
['files_sharing', 'incoming_server2server_share_enabled', 'yes', 'yes'],
];
@@ -287,7 +293,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertTrue($result['federation']['incoming']);
}
- public function testFederatedSharingNoIncoming() {
+ public function testFederatedSharingNoIncoming(): void {
$map = [
['files_sharing', 'incoming_server2server_share_enabled', 'yes', 'no'],
];
@@ -296,7 +302,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertFalse($result['federation']['incoming']);
}
- public function testFederatedSharingOutgoing() {
+ public function testFederatedSharingOutgoing(): void {
$map = [
['files_sharing', 'outgoing_server2server_share_enabled', 'yes', 'yes'],
];
@@ -305,7 +311,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertTrue($result['federation']['outgoing']);
}
- public function testFederatedSharingNoOutgoing() {
+ public function testFederatedSharingNoOutgoing(): void {
$map = [
['files_sharing', 'outgoing_server2server_share_enabled', 'yes', 'no'],
];
@@ -314,10 +320,19 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertFalse($result['federation']['outgoing']);
}
- public function testFederatedSharingExpirationDate() {
+ 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']);
}
+
+ public function testFederatedSharingDisabled(): void {
+ $result = $this->getResults([], false);
+ $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']);
+ }
}