1 # Unix SMB/CIFS implementation.
2 # Copyright (C) Andrew Bartlett 2012
5 # Copyright (C) Sean Dague <sdague@linux.vnet.ibm.com> 2011
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 from samba
.tests
.samba_tool
.base
import SambaToolCmdTest
24 class GpoCmdTestCase(SambaToolCmdTest
):
25 """Tests for samba-tool time subcommands"""
29 def test_gpo_list(self
):
30 """Run gpo list against the server and make sure it looks accurate"""
31 (result
, out
, err
) = self
.runsubcmd("gpo", "listall", "-H", "ldap://%s" % os
.environ
["SERVER"])
32 self
.assertCmdSuccess(result
, "Ensuring gpo listall ran successfully")
34 def test_fetchfail(self
):
35 """Run against a non-existent GPO, and make sure it fails (this hard-coded UUID is very unlikely to exist"""
36 (result
, out
, err
) = self
.runsubcmd("gpo", "fetch", "c25cac17-a02a-4151-835d-fae17446ee43", "-H", "ldap://%s" %
38 self
.assertEquals(result
, -1, "check for result code")
41 """Run against a real GPO, and make sure it passes"""
42 (result
, out
, err
) = self
.runsubcmd("gpo", "fetch", self
.gpo_guid
, "-H", "ldap://%s" % os
.environ
["SERVER"], "--tmpdir", os
.environ
['SELFTEST_PREFIX'])
43 self
.assertCmdSuccess(result
, "Ensuring gpo fetched successfully")
46 """set up a temporary GPO to work with"""
47 super(GpoCmdTestCase
, self
).setUp()
48 (result
, out
, err
) = self
.runsubcmd("gpo", "create", self
.gpo_name
, "-H", "ldap://%s" % os
.environ
["SERVER"], "-U%s%%%s" % (os
.environ
["USERNAME"], os
.environ
["PASSWORD"]))
49 self
.gpo_guid
= "{%s}" % out
.split("{")[1].split("}")[0]
51 self
.assertCmdSuccess(result
, "Ensuring gpo created successfully")
54 """remove the temporary GPO to work with"""
55 (result
, out
, err
) = self
.runsubcmd("gpo", "del", self
.gpo_guid
, "-H", "ldap://%s" % os
.environ
["SERVER"], "-U%s%%%s" % (os
.environ
["USERNAME"], os
.environ
["PASSWORD"]))
56 self
.assertCmdSuccess(result
, "Ensuring gpo deleted successfully")
57 super(GpoCmdTestCase
, self
).tearDown()