configuration_test.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # --- BEGIN COPYRIGHT BLOCK ---
  2. # Copyright (C) 2019 Red Hat, Inc.
  3. # All rights reserved.
  4. #
  5. # License: GPL (version 3 or any later version).
  6. # See LICENSE for details.
  7. # --- END COPYRIGHT BLOCK ---
  8. import os
  9. import pytest
  10. from lib389.topologies import topology_st as topo
  11. from lib389.plugins import AutoMembershipPlugin, AutoMembershipDefinitions, MemberOfPlugin
  12. import ldap
  13. pytestmark = pytest.mark.tier1
  14. @pytest.mark.bz834056
  15. def test_configuration(topo):
  16. """
  17. Automembership plugin and mixed in the plugin configuration
  18. :id: 45a5a8f8-e800-11e8-ab16-8c16451d917b
  19. :setup: Single Instance
  20. :steps:
  21. 1. Automembership plugin fails in a MMR setup, if data and config
  22. area mixed in the plugin configuration
  23. 2. Plugin configuration should throw proper error messages if not configured properly
  24. :expected results:
  25. 1. Should success
  26. 2. Should success
  27. """
  28. # Configure pluginConfigArea for PLUGIN_AUTO
  29. AutoMembershipPlugin(topo.standalone).set("nsslapd-pluginConfigArea", 'cn=config')
  30. # Enable MemberOf plugin
  31. MemberOfPlugin(topo.standalone).enable()
  32. topo.standalone.restart()
  33. # Add invalid configuration, which mixes data and config area: All will fail
  34. automembers = AutoMembershipDefinitions(topo.standalone)
  35. with pytest.raises(ldap.UNWILLING_TO_PERFORM):
  36. automembers.create(properties={
  37. 'cn': 'autouserGroups',
  38. 'autoMemberScope': f'ou=Employees,cn=config',
  39. 'autoMemberFilter': "objectclass=posixAccount",
  40. 'autoMemberDefaultGroup': [f'cn=SuffDef1,ou=autouserGroups,cn=config',
  41. f'cn=SuffDef2,ou=autouserGroups,cn=config'],
  42. 'autoMemberGroupingAttr': 'member:dn'
  43. })
  44. # Search in error logs
  45. assert topo.standalone.ds_error_log.match('.*ERR - auto-membership-plugin - '
  46. 'automember_parse_config_entry - The default group '
  47. '"cn=SuffDef1,ou=autouserGroups,cn=config" '
  48. 'can not be a child of the plugin config area "cn=config"')
  49. if __name__ == "__main__":
  50. CURRENT_FILE = os.path.realpath(__file__)
  51. pytest.main("-s -v %s" % CURRENT_FILE)