From 87afc3aee1ea593069322a49355dd8780d99e123 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 28 Dec 2012 15:37:14 +0100 Subject: Move python modules from source4/scripting/python/ to python/. Reviewed-by: Andrew Bartlett Autobuild-User(master): Andrew Bartlett Autobuild-Date(master): Sat Mar 2 03:57:34 CET 2013 on sn-devel-104 --- source4/scripting/python/samba/tests/__init__.py | 237 ----- source4/scripting/python/samba/tests/auth.py | 31 - .../python/samba/tests/blackbox/__init__.py | 17 - .../python/samba/tests/blackbox/ndrdump.py | 49 - .../python/samba/tests/blackbox/samba_tool_drs.py | 97 -- source4/scripting/python/samba/tests/common.py | 40 - source4/scripting/python/samba/tests/core.py | 63 -- .../scripting/python/samba/tests/credentials.py | 98 -- .../python/samba/tests/dcerpc/__init__.py | 20 - .../scripting/python/samba/tests/dcerpc/bare.py | 51 - .../python/samba/tests/dcerpc/dnsserver.py | 241 ----- .../scripting/python/samba/tests/dcerpc/misc.py | 62 -- .../python/samba/tests/dcerpc/registry.py | 51 - .../python/samba/tests/dcerpc/rpc_talloc.py | 84 -- .../scripting/python/samba/tests/dcerpc/rpcecho.py | 71 -- source4/scripting/python/samba/tests/dcerpc/sam.py | 50 - .../scripting/python/samba/tests/dcerpc/srvsvc.py | 68 -- .../scripting/python/samba/tests/dcerpc/testrpc.py | 141 --- .../scripting/python/samba/tests/dcerpc/unix.py | 49 - source4/scripting/python/samba/tests/dns.py | 622 ----------- source4/scripting/python/samba/tests/docs.py | 127 --- source4/scripting/python/samba/tests/dsdb.py | 130 --- source4/scripting/python/samba/tests/gensec.py | 146 --- source4/scripting/python/samba/tests/getopt.py | 55 - source4/scripting/python/samba/tests/hostconfig.py | 74 -- .../python/samba/tests/libsmb_samba_internal.py | 78 -- source4/scripting/python/samba/tests/messaging.py | 67 -- source4/scripting/python/samba/tests/netcmd.py | 90 -- source4/scripting/python/samba/tests/ntacls.py | 83 -- source4/scripting/python/samba/tests/param.py | 57 - source4/scripting/python/samba/tests/policy.py | 34 - source4/scripting/python/samba/tests/posixacl.py | 732 ------------- source4/scripting/python/samba/tests/provision.py | 203 ---- source4/scripting/python/samba/tests/registry.py | 60 -- source4/scripting/python/samba/tests/samba3.py | 219 ---- source4/scripting/python/samba/tests/samba3sam.py | 1125 -------------------- .../python/samba/tests/samba_tool/__init__.py | 15 - .../python/samba/tests/samba_tool/base.py | 114 -- .../scripting/python/samba/tests/samba_tool/gpo.py | 79 -- .../python/samba/tests/samba_tool/group.py | 169 --- .../python/samba/tests/samba_tool/ntacl.py | 135 --- .../python/samba/tests/samba_tool/processes.py | 35 - .../python/samba/tests/samba_tool/timecmd.py | 43 - .../python/samba/tests/samba_tool/user.py | 362 ------- source4/scripting/python/samba/tests/samdb.py | 96 -- source4/scripting/python/samba/tests/security.py | 143 --- source4/scripting/python/samba/tests/source.py | 264 ----- source4/scripting/python/samba/tests/strings.py | 103 -- .../scripting/python/samba/tests/unicodenames.py | 29 - source4/scripting/python/samba/tests/upgrade.py | 40 - .../python/samba/tests/upgradeprovision.py | 135 --- .../python/samba/tests/upgradeprovisionneeddc.py | 179 ---- source4/scripting/python/samba/tests/xattr.py | 126 --- 53 files changed, 7489 deletions(-) delete mode 100644 source4/scripting/python/samba/tests/__init__.py delete mode 100644 source4/scripting/python/samba/tests/auth.py delete mode 100644 source4/scripting/python/samba/tests/blackbox/__init__.py delete mode 100644 source4/scripting/python/samba/tests/blackbox/ndrdump.py delete mode 100644 source4/scripting/python/samba/tests/blackbox/samba_tool_drs.py delete mode 100644 source4/scripting/python/samba/tests/common.py delete mode 100644 source4/scripting/python/samba/tests/core.py delete mode 100644 source4/scripting/python/samba/tests/credentials.py delete mode 100644 source4/scripting/python/samba/tests/dcerpc/__init__.py delete mode 100644 source4/scripting/python/samba/tests/dcerpc/bare.py delete mode 100644 source4/scripting/python/samba/tests/dcerpc/dnsserver.py delete mode 100644 source4/scripting/python/samba/tests/dcerpc/misc.py delete mode 100644 source4/scripting/python/samba/tests/dcerpc/registry.py delete mode 100644 source4/scripting/python/samba/tests/dcerpc/rpc_talloc.py delete mode 100644 source4/scripting/python/samba/tests/dcerpc/rpcecho.py delete mode 100644 source4/scripting/python/samba/tests/dcerpc/sam.py delete mode 100644 source4/scripting/python/samba/tests/dcerpc/srvsvc.py delete mode 100644 source4/scripting/python/samba/tests/dcerpc/testrpc.py delete mode 100644 source4/scripting/python/samba/tests/dcerpc/unix.py delete mode 100644 source4/scripting/python/samba/tests/dns.py delete mode 100644 source4/scripting/python/samba/tests/docs.py delete mode 100644 source4/scripting/python/samba/tests/dsdb.py delete mode 100644 source4/scripting/python/samba/tests/gensec.py delete mode 100644 source4/scripting/python/samba/tests/getopt.py delete mode 100644 source4/scripting/python/samba/tests/hostconfig.py delete mode 100644 source4/scripting/python/samba/tests/libsmb_samba_internal.py delete mode 100644 source4/scripting/python/samba/tests/messaging.py delete mode 100644 source4/scripting/python/samba/tests/netcmd.py delete mode 100644 source4/scripting/python/samba/tests/ntacls.py delete mode 100644 source4/scripting/python/samba/tests/param.py delete mode 100644 source4/scripting/python/samba/tests/policy.py delete mode 100644 source4/scripting/python/samba/tests/posixacl.py delete mode 100644 source4/scripting/python/samba/tests/provision.py delete mode 100644 source4/scripting/python/samba/tests/registry.py delete mode 100644 source4/scripting/python/samba/tests/samba3.py delete mode 100644 source4/scripting/python/samba/tests/samba3sam.py delete mode 100644 source4/scripting/python/samba/tests/samba_tool/__init__.py delete mode 100644 source4/scripting/python/samba/tests/samba_tool/base.py delete mode 100644 source4/scripting/python/samba/tests/samba_tool/gpo.py delete mode 100644 source4/scripting/python/samba/tests/samba_tool/group.py delete mode 100644 source4/scripting/python/samba/tests/samba_tool/ntacl.py delete mode 100644 source4/scripting/python/samba/tests/samba_tool/processes.py delete mode 100644 source4/scripting/python/samba/tests/samba_tool/timecmd.py delete mode 100644 source4/scripting/python/samba/tests/samba_tool/user.py delete mode 100644 source4/scripting/python/samba/tests/samdb.py delete mode 100644 source4/scripting/python/samba/tests/security.py delete mode 100644 source4/scripting/python/samba/tests/source.py delete mode 100644 source4/scripting/python/samba/tests/strings.py delete mode 100644 source4/scripting/python/samba/tests/unicodenames.py delete mode 100644 source4/scripting/python/samba/tests/upgrade.py delete mode 100644 source4/scripting/python/samba/tests/upgradeprovision.py delete mode 100644 source4/scripting/python/samba/tests/upgradeprovisionneeddc.py delete mode 100644 source4/scripting/python/samba/tests/xattr.py (limited to 'source4/scripting/python/samba/tests') diff --git a/source4/scripting/python/samba/tests/__init__.py b/source4/scripting/python/samba/tests/__init__.py deleted file mode 100644 index 2df30a641bf..00000000000 --- a/source4/scripting/python/samba/tests/__init__.py +++ /dev/null @@ -1,237 +0,0 @@ -# Unix SMB/CIFS implementation. -# Copyright (C) Jelmer Vernooij 2007-2010 -# -# 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 . -# - -"""Samba Python tests.""" - -import os -import ldb -import samba -import samba.auth -from samba import param -from samba.samdb import SamDB -import subprocess -import tempfile - -samba.ensure_external_module("testtools", "testtools") - -# Other modules import these two classes from here, for convenience: -from testtools.testcase import ( - TestCase as TesttoolsTestCase, - TestSkipped, - ) - - -class TestCase(TesttoolsTestCase): - """A Samba test case.""" - - def setUp(self): - super(TestCase, self).setUp() - test_debug_level = os.getenv("TEST_DEBUG_LEVEL") - if test_debug_level is not None: - test_debug_level = int(test_debug_level) - self._old_debug_level = samba.get_debug_level() - samba.set_debug_level(test_debug_level) - self.addCleanup(samba.set_debug_level, test_debug_level) - - def get_loadparm(self): - return env_loadparm() - - def get_credentials(self): - return cmdline_credentials - - -class LdbTestCase(TesttoolsTestCase): - """Trivial test case for running tests against a LDB.""" - - def setUp(self): - super(LdbTestCase, self).setUp() - self.filename = os.tempnam() - self.ldb = samba.Ldb(self.filename) - - def set_modules(self, modules=[]): - """Change the modules for this Ldb.""" - m = ldb.Message() - m.dn = ldb.Dn(self.ldb, "@MODULES") - m["@LIST"] = ",".join(modules) - self.ldb.add(m) - self.ldb = samba.Ldb(self.filename) - - -class TestCaseInTempDir(TestCase): - - def setUp(self): - super(TestCaseInTempDir, self).setUp() - self.tempdir = tempfile.mkdtemp() - self.addCleanup(self._remove_tempdir) - - def _remove_tempdir(self): - self.assertEquals([], os.listdir(self.tempdir)) - os.rmdir(self.tempdir) - self.tempdir = None - - -def env_loadparm(): - lp = param.LoadParm() - try: - lp.load(os.environ["SMB_CONF_PATH"]) - except KeyError: - raise Exception("SMB_CONF_PATH not set") - return lp - - -def env_get_var_value(var_name): - """Returns value for variable in os.environ - - Function throws AssertionError if variable is defined. - Unit-test based python tests require certain input params - to be set in environment, otherwise they can't be run - """ - assert var_name in os.environ.keys(), "Please supply %s in environment" % var_name - return os.environ[var_name] - - -cmdline_credentials = None - -class RpcInterfaceTestCase(TestCase): - """DCE/RPC Test case.""" - - -class ValidNetbiosNameTests(TestCase): - - def test_valid(self): - self.assertTrue(samba.valid_netbios_name("FOO")) - - def test_too_long(self): - self.assertFalse(samba.valid_netbios_name("FOO"*10)) - - def test_invalid_characters(self): - self.assertFalse(samba.valid_netbios_name("*BLA")) - - -class BlackboxProcessError(Exception): - """This is raised when check_output() process returns a non-zero exit status - - Exception instance should contain the exact exit code (S.returncode), - command line (S.cmd), process output (S.stdout) and process error stream - (S.stderr) - """ - - def __init__(self, returncode, cmd, stdout, stderr): - self.returncode = returncode - self.cmd = cmd - self.stdout = stdout - self.stderr = stderr - - def __str__(self): - return "Command '%s'; exit status %d; stdout: '%s'; stderr: '%s'" % (self.cmd, self.returncode, - self.stdout, self.stderr) - -class BlackboxTestCase(TestCase): - """Base test case for blackbox tests.""" - - def _make_cmdline(self, line): - bindir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../../bin")) - parts = line.split(" ") - if os.path.exists(os.path.join(bindir, parts[0])): - parts[0] = os.path.join(bindir, parts[0]) - line = " ".join(parts) - return line - - def check_run(self, line): - line = self._make_cmdline(line) - p = subprocess.Popen(line, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) - retcode = p.wait() - if retcode: - raise BlackboxProcessError(retcode, line, p.stdout.read(), p.stderr.read()) - - def check_output(self, line): - line = self._make_cmdline(line) - p = subprocess.Popen(line, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, close_fds=True) - retcode = p.wait() - if retcode: - raise BlackboxProcessError(retcode, line, p.stdout.read(), p.stderr.read()) - return p.stdout.read() - -def connect_samdb(samdb_url, lp=None, session_info=None, credentials=None, - flags=0, ldb_options=None, ldap_only=False): - """Create SamDB instance and connects to samdb_url database. - - :param samdb_url: Url for database to connect to. - :param lp: Optional loadparm object - :param session_info: Optional session information - :param credentials: Optional credentials, defaults to anonymous. - :param flags: Optional LDB flags - :param ldap_only: If set, only remote LDAP connection will be created. - - Added value for tests is that we have a shorthand function - to make proper URL for ldb.connect() while using default - parameters for connection based on test environment - """ - samdb_url = samdb_url.lower() - if not "://" in samdb_url: - if not ldap_only and os.path.isfile(samdb_url): - samdb_url = "tdb://%s" % samdb_url - else: - samdb_url = "ldap://%s" % samdb_url - # use 'paged_search' module when connecting remotely - if samdb_url.startswith("ldap://"): - ldb_options = ["modules:paged_searches"] - elif ldap_only: - raise AssertionError("Trying to connect to %s while remote " - "connection is required" % samdb_url) - - # set defaults for test environment - if lp is None: - lp = env_loadparm() - if session_info is None: - session_info = samba.auth.system_session(lp) - if credentials is None: - credentials = cmdline_credentials - - return SamDB(url=samdb_url, - lp=lp, - session_info=session_info, - credentials=credentials, - flags=flags, - options=ldb_options) - - -def connect_samdb_ex(samdb_url, lp=None, session_info=None, credentials=None, - flags=0, ldb_options=None, ldap_only=False): - """Connects to samdb_url database - - :param samdb_url: Url for database to connect to. - :param lp: Optional loadparm object - :param session_info: Optional session information - :param credentials: Optional credentials, defaults to anonymous. - :param flags: Optional LDB flags - :param ldap_only: If set, only remote LDAP connection will be created. - :return: (sam_db_connection, rootDse_record) tuple - """ - sam_db = connect_samdb(samdb_url, lp, session_info, credentials, - flags, ldb_options, ldap_only) - # fetch RootDse - res = sam_db.search(base="", expression="", scope=ldb.SCOPE_BASE, - attrs=["*"]) - return (sam_db, res[0]) - - -def delete_force(samdb, dn): - try: - samdb.delete(dn) - except ldb.LdbError, (num, _): - assert(num == ldb.ERR_NO_SUCH_OBJECT) diff --git a/source4/scripting/python/samba/tests/auth.py b/source4/scripting/python/samba/tests/auth.py deleted file mode 100644 index f71e1a784d2..00000000000 --- a/source4/scripting/python/samba/tests/auth.py +++ /dev/null @@ -1,31 +0,0 @@ -# Unix SMB/CIFS implementation. -# Copyright (C) Jelmer Vernooij 2007 -# -# 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 . -# - -"""Tests for the Auth Python bindings. - -Note that this just tests the bindings work. It does not intend to test -the functionality, that's already done in other tests. -""" - -from samba import auth -import samba.tests - -class AuthTests(samba.tests.TestCase): - - def test_system_session(self): - auth.system_session() - diff --git a/source4/scripting/python/samba/tests/blackbox/__init__.py b/source4/scripting/python/samba/tests/blackbox/__init__.py deleted file mode 100644 index 361e5cfe5e5..00000000000 --- a/source4/scripting/python/samba/tests/blackbox/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (C) Jelmer Vernooij 2008 - -# 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 . -# - -"""Blackbox tests. """ diff --git a/source4/scripting/python/samba/tests/blackbox/ndrdump.py b/source4/scripting/python/samba/tests/blackbox/ndrdump.py deleted file mode 100644 index fca9a931533..00000000000 --- a/source4/scripting/python/samba/tests/blackbox/ndrdump.py +++ /dev/null @@ -1,49 +0,0 @@ -# Blackbox tests for ndrdump -# Copyright (C) 2008 Andrew Tridgell -# Copyright (C) 2008 Andrew Bartlett -# Copyright (C) 2010 Jelmer Vernooij -# based on test_smbclient.sh - -# 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 . -# - -"""Blackbox tests for ndrdump.""" - -import os -from samba.tests import BlackboxTestCase - -for p in [ "../../../../../source4/librpc/tests", "../../../../../librpc/tests"]: - data_path_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), p)) - print data_path_dir - if os.path.exists(data_path_dir): - break - - -class NdrDumpTests(BlackboxTestCase): - """Blackbox tests for ndrdump.""" - - def data_path(self, name): - return os.path.join(data_path_dir, name) - - def test_ndrdump_with_in(self): - self.check_run("ndrdump samr samr_CreateUser in %s" % (self.data_path("samr-CreateUser-in.dat"))) - - def test_ndrdump_with_out(self): - self.check_run("ndrdump samr samr_CreateUser out %s" % (self.data_path("samr-CreateUser-out.dat"))) - - def test_ndrdump_context_file(self): - self.check_run("ndrdump --context-file %s samr samr_CreateUser out %s" % (self.data_path("samr-CreateUser-in.dat"), self.data_path("samr-CreateUser-out.dat"))) - - def test_ndrdump_with_validate(self): - self.check_run("ndrdump --validate samr samr_CreateUser in %s" % (self.data_path("samr-CreateUser-in.dat"))) diff --git a/source4/scripting/python/samba/tests/blackbox/samba_tool_drs.py b/source4/scripting/python/samba/tests/blackbox/samba_tool_drs.py deleted file mode 100644 index 62d7bf123bb..00000000000 --- a/source4/scripting/python/samba/tests/blackbox/samba_tool_drs.py +++ /dev/null @@ -1,97 +0,0 @@ -# Blackbox tests for "samba-tool drs" command -# Copyright (C) Kamen Mazdrashki 2011 -# -# 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 . -# - -"""Blackbox tests for samba-tool drs.""" - -import samba.tests - - -class SambaToolDrsTests(samba.tests.BlackboxTestCase): - """Blackbox test case for samba-tool drs.""" - - def setUp(self): - super(SambaToolDrsTests, self).setUp() - - self.dc1 = samba.tests.env_get_var_value("DC1") - self.dc2 = samba.tests.env_get_var_value("DC2") - - creds = self.get_credentials() - self.cmdline_creds = "-U%s/%s%%%s" % (creds.get_domain(), - creds.get_username(), creds.get_password()) - - def _get_rootDSE(self, dc): - samdb = samba.tests.connect_samdb(dc, lp=self.get_loadparm(), - credentials=self.get_credentials(), - ldap_only=True) - return samdb.search(base="", scope=samba.tests.ldb.SCOPE_BASE)[0] - - def test_samba_tool_bind(self): - """Tests 'samba-tool drs bind' command - Output should be like: - Extensions supported: - - Site GUID: - Repl epoch: 0""" - out = self.check_output("samba-tool drs bind %s %s" % (self.dc1, - self.cmdline_creds)) - self.assertTrue("Site GUID:" in out) - self.assertTrue("Repl epoch:" in out) - - def test_samba_tool_kcc(self): - """Tests 'samba-tool drs kcc' command - Output should be like 'Consistency check on successful.'""" - out = self.check_output("samba-tool drs kcc %s %s" % (self.dc1, - self.cmdline_creds)) - self.assertTrue("Consistency check on" in out) - self.assertTrue("successful" in out) - - def test_samba_tool_showrepl(self): - """Tests 'samba-tool drs showrepl' command - Output should be like: - / - DSA Options: - DSA object GUID: - DSA invocationId: - - - - ... - TODO: Perhaps we should check at least for - DSA's objectGUDI and invocationId""" - out = self.check_output("samba-tool drs showrepl %s %s" % (self.dc1, - self.cmdline_creds)) - self.assertTrue("DSA Options:" in out) - self.assertTrue("DSA object GUID:" in out) - self.assertTrue("DSA invocationId:" in out) - - def test_samba_tool_options(self): - """Tests 'samba-tool drs options' command - Output should be like 'Current DSA options: IS_GC '""" - out = self.check_output("samba-tool drs options %s %s" % (self.dc1, - self.cmdline_creds)) - self.assertTrue("Current DSA options:" in out) - - def test_samba_tool_replicate(self): - """Tests 'samba-tool drs replicate' command - Output should be like 'Replicate from to was successful.'""" - nc_name = self._get_rootDSE(self.dc1)["defaultNamingContext"] - out = self.check_output("samba-tool drs replicate %s %s %s %s" % (self.dc1, - self.dc2, - nc_name, - self.cmdline_creds)) - self.assertTrue("Replicate from" in out) - self.assertTrue("was successful" in out) diff --git a/source4/scripting/python/samba/tests/common.py b/source4/scripting/python/samba/tests/common.py deleted file mode 100644 index 8794e9dc8b3..00000000000 --- a/source4/scripting/python/samba/tests/common.py +++ /dev/null @@ -1,40 +0,0 @@ -# Unix SMB/CIFS implementation. Tests for common.py routines -# Copyright (C) Andrew Tridgell 2011 -# -# 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 . -# - -"""Tests for samba.common""" - -import samba, os -import samba.tests -from samba.common import * -from samba.samdb import SamDB - - -class CommonTests(samba.tests.TestCase): - - def test_normalise_int32(self): - self.assertEquals('17', normalise_int32(17)) - self.assertEquals('17', normalise_int32('17')) - self.assertEquals('-123', normalise_int32('-123')) - self.assertEquals('-1294967296', normalise_int32('3000000000')) - - def test_dsdb_Dn(self): - sam = samba.Ldb(url='dntest.ldb') - dn1 = dsdb_Dn(sam, "DC=foo,DC=bar") - dn2 = dsdb_Dn(sam, "B:8:0000000D:;DC=samba,DC=example,DC=com") - self.assertEquals(dn2.binary, "0000000D") - self.assertEquals(13, dn2.get_binary_integer()) - os.unlink('dntest.ldb') diff --git a/source4/scripting/python/samba/tests/core.py b/source4/scripting/python/samba/tests/core.py deleted file mode 100644 index 8206e68d4fb..00000000000 --- a/source4/scripting/python/samba/tests/core.py +++ /dev/null @@ -1,63 +0,0 @@ -# Unix SMB/CIFS implementation. -# Copyright (C) Jelmer Vernooij 2007-2008 -# -# 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 . -# - -"""Samba Python tests.""" - -import ldb -import os -import samba -from samba.tests import TestCase, TestCaseInTempDir - -class SubstituteVarTestCase(TestCase): - - def test_empty(self): - self.assertEquals("", samba.substitute_var("", {})) - - def test_nothing(self): - self.assertEquals("foo bar", - samba.substitute_var("foo bar", {"bar": "bla"})) - - def test_replace(self): - self.assertEquals("foo bla", - samba.substitute_var("foo ${bar}", {"bar": "bla"})) - - def test_broken(self): - self.assertEquals("foo ${bdkjfhsdkfh sdkfh ", - samba.substitute_var("foo ${bdkjfhsdkfh sdkfh ", {"bar": "bla"})) - - def test_unknown_var(self): - self.assertEquals("foo ${bla} gsff", - samba.substitute_var("foo ${bla} gsff", {"bar": "bla"})) - - def test_check_all_substituted(self): - samba.check_all_substituted("nothing to see here") - self.assertRaises(Exception, samba.check_all_substituted, - "Not subsituted: ${FOOBAR}") - - -class LdbExtensionTests(TestCaseInTempDir): - - def test_searchone(self): - path = self.tempdir + "/searchone.ldb" - l = samba.Ldb(path) - try: - l.add({"dn": "foo=dc", "bar": "bla"}) - self.assertEquals("bla", - l.searchone(basedn=ldb.Dn(l, "foo=dc"), attribute="bar")) - finally: - del l - os.unlink(path) diff --git a/source4/scripting/python/samba/tests/credentials.py b/source4/scripting/python/samba/tests/credentials.py deleted file mode 100644 index 95ee0fa0deb..00000000000 --- a/source4/scripting/python/samba/tests/credentials.py +++ /dev/null @@ -1,98 +0,0 @@ -# Unix SMB/CIFS implementation. -# Copyright (C) Jelmer Vernooij 2007 -# -# 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 . -# - -"""Tests for the Credentials Python bindings. - -Note that this just tests the bindings work. It does not intend to test -the functionality, that's already done in other tests. -""" - -from samba import credentials -import samba.tests - -class CredentialsTests(samba.tests.TestCase): - - def setUp(self): - super(CredentialsTests, self).setUp() - self.creds = credentials.Credentials() - - def test_set_username(self): - self.creds.set_username("somebody") - self.assertEquals("somebody", self.creds.get_username()) - - def test_set_password(self): - self.creds.set_password("S3CreT") - self.assertEquals("S3CreT", self.creds.get_password()) - - def test_set_domain(self): - self.creds.set_domain("ABMAS") - self.assertEquals("ABMAS", self.creds.get_domain()) - - def test_set_realm(self): - self.creds.set_realm("myrealm") - self.assertEquals("MYREALM", self.creds.get_realm()) - - def test_parse_string_anon(self): - self.creds.parse_string("%") - self.assertEquals("", self.creds.get_username()) - self.assertEquals(None, self.creds.get_password()) - - def test_parse_string_user_pw_domain(self): - self.creds.parse_string("dom\\someone%secr") - self.assertEquals("someone", self.creds.get_username()) - self.assertEquals("secr", self.creds.get_password()) - self.assertEquals("DOM", self.creds.get_domain()) - - def test_bind_dn(self): - self.assertEquals(None, self.creds.get_bind_dn()) - self.creds.set_bind_dn("dc=foo,cn=bar") - self.assertEquals("dc=foo,cn=bar", self.creds.get_bind_dn()) - - def test_is_anon(self): - self.creds.set_username("") - self.assertTrue(self.creds.is_anonymous()) - self.creds.set_username("somebody") - self.assertFalse(self.creds.is_anonymous()) - self.creds.set_anonymous() - self.assertTrue(self.creds.is_anonymous()) - - def test_workstation(self): - # FIXME: This is uninitialised, it should be None - #self.assertEquals(None, self.creds.get_workstation()) - self.creds.set_workstation("myworksta") - self.assertEquals("myworksta", self.creds.get_workstation()) - - def test_get_nt_hash(self): - self.creds.set_password("geheim") - self.assertEquals('\xc2\xae\x1f\xe6\xe6H\x84cRE>\x81o*\xeb\x93', - self.creds.get_nt_hash()) - - def test_guess(self): - # Just check the method is there and doesn't raise an exception - self.creds.guess() - - def test_set_cmdline_callbacks(self): - self.creds.set_cmdline_callbacks() - - def test_authentication_requested(self): - self.creds.set_username("") - self.assertFalse(self.creds.authentication_requested()) - self.creds.set_username("somebody") - self.assertTrue(self.creds.authentication_requested()) - - def test_wrong_password(self): - self.assertFalse(self.creds.wrong_password()) diff --git a/source4/scripting/python/samba/tests/dcerpc/__init__.py b/source4/scripting/python/samba/tests/dcerpc/__init__.py deleted file mode 100644 index d84cb57a096..00000000000 --- a/source4/scripting/python/samba/tests/dcerpc/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Unix SMB/CIFS implementation. -# Copyright © Jelmer Vernooij 2008 -# -# 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 . - -"""Tests for the DCE/RPC Python bindings.""" - diff --git a/source4/scripting/python/samba/tests/dcerpc/bare.py b/source4/scripting/python/samba/tests/dcerpc/bare.py deleted file mode 100644 index 3efbf9d4cf3..00000000000 --- a/source4/scripting/python/samba/tests/dcerpc/bare.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Unix SMB/CIFS implementation. -# Copyright © Jelmer Vernooij 2008 -# -# 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 . -# - -"""Tests for samba.tests.dcerpc.bare.""" - -from samba.dcerpc import ClientConnection -import samba.tests - -class BareTestCase(samba.tests.TestCase): - - def test_bare(self): - # Connect to the echo pipe - x = ClientConnection("ncalrpc:localhost[DEFAULT]", - ("60a15ec5-4de8-11d7-a637-005056a20182", 1), - lp_ctx=samba.tests.env_loadparm()) - self.assertEquals("\x01\x00\x00\x00", x.request(0, chr(0) * 4)) - - def test_alter_context(self): - x = ClientConnection("ncalrpc:localhost[DEFAULT]", - ("12345778-1234-abcd-ef00-0123456789ac", 1), - lp_ctx=samba.tests.env_loadparm()) - y = ClientConnection("ncalrpc:localhost", - ("60a15ec5-4de8-11d7-a637-005056a20182", 1), - basis_connection=x, lp_ctx=samba.tests.env_loadparm()) - x.alter_context(("60a15ec5-4de8-11d7-a637-005056a20182", 1)) - # FIXME: self.assertEquals("\x01\x00\x00\x00", x.request(0, chr(0) * 4)) - - def test_two_connections(self): - x = ClientConnection("ncalrpc:localhost[DEFAULT]", - ("60a15ec5-4de8-11d7-a637-005056a20182", 1), - lp_ctx=samba.tests.env_loadparm()) - y = ClientConnection("ncalrpc:localhost", - ("60a15ec5-4de8-11d7-a637-005056a20182", 1), - basis_connection=x, lp_ctx=samba.tests.env_loadparm()) - self.assertEquals("\x01\x00\x00\x00", y.request(0, chr(0) * 4)) diff --git a/source4/scripting/python/samba/tests/dcerpc/dnsserver.py b/source4/scripting/python/samba/tests/dcerpc/dnsserver.py deleted file mode 100644 index 59d6eee7618..00000000000 --- a/source4/scripting/python/samba/tests/dcerpc/dnsserver.py +++ /dev/null @@ -1,241 +0,0 @@ -# Unix SMB/CIFS implementation. -# Copyright (C) Amitay Isaacs 2011 -# -# 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 . -# - -"""Tests for samba.dcerpc.dnsserver""" - -from samba.dcerpc import dnsp, dnsserver -from samba.tests import RpcInterfaceTestCase, env_get_var_value -from samba.netcmd.dns import ARecord - -class DnsserverTests(RpcInterfaceTestCase): - - def setUp(self): - super(DnsserverTests, self).setUp() - self.server = env_get_var_value("SERVER_IP") - self.zone = env_get_var_value("REALM").lower() - self.conn = dnsserver.dnsserver("ncacn_ip_tcp:%s" % (self.server), - self.get_loadparm(), - self.get_credentials()) - - def test_operation2(self): - pass - - - def test_query2(self): - typeid, result = self.conn.DnssrvQuery2(dnsserver.DNS_CLIENT_VERSION_W2K, - 0, - self.server, - None, - 'ServerInfo') - self.assertEquals(dnsserver.DNSSRV_TYPEID_SERVER_INFO_W2K, typeid) - - typeid, result = self.conn.DnssrvQuery2(dnsserver.DNS_CLIENT_VERSION_DOTNET, - 0, - self.server, - None, - 'ServerInfo') - self.assertEquals(dnsserver.DNSSRV_TYPEID_SERVER_INFO_DOTNET, typeid) - - typeid, result = self.conn.DnssrvQuery2(dnsserver.DNS_CLIENT_VERSION_LONGHORN, - 0, - self.server, - None, - 'ServerInfo') - self.assertEquals(dnsserver.DNSSRV_TYPEID_SERVER_INFO, typeid) - - def test_operation2(self): - client_version = dnsserver.DNS_CLIENT_VERSION_LONGHORN - rev_zone = '1.168.192.in-addr.arpa' - - zone_create = dnsserver.DNS_RPC_ZONE_CREATE_INFO_LONGHORN() - zone_create.pszZoneName = rev_zone - zone_create.dwZoneType = dnsp.DNS_ZONE_TYPE_PRIMARY - zone_create.fAllowUpdate = dnsp.DNS_ZONE_UPDATE_SECURE - zone_create.fAging = 0 - zone_create.dwDpFlags = dnsserver.DNS_DP_DOMAIN_DEFAULT - - # Create zone - self.conn.DnssrvOperation2(client_version, - 0, - self.server, - None, - 0, - 'ZoneCreate', - dnsserver.DNSSRV_TYPEID_ZONE_CREATE, - zone_create) - - request_filter = (dnsserver.DNS_ZONE_REQUEST_REVERSE | - dnsserver.DNS_ZONE_REQUEST_PRIMARY) - typeid, zones = self.conn.DnssrvComplexOperation2(client_version, - 0, - self.server, - None, - 'EnumZones', - dnsserver.DNSSRV_TYPEID_DWORD, - request_filter) - self.assertEquals(1, zones.dwZoneCount) - - # Delete zone - self.conn.DnssrvOperation2(client_version, - 0, - self.server, - rev_zone, - 0, - 'DeleteZoneFromDs', - dnsserver.DNSSRV_TYPEID_NULL, - None) - - typeid, zones = self.conn.DnssrvComplexOperation2(client_version, - 0, - self.server, - None, - 'EnumZones', - dnsserver.DNSSRV_TYPEID_DWORD, - request_filter) - self.assertEquals(0, zones.dwZoneCount) - - - def test_complexoperation2(self): - client_version = dnsserver.DNS_CLIENT_VERSION_LONGHORN - request_filter = (dnsserver.DNS_ZONE_REQUEST_FORWARD | - dnsserver.DNS_ZONE_REQUEST_PRIMARY) - typeid, zones = self.conn.DnssrvComplexOperation2(client_version, - 0, - self.server, - None, - 'EnumZones', - dnsserver.DNSSRV_TYPEID_DWORD, - request_filter) - self.assertEquals(dnsserver.DNSSRV_TYPEID_ZONE_LIST, typeid) - self.assertEquals(2, zones.dwZoneCount) - - request_filter = (dnsserver.DNS_ZONE_REQUEST_REVERSE | - dnsserver.DNS_ZONE_REQUEST_PRIMARY) - typeid, zones = self.conn.DnssrvComplexOperation2(client_version, - 0, - self.server, - None, - 'EnumZones', - dnsserver.DNSSRV_TYPEID_DWORD, - request_filter) - self.assertEquals(dnsserver.DNSSRV_TYPEID_ZONE_LIST, typeid) - self.assertEquals(0, zones.dwZoneCount) - - - def test_enumrecords2(self): - client_version = dnsserver.DNS_CLIENT_VERSION_LONGHORN - record_type = dnsp.DNS_TYPE_NS - select_flags = (dnsserver.DNS_RPC_VIEW_ROOT_HINT_DATA | - dnsserver.DNS_RPC_VIEW_ADDITIONAL_DATA) - buflen, roothints = self.conn.DnssrvEnumRecords2(client_version, - 0, - self.server, - '..RootHints', - '.', - None, - record_type, - select_flags, - None, - None) - self.assertEquals(14, roothints.count) # 1 NS + 13 A records (a-m) - - - def test_updaterecords2(self): - client_version = dnsserver.DNS_CLIENT_VERSION_LONGHORN - record_type = dnsp.DNS_TYPE_A - select_flags = dnsserver.DNS_RPC_VIEW_AUTHORITY_DATA - - name = 'dummy' - rec = ARecord('1.2.3.4') - rec2 = ARecord('5.6.7.8') - - # Add record - add_rec_buf = dnsserver.DNS_RPC_RECORD_BUF() - add_rec_buf.rec = rec - self.conn.DnssrvUpdateRecord2(client_version, - 0, - self.server, - self.zone, - name, - add_rec_buf, - None) - - buflen, result = self.conn.DnssrvEnumRecords2(client_version, - 0, - self.server, - self.zone, - name, - None, - record_type, - select_flags, - None, - None) - self.assertEquals(1, result.count) - self.assertEquals(1, result.rec[0].wRecordCount) - self.assertEquals(dnsp.DNS_TYPE_A, result.rec[0].records[0].wType) - self.assertEquals('1.2.3.4', result.rec[0].records[0].data) - - # Update record - add_rec_buf = dnsserver.DNS_RPC_RECORD_BUF() - add_rec_buf.rec = rec2 - del_rec_buf = dnsserver.DNS_RPC_RECORD_BUF() - del_rec_buf.rec = rec - self.conn.DnssrvUpdateRecord2(client_version, - 0, - self.server, - self.zone, - name, - add_rec_buf, - del_rec_buf) - - buflen, result = self.conn.DnssrvEnumRecords2(client_version, - 0, - self.server, - self.zone, - name, - None, - record_type, - select_flags, - None, - None) - self.assertEquals(1, result.count) - self.assertEquals(1, result.rec[0].wRecordCount) - self.assertEquals(dnsp.DNS_TYPE_A, result.rec[0].records[0].wType) - self.assertEquals('5.6.7.8', result.rec[0].records[0].data) - - # Delete record - del_rec_buf = dnsserver.DNS_RPC_RECORD_BUF() - del_rec_buf.rec = rec2 - self.conn.DnssrvUpdateRecord2(client_version, - 0, - self.server, - self.zone, - name, - None, - del_rec_buf) - - self.assertRaises(RuntimeError, self.conn.DnssrvEnumRecords2, - client_version, - 0, - self.server, - self.zone, - name, - None, - record_type, - select_flags, - None, - None) diff --git a/source4/scripting/python/samba/tests/dcerpc/misc.py b/source4/scripting/python/samba/tests/dcerpc/misc.py deleted file mode 100644 index 11e14aadfa7..00000000000 --- a/source4/scripting/python/samba/tests/dcerpc/misc.py +++ /dev/null @@ -1,62 +0,0 @@ -# Unix SMB/CIFS implementation. -# Copyright (C) Jelmer Vernooij 2007 -# -# 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 . -# - -"""Tests for samba.dcerpc.misc.""" - -from samba.dcerpc import misc -import samba.tests - -text1 = "76f53846-a7c2-476a-ae2c-20e2b80d7b34" -text2 = "344edffa-330a-4b39-b96e-2c34da52e8b1" - -class GUIDTests(samba.tests.TestCase): - - def test_str(self): - guid = misc.GUID(text1) - self.assertEquals(text1, str(guid)) - - def test_repr(self): - guid = misc.GUID(text1) - self.assertEquals("GUID('%s')" % text1, repr(guid)) - - def test_compare_different(self): - guid1 = misc.GUID(text1) - guid2 = misc.GUID(text2) - self.assertTrue(cmp(guid1, guid2) > 0) - - def test_compare_same(self): - guid1 = misc.GUID(text1) - guid2 = misc.GUID(text1) - self.assertEquals(0, cmp(guid1, guid2)) - self.assertEquals(guid1, guid2) - - -class PolicyHandleTests(samba.tests.TestCase): - - def test_init(self): - x = misc.policy_handle(text1, 1) - self.assertEquals(1, x.handle_type) - self.assertEquals(text1, str(x.uuid)) - - def test_repr(self): - x = misc.policy_handle(text1, 42) - self.assertEquals("policy_handle(%d, '%s')" % (42, text1), repr(x)) - - def test_str(self): - x = misc.policy_handle(text1, 42) - self.assertEquals("%d, %s" % (42, text1), str(x)) - diff --git a/source4/scripting/python/samba/tests/dcerpc/registry.py b/source4/scripting/python/samba/tests/dcerpc/registry.py deleted file mode 100644 index c7bcbfd530a..00000000000 --- a/source4/scripting/python/samba/tests/dcerpc/registry.py +++ /dev/null @@ -1,51 +0,0 @@ -# Unix SMB/CIFS implementation. -# Copyright (C) Jelmer Vernooij 2008 -# -# 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 . -# - -"""Tests for samba.dcerpc.registry.""" - -from samba.dcerpc import winreg -from samba.tests import RpcInterfaceTestCase - - -class WinregTests(RpcInterfaceTestCase): - - def setUp(self): - super(WinregTests, self).setUp() - self.conn = winreg.winreg("ncalrpc:", self.get_loadparm(), - self.get_credentials()) - - def get_hklm(self): - return self.conn.OpenHKLM(None, - winreg.KEY_QUERY_VALUE | winreg.KEY_ENUMERATE_SUB_KEYS) - - def test_hklm(self): - handle = self.conn.OpenHKLM(None, - winreg.KEY_QUERY_VALUE | winreg.KEY_ENUMERATE_SUB_KEYS) - self.conn.CloseKey(handle) - - def test_getversion(self): - handle = self.get_hklm() - version = self.conn.GetVersion(handle) - self.assertEquals(int, version.__class__) - self.conn.CloseKey(handle) - - def test_getkeyinfo(self): - handle = self.conn.OpenHKLM(None, - winreg.KEY_QUERY_VALUE | winreg.KEY_ENUMERATE_SUB_KEYS) - x = self.conn.QueryInfoKey(handle, winreg.String()) - self.assertEquals(9, len(x)) # should return a 9-tuple - self.conn.CloseKey(handle) diff --git a/source4/scripting/python/samba/tests/dcerpc/rpc_talloc.py b/source4/scripting/python/samba/tests/dcerpc/rpc_talloc.py deleted file mode 100644 index c091f26c1b9..00000000000 --- a/source4/scripting/python/samba/tests/dcerpc/rpc_talloc.py +++ /dev/null @@ -1,84 +0,0 @@ -# test generated python code from pidl -# Copyright (C) Andrew Tridgell August 2010 -# -# 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 . -# -# -# to run this test, use one of these: -# -# python -m testtools.run samba.tests.dcerpc.rpc_talloc -# -# or if you have trial installed (from twisted), use -# -# trial samba.tests.dcerpc.rpc_talloc - -"""Tests for the talloc handling in the generated Python DCE/RPC bindings.""" - -import sys - -sys.path.insert(0, "bin/python") - -import samba -import samba.tests -from samba.dcerpc import drsuapi -import talloc - -talloc.enable_null_tracking() - - -class TallocTests(samba.tests.TestCase): - '''test talloc behaviour of pidl generated python code''' - - def check_blocks(self, object, num_expected): - '''check that the number of allocated blocks is correct''' - nblocks = talloc.total_blocks(object) - if object is None: - nblocks -= self.initial_blocks - self.assertEquals(nblocks, num_expected) - - def get_rodc_partial_attribute_set(self): - '''get a list of attributes for RODC replication''' - partial_attribute_set = drsuapi.DsPartialAttributeSet() - - # we expect one block for the object, and one for the structure - self.check_blocks(partial_attribute_set, 2) - - attids = [1, 2, 3] - partial_attribute_set.version = 1 - partial_attribute_set.attids = attids - partial_attribute_set.num_attids = len(attids) - - # we expect one block object, a structure, an ARRAY, and a - # reference to the array - self.check_blocks(partial_attribute_set, 3) - - return partial_attribute_set - - def pas_test(self): - pas = self.get_rodc_partial_attribute_set() - self.check_blocks(pas, 3) - req8 = drsuapi.DsGetNCChangesRequest8() - self.check_blocks(req8, 2) - self.check_blocks(None, 5) - req8.partial_attribute_set = pas - if req8.partial_attribute_set.attids[1] != 2: - raise Exception("Wrong value in attids[2]") - # we now get an additional reference - self.check_blocks(None, 6) - - def test_run(self): - self.initial_blocks = talloc.total_blocks(None) - self.check_blocks(None, 0) - self.pas_test() - self.check_blocks(None, 0) diff --git a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py deleted file mode 100644 index 099f8f619ce..00000000000 --- a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py +++ /dev/null @@ -1,71 +0,0 @@ -# Unix SMB/CIFS implementation. -# Copyright (C) Jelmer Vernooij 2008 -# -# 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 . -# - -"""Tests for samba.dceprc.rpcecho.""" - -from samba.dcerpc import echo -from samba.ndr import ndr_pack, ndr_unpack -from samba.tests import RpcInterfaceTestCase, TestCase - - -class RpcEchoTests(RpcInterfaceTestCase): - - def setUp(self): - super(RpcEchoTests, self).setUp() - self.conn = echo.rpcecho("ncalrpc:", self.get_loadparm()) - - def test_two_contexts(self): - self.conn2 = echo.rpcecho("ncalrpc:", self.get_loadparm(), basis_connection=self.conn) - self.assertEquals(3, self.conn2.AddOne(2)) - - def test_abstract_syntax(self): - self.assertEquals(("60a15ec5-4de8-11d7-a637-005056a20182", 1), - self.conn.abstract_syntax) - - def test_addone(self): - self.assertEquals(2, self.conn.AddOne(1)) - - def test_echodata(self): - self.assertEquals([1,2,3], self.conn.EchoData([1, 2, 3])) - - def test_call(self): - self.assertEquals(u"foobar", self.conn.TestCall(u"foobar")) - - def test_surrounding(self): - surrounding_struct = echo.Surrounding() - surrounding_struct.x = 4 - surrounding_struct.surrounding = [1,2,3,4] - y = self.conn.TestSurrounding(surrounding_struct) - self.assertEquals(8 * [0], y.surrounding) - - def test_manual_request(self): - self.assertEquals("\x01\x00\x00\x00", self.conn.request(0, chr(0) * 4)) - - def test_server_name(self): - self.assertEquals(None, self.conn.server_name) - - -class NdrEchoTests(TestCase): - - def test_info1_push(self): - x = echo.info1() - x.v = 42 - self.assertEquals("\x2a", ndr_pack(x)) - - def test_info1_pull(self): - x = ndr_unpack(echo.info1, "\x42") - self.assertEquals(x.v, 66) diff --git a/source4/scripting/python/samba/tests/dcerpc/sam.py b/source4/scripting/python/samba/tests/dcerpc/sam.py deleted file mode 100644 index 0e09323adbe..00000000000 --- a/source4/scripting/python/samba/tests/dcerpc/sam.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Unix SMB/CIFS implementation. -# Copyright © Jelmer Vernooij 2008 -# -# 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 . -# - -"""Tests for samba.dcerpc.sam.""" - -from samba.dcerpc import samr, security -from samba.tests import RpcInterfaceTestCase - -# FIXME: Pidl should be doing this for us -def toArray((handle, array, num_entries)): - ret = [] - for x in range(num_entries): - ret.append((array.entries[x].idx, array.entries[x].name)) - return ret - - -class SamrTests(RpcInterfaceTestCase): - - def setUp(self): - super(SamrTests, self).setUp() - self.conn = samr.samr("ncalrpc:", self.get_loadparm()) - - def test_connect5(self): - (level, info, handle) = self.conn.Connect5(None, 0, 1, samr.ConnectInfo1()) - - def test_connect2(self): - handle = self.conn.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED) - self.assertTrue(handle is not None) - - def test_EnumDomains(self): - handle = self.conn.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED) - domains = toArray(self.conn.EnumDomains(handle, 0, -1)) - self.conn.Close(handle) - diff --git a/source4/scripting/python/samba/tests/dcerpc/srvsvc.py b/source4/scripting/python/samba/tests/dcerpc/srvsvc.py deleted file mode 100644 index 3206a27e678..00000000000 --- a/source4/scripting/python/samba/tests/dcerpc/srvsvc.py +++ /dev/null @@ -1,68 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Unix SMB/CIFS implementation. -# Copyright © Dhananjay Sathe 2011 -# Copyright © Jelmer Vernooij 2011 -# -# 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 . -# - -"""Tests for samba.dcerpc.srvsvc.""" - -from samba.dcerpc import srvsvc -from samba.tests import RpcInterfaceTestCase - - -class SrvsvcTests(RpcInterfaceTestCase): - - def setUp(self): - super(SrvsvcTests, self).setUp() - self.conn = srvsvc.srvsvc("ncalrpc:", self.get_loadparm()) - self.server_unc = "\\\\." - - def getDummyShareObject(self): - share = srvsvc.NetShareInfo2() - - share.name = u'test' - share.comment = u'test share' - share.type = srvsvc.STYPE_DISKTREE - share.current_users = 0x00000000 - share.max_users = -1 - share.password = None - share.path = u'C:\\tmp' # some random path - share.permissions = 123434566 - return share - - def test_NetShareAdd(self): - self.skip("Dangerous test") - share = self.getDummyShareObject() - self.conn.NetShareAdd(self.server_unc, 2, share, None) - - def test_NetShareSetInfo(self): - self.skip("Dangerous test") - share = self.getDummyShareObject() - parm_error = 0x00000000 - self.conn.NetShareAdd(self.server_unc, 502, share, parm_error) - name = share.name - share.comment = "now sucessfully modified " - parm_error = self.pipe.NetShareSetInfo(self.server_unc, name, - 502, share, parm_error) - - def test_NetShareDel(self): - self.skip("Dangerous test") - share = self.getDummyShareObject() - parm_error = 0x00000000 - self.expectFailure("NetS