s4-python: Remove env from non-executable blackbox test scripts.
[Samba/id10ts.git] / source4 / scripting / python / samba / tests / blackbox / samba_tool_drs.py
blob62d7bf123bb12fa443411aa6d4668853d86371cb
1 # Blackbox tests for "samba-tool drs" command
2 # Copyright (C) Kamen Mazdrashki <kamenim@samba.org> 2011
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/>.
18 """Blackbox tests for samba-tool drs."""
20 import samba.tests
23 class SambaToolDrsTests(samba.tests.BlackboxTestCase):
24 """Blackbox test case for samba-tool drs."""
26 def setUp(self):
27 super(SambaToolDrsTests, self).setUp()
29 self.dc1 = samba.tests.env_get_var_value("DC1")
30 self.dc2 = samba.tests.env_get_var_value("DC2")
32 creds = self.get_credentials()
33 self.cmdline_creds = "-U%s/%s%%%s" % (creds.get_domain(),
34 creds.get_username(), creds.get_password())
36 def _get_rootDSE(self, dc):
37 samdb = samba.tests.connect_samdb(dc, lp=self.get_loadparm(),
38 credentials=self.get_credentials(),
39 ldap_only=True)
40 return samdb.search(base="", scope=samba.tests.ldb.SCOPE_BASE)[0]
42 def test_samba_tool_bind(self):
43 """Tests 'samba-tool drs bind' command
44 Output should be like:
45 Extensions supported:
46 <list-of-supported-extensions>
47 Site GUID: <GUID>
48 Repl epoch: 0"""
49 out = self.check_output("samba-tool drs bind %s %s" % (self.dc1,
50 self.cmdline_creds))
51 self.assertTrue("Site GUID:" in out)
52 self.assertTrue("Repl epoch:" in out)
54 def test_samba_tool_kcc(self):
55 """Tests 'samba-tool drs kcc' command
56 Output should be like 'Consistency check on <DC> successful.'"""
57 out = self.check_output("samba-tool drs kcc %s %s" % (self.dc1,
58 self.cmdline_creds))
59 self.assertTrue("Consistency check on" in out)
60 self.assertTrue("successful" in out)
62 def test_samba_tool_showrepl(self):
63 """Tests 'samba-tool drs showrepl' command
64 Output should be like:
65 <site-name>/<domain-name>
66 DSA Options: <hex-options>
67 DSA object GUID: <DSA-object-GUID>
68 DSA invocationId: <DSA-invocationId>
69 <Inbound-connections-list>
70 <Outbound-connections-list>
71 <KCC-objects>
72 ...
73 TODO: Perhaps we should check at least for
74 DSA's objectGUDI and invocationId"""
75 out = self.check_output("samba-tool drs showrepl %s %s" % (self.dc1,
76 self.cmdline_creds))
77 self.assertTrue("DSA Options:" in out)
78 self.assertTrue("DSA object GUID:" in out)
79 self.assertTrue("DSA invocationId:" in out)
81 def test_samba_tool_options(self):
82 """Tests 'samba-tool drs options' command
83 Output should be like 'Current DSA options: IS_GC <OTHER_FLAGS>'"""
84 out = self.check_output("samba-tool drs options %s %s" % (self.dc1,
85 self.cmdline_creds))
86 self.assertTrue("Current DSA options:" in out)
88 def test_samba_tool_replicate(self):
89 """Tests 'samba-tool drs replicate' command
90 Output should be like 'Replicate from <DC-SRC> to <DC-DEST> was successful.'"""
91 nc_name = self._get_rootDSE(self.dc1)["defaultNamingContext"]
92 out = self.check_output("samba-tool drs replicate %s %s %s %s" % (self.dc1,
93 self.dc2,
94 nc_name,
95 self.cmdline_creds))
96 self.assertTrue("Replicate from" in out)
97 self.assertTrue("was successful" in out)