def test_remove_all_excludescope(topology): plugin = MemberOfPlugin(topology.standalone) # setup test if not "a=b" in plugin.get_excludescope(): plugin.add_excludescope("a=b") 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 = None memberof_cli.display_excludescope(topology.standalone, None, topology.logcap.log, args) assert topology.logcap.contains(": a=b") assert topology.logcap.contains(": ou=people,dc=example,dc=com") topology.logcap.flush() args.value = None memberof_cli.remove_all_excludescope(topology.standalone, None, topology.logcap.log, args) assert topology.logcap.contains( "successfully removed all memberOfEntryScopeExcludeSubtree values") topology.logcap.flush() args.value = None memberof_cli.display_excludescope(topology.standalone, None, topology.logcap.log, args) assert not topology.logcap.contains(": a=b") assert not topology.logcap.contains(": ou=people,dc=example,dc=com") topology.logcap.flush()
def add_excludescope(inst, basedn, log, args): plugin = MemberOfPlugin(inst) try: plugin.add_excludescope(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: Suffix ({0}) is listed in entry scope.'.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 memberOfEntryScopeExcludeSubtree value "{}"'.format(args.value))
def test_add_excludescope_with_existing_value(topology): plugin = MemberOfPlugin(topology.standalone) # setup test 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_excludescope(topology.standalone, None, topology.logcap.log, args) assert topology.logcap.contains('Value "{}" already exists'.format( args.value)) topology.logcap.flush()
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()