def as_dict(self): from octoprint.access.permissions import OctoPrintPermission return dict(key=self.key, name=self.get_name(), description=self._description, permissions=list(map(lambda p: p.key, self._permissions)), subgroups=list(map(lambda g: g.key, self._subgroups)), needs=OctoPrintPermission.convert_needs_to_dict( self.needs), default=self._default, removable=self._removable, changeable=self._changeable, toggleable=self._toggleable)
def as_dict(self): from octoprint.access.permissions import OctoPrintPermission return { "name": self._username, "active": bool(self.is_active), "permissions": list(map(lambda p: p.key, self._permissions)), "groups": list(map(lambda g: g.key, self._groups)), "needs": OctoPrintPermission.convert_needs_to_dict(self.needs), "apikey": self._apikey, "settings": self._settings, # TODO: deprecated, remove in 1.5.0 "admin": self.has_permission(Permissions.ADMIN), "user": not self.is_anonymous, "roles": self._roles }
def as_dict(self): from octoprint.access.permissions import OctoPrintPermission return { "key": self.key, "name": self.get_name(), "description": self._description, "permissions": list(map(lambda p: p.key, self._permissions)), "subgroups": list(map(lambda g: g.key, self._subgroups)), "needs": OctoPrintPermission.convert_needs_to_dict(self.needs), "default": self._default, "removable": self._removable, "changeable": self._changeable, "toggleable": self._toggleable, "dangerous": self.dangerous, }
def as_dict(self): from octoprint.access.permissions import OctoPrintPermission return {"needs": OctoPrintPermission.convert_needs_to_dict(self.needs)}
Unit tests for octoprint.access.groups.GroupManager """ __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html' __copyright__ = "Copyright (C) 2017 The OctoPrint Project - Released under terms of the AGPLv3 License" import unittest import tempfile import os import contextlib import octoprint.access.groups from octoprint.access.permissions import OctoPrintPermission TEST_PERMISSION_1 = OctoPrintPermission("Test 1", "Test permission 1", "p1") TEST_PERMISSION_2 = OctoPrintPermission("Test 2", "Test permission 2", "p2") @contextlib.contextmanager def group_manager_with_temp_file(): with tempfile.NamedTemporaryFile() as f: path = f.name try: f.close() group_manager = octoprint.access.groups.FilebasedGroupManager(path=path) yield group_manager finally: if os.path.exists(path): os.remove(path) class GroupManagerTestCase(unittest.TestCase):