Esempio n. 1
0
def add_groupattr(inst, basedn, log, args):
    plugin = MemberOfPlugin(inst)
    try:
        plugin.add_groupattr(args.value)
    except ldap.UNWILLING_TO_PERFORM:
        log.error('Error: Illegal value "{}". Failed to add.'.format(args.value))
    except ldap.TYPE_OR_VALUE_EXISTS:
        log.info('Value "{}" already exists.'.format(args.value))
    else:
        log.info('successfully added memberOfGroupAttr value "{}"'.format(args.value))
Esempio n. 2
0
def test_set_groupattr_with_value_that_already_exists(topology):
    plugin = MemberOfPlugin(topology.standalone)
    # setup test
    if not "uniquemember" in plugin.get_groupattr():
        plugin.add_groupattr("uniquemember")

    args = FakeArgs()

    args.value = "uniquemember"
    memberof_cli.add_groupattr(topology.standalone, None, topology.logcap.log,
                               args)
    assert topology.logcap.contains("already exists")
    topology.logcap.flush()
Esempio n. 3
0
def test_remove_groupattr_with_value_that_exists(topology):
    plugin = MemberOfPlugin(topology.standalone)
    # setup test
    if not "uniquemember" in plugin.get_groupattr():
        plugin.add_groupattr("uniquemember")

    args = FakeArgs()

    args.value = "uniquemember"
    memberof_cli.remove_groupattr(topology.standalone, None,
                                  topology.logcap.log, args)
    assert topology.logcap.contains(
        "successfully removed memberOfGroupAttr value")
    topology.logcap.flush()

    memberof_cli.display_groupattr(topology.standalone, None,
                                   topology.logcap.log, args)
    assert not topology.logcap.contains(": uniquemember")
    topology.logcap.flush()