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
22 class ForestCmdTestCase(SambaToolCmdTest):
23 """Tests for samba-tool dsacl subcommands"""
27 super(ForestCmdTestCase, self).setUp()
28 self.samdb = self.getSamDB("-H", "ldap://%s" % os.environ["DC_SERVER"],
29 "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"]))
30 self.domain_dn = self.samdb.domain_dn()
33 super(ForestCmdTestCase, self).tearDown()
34 # Reset the values we might have changed.
35 ds_dn = "CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration"
37 m.dn = ldb.Dn(self.samdb, "%s,%s" % (ds_dn, self.domain_dn))
38 m['dsheuristics'] = ldb.MessageElement(
39 '0000000', ldb.FLAG_MOD_REPLACE, 'dsheuristics')
43 def test_display(self):
44 """Tests that we can display forest settings"""
45 (result, out, err) = self.runsublevelcmd("forest", ("directory_service",
47 "-H", "ldap://%s" % os.environ["DC_SERVER"],
48 "-U%s%%%s" % (os.environ["DC_USERNAME"],
49 os.environ["DC_PASSWORD"]))
51 self.assertCmdSuccess(result, out, err)
52 self.assertEquals(err, "", "Shouldn't be any error messages")
53 self.assertIn("dsheuristics: <NO VALUE>", out)
55 def test_modify_dsheuristics(self):
56 """Test that we can modify the dsheuristics setting"""
58 (result, out, err) = self.runsublevelcmd("forest", ("directory_service",
59 "dsheuristics"), "0000002",
60 "-H", "ldap://%s" % os.environ["DC_SERVER"],
61 "-U%s%%%s" % (os.environ["DC_USERNAME"],
62 os.environ["DC_PASSWORD"]))
64 self.assertCmdSuccess(result, out, err)
65 self.assertEquals(err, "", "Shouldn't be any error messages")
66 self.assertIn("set dsheuristics: 0000002", out)