summaryrefslogtreecommitdiffstats
path: root/apps/federatedfilesharing/tests
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2017-05-24 09:07:58 +0200
committerBjoern Schiessle <bjoern@schiessle.org>2017-05-29 18:19:28 +0200
commit7c2d473d7686f4824d3b7f05238d262e26d5efa2 (patch)
treef4aae21880e293a2ded78e63ee3300b61b5f487f /apps/federatedfilesharing/tests
parent4be17dff0f9846d32f9740e7d7766bdbc1e98b51 (diff)
downloadnextcloud-server-7c2d473d7686f4824d3b7f05238d262e26d5efa2.tar.gz
nextcloud-server-7c2d473d7686f4824d3b7f05238d262e26d5efa2.zip
add new config switched for the global scale architecture
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/federatedfilesharing/tests')
-rw-r--r--apps/federatedfilesharing/tests/FederatedShareProviderTest.php80
-rw-r--r--apps/federatedfilesharing/tests/Settings/AdminTest.php13
2 files changed, 72 insertions, 21 deletions
diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
index e01e02c83ba..3ecd8162cad 100644
--- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
+++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
@@ -65,6 +65,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
protected $config;
/** @var IUserManager | \PHPUnit_Framework_MockObject_MockObject */
protected $userManager;
+ /** @var \OCP\GlobalScale\IConfig|\PHPUnit_Framework_MockObject_MockObject */
+ protected $gsConfig;
/** @var IManager */
protected $shareManager;
@@ -96,11 +98,11 @@ class FederatedShareProviderTest extends \Test\TestCase {
$this->userManager = $this->getMockBuilder('OCP\IUserManager')->getMock();
//$this->addressHandler = new AddressHandler(\OC::$server->getURLGenerator(), $this->l);
$this->addressHandler = $this->getMockBuilder('OCA\FederatedFileSharing\AddressHandler')->disableOriginalConstructor()->getMock();
+ $this->cloudIdManager = new CloudIdManager();
+ $this->gsConfig = $this->createMock(\OCP\GlobalScale\IConfig::class);
$this->userManager->expects($this->any())->method('userExists')->willReturn(true);
- $this->cloudIdManager = new CloudIdManager();
-
$this->provider = new FederatedShareProvider(
$this->connection,
$this->addressHandler,
@@ -111,7 +113,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
$this->rootFolder,
$this->config,
$this->userManager,
- $this->cloudIdManager
+ $this->cloudIdManager,
+ $this->gsConfig
);
$this->shareManager = \OC::$server->getShareManager();
@@ -409,7 +412,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
$this->rootFolder,
$this->config,
$this->userManager,
- $this->cloudIdManager
+ $this->cloudIdManager,
+ $this->gsConfig
]
)->setMethods(['sendPermissionUpdate'])->getMock();
@@ -674,13 +678,15 @@ class FederatedShareProviderTest extends \Test\TestCase {
}
/**
- * @dataProvider dataTestFederatedSharingSettings
+ * @dataProvider dataTestIsOutgoingServer2serverShareEnabled
*
* @param string $isEnabled
* @param bool $expected
*/
- public function testIsOutgoingServer2serverShareEnabled($isEnabled, $expected) {
- $this->config->expects($this->once())->method('getAppValue')
+ public function testIsOutgoingServer2serverShareEnabled($internalOnly, $isEnabled, $expected) {
+ $this->gsConfig->expects($this->once())->method('onlyInternalFederation')
+ ->willReturn($internalOnly);
+ $this->config->expects($this->any())->method('getAppValue')
->with('files_sharing', 'outgoing_server2server_share_enabled', 'yes')
->willReturn($isEnabled);
@@ -689,14 +695,25 @@ class FederatedShareProviderTest extends \Test\TestCase {
);
}
+ public function dataTestIsOutgoingServer2serverShareEnabled() {
+ return [
+ [false, 'yes', true],
+ [false, 'no', false],
+ [true, 'yes', false],
+ [true, 'no', false],
+ ];
+ }
+
/**
- * @dataProvider dataTestFederatedSharingSettings
+ * @dataProvider dataTestIsIncomingServer2serverShareEnabled
*
* @param string $isEnabled
* @param bool $expected
*/
- public function testIsIncomingServer2serverShareEnabled($isEnabled, $expected) {
- $this->config->expects($this->once())->method('getAppValue')
+ public function testIsIncomingServer2serverShareEnabled($onlyInternal, $isEnabled, $expected) {
+ $this->gsConfig->expects($this->once())->method('onlyInternalFederation')
+ ->willReturn($onlyInternal);
+ $this->config->expects($this->any())->method('getAppValue')
->with('files_sharing', 'incoming_server2server_share_enabled', 'yes')
->willReturn($isEnabled);
@@ -705,14 +722,25 @@ class FederatedShareProviderTest extends \Test\TestCase {
);
}
+ public function dataTestIsIncomingServer2serverShareEnabled() {
+ return [
+ [false, 'yes', true],
+ [false, 'no', false],
+ [true, 'yes', false],
+ [true, 'no', false],
+ ];
+ }
+
/**
- * @dataProvider dataTestFederatedSharingSettings
+ * @dataProvider dataTestIsLookupServerQueriesEnabled
*
* @param string $isEnabled
* @param bool $expected
*/
- public function testIsLookupServerQueriesEnabled($isEnabled, $expected) {
- $this->config->expects($this->once())->method('getAppValue')
+ public function testIsLookupServerQueriesEnabled($gsEnabled, $isEnabled, $expected) {
+ $this->gsConfig->expects($this->once())->method('isGlobalScaleEnabled')
+ ->willReturn($gsEnabled);
+ $this->config->expects($this->any())->method('getAppValue')
->with('files_sharing', 'lookupServerEnabled', 'no')
->willReturn($isEnabled);
@@ -721,14 +749,26 @@ class FederatedShareProviderTest extends \Test\TestCase {
);
}
+
+ public function dataTestIsLookupServerQueriesEnabled() {
+ return [
+ [false, 'yes', true],
+ [false, 'no', false],
+ [true, 'yes', true],
+ [true, 'no', true],
+ ];
+ }
+
/**
- * @dataProvider dataTestFederatedSharingSettings
+ * @dataProvider dataTestIsLookupServerUploadEnabled
*
* @param string $isEnabled
* @param bool $expected
*/
- public function testIsLookupServerUploadEnabled($isEnabled, $expected) {
- $this->config->expects($this->once())->method('getAppValue')
+ public function testIsLookupServerUploadEnabled($gsEnabled, $isEnabled, $expected) {
+ $this->gsConfig->expects($this->once())->method('isGlobalScaleEnabled')
+ ->willReturn($gsEnabled);
+ $this->config->expects($this->any())->method('getAppValue')
->with('files_sharing', 'lookupServerUploadEnabled', 'yes')
->willReturn($isEnabled);
@@ -737,10 +777,12 @@ class FederatedShareProviderTest extends \Test\TestCase {
);
}
- public function dataTestFederatedSharingSettings() {
+ public function dataTestIsLookupServerUploadEnabled() {
return [
- ['yes', true],
- ['no', false]
+ [false, 'yes', true],
+ [false, 'no', false],
+ [true, 'yes', false],
+ [true, 'no', false],
];
}
diff --git a/apps/federatedfilesharing/tests/Settings/AdminTest.php b/apps/federatedfilesharing/tests/Settings/AdminTest.php
index 9eae6317bf7..ce47ffb2385 100644
--- a/apps/federatedfilesharing/tests/Settings/AdminTest.php
+++ b/apps/federatedfilesharing/tests/Settings/AdminTest.php
@@ -25,6 +25,7 @@ namespace OCA\FederatedFileSharing\Tests\Settings;
use OCA\FederatedFileSharing\Settings\Admin;
use OCP\AppFramework\Http\TemplateResponse;
+use OCP\GlobalScale\IConfig;
use Test\TestCase;
class AdminTest extends TestCase {
@@ -32,12 +33,17 @@ class AdminTest extends TestCase {
private $admin;
/** @var \OCA\FederatedFileSharing\FederatedShareProvider */
private $federatedShareProvider;
+ /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
+ private $gsConfig;
public function setUp() {
parent::setUp();
- $this->federatedShareProvider = $this->getMockBuilder('\OCA\FederatedFileSharing\FederatedShareProvider')->disableOriginalConstructor()->getMock();
+ $this->federatedShareProvider = $this->getMockBuilder('\OCA\FederatedFileSharing\FederatedShareProvider')
+ ->disableOriginalConstructor()->getMock();
+ $this->gsConfig = $this->getMock(IConfig::class);
$this->admin = new Admin(
- $this->federatedShareProvider
+ $this->federatedShareProvider,
+ $this->gsConfig
);
}
@@ -73,8 +79,11 @@ class AdminTest extends TestCase {
->expects($this->once())
->method('isLookupServerUploadEnabled')
->willReturn($state);
+ $this->gsConfig->expects($this->once())->method('onlyInternalFederation')
+ ->willReturn($state);
$params = [
+ 'internalOnly' => $state,
'outgoingServer2serverShareEnabled' => $state,
'incomingServer2serverShareEnabled' => $state,
'lookupServerEnabled' => $state,