Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
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 <[email protected]>
  • Loading branch information
danxuliu committed Aug 18, 2021
commit 193cf6cfde8a91e225947021e582997403074c78
9 changes: 6 additions & 3 deletions apps/provisioning_api/lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,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
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,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 @@ -83,7 +88,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