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"""
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()
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
.runcmd("forest",
49 "-H", "ldap://%s" % os
.environ
["DC_SERVER"],
50 "-U%s%%%s" % (os
.environ
["DC_USERNAME"],
51 os
.environ
["DC_PASSWORD"]))
53 self
.assertCmdSuccess(result
, out
, err
)
54 self
.assertEqual(err
, "", "Shouldn't be any error messages")
55 self
.assertIn("dsheuristics: <NO VALUE>", out
)
57 def test_modify_dsheuristics(self
):
58 """Test that we can modify the dsheuristics setting"""
60 (result
, out
, err
) = self
.runcmd("forest",
64 "-H", "ldap://%s" % os
.environ
["DC_SERVER"],
65 "-U%s%%%s" % (os
.environ
["DC_USERNAME"],
66 os
.environ
["DC_PASSWORD"]))
68 self
.assertCmdSuccess(result
, out
, err
)
69 self
.assertEqual(err
, "", "Shouldn't be any error messages")
70 self
.assertIn("set dsheuristics: 0000002", out
)