Merge pull request #24186 from owncloud/fs-initmountpoint-nulluser
Throw NoUserException when attempting to init mount point for null user
This commit is contained in:
commit
e0514d2c04
|
@ -372,6 +372,9 @@ class Filesystem {
|
||||||
if ($user == '') {
|
if ($user == '') {
|
||||||
$user = \OC_User::getUser();
|
$user = \OC_User::getUser();
|
||||||
}
|
}
|
||||||
|
if ($user === null || $user === false || $user === '') {
|
||||||
|
throw new \OC\User\NoUserException('Attempted to initialize mount points for null user and no user in session');
|
||||||
|
}
|
||||||
if (isset(self::$usersSetup[$user])) {
|
if (isset(self::$usersSetup[$user])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,6 +319,28 @@ class Filesystem extends \Test\TestCase {
|
||||||
\OC\Files\Filesystem::initMountPoints($userId);
|
\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
|
* Tests that the home storage is used for the user's mount point
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue