def add_group(name, users): """Add a group to arkOS LDAP""" try: g = groups.Group(name=name, users=users) g.add() logger.success('ctl:grp:add', 'Added {0}'.format(name)) except Exception as e: raise CLIException(str(e))
def post(self): data = request.get_json()["group"] g = groups.Group(name=data["name"], users=data.get("users", [])) try: g.add() except errors.InvalidConfigError as e: return jsonify(errors={"msg": str(e)}), 422 return jsonify(group=g.serialized)
def test_upd_group(self): _add_test_user("testuser1") _add_test_user("testuser2") g = groups.Group(name="testgroup", users=["testuser1"]) g.add() g = groups.get(name="testgroup") g.users = ["testuser2"] g.update() g = groups.get(name="testgroup") self.assertEqual(g.users, ["testuser2"])
def test_del_group(self): g = groups.Group(name="testgroup", users=[]) g.add() g = groups.get(name="testgroup") g.delete() self.assertIsNone(groups.get(name="testgroup"))
def test_add_group(self): _add_test_user("testuser1") g = groups.Group(name="testgroup", users=["testuser1"]) g.add()