regression_nsslapd_plugin_binddn_tracking_test.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. # --- BEGIN COPYRIGHT BLOCK ---
  2. # Copyright (C) 2018 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 logging
  10. import pytest
  11. from lib389.tasks import *
  12. from lib389.topologies import topology_m2 as topo_m2
  13. from lib389.utils import *
  14. from lib389.replica import *
  15. from lib389._constants import *
  16. from lib389.idm.user import UserAccounts
  17. from lib389.idm.domain import Domain
  18. pytestmark = pytest.mark.tier1
  19. log = logging.getLogger(__name__)
  20. @pytest.mark.DS47950
  21. def test_nsslapd_plugin_binddn_tracking(topo_m2):
  22. """
  23. Testing nsslapd-plugin-binddn-tracking does not cause issues around
  24. access control and reconfiguring replication/repl agmt.
  25. :id: f5ba7b64-fe04-11e8-a298-8c16451d917b
  26. :setup: Replication with two masters.
  27. :steps:
  28. 1. Turn on bind dn tracking
  29. 2. Add two users
  30. 3. Add an aci
  31. 4. Make modification as user
  32. 5. Setup replica and create a repl agmt
  33. 6. Modify replica
  34. 7. Modify repl agmt
  35. :expectedresults:
  36. 1. Should Success.
  37. 2. Should Success.
  38. 3. Should Success.
  39. 4. Should Success.
  40. 5. Should Success.
  41. 6. Should Success.
  42. 7. Should Success.
  43. """
  44. log.info("Testing Ticket 47950 - Testing nsslapd-plugin-binddn-tracking")
  45. #
  46. # Turn on bind dn tracking
  47. #
  48. topo_m2.ms["master1"].config.replace("nsslapd-plugin-binddn-tracking", "on")
  49. #
  50. # Add two users
  51. #
  52. users = UserAccounts(topo_m2.ms["master1"], DEFAULT_SUFFIX)
  53. test_user_1 = users.create_test_user(uid=1)
  54. test_user_2 = users.create_test_user(uid=2)
  55. test_user_1.set('userPassword', 'password')
  56. test_user_2.set('userPassword', 'password')
  57. #
  58. # Add an aci
  59. #
  60. USER1_DN = users.list()[0].dn
  61. USER2_DN = users.list()[1].dn
  62. acival = (
  63. '(targetattr ="cn")(version 3.0;acl "Test bind dn tracking"'
  64. + ';allow (all) (userdn = "ldap:///%s");)' % USER1_DN
  65. )
  66. Domain(topo_m2.ms["master1"], DEFAULT_SUFFIX).add("aci", acival)
  67. #
  68. # Make modification as user
  69. #
  70. assert topo_m2.ms["master1"].simple_bind_s(USER1_DN, "password")
  71. test_user_2.replace("cn", "new value")
  72. #
  73. # Setup replica and create a repl agmt
  74. #
  75. repl = ReplicationManager(DEFAULT_SUFFIX)
  76. assert topo_m2.ms["master1"].simple_bind_s(DN_DM, PASSWORD)
  77. repl.test_replication(topo_m2.ms["master1"], topo_m2.ms["master2"], 30)
  78. repl.test_replication(topo_m2.ms["master2"], topo_m2.ms["master1"], 30)
  79. properties = {
  80. "cn": "test_agreement",
  81. "nsDS5ReplicaRoot": "dc=example,dc=com",
  82. "nsDS5ReplicaHost": "localhost.localdomain",
  83. "nsDS5ReplicaPort": "5555",
  84. "nsDS5ReplicaBindDN": "uid=tester",
  85. "nsds5ReplicaCredentials": "password",
  86. "nsDS5ReplicaTransportInfo": "LDAP",
  87. "nsDS5ReplicaBindMethod": "SIMPLE",
  88. }
  89. replicas = Replicas(topo_m2.ms["master1"])
  90. replica = replicas.get(DEFAULT_SUFFIX)
  91. agmts = Agreements(topo_m2.ms["master1"], basedn=replica.dn)
  92. repl_agreement = agmts.create(properties=properties)
  93. #
  94. # modify replica
  95. #
  96. replica.replace("nsDS5ReplicaId", "7")
  97. assert replica.present("nsDS5ReplicaId", "7")
  98. #
  99. # modify repl agmt
  100. #
  101. repl_agreement.replace('nsDS5ReplicaPort', "8888")
  102. assert repl_agreement.present('nsDS5ReplicaPort', "8888")
  103. if __name__ == "__main__":
  104. # Run isolated
  105. # -s for DEBUG mode
  106. CURRENT_FILE = os.path.realpath(__file__)
  107. pytest.main("-s %s" % CURRENT_FILE)