From f67a3c2eb95ca1c91319c5b4cdf2c18c190ab253 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 1 Sep 2015 15:58:30 +1200 Subject: [PATCH] selftest: confirm samba_dnsupdate works in both nsupdate and samba_tool mode This can be extended, but already checks the basic functionality Signed-off-by: Andrew Bartlett Reviewed-by: Garming Sam --- .../samba/tests/blackbox/samba_dnsupdate.py | 50 +++++++++++++++++++ source4/selftest/tests.py | 3 ++ 2 files changed, 53 insertions(+) create mode 100644 python/samba/tests/blackbox/samba_dnsupdate.py diff --git a/python/samba/tests/blackbox/samba_dnsupdate.py b/python/samba/tests/blackbox/samba_dnsupdate.py new file mode 100644 index 00000000000..613615e8a55 --- /dev/null +++ b/python/samba/tests/blackbox/samba_dnsupdate.py @@ -0,0 +1,50 @@ +# Blackbox tests for "samba_dnsupdate" command +# Copyright (C) Kamen Mazdrashki 2011 +# Copyright (C) Andrew Bartlett 2015 +# +# 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 samba.tests + +class SambaDnsUpdateTests(samba.tests.BlackboxTestCase): + """Blackbox test case for samba_dnsupdate.""" + + def setUp(self): + self.server_ip = samba.tests.env_get_var_value("DNS_SERVER_IP") + super(SambaDnsUpdateTests, self).setUp() + try: + out = self.check_output("samba_dnsupdate --verbose") + self.assertTrue("Looking for DNS entry" in out) + except samba.tests.BlackboxProcessError: + pass + + def test_samba_dnsupate_no_change(self): + out = self.check_output("samba_dnsupdate --verbose") + self.assertTrue("No DNS updates needed" in out) + + def test_samba_dnsupate_set_ip(self): + try: + out = self.check_output("samba_dnsupdate --verbose --current-ip=10.0.0.1") + self.assertTrue(" DNS updates and" in out) + self.assertTrue(" DNS deletes needed" in out) + except samba.tests.BlackboxProcessError: + pass + out = self.check_output("samba_dnsupdate --verbose --use-nsupdate --current-ip=10.0.0.1") + self.assertTrue("No DNS updates needed" in out) + out = self.check_output("samba_dnsupdate --verbose --use-samba-tool --rpc-server-ip=%s" % self.server_ip) + self.assertTrue(" DNS updates and" in out) + self.assertTrue(" DNS deletes needed" in out) + out = self.check_output("samba_dnsupdate --verbose") + self.assertTrue("No DNS updates needed" in out) diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index cebdab7d889..844b93c52d9 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -662,6 +662,9 @@ for env in ['vampire_dc', 'promoted_dc']: extra_args=['-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD']) +planoldpythontestsuite("chgdcpass:local", "samba.tests.blackbox.samba_dnsupdate", + environ={'DNS_SERVER_IP': '$SERVER_IP'}) + for env in ["ad_dc_ntvfs", "s4member", "rodc", "promoted_dc", "ad_dc", "ad_member"]: plantestsuite("samba.blackbox.wbinfo(%s:local)" % env, "%s:local" % env, [os.path.join(samba4srcdir, "../nsswitch/tests/test_wbinfo.sh"), '$DOMAIN', '$DC_USERNAME', '$DC_PASSWORD', env])