From 085bcd7da27e82e4695ff1a2cf961e9b6a820712 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 22 Apr 2016 11:10:51 +0200 Subject: Throw NoUserException when attempting to init mount point for null user In some scenarios initMountPoints is called with an empty user, and also there is no user in the session. In such cases, it is unsafe to let the code move on with an empty user. --- tests/lib/files/filesystem.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests') diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php index db1f22f894a..8245af0ace1 100644 --- a/tests/lib/files/filesystem.php +++ b/tests/lib/files/filesystem.php @@ -319,6 +319,28 @@ class Filesystem extends \Test\TestCase { \OC\Files\Filesystem::initMountPoints($userId); } + /** + * @expectedException \OC\User\NoUserException + */ + public function testNullUserThrows() { + \OC\Files\Filesystem::initMountPoints(null); + } + + public function testNullUserThrowsTwice() { + $thrown = 0; + try { + \OC\Files\Filesystem::initMountPoints(null); + } catch (NoUserException $e) { + $thrown++; + } + try { + \OC\Files\Filesystem::initMountPoints(null); + } catch (NoUserException $e) { + $thrown++; + } + $this->assertEquals(2, $thrown); + } + /** * Tests that the home storage is used for the user's mount point */ -- cgit v1.2.3