diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2021-06-24 01:47:07 +0200 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2021-08-18 19:56:10 +0200 |
commit | 193cf6cfde8a91e225947021e582997403074c78 (patch) | |
tree | 728cb2654c53c3d13dd68419101f32acd667ba97 | |
parent | 1e19b1cc994d38b19a29494cc1579fe3182a34bd (diff) | |
download | nextcloud-server-193cf6cfde8a91e225947021e582997403074c78.tar.gz nextcloud-server-193cf6cfde8a91e225947021e582997403074c78.zip |
Split capability
The "federated" and "published" scopes are independent one from each
other, so the capability that encompassed both needs to be split.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
-rw-r--r-- | apps/provisioning_api/lib/Capabilities.php | 9 | ||||
-rw-r--r-- | apps/provisioning_api/tests/CapabilitiesTest.php | 24 |
2 files changed, 21 insertions, 12 deletions
diff --git a/apps/provisioning_api/lib/Capabilities.php b/apps/provisioning_api/lib/Capabilities.php index 59c462c5d90..835bbfe9b5c 100644 --- a/apps/provisioning_api/lib/Capabilities.php +++ b/apps/provisioning_api/lib/Capabilities.php @@ -41,20 +41,23 @@ class Capabilities implements ICapability { * @return array Array containing the apps capabilities */ public function getCapabilities() { - $federationScopesEnabled = false; + $federatedScopeEnabled = $this->appManager->isEnabledForUser('federation'); + + $publishedScopeEnabled = false; $federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing'); if ($federatedFileSharingEnabled) { /** @var FederatedShareProvider $shareProvider */ $shareProvider = \OC::$server->query(FederatedShareProvider::class); - $federationScopesEnabled = $shareProvider->isLookupServerUploadEnabled(); + $publishedScopeEnabled = $shareProvider->isLookupServerUploadEnabled(); } return [ 'provisioning_api' => [ 'version' => $this->appManager->getAppVersion('provisioning_api'), 'AccountPropertyScopesVersion' => 2, - 'AccountPropertyScopesFederationEnabled' => $federationScopesEnabled, + 'AccountPropertyScopesFederatedEnabled' => $federatedScopeEnabled, + 'AccountPropertyScopesPublishedEnabled' => $publishedScopeEnabled, ] ]; } diff --git a/apps/provisioning_api/tests/CapabilitiesTest.php b/apps/provisioning_api/tests/CapabilitiesTest.php index 97f9ba562bc..8fc29b442eb 100644 --- a/apps/provisioning_api/tests/CapabilitiesTest.php +++ b/apps/provisioning_api/tests/CapabilitiesTest.php @@ -57,20 +57,25 @@ class CapabilitiesTest extends TestCase { public function getCapabilitiesProvider() { return [ - [false, false, false], - [true, false, false], - [true, true, true], + [true, false, false, true, false], + [true, true, false, true, false], + [true, true, true, true, true], + [false, false, false, false, false], + [false, true, false, false, false], + [false, true, true, false, true], ]; } /** * @dataProvider getCapabilitiesProvider */ - public function testGetCapabilities($federationAppEnabled, $lookupServerEnabled, $expectedFederationScopesEnabled) { - $this->appManager->expects($this->once()) - ->method('isEnabledForUser') - ->with('federatedfilesharing') - ->willReturn($federationAppEnabled); + public function testGetCapabilities($federationAppEnabled, $federatedFileSharingAppEnabled, $lookupServerEnabled, $expectedFederatedScopeEnabled, $expectedPublishedScopeEnabled) { + $this->appManager->expects($this->any()) + ->method('isEnabledForUser') + ->will($this->returnValueMap([ + ['federation', null, $federationAppEnabled], + ['federatedfilesharing', null, $federatedFileSharingAppEnabled], + ])); $federatedShareProvider = $this->createMock(FederatedShareProvider::class); $this->overwriteService(FederatedShareProvider::class, $federatedShareProvider); @@ -83,7 +88,8 @@ class CapabilitiesTest extends TestCase { 'provisioning_api' => [ 'version' => '1.12', 'AccountPropertyScopesVersion' => 2, - 'AccountPropertyScopesFederationEnabled' => $expectedFederationScopesEnabled, + 'AccountPropertyScopesFederatedEnabled' => $expectedFederatedScopeEnabled, + 'AccountPropertyScopesPublishedEnabled' => $expectedPublishedScopeEnabled, ], ]; $this->assertSame($expected, $this->capabilities->getCapabilities()); |