Skip to content

Commit df9c510

Browse files
committed
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>
1 parent c6d023f commit df9c510

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

apps/provisioning_api/lib/Capabilities.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,23 @@ public function __construct(IAppManager $appManager) {
4141
* @return array Array containing the apps capabilities
4242
*/
4343
public function getCapabilities() {
44-
$federationScopesEnabled = false;
44+
$federatedScopeEnabled = $this->appManager->isEnabledForUser('federation');
45+
46+
$publishedScopeEnabled = false;
4547

4648
$federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing');
4749
if ($federatedFileSharingEnabled) {
4850
/** @var FederatedShareProvider $shareProvider */
4951
$shareProvider = \OC::$server->query(FederatedShareProvider::class);
50-
$federationScopesEnabled = $shareProvider->isLookupServerUploadEnabled();
52+
$publishedScopeEnabled = $shareProvider->isLookupServerUploadEnabled();
5153
}
5254

5355
return [
5456
'provisioning_api' => [
5557
'version' => $this->appManager->getAppVersion('provisioning_api'),
5658
'AccountPropertyScopesVersion' => 2,
57-
'AccountPropertyScopesFederationEnabled' => $federationScopesEnabled,
59+
'AccountPropertyScopesFederatedEnabled' => $federatedScopeEnabled,
60+
'AccountPropertyScopesPublishedEnabled' => $publishedScopeEnabled,
5861
]
5962
];
6063
}

apps/provisioning_api/tests/CapabilitiesTest.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,25 @@ public function setUp(): void {
5757

5858
public function getCapabilitiesProvider() {
5959
return [
60-
[false, false, false],
61-
[true, false, false],
62-
[true, true, true],
60+
[true, false, false, true, false],
61+
[true, true, false, true, false],
62+
[true, true, true, true, true],
63+
[false, false, false, false, false],
64+
[false, true, false, false, false],
65+
[false, true, true, false, true],
6366
];
6467
}
6568

6669
/**
6770
* @dataProvider getCapabilitiesProvider
6871
*/
69-
public function testGetCapabilities($federationAppEnabled, $lookupServerEnabled, $expectedFederationScopesEnabled) {
70-
$this->appManager->expects($this->once())
72+
public function testGetCapabilities($federationAppEnabled, $federatedFileSharingAppEnabled, $lookupServerEnabled, $expectedFederatedScopeEnabled, $expectedPublishedScopeEnabled) {
73+
$this->appManager->expects($this->any())
7174
->method('isEnabledForUser')
72-
->with('federatedfilesharing')
73-
->willReturn($federationAppEnabled);
75+
->will($this->returnValueMap([
76+
['federation', null, $federationAppEnabled],
77+
['federatedfilesharing', null, $federatedFileSharingAppEnabled],
78+
]));
7479

7580
$federatedShareProvider = $this->createMock(FederatedShareProvider::class);
7681
$this->overwriteService(FederatedShareProvider::class, $federatedShareProvider);
@@ -83,7 +88,8 @@ public function testGetCapabilities($federationAppEnabled, $lookupServerEnabled,
8388
'provisioning_api' => [
8489
'version' => '1.12',
8590
'AccountPropertyScopesVersion' => 2,
86-
'AccountPropertyScopesFederationEnabled' => $expectedFederationScopesEnabled,
91+
'AccountPropertyScopesFederatedEnabled' => $expectedFederatedScopeEnabled,
92+
'AccountPropertyScopesPublishedEnabled' => $expectedPublishedScopeEnabled,
8793
],
8894
];
8995
$this->assertSame($expected, $this->capabilities->getCapabilities());

0 commit comments

Comments
 (0)