예제 #1
0
 def apply(self, inst):
     rip = ReferentialIntegrityPlugin(inst)
     try:
         rip.add_membership_attr(self.attr)
     except ldap.TYPE_OR_VALUE_EXISTS:
         # This is okay, move on.
         pass
예제 #2
0
def add_membership_attr(inst, basedn, log, args):
    plugin = ReferentialIntegrityPlugin(inst)
    try:
        plugin.add_membership_attr(args.value)
    except ldap.TYPE_OR_VALUE_EXISTS:
        log.info('Value "{}" already exists.'.format(args.value))
    else:
        log.info('successfully added membership attribute "{}"'.format(
            args.value))
예제 #3
0
def test_add_membership_attr_with_value_that_already_exists(topology):
    plugin = ReferentialIntegrityPlugin(topology.standalone)
    # setup test
    if not "uniqueMember" in plugin.get_membership_attr():
        plugin.add_membership_attr("uniqueMember")

    args = FakeArgs()

    args.value = "uniqueMember"
    referint_cli.add_membership_attr(topology.standalone, None, topology.logcap.log, args)
    assert topology.logcap.contains("already exists")
    topology.logcap.flush()
예제 #4
0
def test_remove_membership_attr_with_value_that_exists(topology):
    plugin = ReferentialIntegrityPlugin(topology.standalone)
    # setup test
    if not "uniqueMember" in plugin.get_membership_attr():
        plugin.add_membership_attr("uniqueMember")

    args = FakeArgs()

    args.value = "uniqueMember"
    referint_cli.remove_membership_attr(topology.standalone, None, topology.logcap.log, args)
    assert topology.logcap.contains("successfully removed membership attribute")
    topology.logcap.flush()

    referint_cli.display_membership_attr(topology.standalone, None, topology.logcap.log, args)
    assert not topology.logcap.contains(": uniqueMember")
    topology.logcap.flush()