• Bug#1033661: marked as done (unblock: samba/2:4.17.7+dfsg-1) (9/12)

    From Debian Bug Tracking System@21:1/5 to All on Thu Mar 30 17:00:01 2023
    [continued from previous message]

    + m = Message()
    + m.dn = Dn(self.ldb, "cn=e1,%s" % self.ou)
    + m["e1"] = MessageElement("cn=e2,%s" % self.ou,
    + FLAG_MOD_ADD, "addressBookRoots2")
    + self.ldb.modify(m)
    +
    +
    +
    +class MatchRulesTests(MatchRulesTestsBase):
    + def setUp(self):
    + self.sambaopts = sambaopts
    + self.credopts = credopts
    + self.host = host
    + super().setUp()
    +
    # The msDS-RevealedUsers is owned by system and cannot be modified
    # directly. Set the schemaUpgradeInProgress flag as workaround
    # and create this hierarchy:
    @@ -243,33 +289,6 @@
    m["e1"] = MessageElement("0", FLAG_MOD_REPLACE, "schemaUpgradeInProgress")
    self.ldb.modify(m)

    - # Add a couple of ms-Exch-Configuration-Container to test forward-link - # attributes without backward link (addressBookRoots2)
    - # e1
    - # |--> e2
    - # | |--> c1
    - self.ldb.add({
    - "dn": "cn=e1,%s" % self.ou,
    - "objectclass": "msExchConfigurationContainer"})
    - self.ldb.add({
    - "dn": "cn=e2,%s" % self.ou,
    - "objectclass": "msExchConfigurationContainer"})
    -
    - m = Message()
    - m.dn = Dn(self.ldb, "cn=e2,%s" % self.ou)
    - m["e1"] = MessageElement("cn=c1,%s" % self.ou_computers,
    - FLAG_MOD_ADD, "addressBookRoots2")
    - self.ldb.modify(m)
    -
    - m = Message()
    - m.dn = Dn(self.ldb, "cn=e1,%s" % self.ou)
    - m["e1"] = MessageElement("cn=e2,%s" % self.ou,
    - FLAG_MOD_ADD, "addressBookRoots2")
    - self.ldb.modify(m)
    -
    - def tearDown(self):
    - super(MatchRulesTests, self).tearDown()
    - self.ldb.delete(self.ou, controls=['tree_delete:0'])

    def test_u1_member_of_g4(self):
    # Search without transitive match must return 0 results
    @@ -945,8 +964,12 @@
    class MatchRuleConditionTests(samba.tests.TestCase):
    def setUp(self):
    super(MatchRuleConditionTests, self).setUp()
    - self.lp = lp
    - self.ldb = SamDB(host, credentials=creds, session_info=system_session(lp), lp=lp)
    + self.lp = sambaopts.get_loadparm()
    + self.creds = credopts.get_credentials(self.lp)
    +
    + self.ldb = SamDB(host, credentials=self.creds,
    + session_info=system_session(self.lp),
    + lp=self.lp)
    self.base_dn = self.ldb.domain_dn()
    self.ou = "OU=matchruleconditiontests,%s" % self.base_dn
    self.ou_users = "OU=users,%s" % self.ou
    @@ -1745,32 +1768,30 @@
    self.ou_groups, self.ou_computers))
    self.assertEqual(len(res1), 0)

    +if __name__ == "__main__":

    -parser = optparse.OptionParser("match_rules.py [options] <host>")
    -sambaopts = options.SambaOptions(parser)
    -parser.add_option_group(sambaopts) -parser.add_option_group(options.VersionOptions(parser))
    -
    -# use command line creds if available
    -credopts = options.CredentialsOptions(parser) -parser.add_option_group(credopts)
    -opts, args = parser.parse_args()
    -subunitopts = SubunitOptions(parser)
    -parser.add_option_group(subunitopts)
    -
    -if len(args) < 1:
    - parser.print_usage()
    - sys.exit(1)
    -
    -host = args[0]
    -
    -lp = sambaopts.get_loadparm()
    -creds = credopts.get_credentials(lp)
    -
    -if "://" not in host:
    - if os.path.isfile(host):
    - host = "tdb://%s" % host
    - else:
    - host = "ldap://%s" % host
    + parser = optparse.OptionParser("match_rules.py [options] <host>")
    + sambaopts = options.SambaOptions(parser)
    + parser.add_option_group(sambaopts)
    + parser.add_option_group(options.VersionOptions(parser))
    +
    + # use command line creds if available
    + credopts = options.CredentialsOptions(parser)
    + parser.add_option_group(credopts)
    + opts, args = parser.parse_args()
    + subunitopts = SubunitOptions(parser)
    + parser.add_option_group(subunitopts)
    +
    + if len(args) < 1:
    + parser.print_usage()
    + sys.exit(1)
    +
    + host = args[0]
    +
    + if "://" not in host:
    + if os.path.isfile(host):
    + host = "tdb://%s" % host
    + else:
    + host = "ldap://%s" % host

    -TestProgram(module=__name__, opts=subunitopts)
    + TestProgram(module=__name__, opts=subunitopts)
    diff -Nru samba-4.17.6+dfsg/lib/ldb-samba/tests/match_rules_remote.py samba-4.17.7+dfsg/lib/ldb-samba/tests/match_rules_remote.py
    --- samba-4.17.6+dfsg/lib/ldb-samba/tests/match_rules_remote.py 1970-01-01 03:00:00.000000000 +0300
    +++ samba-4.17.7+dfsg/lib/ldb-samba/tests/match_rules_remote.py 2023-03-20 12:03:45.287654200 +0300
    @@ -0,0 +1,104 @@
    +#!/usr/bin/env python3
    +
    +import optparse
    +import sys
    +import os
    +import samba
    +import samba.getopt as options
    +
    +from samba.tests.subunitrun import SubunitOptions, TestProgram
    +
    +from samba.samdb import SamDB
    +from samba.auth import system_session
    +from samba import sd_utils
    +from samba.ndr import ndr_unpack
    +from ldb import Message, MessageElement, Dn, LdbError
    +from ldb import FLAG_MOD_ADD, FLAG_MOD_REPLACE, FLAG_MOD_DELETE
    +from ldb import SCOPE_BASE, SCOPE_SUBTREE, SCOPE_ONELEVEL
    +
    +from match_rules import MatchRulesTestsBase
    +
    +
    +class MatchRulesTestsUser(MatchRulesTestsBase):
    + def setUp(self):
    + self.sambaopts = sambaopts
    + self.credopts = credopts
    + self.host = host
    + super().setUp()
    + self.sd_utils = sd_utils.SDUtils(