def test_editdefinition(topology): """ Test if automember definition is updated successfully. """ args = FakeArgs() args.name = "sometestcn" args.scope = "ou=People,dc=example,dc=com" args.filter = "objectclass=*" args.groupattr = "member:dn" args.defaultgroup = "cn=windows-group,cn=groups,dc=example,dc=com" a = automember_cli.edit_definition(topology.standalone, None, topology.logcap.log, args) assert topology.logcap.contains("Definition updated successfully.")
def test_invalidattributes_createdefinition(topology): """ Test if invalid attributes raise ldap.INVALID_SYNTAX exception when creating new automember definition. """ args = FakeArgs() args.name = "sometestcn" args.scope = "someinvalidscope" args.filter = "objectclass=*" args.groupattr = "member:dn" args.defaultgroup = "someinvaliddefaultgroup" with pytest.raises(ldap.INVALID_SYNTAX): automember_cli.create_definition(topology.standalone, None, topology.logcap.log, args)
def test_ifnameexists_createdefinition(topology): """ Test if already existing instance name raises ldap.ALREADY-EXISTS exception when creating new automember definition. """ args = FakeArgs() args.name = "sometestcn" args.scope = "ou=People,dc=example,dc=com" args.filter = "objectclass=*" args.groupattr = "member:dn" args.defaultgroup = "cn=windows-group,cn=groups,dc=example,dc=com" with pytest.raises(ldap.ALREADY_EXISTS): automember_cli.create_definition(topology.standalone, None, topology.logcap.log, args)
def test_createdefinition(topology): """ Test if new automember definition is created successfully. """ args = FakeArgs() args.name = "sometestcn" args.scope = "ou=People,dc=example,dc=com" args.filter = "objectclass=*" args.groupattr = "member:dn" args.defaultgroup = "cn=linux-group,cn=groups,dc=example,dc=com" automember_cli.create_definition(topology.standalone, None, topology.logcap.log, args) assert topology.logcap.contains( "Automember definition created successfully!") topology.logcap.flush()