pwdPolicy_test.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # --- BEGIN COPYRIGHT BLOCK ---
  2. # Copyright (C) 2015 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. #
  9. import os
  10. import sys
  11. import time
  12. import ldap
  13. import logging
  14. import pytest
  15. from lib389 import DirSrv, Entry, tools, tasks
  16. from lib389.tools import DirSrvTools
  17. from lib389._constants import *
  18. from lib389.properties import *
  19. from lib389.tasks import *
  20. logging.getLogger(__name__).setLevel(logging.DEBUG)
  21. log = logging.getLogger(__name__)
  22. installation1_prefix = None
  23. class TopologyStandalone(object):
  24. def __init__(self, standalone):
  25. standalone.open()
  26. self.standalone = standalone
  27. @pytest.fixture(scope="module")
  28. def topology(request):
  29. global installation1_prefix
  30. if installation1_prefix:
  31. args_instance[SER_DEPLOYED_DIR] = installation1_prefix
  32. # Creating standalone instance ...
  33. standalone = DirSrv(verbose=False)
  34. args_instance[SER_HOST] = HOST_STANDALONE
  35. args_instance[SER_PORT] = PORT_STANDALONE
  36. args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
  37. args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
  38. args_standalone = args_instance.copy()
  39. standalone.allocate(args_standalone)
  40. instance_standalone = standalone.exists()
  41. if instance_standalone:
  42. standalone.delete()
  43. standalone.create()
  44. standalone.open()
  45. # Clear out the tmp dir
  46. standalone.clearTmpDir(__file__)
  47. return TopologyStandalone(standalone)
  48. def test_pwdPolicy_init(topology):
  49. '''
  50. Init the test suite (if necessary)
  51. '''
  52. return
  53. def test_pwdPolicy_final(topology):
  54. topology.standalone.delete()
  55. log.info('Password Policy test suite PASSED')
  56. def run_isolated():
  57. global installation1_prefix
  58. installation1_prefix = None
  59. topo = topology(True)
  60. test_pwdPolicy_init(topo)
  61. test_pwdPolicy_final(topo)
  62. if __name__ == '__main__':
  63. run_isolated()