From: Noel Power Date: Thu, 15 Feb 2018 20:43:53 +0000 (+0000) Subject: s4/selftest: Add simple python netbios test python2 only for the moment X-Git-Tag: talloc-2.1.13~260 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0fa93f5fe99bd31c3f13241960c4ac600197c837;p=thirdparty%2Fsamba.git s4/selftest: Add simple python netbios test python2 only for the moment Signed-off-by: Noel Power Reviewed-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- diff --git a/python/samba/tests/netbios.py b/python/samba/tests/netbios.py new file mode 100644 index 00000000000..65ec5f1d7d1 --- /dev/null +++ b/python/samba/tests/netbios.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Unix SMB/CIFS implementation. Tests for netbios py module +# Copyright (C) Noel Power 2018 +# +# 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, os, random, sys +from samba import netbios + +class NetBiosTests(samba.tests.TestCase): + def setUp(self): + super(NetBiosTests, self).setUp() + self.n = netbios.Node() + self.ifc = os.environ["SERVER_IP"] + self.dc = os.environ["DC_NETBIOSNAME"] + def tearDown(self): + super(NetBiosTests, self).tearDown() + def test_query_name(self): + (reply_from, names, addresses) = self.n.query_name(self.dc, self.ifc, timeout=4) + assert reply_from == self.ifc + assert names[0] == self.dc + assert addresses[0] == self.ifc + + def test_name_status(self): + (reply_from, name, name_list) = self.n.name_status(self.dc, self.ifc, timeout=4) + assert reply_from == self.ifc + assert name[0] == self.dc + assert len(name_list) > 0 + + def test_register_name(self): + address = '127.0.0.3' + (reply_from, name, reply_address, code) = self.n.register_name((self.dc, 0x20), address, self.ifc, multi_homed=False, timeout=4) + assert reply_from == self.ifc + assert name[0] == self.dc + assert reply_address == address + assert code == 6 + + def disabled_test_refresh(self): + # can't get the below test to work, disabling + address = '127.0.0.3' + res = self.n.refresh_name((self.dc, 0x20), address, self.ifc, timeout=10) diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index a305757e1fe..317350b8484 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -616,6 +616,9 @@ planpythontestsuite("ad_dc:local", "samba.tests.samba_tool.sites") planpythontestsuite("ad_dc:local", "samba.tests.samba_tool.dnscmd") planpythontestsuite("ad_dc_ntvfs:local", "samba.tests.dcerpc.rpcecho") + +planoldpythontestsuite("nt4_dc", "samba.tests.netbios", extra_args=['-U"$USERNAME%$PASSWORD"'], py3_compatible=False) + 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"']) planoldpythontestsuite("ad_dc", "samba.tests.dcerpc.dnsserver", extra_args=['-U"$USERNAME%$PASSWORD"'])