From 82da4fde1843a682562ed34fb1de5dc55e32d4f5 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 5 Jan 2018 14:27:36 +0100 Subject: create failing test for this case Signed-off-by: Arthur Schiwon --- .../composer/composer/autoload_classmap.php | 2 + .../composer/composer/autoload_static.php | 2 + apps/user_ldap/lib/AccessFactory.php | 61 ++++++++++++++++++++++ apps/user_ldap/lib/ConnectionFactory.php | 38 ++++++++++++++ apps/user_ldap/lib/Jobs/Sync.php | 27 +++++++++- apps/user_ldap/tests/Jobs/SyncTest.php | 55 +++++++++++++++++++ 6 files changed, 183 insertions(+), 2 deletions(-) create mode 100644 apps/user_ldap/lib/AccessFactory.php create mode 100644 apps/user_ldap/lib/ConnectionFactory.php diff --git a/apps/user_ldap/composer/composer/autoload_classmap.php b/apps/user_ldap/composer/composer/autoload_classmap.php index 7bade37d9f7..98a1bbfa1b7 100644 --- a/apps/user_ldap/composer/composer/autoload_classmap.php +++ b/apps/user_ldap/composer/composer/autoload_classmap.php @@ -7,6 +7,7 @@ $baseDir = $vendorDir; return array( 'OCA\\User_LDAP\\Access' => $baseDir . '/../lib/Access.php', + 'OCA\\User_LDAP\\AccessFactory' => $baseDir . '/../lib/AccessFactory.php', 'OCA\\User_LDAP\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', 'OCA\\User_LDAP\\BackendUtility' => $baseDir . '/../lib/BackendUtility.php', 'OCA\\User_LDAP\\Command\\CheckUser' => $baseDir . '/../lib/Command/CheckUser.php', @@ -19,6 +20,7 @@ return array( 'OCA\\User_LDAP\\Command\\TestConfig' => $baseDir . '/../lib/Command/TestConfig.php', 'OCA\\User_LDAP\\Configuration' => $baseDir . '/../lib/Configuration.php', 'OCA\\User_LDAP\\Connection' => $baseDir . '/../lib/Connection.php', + 'OCA\\User_LDAP\\ConnectionFactory' => $baseDir . '/../lib/ConnectionFactory.php', 'OCA\\User_LDAP\\Controller\\ConfigAPIController' => $baseDir . '/../lib/Controller/ConfigAPIController.php', 'OCA\\User_LDAP\\Controller\\RenewPasswordController' => $baseDir . '/../lib/Controller/RenewPasswordController.php', 'OCA\\User_LDAP\\Exceptions\\ConstraintViolationException' => $baseDir . '/../lib/Exceptions/ConstraintViolationException.php', diff --git a/apps/user_ldap/composer/composer/autoload_static.php b/apps/user_ldap/composer/composer/autoload_static.php index fbe63285273..6c97237d62d 100644 --- a/apps/user_ldap/composer/composer/autoload_static.php +++ b/apps/user_ldap/composer/composer/autoload_static.php @@ -19,6 +19,7 @@ class ComposerStaticInitUser_LDAP public static $classMap = array ( 'OCA\\User_LDAP\\Access' => __DIR__ . '/..' . '/../lib/Access.php', + 'OCA\\User_LDAP\\AccessFactory' => __DIR__ . '/..' . '/../lib/AccessFactory.php', 'OCA\\User_LDAP\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', 'OCA\\User_LDAP\\BackendUtility' => __DIR__ . '/..' . '/../lib/BackendUtility.php', 'OCA\\User_LDAP\\Command\\CheckUser' => __DIR__ . '/..' . '/../lib/Command/CheckUser.php', @@ -31,6 +32,7 @@ class ComposerStaticInitUser_LDAP 'OCA\\User_LDAP\\Command\\TestConfig' => __DIR__ . '/..' . '/../lib/Command/TestConfig.php', 'OCA\\User_LDAP\\Configuration' => __DIR__ . '/..' . '/../lib/Configuration.php', 'OCA\\User_LDAP\\Connection' => __DIR__ . '/..' . '/../lib/Connection.php', + 'OCA\\User_LDAP\\ConnectionFactory' => __DIR__ . '/..' . '/../lib/ConnectionFactory.php', 'OCA\\User_LDAP\\Controller\\ConfigAPIController' => __DIR__ . '/..' . '/../lib/Controller/ConfigAPIController.php', 'OCA\\User_LDAP\\Controller\\RenewPasswordController' => __DIR__ . '/..' . '/../lib/Controller/RenewPasswordController.php', 'OCA\\User_LDAP\\Exceptions\\ConstraintViolationException' => __DIR__ . '/..' . '/../lib/Exceptions/ConstraintViolationException.php', diff --git a/apps/user_ldap/lib/AccessFactory.php b/apps/user_ldap/lib/AccessFactory.php new file mode 100644 index 00000000000..45ff779bb01 --- /dev/null +++ b/apps/user_ldap/lib/AccessFactory.php @@ -0,0 +1,61 @@ + + * + * @author Arthur Schiwon + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\User_LDAP; + + +use OCA\User_LDAP\User\Manager; +use OCP\IConfig; + +class AccessFactory { + /** @var ILDAPWrapper */ + protected $ldap; + /** @var Manager */ + protected $userManager; + /** @var Helper */ + protected $helper; + /** @var IConfig */ + protected $config; + + public function __construct( + ILDAPWrapper $ldap, + Manager $userManager, + Helper $helper, + IConfig $config) + { + $this->ldap = $ldap; + $this->userManager = $userManager; + $this->helper = $helper; + $this->config = $config; + } + + public function get(Connection $connection) { + return new Access( + $connection, + $this->ldap, + $this->userManager, + $this->helper, + $this->config + ); + } +} diff --git a/apps/user_ldap/lib/ConnectionFactory.php b/apps/user_ldap/lib/ConnectionFactory.php new file mode 100644 index 00000000000..0857afdcc8d --- /dev/null +++ b/apps/user_ldap/lib/ConnectionFactory.php @@ -0,0 +1,38 @@ + + * + * @author Arthur Schiwon + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\User_LDAP; + + +class ConnectionFactory { + /** @var ILDAPWrapper */ + private $ldap; + + public function __construct(ILDAPWrapper $ldap) { + $this->ldap = $ldap; + } + + public function get($prefix) { + return new Connection($this->ldap, $prefix, 'user_ldap'); + } +} diff --git a/apps/user_ldap/lib/Jobs/Sync.php b/apps/user_ldap/lib/Jobs/Sync.php index d8e0e854718..e80223a6255 100644 --- a/apps/user_ldap/lib/Jobs/Sync.php +++ b/apps/user_ldap/lib/Jobs/Sync.php @@ -26,8 +26,10 @@ namespace OCA\User_LDAP\Jobs; use OC\BackgroundJob\TimedJob; use OC\ServerNotAvailableException; use OCA\User_LDAP\Access; +use OCA\User_LDAP\AccessFactory; use OCA\User_LDAP\Configuration; use OCA\User_LDAP\Connection; +use OCA\User_LDAP\ConnectionFactory; use OCA\User_LDAP\FilesystemHelper; use OCA\User_LDAP\Helper; use OCA\User_LDAP\LDAP; @@ -62,6 +64,10 @@ class Sync extends TimedJob { protected $ncUserManager; /** @var IManager */ protected $notificationManager; + /** @var ConnectionFactory */ + protected $connectionFactory; + /** @var AccessFactory */ + protected $accessFactory; public function __construct() { $this->setInterval( @@ -153,8 +159,8 @@ class Sync extends TimedJob { * @return bool whether more results are expected from the same configuration */ public function runCycle($cycleData) { - $connection = new Connection($this->ldap, $cycleData['prefix']); - $access = new Access($connection, $this->ldap, $this->userManager, $this->ldapHelper, $this->config); + $connection = $this->connectionFactory->get($cycleData['prefix']); + $access = $this->accessFactory->get($connection); $access->setUserMapper($this->mapper); $filter = $access->combineFilterWithAnd(array( @@ -358,5 +364,22 @@ class Sync extends TimedJob { } else { $this->mapper = new UserMapping($this->dbc); } + + if(isset($argument['connectionFactory'])) { + $this->connectionFactory = $argument['connectionFactory']; + } else { + $this->connectionFactory = new ConnectionFactory($this->ldap); + } + + if(isset($argument['accessFactory'])) { + $this->accessFactory = $argument['accessFactory']; + } else { + $this->accessFactory = new AccessFactory( + $this->ldap, + $this->userManager, + $this->ldapHelper, + $this->config + ); + } } } diff --git a/apps/user_ldap/tests/Jobs/SyncTest.php b/apps/user_ldap/tests/Jobs/SyncTest.php index f8a44de87e8..686455f5ac6 100644 --- a/apps/user_ldap/tests/Jobs/SyncTest.php +++ b/apps/user_ldap/tests/Jobs/SyncTest.php @@ -23,6 +23,10 @@ namespace OCA\User_LDAP\Tests\Jobs; +use OCA\User_LDAP\Access; +use OCA\User_LDAP\AccessFactory; +use OCA\User_LDAP\Connection; +use OCA\User_LDAP\ConnectionFactory; use OCA\User_LDAP\Helper; use OCA\User_LDAP\Jobs\Sync; use OCA\User_LDAP\LDAP; @@ -59,6 +63,10 @@ class SyncTest extends TestCase { protected $ncUserManager; /** @var IManager|\PHPUnit_Framework_MockObject_MockObject */ protected $notificationManager; + /** @var ConnectionFactory|\PHPUnit_Framework_MockObject_MockObject */ + protected $connectionFactory; + /** @var AccessFactory|\PHPUnit_Framework_MockObject_MockObject */ + protected $accessFactory; public function setUp() { parent::setUp(); @@ -72,6 +80,8 @@ class SyncTest extends TestCase { $this->dbc = $this->createMock(IDBConnection::class); $this->ncUserManager = $this->createMock(IUserManager::class); $this->notificationManager = $this->createMock(IManager::class); + $this->connectionFactory = $this->createMock(ConnectionFactory::class); + $this->accessFactory = $this->createMock(AccessFactory::class); $this->arguments = [ 'helper' => $this->helper, @@ -83,6 +93,8 @@ class SyncTest extends TestCase { 'dbc' => $this->dbc, 'ncUserManager' => $this->ncUserManager, 'notificationManager' => $this->notificationManager, + 'connectionFactory' => $this->connectionFactory, + 'accessFactory' => $this->accessFactory, ]; $this->sync = new Sync(); @@ -141,4 +153,47 @@ class SyncTest extends TestCase { $this->sync->updateInterval(); } + public function moreResultsProvider() { + return [ + [ 3, 3, true ], + [ 3, 5, true ], + [ 3, 2, false] + ]; + } + + /** + * @dataProvider moreResultsProvider + */ + public function testMoreResults($pagingSize, $results, $expected) { + $connection = $this->createMock(Connection::class); + $this->connectionFactory->expects($this->any()) + ->method('get') + ->willReturn($connection); + $connection->expects($this->any()) + ->method('__get') + ->willReturnCallback(function ($key) use ($pagingSize) { + if($key === 'ldapPagingSize') { + return $pagingSize; + } + return null; + }); + + /** @var Access|\PHPUnit_Framework_MockObject_MockObject $access */ + $access = $this->createMock(Access::class); + $this->accessFactory->expects($this->any()) + ->method('get') + ->with($connection) + ->willReturn($access); + + $access->expects($this->once()) + ->method('fetchListOfUsers') + ->willReturn(array_pad([], $results, 'someUser')); + $access->connection = $connection; + $access->userManager = $this->userManager; + + $this->sync->setArgument($this->arguments); + $hasMoreResults = $this->sync->runCycle(['prefix' => 's01', 'offset' => 100]); + $this->assertSame($expected, $hasMoreResults); + } + } -- cgit v1.2.3 From a565bf0b9f9d81d46ff705498b66b676fe9a628a Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 5 Jan 2018 14:29:11 +0100 Subject: fix offset is never being reset Signed-off-by: Arthur Schiwon --- apps/user_ldap/lib/Jobs/Sync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/user_ldap/lib/Jobs/Sync.php b/apps/user_ldap/lib/Jobs/Sync.php index e80223a6255..38eba5ca4bf 100644 --- a/apps/user_ldap/lib/Jobs/Sync.php +++ b/apps/user_ldap/lib/Jobs/Sync.php @@ -179,7 +179,7 @@ class Sync extends TimedJob { if($connection->ldapPagingSize === 0) { return true; } - return count($results) !== $connection->ldapPagingSize; + return count($results) >= $connection->ldapPagingSize; } /** -- cgit v1.2.3 From e4310648dfcc57618c4a0d61ae73f889e08f3b53 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 8 Jan 2018 12:57:14 +0100 Subject: add unit test for determining next cycle Signed-off-by: Arthur Schiwon --- apps/user_ldap/tests/Jobs/SyncTest.php | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/apps/user_ldap/tests/Jobs/SyncTest.php b/apps/user_ldap/tests/Jobs/SyncTest.php index 686455f5ac6..338b1210a98 100644 --- a/apps/user_ldap/tests/Jobs/SyncTest.php +++ b/apps/user_ldap/tests/Jobs/SyncTest.php @@ -196,4 +196,45 @@ class SyncTest extends TestCase { $this->assertSame($expected, $hasMoreResults); } + public function cycleDataProvider() { + $cycle1 = ['prefix' => 's01', 'offset' => 1000]; + return [ + [ null, ['s01'], ['prefix' => 's01', 'offset' => 0] ], + [ $cycle1, ['s01', 's02'], ['prefix' => 's02', 'offset' => 0] ], + [ $cycle1, [], null ], + ]; + } + + /** + * @dataProvider cycleDataProvider + */ + public function testDetermineNextCycle($cycleData, $prefixes, $expectedCycle) { + $this->helper->expects($this->any()) + ->method('getServerConfigurationPrefixes') + ->with(true) + ->willReturn($prefixes); + + if(is_array($expectedCycle)) { + $this->config->expects($this->exactly(2)) + ->method('setAppValue') + ->withConsecutive( + ['user_ldap', 'background_sync_prefix', $expectedCycle['prefix']], + ['user_ldap', 'background_sync_offset', $expectedCycle['offset']] + ); + } else { + $this->config->expects($this->never()) + ->method('setAppValue'); + } + + $this->sync->setArgument($this->arguments); + $nextCycle = $this->sync->determineNextCycle($cycleData); + + if($expectedCycle === null) { + $this->assertNull($nextCycle); + } else { + $this->assertSame($expectedCycle['prefix'], $nextCycle['prefix']); + $this->assertSame($expectedCycle['offset'], $nextCycle['offset']); + } + } + } -- cgit v1.2.3 From b17c5fec40769ffc0b96c42618048046beb8f85e Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 8 Jan 2018 13:08:18 +0100 Subject: add unit test for qualifies to run Signed-off-by: Arthur Schiwon --- apps/user_ldap/lib/Jobs/Sync.php | 4 ++-- apps/user_ldap/tests/Jobs/SyncTest.php | 22 +++++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/apps/user_ldap/lib/Jobs/Sync.php b/apps/user_ldap/lib/Jobs/Sync.php index 38eba5ca4bf..7a1f7703e5c 100644 --- a/apps/user_ldap/lib/Jobs/Sync.php +++ b/apps/user_ldap/lib/Jobs/Sync.php @@ -118,7 +118,7 @@ class Sync extends TimedJob { /** * @param array $argument */ - protected function run($argument) { + public function run($argument) { $this->setArgument($argument); $isBackgroundJobModeAjax = $this->config @@ -252,7 +252,7 @@ class Sync extends TimedJob { * @param $cycleData * @return bool */ - protected function qualifiesToRun($cycleData) { + public function qualifiesToRun($cycleData) { $lastChange = $this->config->getAppValue('user_ldap', $cycleData['prefix'] . '_lastChange', 0); if((time() - $lastChange) > 60 * 30) { return true; diff --git a/apps/user_ldap/tests/Jobs/SyncTest.php b/apps/user_ldap/tests/Jobs/SyncTest.php index 338b1210a98..68a7887c12b 100644 --- a/apps/user_ldap/tests/Jobs/SyncTest.php +++ b/apps/user_ldap/tests/Jobs/SyncTest.php @@ -197,11 +197,15 @@ class SyncTest extends TestCase { } public function cycleDataProvider() { - $cycle1 = ['prefix' => 's01', 'offset' => 1000]; + $lastCycle = ['prefix' => 's01', 'offset' => 1000]; + $lastCycle2 = ['prefix' => '', 'offset' => 1000]; return [ [ null, ['s01'], ['prefix' => 's01', 'offset' => 0] ], - [ $cycle1, ['s01', 's02'], ['prefix' => 's02', 'offset' => 0] ], - [ $cycle1, [], null ], + [ null, [''], ['prefix' => '', 'offset' => 0] ], + [ $lastCycle, ['s01', 's02'], ['prefix' => 's02', 'offset' => 0] ], + [ $lastCycle, [''], ['prefix' => '', 'offset' => 0] ], + [ $lastCycle2, ['', 's01'], ['prefix' => 's01', 'offset' => 0] ], + [ $lastCycle, [], null ], ]; } @@ -237,4 +241,16 @@ class SyncTest extends TestCase { } } + public function testQualifiesToRun() { + $cycleData = ['prefix' => 's01']; + + $this->config->expects($this->exactly(2)) + ->method('getAppValue') + ->willReturnOnConsecutiveCalls(time() - 60*40, time() - 60*20); + + $this->sync->setArgument($this->arguments); + $this->assertTrue($this->sync->qualifiesToRun($cycleData)); + $this->assertFalse($this->sync->qualifiesToRun($cycleData)); + } + } -- cgit v1.2.3 From 0d3f945209f70905e4125fd62501b5adad8901d3 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 8 Jan 2018 13:44:45 +0100 Subject: add tests for whole run command Signed-off-by: Arthur Schiwon --- apps/user_ldap/tests/Jobs/SyncTest.php | 104 +++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/apps/user_ldap/tests/Jobs/SyncTest.php b/apps/user_ldap/tests/Jobs/SyncTest.php index 68a7887c12b..62f15472138 100644 --- a/apps/user_ldap/tests/Jobs/SyncTest.php +++ b/apps/user_ldap/tests/Jobs/SyncTest.php @@ -37,6 +37,7 @@ use OCP\IConfig; use OCP\IDBConnection; use OCP\IUserManager; use OCP\Notification\IManager; +use function Sodium\memcmp; use Test\TestCase; class SyncTest extends TestCase { @@ -253,4 +254,107 @@ class SyncTest extends TestCase { $this->assertFalse($this->sync->qualifiesToRun($cycleData)); } + public function runDataProvider() { + return [ + #0 - one LDAP server, reset + [[ + 'prefixes' => [''], + 'scheduledCycle' => ['prefix' => '', 'offset' => '4500'], + 'pagingSize' => 500, + 'usersThisCycle' => 0, + 'expectedNextCycle' => ['prefix' => '', 'offset' => '0'], + 'mappedUsers' => 123, + ]], + #0 - 2 LDAP servers, next prefix + [[ + 'prefixes' => ['', 's01'], + 'scheduledCycle' => ['prefix' => '', 'offset' => '4500'], + 'pagingSize' => 500, + 'usersThisCycle' => 0, + 'expectedNextCycle' => ['prefix' => 's01', 'offset' => '0'], + 'mappedUsers' => 123, + ]], + ]; + } + + /** + * @dataProvider runDataProvider + */ + public function testRun($runData) { + $this->config->expects($this->any()) + ->method('getAppValue') + ->willReturnCallback(function($app, $key, $default) use ($runData) { + if($app === 'core' && $key === 'backgroundjobs_mode') { + return 'cron'; + } + if($app = 'user_ldap') { + // for getCycle() + if($key === 'background_sync_prefix') { + return $runData['scheduledCycle']['prefix']; + } + if($key === 'background_sync_offset') { + return $runData['scheduledCycle']['offset']; + } + // for qualifiesToRun() + if($key === $runData['scheduledCycle']['prefix'] . '_lastChange') { + return time() - 60*40; + } + // for getMinPagingSize + if($key === $runData['scheduledCycle']['prefix'] . 'ldap_paging_size') { + return $runData['pagingSize']; + } + } + + return $default; + }); + $this->config->expects($this->exactly(3)) + ->method('setAppValue') + ->withConsecutive( + ['user_ldap', 'background_sync_prefix', $runData['expectedNextCycle']['prefix']], + ['user_ldap', 'background_sync_offset', $runData['expectedNextCycle']['offset']], + ['user_ldap', 'background_sync_interval', $this->anything()] + ); + $this->config->expects($this->any()) + ->method('getAppKeys') + ->with('user_ldap') + ->willReturn([$runData['scheduledCycle']['prefix'] . 'ldap_paging_size']); + + $this->helper->expects($this->any()) + ->method('getServerConfigurationPrefixes') + ->with(true) + ->willReturn($runData['prefixes']); + + $connection = $this->createMock(Connection::class); + $this->connectionFactory->expects($this->any()) + ->method('get') + ->willReturn($connection); + $connection->expects($this->any()) + ->method('__get') + ->willReturnCallback(function ($key) use ($runData) { + if($key === 'ldapPagingSize') { + return $runData['pagingSize']; + } + return null; + }); + + /** @var Access|\PHPUnit_Framework_MockObject_MockObject $access */ + $access = $this->createMock(Access::class); + $this->accessFactory->expects($this->any()) + ->method('get') + ->with($connection) + ->willReturn($access); + + $access->expects($this->once()) + ->method('fetchListOfUsers') + ->willReturn(array_pad([], $runData['usersThisCycle'], 'someUser')); + $access->connection = $connection; + $access->userManager = $this->userManager; + + $this->mapper->expects($this->any()) + ->method('count') + ->willReturn($runData['mappedUsers']); + + $this->sync->run($this->arguments); + } + } -- cgit v1.2.3 From 7c3db54ff697920a7fc35c6454c0b7c407ec2aa4 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 8 Jan 2018 13:45:06 +0100 Subject: fix changing to next cycle Signed-off-by: Arthur Schiwon --- apps/user_ldap/lib/Jobs/Sync.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/user_ldap/lib/Jobs/Sync.php b/apps/user_ldap/lib/Jobs/Sync.php index 7a1f7703e5c..b78a1947e27 100644 --- a/apps/user_ldap/lib/Jobs/Sync.php +++ b/apps/user_ldap/lib/Jobs/Sync.php @@ -146,11 +146,11 @@ class Sync extends TimedJob { if ($expectMoreResults) { $this->increaseOffset($cycleData); } else { - $this->determineNextCycle(); + $this->determineNextCycle($cycleData); } $this->updateInterval(); } catch (ServerNotAvailableException $e) { - $this->determineNextCycle(); + $this->determineNextCycle($cycleData); } } -- cgit v1.2.3 From cf915b0f754fa1558e31af96d42d825f7b0e8017 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 8 Jan 2018 13:46:07 +0100 Subject: extend test for rotating prefixes Signed-off-by: Arthur Schiwon --- apps/user_ldap/tests/Jobs/SyncTest.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/user_ldap/tests/Jobs/SyncTest.php b/apps/user_ldap/tests/Jobs/SyncTest.php index 62f15472138..f8852a46664 100644 --- a/apps/user_ldap/tests/Jobs/SyncTest.php +++ b/apps/user_ldap/tests/Jobs/SyncTest.php @@ -265,7 +265,7 @@ class SyncTest extends TestCase { 'expectedNextCycle' => ['prefix' => '', 'offset' => '0'], 'mappedUsers' => 123, ]], - #0 - 2 LDAP servers, next prefix + #1 - 2 LDAP servers, next prefix [[ 'prefixes' => ['', 's01'], 'scheduledCycle' => ['prefix' => '', 'offset' => '4500'], @@ -274,6 +274,15 @@ class SyncTest extends TestCase { 'expectedNextCycle' => ['prefix' => 's01', 'offset' => '0'], 'mappedUsers' => 123, ]], + #2 - 2 LDAP servers, rotate prefix + [[ + 'prefixes' => ['', 's01'], + 'scheduledCycle' => ['prefix' => 's01', 'offset' => '4500'], + 'pagingSize' => 500, + 'usersThisCycle' => 0, + 'expectedNextCycle' => ['prefix' => '', 'offset' => '0'], + 'mappedUsers' => 123, + ]], ]; } -- cgit v1.2.3