From: Douglas Bagnall Date: Thu, 17 Sep 2015 06:16:49 +0000 (+1200) Subject: samba-tool tests: Add command line tests for sites X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=8e6f2d923c9fc4249d162c8731fbbf5b44e87936;p=ambi%2Fsamba.git samba-tool tests: Add command line tests for sites Signed-off-by: Douglas Bagnall Reviewed-by: Garming Sam Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/tests/samba_tool/sites.py b/python/samba/tests/samba_tool/sites.py new file mode 100644 index 0000000000..212df92cac --- /dev/null +++ b/python/samba/tests/samba_tool/sites.py @@ -0,0 +1,57 @@ +# Unix SMB/CIFS implementation. +# Copyright (C) Catalyst.Net LTD 2015 +# Copyright (C) Sean Dague 2011 +# +# Catalyst.Net's contribution was written by Douglas Bagnall +# . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import os +import ldb +from samba.tests.samba_tool.base import SambaToolCmdTest +from samba import sites + + +class BaseSitesCmdTestCase(SambaToolCmdTest): + """Tests for samba-tool sites subnets""" + def setUp(self): + super(BaseSitesCmdTestCase, self).setUp() + self.dburl = "ldap://%s" % os.environ["DC_SERVER"] + self.creds_string = "-U%s%%%s" % (os.environ["DC_USERNAME"], + os.environ["DC_PASSWORD"]) + + self.samdb = self.getSamDB("-H", self.dburl, self.creds_string) + self.config_dn = str(self.samdb.get_config_basedn()) + + +class SitesCmdTestCase(BaseSitesCmdTestCase): + + def test_site_create(self): + sitename = 'new_site' + + result, out, err = self.runsubcmd("sites", "create", sitename, + "-H", self.dburl, self.creds_string) + self.assertCmdSuccess(result) + + dnsites = ldb.Dn(self.samdb, "CN=Sites,%s" % self.config_dn) + dnsite = ldb.Dn(self.samdb, "CN=%s,%s" % (sitename, dnsites)) + + ret = self.samdb.search(base=dnsites, scope=ldb.SCOPE_ONELEVEL, + expression='(dn=%s)' % str(dnsite)) + self.assertEquals(len(ret), 1) + + # now delete it + self.samdb.delete(dnsite, ["tree_delete:0"]) diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index 1425323f41..8586531295 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -479,6 +479,8 @@ planpythontestsuite("ad_dc_ntvfs:local", "samba.tests.samba_tool.user") planpythontestsuite("ad_dc_ntvfs:local", "samba.tests.samba_tool.group") planpythontestsuite("ad_dc:local", "samba.tests.samba_tool.ntacl") +planpythontestsuite("ad_dc:local", "samba.tests.samba_tool.sites") + planpythontestsuite("ad_dc_ntvfs:local", "samba.tests.dcerpc.rpcecho") planoldpythontestsuite("ad_dc_ntvfs:local", "samba.tests.dcerpc.registry", extra_args=['-U"$USERNAME%$PASSWORD"']) planoldpythontestsuite("ad_dc_ntvfs", "samba.tests.dcerpc.dnsserver", extra_args=['-U"$USERNAME%$PASSWORD"'])