summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-05-20 13:52:08 +0200
committerVincent Petry <pvince81@owncloud.com>2015-05-20 13:52:08 +0200
commit7386257676cff4648f4e71d05cdabff75578e947 (patch)
treea7320e5eec4f943cbc03f97cf5b9d942a5ef672e /apps
parentf9784745776eda5caedbbc72cf516ae70bce6f6a (diff)
parent6d97dfb00c6bd660d9f8ac3a579f34d70fe87af1 (diff)
downloadnextcloud-server-7386257676cff4648f4e71d05cdabff75578e947.tar.gz
nextcloud-server-7386257676cff4648f4e71d05cdabff75578e947.zip
Merge pull request #16075 from owncloud/skeleton-copy-delay
wait with copying the skeleton untill login and setupfs are done
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/tests/controller/sharecontroller.php5
-rw-r--r--apps/files_sharing/tests/testcase.php1
-rw-r--r--apps/files_trashbin/tests/trashbin.php1
-rw-r--r--apps/files_versions/tests/versions.php1
-rw-r--r--apps/provisioning_api/lib/users.php36
-rw-r--r--apps/provisioning_api/tests/appstest.php2
-rw-r--r--apps/provisioning_api/tests/groupstest.php12
-rw-r--r--apps/provisioning_api/tests/userstest.php86
8 files changed, 81 insertions, 63 deletions
diff --git a/apps/files_sharing/tests/controller/sharecontroller.php b/apps/files_sharing/tests/controller/sharecontroller.php
index d0c111b8e5b..eaa7ce7bfde 100644
--- a/apps/files_sharing/tests/controller/sharecontroller.php
+++ b/apps/files_sharing/tests/controller/sharecontroller.php
@@ -77,10 +77,7 @@ class ShareControllerTest extends \Test\TestCase {
\OC_User::createUser($this->user, $this->user);
\OC_Util::tearDownFS();
- \OC_User::setUserId('');
- Filesystem::tearDown();
- \OC_User::setUserId($this->user);
- \OC_Util::setupFS($this->user);
+ $this->loginAsUser($this->user);
// Create a dummy shared file
$view = new View('/'. $this->user . '/files');
diff --git a/apps/files_sharing/tests/testcase.php b/apps/files_sharing/tests/testcase.php
index b9e9f077201..7533b13f79d 100644
--- a/apps/files_sharing/tests/testcase.php
+++ b/apps/files_sharing/tests/testcase.php
@@ -153,6 +153,7 @@ abstract class TestCase extends \Test\TestCase {
\OC::$server->getUserSession()->setUser(null);
\OC\Files\Filesystem::tearDown();
\OC::$server->getUserSession()->login($user, $password);
+ \OC::$server->getUserFolder($user);
\OC_Util::setupFS($user);
}
diff --git a/apps/files_trashbin/tests/trashbin.php b/apps/files_trashbin/tests/trashbin.php
index 85c47b527b7..0c37af24de5 100644
--- a/apps/files_trashbin/tests/trashbin.php
+++ b/apps/files_trashbin/tests/trashbin.php
@@ -646,6 +646,7 @@ class Test_Trashbin extends \Test\TestCase {
\OC\Files\Filesystem::tearDown();
\OC_User::setUserId($user);
\OC_Util::setupFS($user);
+ \OC::$server->getUserFolder($user);
}
}
diff --git a/apps/files_versions/tests/versions.php b/apps/files_versions/tests/versions.php
index 97afcf715cb..685bf48d652 100644
--- a/apps/files_versions/tests/versions.php
+++ b/apps/files_versions/tests/versions.php
@@ -753,6 +753,7 @@ class Test_Files_Versioning extends \Test\TestCase {
\OC\Files\Filesystem::tearDown();
\OC_User::setUserId($user);
\OC_Util::setupFS($user);
+ \OC::$server->getUserFolder($user);
}
}
diff --git a/apps/provisioning_api/lib/users.php b/apps/provisioning_api/lib/users.php
index 43cf22b071b..b709e09726d 100644
--- a/apps/provisioning_api/lib/users.php
+++ b/apps/provisioning_api/lib/users.php
@@ -27,6 +27,7 @@ use \OC_SubAdmin;
use \OC_User;
use \OC_Group;
use \OC_Helper;
+use OCP\Files\NotFoundException;
class Users {
@@ -92,16 +93,8 @@ class Users {
$config = \OC::$server->getConfig();
// Find the data
- $data = array();
- \OC_Util::tearDownFS();
- \OC_Util::setupFS($userId);
- $storage = OC_Helper::getStorageInfo('/');
- $data['quota'] = array(
- 'free' => $storage['free'],
- 'used' => $storage['used'],
- 'total' => $storage['total'],
- 'relative' => $storage['relative'],
- );
+ $data = [];
+ $data = self::fillStorageInfo($userId, $data);
$data['enabled'] = $config->getUserValue($userId, 'core', 'enabled', 'true');
$data['email'] = $config->getUserValue($userId, 'settings', 'email');
$data['displayname'] = OC_User::getDisplayName($parameters['userid']);
@@ -350,4 +343,27 @@ class Users {
return new OC_OCS_Result($groups);
}
}
+
+ /**
+ * @param $userId
+ * @param $data
+ * @return mixed
+ * @throws \OCP\Files\NotFoundException
+ */
+ private static function fillStorageInfo($userId, $data) {
+ try {
+ \OC_Util::tearDownFS();
+ \OC_Util::setupFS($userId);
+ $storage = OC_Helper::getStorageInfo('/');
+ $data['quota'] = [
+ 'free' => $storage['free'],
+ 'used' => $storage['used'],
+ 'total' => $storage['total'],
+ 'relative' => $storage['relative'],
+ ];
+ } catch (NotFoundException $ex) {
+ $data['quota'] = [];
+ }
+ return $data;
+ }
}
diff --git a/apps/provisioning_api/tests/appstest.php b/apps/provisioning_api/tests/appstest.php
index 140dd287a0e..94bff8bbf5b 100644
--- a/apps/provisioning_api/tests/appstest.php
+++ b/apps/provisioning_api/tests/appstest.php
@@ -44,7 +44,7 @@ class AppsTest extends TestCase {
$user = $this->generateUsers();
\OC_Group::addToGroup($user, 'admin');
- \OC_User::setUserId($user);
+ self::loginAsUser($user);
$result = \OCA\provisioning_API\Apps::getApps(array());
diff --git a/apps/provisioning_api/tests/groupstest.php b/apps/provisioning_api/tests/groupstest.php
index 94bde52c392..cb677d9b512 100644
--- a/apps/provisioning_api/tests/groupstest.php
+++ b/apps/provisioning_api/tests/groupstest.php
@@ -27,7 +27,7 @@ class GroupsTest extends TestCase {
public function testGetGroupAsUser() {
$users = $this->generateUsers(2);
- \OC_User::setUserId($users[0]);
+ self::loginAsUser($users[0]);
$group = $this->getUniqueID();
\OC_Group::createGroup($group);
@@ -46,7 +46,7 @@ class GroupsTest extends TestCase {
public function testGetGroupAsSubadmin() {
$users = $this->generateUsers(2);
- \OC_User::setUserId($users[0]);
+ self::loginAsUser($users[0]);
$group = $this->getUniqueID();
\OC_Group::createGroup($group);
@@ -75,7 +75,7 @@ class GroupsTest extends TestCase {
public function testGetGroupAsIrrelevantSubadmin() {
$users = $this->generateUsers(2);
- \OC_User::setUserId($users[0]);
+ self::loginAsUser($users[0]);
$group = $this->getUniqueID();
\OC_Group::createGroup($group);
@@ -99,7 +99,7 @@ class GroupsTest extends TestCase {
public function testGetGroupAsAdmin() {
$users = $this->generateUsers(2);
- \OC_User::setUserId($users[0]);
+ self::loginAsUser($users[0]);
$group = $this->getUniqueID();
\OC_Group::createGroup($group);
@@ -120,7 +120,7 @@ class GroupsTest extends TestCase {
public function testGetSubAdminsOfGroup() {
$user1 = $this->generateUsers();
$user2 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
\OC_Group::addToGroup($user1, 'admin');
$group1 = $this->getUniqueID();
\OC_Group::createGroup($group1);
@@ -135,7 +135,7 @@ class GroupsTest extends TestCase {
\OC_Group::deleteGroup($group1);
$user1 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
\OC_Group::addToGroup($user1, 'admin');
$result = \OCA\provisioning_api\Groups::getSubAdminsOfGroup(array(
'groupid' => $this->getUniqueID(),
diff --git a/apps/provisioning_api/tests/userstest.php b/apps/provisioning_api/tests/userstest.php
index c6a6133b7d2..0ba76355d58 100644
--- a/apps/provisioning_api/tests/userstest.php
+++ b/apps/provisioning_api/tests/userstest.php
@@ -81,7 +81,7 @@ class UsersTest extends TestCase {
public function testGetUserOnSelf() {
$user = $this->generateUsers();
- \OC_User::setUserId($user);
+ self::loginAsUser($user);
$params['userid'] = $user;
$result = \OCA\provisioning_API\Users::getUser($params);
$this->assertInstanceOf('OC_OCS_Result', $result);
@@ -92,7 +92,7 @@ class UsersTest extends TestCase {
public function testGetUserOnNonExistingUser() {
$user = $this->generateUsers();
\OC_Group::addToGroup($user, 'admin');
- \OC_User::setUserId($user);
+ self::loginAsUser($user);
$params = array();
$params['userid'] = $this->getUniqueID();
while(\OC_User::userExists($params['userid'])) {
@@ -108,7 +108,7 @@ class UsersTest extends TestCase {
public function testGetUserOnOtherUser() {
$users = $this->generateUsers(2);
$params['userid'] = $users[0];
- \OC_User::setUserId($users[1]);
+ self::loginAsUser($users[1]);
$result = \OCA\provisioning_API\Users::getUser($params);
$this->assertInstanceOf('OC_OCS_Result', $result);
$this->assertFalse($result->succeeded());
@@ -116,8 +116,10 @@ class UsersTest extends TestCase {
// Now as as admin
$users = $this->generateUsers(2);
$params['userid'] = $users[0];
+ // login to generate home
+ self::loginAsUser($users[0]);
\OC_Group::addToGroup($users[1], 'admin');
- \OC_User::setUserId($users[1]);
+ self::loginAsUser($users[1]);
$result = \OCA\provisioning_API\Users::getUser($params);
$this->assertInstanceOf('OC_OCS_Result', $result);
$this->assertTrue($result->succeeded());
@@ -129,7 +131,7 @@ class UsersTest extends TestCase {
// Test editing own name
$user = $this->generateUsers();
- \OC_User::setUserId($user);
+ self::loginAsUser($user);
$result = \OCA\provisioning_API\Users::editUser(
array(
'userid' => $user,
@@ -150,7 +152,7 @@ class UsersTest extends TestCase {
// Test admin editing users name
$user = $this->generateUsers();
\OC_Group::addToGroup($user, 'admin');
- \OC_User::setUserId($user);
+ self::loginAsUser($user);
$user2 = $this->generateUsers();
$result = \OCA\provisioning_API\Users::editUser(
array(
@@ -171,7 +173,7 @@ class UsersTest extends TestCase {
// Test editing other users name
$user = $this->generateUsers();
- \OC_User::setUserId($user);
+ self::loginAsUser($user);
$user2 = $this->generateUsers();
$result = \OCA\provisioning_API\Users::editUser(
array(
@@ -195,7 +197,7 @@ class UsersTest extends TestCase {
public function testEditOwnQuota($expected, $quota) {
$user = $this->generateUsers();
\OC_Group::addToGroup($user, 'admin');
- \OC_User::setUserId($user);
+ self::loginAsUser($user);
$result = \OCA\provisioning_API\Users::editUser(
[
'userid' => $user,
@@ -222,7 +224,7 @@ class UsersTest extends TestCase {
public function testAdminEditOwnQuota() {
$user = $this->generateUsers();
\OC_Group::addToGroup($user, 'admin');
- \OC_User::setUserId($user);
+ self::loginAsUser($user);
$result = \OCA\provisioning_API\Users::editUser(
array(
'userid' => $user,
@@ -239,7 +241,7 @@ class UsersTest extends TestCase {
public function testAdminEditOtherUserQuota() {
$user = $this->generateUsers();
\OC_Group::addToGroup($user, 'admin');
- \OC_User::setUserId($user);
+ self::loginAsUser($user);
$user2 = $this->generateUsers();
$result = \OCA\provisioning_API\Users::editUser(
array(
@@ -256,7 +258,7 @@ class UsersTest extends TestCase {
public function testUserEditOtherUserQuota() {
$user = $this->generateUsers();
- \OC_User::setUserId($user);
+ self::loginAsUser($user);
$user2 = $this->generateUsers();
$result = \OCA\provisioning_API\Users::editUser(
array(
@@ -274,7 +276,7 @@ class UsersTest extends TestCase {
public function testUserEditOwnEmail() {
$user = $this->generateUsers();
$email = 'test@example.com';
- \OC_User::setUserId($user);
+ self::loginAsUser($user);
$result = \OCA\provisioning_API\Users::editUser(
array(
'userid' => $user,
@@ -292,7 +294,7 @@ class UsersTest extends TestCase {
public function testUserEditOtherUserEmailAsUser() {
$users = $this->generateUsers(2);
$email = 'test@example.com';
- \OC_User::setUserId($users[0]);
+ self::loginAsUser($users[0]);
$result = \OCA\provisioning_API\Users::editUser(
array(
'userid' => $users[1],
@@ -309,7 +311,7 @@ class UsersTest extends TestCase {
public function testUserEditOtherUserEmailAsAdmin() {
$users = $this->generateUsers(2);
$email = 'test@example.com';
- \OC_User::setUserId($users[0]);
+ self::loginAsUser($users[0]);
\OC_Group::addToGroup($users[0], 'admin');
$result = \OCA\provisioning_API\Users::editUser(
array(
@@ -327,7 +329,7 @@ class UsersTest extends TestCase {
public function testDeleteSelf() {
$user = $this->generateUsers();
- \OC_User::setUserId($user);
+ self::loginAsUser($user);
$result = \OCA\provisioning_API\Users::deleteUser(array(
'userid' => $user,
));
@@ -337,7 +339,7 @@ class UsersTest extends TestCase {
public function testDeleteOtherAsUser() {
$user = $this->generateUsers();
- \OC_User::setUserId($user);
+ self::loginAsUser($user);
$user2 = $this->generateUsers();
$result = \OCA\provisioning_API\Users::deleteUser(array(
'userid' => $user2,
@@ -348,7 +350,7 @@ class UsersTest extends TestCase {
public function testDeleteOtherAsSubAdmin() {
$user = $this->generateUsers();
- \OC_User::setUserId($user);
+ self::loginAsUser($user);
$user2 = $this->generateUsers();
$group = $this->getUniqueID();
\OC_Group::createGroup($group);
@@ -365,7 +367,7 @@ class UsersTest extends TestCase {
public function testDeleteOtherAsIrelevantSubAdmin() {
$user = $this->generateUsers();
- \OC_User::setUserId($user);
+ self::loginAsUser($user);
$user2 = $this->generateUsers();
$group = $this->getUniqueID();
$group2 = $this->getUniqueID();
@@ -386,7 +388,7 @@ class UsersTest extends TestCase {
public function testDeleteOtherAsAdmin() {
$user = $this->generateUsers();
\OC_Group::addToGroup($user, 'admin');
- \OC_User::setUserId($user);
+ self::loginAsUser($user);
$user2 = $this->generateUsers();
$result = \OCA\provisioning_API\Users::deleteUser(array(
'userid' => $user2,
@@ -398,7 +400,7 @@ class UsersTest extends TestCase {
public function testDeleteSelfAsAdmin() {
$user = $this->generateUsers();
\OC_Group::addToGroup($user, 'admin');
- \OC_User::setUserId($user);
+ self::loginAsUser($user);
$result = \OCA\provisioning_API\Users::deleteUser(array(
'userid' => $user,
));
@@ -408,7 +410,7 @@ class UsersTest extends TestCase {
public function testGetUsersGroupsOnSelf() {
$user = $this->generateUsers();
- \OC_User::setUserId($user);
+ self::loginAsUser($user);
$group = $this->getUniqueID();
\OC_Group::createGroup($group);
\OC_Group::addToGroup($user, $group);
@@ -426,7 +428,7 @@ class UsersTest extends TestCase {
public function testGetUsersGroupOnOther() {
$user1 = $this->generateUsers();
$user2 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
$group = $this->getUniqueID();
\OC_Group::createGroup($group);
\OC_Group::addToGroup($user2, $group);
@@ -442,7 +444,7 @@ class UsersTest extends TestCase {
$user1 = $this->generateUsers();
\OC_Group::addToGroup($user1, 'admin');
$user2 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
$group = $this->getUniqueID();
\OC_Group::createGroup($group);
\OC_Group::addToGroup($user2, $group);
@@ -460,7 +462,7 @@ class UsersTest extends TestCase {
public function testGetUsersGroupsOnOtherAsSubAdmin() {
$user1 = $this->generateUsers();
$user2 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
$group1 = $this->getUniqueID();
$group2 = $this->getUniqueID();
\OC_Group::createGroup($group1);
@@ -484,7 +486,7 @@ class UsersTest extends TestCase {
public function testGetUsersGroupsOnOtherAsIrelevantSubAdmin() {
$user1 = $this->generateUsers();
$user2 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
$group1 = $this->getUniqueID();
$group2 = $this->getUniqueID();
\OC_Group::createGroup($group1);
@@ -505,7 +507,7 @@ class UsersTest extends TestCase {
$user = $this->generateUsers();
$group = $this->getUniqueID();
\OC_Group::createGroup($group);
- \OC_User::setUserId($user);
+ self::loginAsUser($user);
$_POST['groupid'] = $group;
$result = \OCA\provisioning_API\Users::addToGroup(array(
'userid' => $user,
@@ -522,7 +524,7 @@ class UsersTest extends TestCase {
$group = $this->getUniqueID();
\OC_Group::createGroup($group);
$user2 = $this->generateUsers();
- \OC_User::setUserId($user);
+ self::loginAsUser($user);
$_POST['groupid'] = $group;
$result = \OCA\provisioning_API\Users::addToGroup(array(
'userid' => $user2,
@@ -536,7 +538,7 @@ class UsersTest extends TestCase {
public function testAddToGroupAsSubAdmin() {
$user1 = $this->generateUsers();
$user2 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
$group1 = $this->getUniqueID();
\OC_Group::createGroup($group1);
\OC_SubAdmin::createSubAdmin($user1, $group1);
@@ -553,7 +555,7 @@ class UsersTest extends TestCase {
public function testAddToGroupAsIrelevantSubAdmin() {
$user1 = $this->generateUsers();
$user2 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
$group1 = $this->getUniqueID();
$group2 = $this->getUniqueID();
\OC_Group::createGroup($group1);
@@ -573,7 +575,7 @@ class UsersTest extends TestCase {
// test delete /cloud/users/{userid}/groups
public function testRemoveFromGroupAsSelf() {
$user1 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
$group1 = $this->getUniqueID();
\OC_Group::createGroup($group1);
\OC_Group::addToGroup($user1, $group1);
@@ -592,7 +594,7 @@ class UsersTest extends TestCase {
public function testRemoveFromGroupAsAdmin() {
$user1 = $this->generateUsers();
$user2 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
$group1 = $this->getUniqueID();
\OC_Group::createGroup($group1);
\OC_Group::addToGroup($user2, $group1);
@@ -611,7 +613,7 @@ class UsersTest extends TestCase {
public function testRemoveFromGroupAsSubAdmin() {
$user1 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
$user2 = $this->generateUsers();
$group1 = $this->getUniqueID();
\OC_Group::createGroup($group1);
@@ -632,7 +634,7 @@ class UsersTest extends TestCase {
public function testRemoveFromGroupAsIrelevantSubAdmin() {
$user1 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
$user2 = $this->generateUsers();
$group1 = $this->getUniqueID();
$group2 = $this->getUniqueID();
@@ -657,7 +659,7 @@ class UsersTest extends TestCase {
public function testCreateSubAdmin() {
$user1 = $this->generateUsers();
$user2 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
\OC_Group::addToGroup($user1, 'admin');
$group1 = $this->getUniqueID();
\OC_Group::createGroup($group1);
@@ -674,7 +676,7 @@ class UsersTest extends TestCase {
$user1 = $this->generateUsers();
$user2 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
\OC_Group::addToGroup($user1, 'admin');
$_POST['groupid'] = 'admin';
$result = \OCA\provisioning_api\Users::addSubAdmin(array(
@@ -687,7 +689,7 @@ class UsersTest extends TestCase {
$this->resetParams();
$user1 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
\OC_Group::addToGroup($user1, 'admin');
$group1 = $this->getUniqueID();
\OC_Group::createGroup($group1);
@@ -704,7 +706,7 @@ class UsersTest extends TestCase {
public function testRemoveSubAdmin() {
$user1 = $this->generateUsers();
$user2 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
\OC_Group::addToGroup($user1, 'admin');
$group1 = $this->getUniqueID();
\OC_Group::createGroup($group1);
@@ -721,7 +723,7 @@ class UsersTest extends TestCase {
\OC_Group::deleteGroup($group1);
$user1 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
\OC_Group::addToGroup($user1, 'admin');
$result = \OCA\provisioning_api\Users::removeSubAdmin(array(
'userid' => $this->getUniqueID(),
@@ -737,7 +739,7 @@ class UsersTest extends TestCase {
$user1 = $this->generateUsers();
$user2 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
\OC_Group::addToGroup($user1, 'admin');
$group1 = $this->getUniqueID();
\OC_Group::createGroup($group1);
@@ -757,7 +759,7 @@ class UsersTest extends TestCase {
public function testGetSubAdminGroups() {
$user1 = $this->generateUsers();
$user2 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
\OC_Group::addToGroup($user1, 'admin');
$group1 = $this->getUniqueID();
\OC_Group::createGroup($group1);
@@ -772,7 +774,7 @@ class UsersTest extends TestCase {
\OC_Group::deleteGroup($group1);
$user1 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
\OC_Group::addToGroup($user1, 'admin');
$group1 = $this->getUniqueID();
$result = \OCA\provisioning_api\Users::getUserSubAdminGroups(array(
@@ -786,7 +788,7 @@ class UsersTest extends TestCase {
public function testSubAdminOfGroupAlreadySubAdmin() {
$user1 = $this->generateUsers();
$user2 = $this->generateUsers();
- \OC_User::setUserId($user1);
+ self::loginAsUser($user1);
\OC_Group::addToGroup($user1, 'admin');
$group1 = $this->getUniqueID();
\OC_Group::createGroup($group1);