diff options
author | Morris Jobke <hey@morrisjobke.de> | 2019-07-17 17:36:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-17 17:36:00 +0200 |
commit | 782554d2acdfd48b322753500906e8b291035250 (patch) | |
tree | 883a1a7b664ce1d0af21cf76b284afa2fae1b470 /tests | |
parent | 223a91d5ef91057f0e373a5824e4f360724d72fd (diff) | |
parent | 99f2c82222b0c67b3eddc8dff71aed1acacf1f23 (diff) | |
download | nextcloud-server-782554d2acdfd48b322753500906e8b291035250.tar.gz nextcloud-server-782554d2acdfd48b322753500906e8b291035250.zip |
Merge pull request #16075 from nextcloud/bugfix/15823/app-restricted-groups
Remove deleted groups from app restrictions fixes #15823
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/App/AppManagerTest.php | 53 | ||||
-rw-r--r-- | tests/lib/AppTest.php | 3 |
2 files changed, 49 insertions, 7 deletions
diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php index cb94ccf44d0..371c2373f81 100644 --- a/tests/lib/App/AppManagerTest.php +++ b/tests/lib/App/AppManagerTest.php @@ -19,6 +19,7 @@ use OCP\ICache; use OCP\ICacheFactory; use OCP\IGroup; use OCP\IGroupManager; +use OCP\ILogger; use OCP\IUser; use OCP\IUserSession; use OCP\IAppConfig; @@ -90,6 +91,9 @@ class AppManagerTest extends TestCase { /** @var EventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $eventDispatcher; + /** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */ + protected $logger; + /** @var IAppManager */ protected $manager; @@ -102,11 +106,12 @@ class AppManagerTest extends TestCase { $this->cacheFactory = $this->createMock(ICacheFactory::class); $this->cache = $this->createMock(ICache::class); $this->eventDispatcher = $this->createMock(EventDispatcherInterface::class); + $this->logger = $this->createMock(ILogger::class); $this->cacheFactory->expects($this->any()) ->method('createDistributed') ->with('settings') ->willReturn($this->cache); - $this->manager = new AppManager($this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher); + $this->manager = new AppManager($this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger); } protected function expectClearCache() { @@ -159,7 +164,7 @@ class AppManagerTest extends TestCase { /** @var AppManager|\PHPUnit_Framework_MockObject_MockObject $manager */ $manager = $this->getMockBuilder(AppManager::class) ->setConstructorArgs([ - $this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher + $this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger ]) ->setMethods([ 'getAppPath', @@ -206,7 +211,7 @@ class AppManagerTest extends TestCase { /** @var AppManager|\PHPUnit_Framework_MockObject_MockObject $manager */ $manager = $this->getMockBuilder(AppManager::class) ->setConstructorArgs([ - $this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher + $this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger ]) ->setMethods([ 'getAppPath', @@ -259,7 +264,7 @@ class AppManagerTest extends TestCase { /** @var AppManager|\PHPUnit_Framework_MockObject_MockObject $manager */ $manager = $this->getMockBuilder(AppManager::class) ->setConstructorArgs([ - $this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher + $this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger ]) ->setMethods([ 'getAppPath', @@ -418,7 +423,7 @@ class AppManagerTest extends TestCase { public function testGetAppsNeedingUpgrade() { /** @var AppManager|\PHPUnit_Framework_MockObject_MockObject $manager */ $manager = $this->getMockBuilder(AppManager::class) - ->setConstructorArgs([$this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher]) + ->setConstructorArgs([$this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger]) ->setMethods(['getAppInfo']) ->getMock(); @@ -466,7 +471,7 @@ class AppManagerTest extends TestCase { public function testGetIncompatibleApps() { /** @var AppManager|\PHPUnit_Framework_MockObject_MockObject $manager */ $manager = $this->getMockBuilder(AppManager::class) - ->setConstructorArgs([$this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher]) + ->setConstructorArgs([$this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger]) ->setMethods(['getAppInfo']) ->getMock(); @@ -504,4 +509,40 @@ class AppManagerTest extends TestCase { $this->assertEquals('test1', $apps[0]['id']); $this->assertEquals('test3', $apps[1]['id']); } + + public function testGetEnabledAppsForGroup() { + $group = $this->createMock(IGroup::class); + $group->expects($this->any()) + ->method('getGID') + ->will($this->returnValue('foo')); + + $this->appConfig->setValue('test1', 'enabled', 'yes'); + $this->appConfig->setValue('test2', 'enabled', 'no'); + $this->appConfig->setValue('test3', 'enabled', '["foo"]'); + $this->appConfig->setValue('test4', 'enabled', '["asd"]'); + $enabled = [ + 'cloud_federation_api', + 'dav', + 'federatedfilesharing', + 'files', + 'lookup_server_connector', + 'oauth2', + 'provisioning_api', + 'test1', + 'test3', + 'twofactor_backupcodes', + 'workflowengine', + ]; + $this->assertEquals($enabled, $this->manager->getEnabledAppsForGroup($group)); + } + + public function testGetAppRestriction() { + $this->appConfig->setValue('test1', 'enabled', 'yes'); + $this->appConfig->setValue('test2', 'enabled', 'no'); + $this->appConfig->setValue('test3', 'enabled', '["foo"]'); + + $this->assertEquals([], $this->manager->getAppRestriction('test1')); + $this->assertEquals([], $this->manager->getAppRestriction('test2')); + $this->assertEquals(['foo'], $this->manager->getAppRestriction('test3')); + } } diff --git a/tests/lib/AppTest.php b/tests/lib/AppTest.php index 5d98dc7df57..954ffcfae7f 100644 --- a/tests/lib/AppTest.php +++ b/tests/lib/AppTest.php @@ -542,7 +542,8 @@ class AppTest extends \Test\TestCase { $appConfig, \OC::$server->getGroupManager(), \OC::$server->getMemCacheFactory(), - \OC::$server->getEventDispatcher() + \OC::$server->getEventDispatcher(), + \OC::$server->getLogger() )); } |