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. """Automembership plugin and mixed in the plugin configuration
  17. :id: 45a5a8f8-e800-11e8-ab16-8c16451d917b
  18. :setup: Single Instance
  19. :steps:
  20. 1. Automembership plugin fails in a MMR setup, if data and config
  21. area mixed in the plugin configuration
  22. 2. Plugin configuration should throw proper error messages if not configured properly
  23. :expected results:
  24. 1. Should success
  25. 2. Should success
  26. """
  27. # Configure pluginConfigArea for PLUGIN_AUTO
  28. AutoMembershipPlugin(topo.standalone).set("nsslapd-pluginConfigArea", 'cn=config')
  29. # Enable MemberOf plugin
  30. MemberOfPlugin(topo.standalone).enable()
  31. topo.standalone.restart()
  32. # Add invalid configuration, which mixes data and config area: All will fail
  33. automembers = AutoMembershipDefinitions(topo.standalone)
  34. with pytest.raises(ldap.UNWILLING_TO_PERFORM):
  35. automembers.create(properties={
  36. 'cn': 'autouserGroups',
  37. 'autoMemberScope': f'ou=Employees,cn=config',
  38. 'autoMemberFilter': "objectclass=posixAccount",
  39. 'autoMemberDefaultGroup': [f'cn=SuffDef1,ou=autouserGroups,cn=config',
  40. f'cn=SuffDef2,ou=autouserGroups,cn=config'],
  41. 'autoMemberGroupingAttr': 'member:dn'
  42. })
  43. # Search in error logs
  44. assert topo.standalone.ds_error_log.match('.*ERR - auto-membership-plugin - '
  45. 'automember_parse_config_entry - The default group '
  46. '"cn=SuffDef1,ou=autouserGroups,cn=config" '
  47. 'can not be a child of the plugin config area "cn=config"')
  48. if __name__ == "__main__":
  49. CURRENT_FILE = os.path.realpath(__file__)
  50. pytest.main("-s -v %s" % CURRENT_FILE)