def runTest(self): can_ban = database.can_ban("test_user3") self.assertEqual(can_ban, False) if database.login_exists("test_user"): database.delete_login("test_user") database.add_login("test_user", "abc", sysop=False, can_ban_user=True) can_ban = database.can_ban("test_user") self.assertEqual(can_ban, True) database.delete_login("test_user")
def runTest(self): can_blacklist = database.can_modify_blacklist("test_user3") self.assertEqual(can_blacklist, False) if database.login_exists("test_user"): database.delete_login("test_user") database.add_login("test_user", "abc", sysop=False, can_modify_blacklist=True) can_blacklist = database.can_modify_blacklist("test_user") self.assertEqual(can_blacklist, True) database.delete_login("test_user")
def remove_user(self, username): """Remove user""" if not username: self.set_error("Missing parameters") return if not database.is_sysop(self.get_username()): self.set_error("Only sysop can delete users") return if not database.login_exists(username): self.set_error("No such user") return if self.get_username() == username: self.set_error("Can't delete own account!") return database.delete_login(username)
def create_user(self, username, password, sysop, can_ban, can_modify_blacklist): if not username and not password: self.set_error("Missing parameters") return if not database.is_sysop(self.get_username()): self.set_error("Only sysop can create users") return if database.login_exists(username): self.set_error("User already exists") return if not password: self.set_error("Password cannot be empty!") return database.add_login(username, password, sysop, can_ban, can_modify_blacklist)
def change_user_password(self, username, password): """Change username's password""" if not username or not password: self.set_error("Missing parameters") return if self.get_username() != username and not database.is_sysop( self.get_username()): self.set_error("Only sysop can change other users passwords") return if not database.login_exists(username): self.set_error("No such user") return if not password: self.set_error("Password cannot be empty!") return database.update_login(username, password)