Skip to content

Commit

Permalink
Merge pull request #29528 from nextcloud/revert-stable22-split-capabi…
Browse files Browse the repository at this point in the history
…lity-AccountPropertyScopesFederationEnabled
  • Loading branch information
skjnldsv authored Nov 3, 2021
2 parents 7d3a01e + 33cd007 commit 9b1eab2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
9 changes: 3 additions & 6 deletions apps/provisioning_api/lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,20 @@ public function __construct(IAppManager $appManager) {
* @return array Array containing the apps capabilities
*/
public function getCapabilities() {
$federatedScopeEnabled = $this->appManager->isEnabledForUser('federation');

$publishedScopeEnabled = false;
$federationScopesEnabled = false;

$federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing');
if ($federatedFileSharingEnabled) {
/** @var FederatedShareProvider $shareProvider */
$shareProvider = \OC::$server->query(FederatedShareProvider::class);
$publishedScopeEnabled = $shareProvider->isLookupServerUploadEnabled();
$federationScopesEnabled = $shareProvider->isLookupServerUploadEnabled();
}

return [
'provisioning_api' => [
'version' => $this->appManager->getAppVersion('provisioning_api'),
'AccountPropertyScopesVersion' => 2,
'AccountPropertyScopesFederatedEnabled' => $federatedScopeEnabled,
'AccountPropertyScopesPublishedEnabled' => $publishedScopeEnabled,
'AccountPropertyScopesFederationEnabled' => $federationScopesEnabled,
]
];
}
Expand Down
24 changes: 9 additions & 15 deletions apps/provisioning_api/tests/CapabilitiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,20 @@ public function setUp(): void {

public function getCapabilitiesProvider() {
return [
[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],
[false, false, false],
[true, false, false],
[true, true, true],
];
}

/**
* @dataProvider getCapabilitiesProvider
*/
public function testGetCapabilities($federationAppEnabled, $federatedFileSharingAppEnabled, $lookupServerEnabled, $expectedFederatedScopeEnabled, $expectedPublishedScopeEnabled) {
$this->appManager->expects($this->any())
->method('isEnabledForUser')
->will($this->returnValueMap([
['federation', null, $federationAppEnabled],
['federatedfilesharing', null, $federatedFileSharingAppEnabled],
]));
public function testGetCapabilities($federationAppEnabled, $lookupServerEnabled, $expectedFederationScopesEnabled) {
$this->appManager->expects($this->once())
->method('isEnabledForUser')
->with('federatedfilesharing')
->willReturn($federationAppEnabled);

$federatedShareProvider = $this->createMock(FederatedShareProvider::class);
$this->overwriteService(FederatedShareProvider::class, $federatedShareProvider);
Expand All @@ -88,8 +83,7 @@ public function testGetCapabilities($federationAppEnabled, $federatedFileSharing
'provisioning_api' => [
'version' => '1.12',
'AccountPropertyScopesVersion' => 2,
'AccountPropertyScopesFederatedEnabled' => $expectedFederatedScopeEnabled,
'AccountPropertyScopesPublishedEnabled' => $expectedPublishedScopeEnabled,
'AccountPropertyScopesFederationEnabled' => $expectedFederationScopesEnabled,
],
];
$this->assertSame($expected, $this->capabilities->getCapabilities());
Expand Down

0 comments on commit 9b1eab2

Please sign in to comment.