示例#1
0
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))
示例#2
0
文件: roles.py 项目: wrestrtdr/kraken
 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)
示例#3
0
 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"])
示例#4
0
 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"))
示例#5
0
 def test_add_group(self):
     _add_test_user("testuser1")
     g = groups.Group(name="testgroup", users=["testuser1"])
     g.add()