1 # Unix SMB/CIFS implementation.
2 # Copyright (C) William Brown <william@blackhats.net.au> 2018
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 from samba.tests.samba_tool.base import SambaToolCmdTest
23 class ForestCmdTestCase(SambaToolCmdTest):
24 """Tests for samba-tool dsacl subcommands"""
28 super(ForestCmdTestCase, self).setUp()
29 self.samdb = self.getSamDB("-H", "ldap://%s" % os.environ["DC_SERVER"],
30 "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"]))
31 self.domain_dn = self.samdb.domain_dn()
34 super(ForestCmdTestCase, self).tearDown()
35 # Reset the values we might have changed.
36 ds_dn = "CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration"
38 m.dn = ldb.Dn(self.samdb, "%s,%s" % (ds_dn, self.domain_dn))
39 m['dsheuristics'] = ldb.MessageElement(
40 '0000000', ldb.FLAG_MOD_REPLACE, 'dsheuristics')
44 def test_display(self):
45 """Tests that we can display forest settings"""
46 (result, out, err) = self.runsublevelcmd("forest", ("directory_service",
48 "-H", "ldap://%s" % os.environ["DC_SERVER"],
49 "-U%s%%%s" % (os.environ["DC_USERNAME"],
50 os.environ["DC_PASSWORD"]))
52 self.assertCmdSuccess(result, out, err)
53 self.assertEqual(err, "", "Shouldn't be any error messages")
54 self.assertIn("dsheuristics: <NO VALUE>", out)
56 def test_modify_dsheuristics(self):
57 """Test that we can modify the dsheuristics setting"""
59 (result, out, err) = self.runsublevelcmd("forest", ("directory_service",
60 "dsheuristics"), "0000002",
61 "-H", "ldap://%s" % os.environ["DC_SERVER"],
62 "-U%s%%%s" % (os.environ["DC_USERNAME"],
63 os.environ["DC_PASSWORD"]))
65 self.assertCmdSuccess(result, out, err)
66 self.assertEqual(err, "", "Shouldn't be any error messages")
67 self.assertIn("set dsheuristics: 0000002", out)