def test_remove_user(self):
     testuser = self.get_random_username()
     create_user(testuser, u'randompass', u'planlos-test1@localhost')
     remove_user(testuser)
     userdoc = self.db.users.find_one({'username': testuser})
     self.assertEqual(userdoc, None)
     groupdoc = self.db.groups.find_one({'name': testuser})
     self.assertEqual(groupdoc, None)
 def test_remove_user(self):
     testuser = self.get_random_username()
     create_user(testuser, u'randompass', u'planlos-test1@localhost')
     remove_user(testuser)
     userdoc = self.db.users.find_one({'username': testuser})
     self.assertEqual(userdoc, None)
     groupdoc = self.db.groups.find_one({'name': testuser})
     self.assertEqual(groupdoc, None)
 def test_add_user_to_group(self):
     testuser = self.get_random_username()
     create_user(testuser)
     testgroup = self.get_random_username()
     create_group(testgroup)
     group_add(testgroup, testuser)
     groupdoc = self.db.groups.find_one({'name': testgroup})
     userdoc = self.db.users.find_one({'username': testuser, 'groups': groupdoc['_id']})
     self.assertNotEqual(userdoc, None)
 def test_create_user(self):
     testuser = self.get_random_username()
     create_user(testuser, u'randompass', u'planlos-test1@localhost')
     userdoc = self.db.users.find_one({'username': testuser})
     self.assertNotEqual(userdoc, None)
     groupdoc = self.db.groups.find_one({'name': testuser})
     self.assertNotEqual(groupdoc, None)
     print groupdoc
     doc = self.db.groupadmins.find_one({'group': groupdoc['_id']})
     self.assertIn(userdoc['_id'], doc['admins'])
 def test_create_user(self):
     testuser = self.get_random_username()
     create_user(testuser, u'randompass', u'planlos-test1@localhost')
     userdoc = self.db.users.find_one({'username': testuser})
     self.assertNotEqual(userdoc, None)
     groupdoc = self.db.groups.find_one({'name': testuser})
     self.assertNotEqual(groupdoc, None)
     print groupdoc
     doc = self.db.groupadmins.find_one({'group': groupdoc['_id']})
     self.assertIn(userdoc['_id'], doc['admins'])
 def test_add_user_to_group(self):
     testuser = self.get_random_username()
     create_user(testuser)
     testgroup = self.get_random_username()
     create_group(testgroup)
     group_add(testgroup, testuser)
     groupdoc = self.db.groups.find_one({'name': testgroup})
     userdoc = self.db.users.find_one({
         'username': testuser,
         'groups': groupdoc['_id']
     })
     self.assertNotEqual(userdoc, None)
 def test_remove_group_check_users(self):
     # setup
     testuser = self.get_random_username()
     create_user(testuser)
     testgroup = self.get_random_username()
     create_group(testgroup)
     group_add(testgroup, testuser)
     groupid = self.db.groups.find_one({'name': testgroup})['_id']
     # action
     remove_group(testgroup)
     # tests
     groupdoc = self.db.groups.find_one({'name': testgroup})
     self.assertEqual(groupdoc, None)
     userdoc = self.db.users.find({'groups': groupid})
     self.assertEqual(usersdoc, None)
 def test_remove_group_check_users(self):
     # setup
     testuser = self.get_random_username()
     create_user(testuser)
     testgroup = self.get_random_username()
     create_group(testgroup)
     group_add(testgroup, testuser)
     groupid = self.db.groups.find_one({'name': testgroup})['_id']
     # action
     remove_group(testgroup)
     # tests
     groupdoc = self.db.groups.find_one({'name': testgroup})
     self.assertEqual(groupdoc, None)
     userdoc = self.db.users.find({'groups': groupid})
     self.assertEqual(usersdoc, None)
 def test_create_existing_user(self):
     testuser = self.get_random_username()
     create_user(testuser, u'randompass', u'planlos-test1@localhost')
     # should fail:
     create_user(testuser, u'randompass', u'planlos-test1@localhost')
 def test_create_existing_user(self):
     testuser = self.get_random_username()
     create_user(testuser, u'randompass', u'planlos-test1@localhost')
     # should fail:
     create_user(testuser, u'randompass', u'planlos-test1@localhost')