mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
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>
This commit is contained in:
parent
1e19b1cc99
commit
193cf6cfde
2 changed files with 21 additions and 12 deletions
|
|
@ -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,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
Loading…
Reference in a new issue