Skip to content

Commit

Permalink
Split capability
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
danxuliu authored and backportbot[bot] committed Oct 22, 2021
1 parent 46290e9 commit aec1c0c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
9 changes: 6 additions & 3 deletions apps/provisioning_api/lib/Capabilities.php
Expand Up @@ -42,20 +42,23 @@ public function __construct(IAppManager $appManager) {
* @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,
]
];
}
Expand Down
24 changes: 15 additions & 9 deletions apps/provisioning_api/tests/CapabilitiesTest.php
Expand Up @@ -58,20 +58,25 @@ public function setUp(): void {

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);
Expand All @@ -84,7 +89,8 @@ public function testGetCapabilities($federationAppEnabled, $lookupServerEnabled,
'provisioning_api' => [
'version' => '1.12',
'AccountPropertyScopesVersion' => 2,
'AccountPropertyScopesFederationEnabled' => $expectedFederationScopesEnabled,
'AccountPropertyScopesFederatedEnabled' => $expectedFederatedScopeEnabled,
'AccountPropertyScopesPublishedEnabled' => $expectedPublishedScopeEnabled,
],
];
$this->assertSame($expected, $this->capabilities->getCapabilities());
Expand Down

0 comments on commit aec1c0c

Please sign in to comment.