Example #1
0
def test_remove_all_entryscope(topology):
    plugin = MemberOfPlugin(topology.standalone)
    # setup test
    if not "dc=example,dc=com" in plugin.get_entryscope():
        plugin.add_entryscope("dc=example,dc=com")
    if not "a=b" in plugin.get_entryscope():
        plugin.add_entryscope("a=b")

    args = FakeArgs()

    args.value = None
    memberof_cli.display_scope(topology.standalone, None, topology.logcap.log,
                               args)
    assert topology.logcap.contains(": a=b")
    assert topology.logcap.contains(": dc=example,dc=com")
    topology.logcap.flush()

    args.value = None
    memberof_cli.remove_all_scope(topology.standalone, None,
                                  topology.logcap.log, args)
    assert topology.logcap.contains(
        "successfully removed all memberOfEntryScope values")
    topology.logcap.flush()

    args.value = None
    memberof_cli.display_scope(topology.standalone, None, topology.logcap.log,
                               args)
    assert not topology.logcap.contains(": a=b")
    assert not topology.logcap.contains(": dc=example,dc=com")
    topology.logcap.flush()
Example #2
0
def add_scope(inst, basedn, log, args):
    plugin = MemberOfPlugin(inst)
    try:
        plugin.add_entryscope(args.value)
    except ldap.UNWILLING_TO_PERFORM as ex:
        if "is also listed as an exclude suffix" in ex.args[0]['info']:
            log.error('Error: Include suffix ({0}) is also listed as an exclude suffix.'.format(args.value))
        else:
            log.error('Error: Invalid DN "{}". 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 memberOfEntryScope value "{}"'.format(args.value))
Example #3
0
def test_add_entryscope_with_existing_value(topology):
    plugin = MemberOfPlugin(topology.standalone)
    # setup test
    if not "dc=example,dc=com" in plugin.get_entryscope():
        plugin.add_entryscope("dc=example,dc=com")

    args = FakeArgs()

    args.value = "dc=example,dc=com"
    memberof_cli.add_scope(topology.standalone, None, topology.logcap.log,
                           args)
    assert topology.logcap.contains('Value "{}" already exists'.format(
        args.value))
    topology.logcap.flush()
Example #4
0
def test_add_excludescope_with_value_that_exists_in_entryscope(topology):
    plugin = MemberOfPlugin(topology.standalone)
    # setup test
    if not "dc=example,dc=com" in plugin.get_entryscope():
        plugin.add_entryscope("dc=example,dc=com")
    if not "ou=people,dc=example,dc=com" in plugin.get_excludescope():
        plugin.add_excludescope("ou=people,dc=example,dc=com")

    args = FakeArgs()

    args.value = "ou=people,dc=example,dc=com"
    memberof_cli.add_scope(topology.standalone, None, topology.logcap.log,
                           args)
    assert topology.logcap.contains("is also listed as an exclude suffix")
    topology.logcap.flush()
Example #5
0
 def apply(self, inst):
     mo = MemberOfPlugin(inst)
     try:
         mo.add_entryscope(self.suffix)
     except ldap.TYPE_OR_VALUE_EXISTS:
         pass