s4-test: added a tokengroups test
[samba.git] / source4 / selftest / tests.py
1 #!/usr/bin/python
2 # This script generates a list of testsuites that should be run as part of
3 # the Samba 4 test suite.
4
5 # The output of this script is parsed by selftest.pl, which then decides
6 # which of the tests to actually run. It will, for example, skip all tests
7 # listed in selftest/skip or only run a subset during "make quicktest".
8
9 # The idea is that this script outputs all of the tests of Samba 4, not
10 # just those that are known to pass, and list those that should be skipped
11 # or are known to fail in selftest/skip or selftest/knownfail. This makes it
12 # very easy to see what functionality is still missing in Samba 4 and makes
13 # it possible to run the testsuite against other servers, such as Samba 3 or
14 # Windows that have a different set of features.
15
16 # The syntax for a testsuite is "-- TEST --" on a single line, followed
17 # by the name of the test, the environment it needs and the command to run, all
18 # three separated by newlines. All other lines in the output are considered
19 # comments.
20
21 import os
22 import subprocess
23
24 def binpath(name):
25     return os.path.join(samba4bindir, "%s%s" % (name, os.getenv("EXEEXT", "")))
26
27 perl = os.getenv("PERL", "perl")
28
29 if subprocess.call([perl, "-e", "eval require Test::More;"]) == 0:
30     has_perl_test_more = True
31 else:
32     has_perl_test_more = False
33
34 try:
35     from subunit.run import TestProgram
36 except ImportError:
37     has_system_subunit_run = False
38 else:
39     has_system_subunit_run = True
40
41 python = os.getenv("PYTHON", "python")
42
43 def valgrindify(cmdline):
44     """Run a command under valgrind, if $VALGRIND was set."""
45     valgrind = os.getenv("VALGRIND")
46     if valgrind is None:
47         return cmdline
48     return valgrind + " " + cmdline
49
50
51 def plantestsuite(name, env, cmdline, allow_empty_output=False):
52     """Plan a test suite.
53
54     :param name: Testsuite name
55     :param env: Environment to run the testsuite in
56     :param cmdline: Command line to run
57     """
58     print "-- TEST --"
59     print name
60     print env
61     if isinstance(cmdline, list):
62         cmdline = " ".join(cmdline)
63     filter_subunit_args = []
64     if not allow_empty_output:
65         filter_subunit_args.append("--fail-on-empty")
66     if "$LISTOPT" in cmdline:
67         filter_subunit_args.append("$LISTOPT")
68     print "%s 2>&1 | ../selftest/filter-subunit %s --prefix=\"%s.\"" % (cmdline, " ".join(filter_subunit_args), name)
69     if allow_empty_output:
70         print "WARNING: allowing empty subunit output from %s" % name
71
72
73 def add_prefix(prefix, support_list=False):
74     if support_list:
75         listopt = "$LISTOPT "
76     else:
77         listopt = ""
78     return "../selftest/filter-subunit %s--fail-on-empty --prefix=\"%s.\"" % (listopt, prefix)
79
80
81 def plantestsuite_loadlist(name, env, cmdline):
82     print "-- TEST-LOADLIST --"
83     if env == "none":
84         fullname = name
85     else:
86         fullname = "%s(%s)" % (name, env)
87     print fullname
88     print env
89     if isinstance(cmdline, list):
90         cmdline = " ".join(cmdline)
91     support_list = ("$LISTOPT" in cmdline)
92     print "%s $LOADLIST 2>&1 | %s" % (cmdline, add_prefix(name, support_list))
93
94
95 def plantestsuite_idlist(name, env, cmdline):
96     print "-- TEST-IDLIST --"
97     print name
98     print env
99     if isinstance(cmdline, list):
100         cmdline = " ".join(cmdline)
101     print cmdline
102
103
104 def skiptestsuite(name, reason):
105     """Indicate that a testsuite was skipped.
106
107     :param name: Test suite name
108     :param reason: Reason the test suite was skipped
109     """
110     # FIXME: Report this using subunit, but re-adjust the testsuite count somehow
111     print "skipping %s (%s)" % (name, reason)
112
113
114 def planperltestsuite(name, path):
115     """Run a perl test suite.
116
117     :param name: Name of the test suite
118     :param path: Path to the test runner
119     """
120     if has_perl_test_more:
121         plantestsuite(name, "none", "%s %s | %s" % (perl, path, tap2subunit))
122     else:
123         skiptestsuite(name, "Test::More not available")
124
125
126 def planpythontestsuite(env, module):
127     if has_system_subunit_run:
128         plantestsuite_idlist(module, env, [python, "-m", "subunit.run", "$LISTOPT", module])
129     else:
130         plantestsuite_idlist(module, env, "PYTHONPATH=$PYTHONPATH:%s/../lib/subunit/python:%s/../lib/testtools %s -m subunit.run $LISTOPT %s" % (samba4srcdir, samba4srcdir, python, module))
131
132
133 def plansmbtorturetestsuite(name, env, options):
134     modname = "samba4.%s" % name
135     cmdline = "%s $LISTOPT %s %s" % (valgrindify(smb4torture), options, name)
136     plantestsuite_loadlist(modname, env, cmdline)
137
138
139 samba4srcdir = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
140 builddir = os.getenv("BUILDDIR", samba4srcdir)
141 samba4bindir = os.path.normpath(os.path.join(builddir, "bin"))
142 smb4torture = binpath("smbtorture")
143 smb4torture_testsuite_list = subprocess.Popen([smb4torture, "--list-suites"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate("")[0].splitlines()
144 validate = os.getenv("VALIDATE", "")
145 if validate:
146     validate_list = [validate]
147 else:
148     validate_list = []
149 def smb4torture_testsuites(prefix):
150     return filter(lambda x: x.startswith(prefix), smb4torture_testsuite_list)
151
152 sub = subprocess.Popen("tap2subunit 2> /dev/null", stdout=subprocess.PIPE, stdin=subprocess.PIPE, shell=True)
153 sub.communicate("")
154 if sub.returncode != 0:
155     tap2subunit = "PYTHONPATH=%s/../lib/subunit/python:%s/../lib/testtools %s %s/../lib/subunit/filters/tap2subunit" % (samba4srcdir, samba4srcdir, python, samba4srcdir)
156 else:
157     cmd = "echo -ne \"1..1\nok 1 # skip doesn't seem to work yet\n\" | tap2subunit 2> /dev/null | grep skip"
158     sub = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
159     if sub.returncode == 0:
160         tap2subunit = "tap2subunit"
161     else:
162         tap2subunit = "PYTHONPATH=%s/../lib/subunit/python:%s/../lib/testtools %s %s/../lib/subunit/filters/tap2subunit" % (samba4srcdir, samba4srcdir, python, samba4srcdir)
163
164 subprocess.call([smb4torture, "-V"])
165
166 bbdir = "../testprogs/blackbox"
167
168 configuration = "--configfile=$SMB_CONF_PATH"
169
170 torture_options = [configuration, "--maximum-runtime=$SELFTEST_MAXTIME", "--target=$SELFTEST_TARGET", "--basedir=$SELFTEST_TMPDIR"]
171 if not os.getenv("SELFTEST_VERBOSE"):
172     torture_options.append("--option=torture:progress=no")
173 torture_options.append("--format=subunit")
174 if os.getenv("SELFTEST_QUICK"):
175     torture_options.append("--option=torture:quick=yes")
176 smb4torture += " " + " ".join(torture_options)
177
178 print "OPTIONS %s" % " ".join(torture_options)
179
180 # Simple tests for LDAP and CLDAP
181 for options in ['-U"$USERNAME%$PASSWORD" --option=socket:testnonblock=true', '-U"$USERNAME%$PASSWORD"', '-U"$USERNAME%$PASSWORD" -k yes', '-U"$USERNAME%$PASSWORD" -k no', '-U"$USERNAME%$PASSWORD" -k no --sign', '-U"$USERNAME%$PASSWORD" -k no --encrypt', '-U"$USERNAME%$PASSWORD" -k yes --encrypt', '-U"$USERNAME%$PASSWORD" -k yes --sign']:
182     plantestsuite("samba4.ldb.ldap with options %s(dc)" % options, "dc", "%s/test_ldb.sh ldap $SERVER %s" % (bbdir, options))
183
184 # see if we support ldaps
185 try:
186     config_h = os.environ["CONFIG_H"]
187 except KeyError:
188     config_h = os.path.join(samba4bindir, "default/source4/include/config.h")
189 f = open(config_h, 'r')
190 try:
191     have_tls_support = ("ENABLE_GNUTLS 1" in f.read())
192 finally:
193     f.close()
194
195 if have_tls_support:
196     for options in ['-U"$USERNAME%$PASSWORD"']:
197         plantestsuite("samba4.ldb.ldaps with options %s(dc)" % options, "dc",
198                 "%s/test_ldb.sh ldaps $SERVER_IP %s" % (bbdir, options))
199
200 for options in ['-U"$USERNAME%$PASSWORD"']:
201     plantestsuite("samba4.ldb.ldapi with options %s(dc:local)" % options, "dc:local",
202             "%s/test_ldb.sh ldapi $PREFIX_ABS/dc/private/ldapi %s" % (bbdir, options))
203
204 for t in smb4torture_testsuites("ldap."):
205     plansmbtorturetestsuite(t, "dc", '-U"$USERNAME%$PASSWORD" //$SERVER_IP/_none_')
206
207 ldbdir = os.path.join(samba4srcdir, "lib/ldb")
208 # Don't run LDB tests when using system ldb, as we won't have ldbtest installed
209 if os.path.exists(os.path.join(samba4bindir, "ldbtest")):
210     plantestsuite("ldb.base", "none", "%s/tests/test-tdb.sh" % ldbdir,
211                   allow_empty_output=True)
212 else:
213     skiptestsuite("ldb.base", "Using system LDB, ldbtest not available")
214
215 # Tests for RPC
216
217 # add tests to this list as they start passing, so we test
218 # that they stay passing
219 ncacn_np_tests = ["rpc.schannel", "rpc.join", "rpc.lsa", "rpc.dssetup", "rpc.altercontext", "rpc.multibind", "rpc.netlogon", "rpc.handles", "rpc.samsync", "rpc.samba3-sessionkey", "rpc.samba3-getusername", "rpc.samba3-lsa", "rpc.samba3-bind", "rpc.samba3-netlogon", "rpc.asyncbind", "rpc.lsalookup", "rpc.lsa-getuser", "rpc.schannel2", "rpc.authcontext"]
220 ncalrpc_tests = ["rpc.schannel", "rpc.join", "rpc.lsa", "rpc.dssetup", "rpc.altercontext", "rpc.multibind", "rpc.netlogon", "rpc.drsuapi", "rpc.asyncbind", "rpc.lsalookup", "rpc.lsa-getuser", "rpc.schannel2", "rpc.authcontext"]
221 drs_rpc_tests = smb4torture_testsuites("drs.rpc")
222 ncacn_ip_tcp_tests = ["rpc.schannel", "rpc.join", "rpc.lsa", "rpc.dssetup", "rpc.altercontext", "rpc.multibind", "rpc.netlogon", "rpc.handles", "rpc.asyncbind", "rpc.lsalookup", "rpc.lsa-getuser", "rpc.schannel2", "rpc.authcontext", "rpc.objectuuid"] + drs_rpc_tests
223 slow_ncacn_np_tests = ["rpc.samlogon", "rpc.samr.users", "rpc.samr.large-dc", "rpc.samr.users.privileges", "rpc.samr.passwords", "rpc.samr.passwords.pwdlastset"]
224 slow_ncacn_ip_tcp_tests = ["rpc.samr", "rpc.cracknames"]
225
226 all_rpc_tests = ncalrpc_tests + ncacn_np_tests + ncacn_ip_tcp_tests + slow_ncacn_np_tests + slow_ncacn_ip_tcp_tests + ["rpc.lsa.secrets", "rpc.pac", "rpc.samba3-sharesec", "rpc.countcalls"]
227
228 # Make sure all tests get run
229 rpc_tests = smb4torture_testsuites("rpc.")
230 auto_rpc_tests = filter(lambda t: t not in all_rpc_tests, rpc_tests)
231
232 for bindoptions in ["seal,padcheck"] + validate_list + ["bigendian"]:
233     for transport in ["ncalrpc", "ncacn_np", "ncacn_ip_tcp"]:
234         env = "dc"
235         if transport == "ncalrpc":
236             tests = ncalrpc_tests
237             env = "dc:local"
238         elif transport == "ncacn_np":
239             tests = ncacn_np_tests
240         elif transport == "ncacn_ip_tcp":
241             tests = ncacn_ip_tcp_tests
242         for t in tests:
243             plantestsuite_loadlist("samba4.%s on %s with %s" % (t, transport, bindoptions), env, [valgrindify(smb4torture), "$LISTOPT", "%s:$SERVER[%s]" % (transport, bindoptions), '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', t])
244         plantestsuite_loadlist("samba4.rpc.samba3.sharesec on %s with %s" % (transport, bindoptions), env, [valgrindify(smb4torture), "$LISTOPT", "%s:$SERVER[%s]" % (transport, bindoptions), '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', '--option=torture:share=tmp', 'rpc.samba3-sharesec'])
245
246 for bindoptions in [""] + validate_list + ["bigendian"]:
247     for t in auto_rpc_tests:
248         plantestsuite_loadlist("samba4.%s with %s" % (t, bindoptions), "dc", [valgrindify(smb4torture), "$LISTOPT", "$SERVER[%s]" % bindoptions, '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', t])
249
250 t = "rpc.countcalls"
251 plantestsuite_loadlist("samba4.%s" % t, "dc:local", [valgrindify(smb4torture), "$LISTOPT", "$SERVER[%s]" % bindoptions, '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', t])
252
253 for transport in ["ncacn_np", "ncacn_ip_tcp"]:
254     env = "dc"
255     if transport == "ncacn_np":
256         tests = slow_ncacn_np_tests
257     elif transport == "ncacn_ip_tcp":
258         tests = slow_ncacn_ip_tcp_tests
259     for t in tests:
260         plantestsuite_loadlist("samba4.%s on %s" % (t, transport), env, [valgrindify(smb4torture), "$LISTOPT", "%s:$SERVER" % transport, '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', t])
261
262 # Tests for the DFS referral calls implementation
263 for t in smb4torture_testsuites("dfs."):
264     plansmbtorturetestsuite(t, "dc", '//$SERVER/ipc\$ -U$USERNAME%$PASSWORD')
265
266 # Tests for the NET API (net.api.become.dc tested below against all the roles)
267 net_tests = filter(lambda x: "net.api.become.dc" not in x, smb4torture_testsuites("net."))
268 for t in net_tests:
269     plansmbtorturetestsuite(t, "dc", '$SERVER[%s] -U$USERNAME%%$PASSWORD -W $DOMAIN' % validate)
270
271 # Tests for session keys and encryption of RPC pipes
272 # FIXME: Integrate these into a single smbtorture test
273
274 transport = "ncacn_np"
275 for ntlmoptions in [
276     "-k no --option=usespnego=yes",
277     "-k no --option=usespnego=yes --option=ntlmssp_client:128bit=no",
278     "-k no --option=usespnego=yes --option=ntlmssp_client:56bit=yes",
279     "-k no --option=usespnego=yes --option=ntlmssp_client:56bit=no",
280     "-k no --option=usespnego=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:56bit=yes",
281     "-k no --option=usespnego=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:56bit=no",
282     "-k no --option=usespnego=yes --option=clientntlmv2auth=yes",
283     "-k no --option=usespnego=yes --option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no",
284     "-k no --option=usespnego=yes --option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:56bit=yes",
285     "-k no --option=usespnego=no --option=clientntlmv2auth=yes",
286     "-k no --option=gensec:spnego=no --option=clientntlmv2auth=yes",
287     "-k no --option=usespnego=no"]:
288     name = "rpc.lsa.secrets on %s with with %s" % (transport, ntlmoptions)
289     plantestsuite_loadlist("samba4.%s" % name, "dc", [smb4torture, "$LISTOPT", "%s:$SERVER[]" % (transport), ntlmoptions, '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', '--option=gensec:target_hostname=$NETBIOSNAME', 'rpc.lsa.secrets'])
290
291 transports = ["ncacn_np", "ncacn_ip_tcp"]
292
293 #Kerberos varies between functional levels, so it is important to check this on all of them
294 for env in ["dc", "fl2000dc", "fl2003dc", "fl2008r2dc"]:
295     transport = "ncacn_np"
296     plantestsuite_loadlist("samba4.rpc.pac on %s" % (transport,), env, [smb4torture, "$LISTOPT", "%s:$SERVER[]" % (transport, ), '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', 'rpc.pac'])
297     for transport in transports:
298         plantestsuite_loadlist("samba4.rpc.lsa.secrets on %s with Kerberos" % (transport,), env, [smb4torture, "$LISTOPT", "%s:$SERVER[]" % (transport, ), '-k', 'yes', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', '--option=gensec:target_hostname=$NETBIOSNAME', 'rpc.lsa.secrets'])
299         plantestsuite_loadlist("samba4.rpc.lsa.secrets on %s with Kerberos - use target principal" % (transport,), env, [smb4torture, "$LISTOPT", "%s:$SERVER[]" % (transport, ), '-k', 'yes', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', "--option=clientusespnegoprincipal=yes", '--option=gensec:target_hostname=$NETBIOSNAME', 'rpc.lsa.secrets'])
300         plantestsuite_loadlist("samba4.rpc.lsa.secrets on %s with Kerberos - use Samba3 style login" % transport, env, [smb4torture, "$LISTOPT", "%s:$SERVER" % transport, '-k', 'yes', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', "--option=gensec:fake_gssapi_krb5=yes", '--option=gensec:gssapi_krb5=no', '--option=gensec:target_hostname=$NETBIOSNAME', "rpc.lsa.secrets.none*"])
301         plantestsuite_loadlist("samba4.rpc.lsa.secrets on %s with Kerberos - use Samba3 style login, use target principal" % transport, env, [smb4torture, "$LISTOPT", "%s:$SERVER" % transport, '-k', 'yes', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', "--option=clientusespnegoprincipal=yes", '--option=gensec:fake_gssapi_krb5=yes', '--option=gensec:gssapi_krb5=no', '--option=gensec:target_hostname=$NETBIOSNAME', "rpc.lsa.secrets.none*"])
302         plantestsuite_loadlist("samba4.rpc.echo on %s" % (transport, ), env, [smb4torture, "$LISTOPT", "%s:$SERVER[]" % (transport,), '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', 'rpc.echo'])
303
304         # Echo tests test bulk Kerberos encryption of DCE/RPC
305         for bindoptions in ["connect", "spnego", "spnego,sign", "spnego,seal"] + validate_list + ["padcheck", "bigendian", "bigendian,seal"]:
306             echooptions = "--option=socket:testnonblock=True --option=torture:quick=yes -k yes"
307             plantestsuite_loadlist("samba4.rpc.echo on %s with %s and %s" % (transport, bindoptions, echooptions), env, [smb4torture, "$LISTOPT", "%s:$SERVER[%s]" % (transport, bindoptions), echooptions, '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', 'rpc.echo'])
308     plansmbtorturetestsuite("net.api.become.dc", env, '$SERVER[%s] -U$USERNAME%%$PASSWORD -W $DOMAIN' % validate)
309
310 for transport in transports:
311     for bindoptions in ["sign", "seal"]:
312         for ntlmoptions in [
313         "--option=ntlmssp_client:ntlm2=yes --option=torture:quick=yes",
314         "--option=ntlmssp_client:ntlm2=no --option=torture:quick=yes",
315         "--option=ntlmssp_client:ntlm2=yes --option=ntlmssp_client:128bit=no --option=torture:quick=yes",
316         "--option=ntlmssp_client:ntlm2=no --option=ntlmssp_client:128bit=no --option=torture:quick=yes",
317         "--option=ntlmssp_client:ntlm2=yes --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes",
318         "--option=ntlmssp_client:ntlm2=no --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes",
319         "--option=clientntlmv2auth=yes --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes",
320         "--option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:keyexchange=yes --option=torture:quick=yes",
321         "--option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes"]:
322             if transport == "ncalrpc":
323                 env = "dc:local"
324             else:
325                 env = "dc"
326             plantestsuite_loadlist("samba4.rpc.echo on %s with %s and %s" % (transport, bindoptions, ntlmoptions), env, [smb4torture, "$LISTOPT", "%s:$SERVER[%s]" % (transport, bindoptions), ntlmoptions, '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', 'rpc.echo'])
327
328 plantestsuite_loadlist("samba4.rpc.echo on ncacn_np over smb2", "dc", [smb4torture, "$LISTOPT", 'ncacn_np:$SERVER[smb2]', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', 'rpc.echo'])
329
330 plantestsuite_loadlist("samba4.ntp.signd", "dc:local", [smb4torture, "$LISTOPT", 'ncacn_np:$SERVER', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', 'ntp.signd'])
331
332 # Tests against the NTVFS POSIX backend
333 ntvfsargs = ["--option=torture:sharedelay=10000", "--option=torture:oplocktimeout=3", "--option=torture:writetimeupdatedelay=50000"]
334
335 smb2 = smb4torture_testsuites("smb2.")
336 #The QFILEINFO-IPC test needs to be on ipc$
337 raw = filter(lambda x: "raw.qfileinfo.ipc" not in x, smb4torture_testsuites("raw."))
338 base = smb4torture_testsuites("base.")
339
340 for t in base + raw + smb2:
341     plansmbtorturetestsuite(t, "dc", '//$SERVER/tmp -U$USERNAME%$PASSWORD' + " " + " ".join(ntvfsargs))
342
343 plansmbtorturetestsuite("raw.qfileinfo.ipc", "dc", '//$SERVER/ipc\$ -U$USERNAME%$PASSWORD')
344
345 for t in smb4torture_testsuites("rap."):
346     plansmbtorturetestsuite(t, "dc", '//$SERVER/IPC\$ -U$USERNAME%$PASSWORD')
347
348 # Tests against the NTVFS CIFS backend
349 for t in base + raw:
350     plantestsuite_loadlist("samba4.ntvfs.cifs.%s" % t, "dc", [valgrindify(smb4torture), "$LISTOPT", '//$NETBIOSNAME/cifs', '-U$USERNAME%$PASSWORD'] + ntvfsargs + [t])
351
352 plansmbtorturetestsuite('echo.udp', 'dc:local', '//$SERVER/whatever')
353
354 # Local tests
355 for t in smb4torture_testsuites("local."):
356     plansmbtorturetestsuite(t, "none", "ncalrpc:")
357
358 tdbtorture4 = binpath("tdbtorture")
359 if os.path.exists(tdbtorture4):
360     plantestsuite("tdb.stress", "none", valgrindify(tdbtorture4))
361 else:
362     skiptestsuite("tdb.stress", "Using system TDB, tdbtorture not available")
363
364 plansmbtorturetestsuite("drs.unit", "none", "ncalrpc:")
365
366 # Pidl tests
367 for f in sorted(os.listdir(os.path.join(samba4srcdir, "../pidl/tests"))):
368     if f.endswith(".pl"):
369         planperltestsuite("pidl.%s" % f[:-3], os.path.normpath(os.path.join(samba4srcdir, "../pidl/tests", f)))
370 planperltestsuite("selftest.samba4", os.path.normpath(os.path.join(samba4srcdir, "../selftest/test_samba4.pl")))
371
372 # Blackbox Tests:
373 # tests that interact directly with the command-line tools rather than using
374 # the API. These mainly test that the various command-line options of commands
375 # work correctly.
376
377 planpythontestsuite("none", "samba.tests.blackbox.ndrdump")
378 plantestsuite("samba4.blackbox.samba_tool(dc:local)", "dc:local", [os.path.join(samba4srcdir, "utils/tests/test_samba_tool.sh"),  '$SERVER', "$USERNAME", "$PASSWORD", "$DOMAIN"])
379 plantestsuite("samba4.blackbox.pkinit(dc:local)", "dc:local", [os.path.join(bbdir, "test_pkinit.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$REALM', '$DOMAIN', '$PREFIX', "aes256-cts-hmac-sha1-96", configuration])
380 plantestsuite("samba4.blackbox.kinit(dc:local)", "dc:local", [os.path.join(bbdir, "test_kinit.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$REALM', '$DOMAIN', '$PREFIX', "aes256-cts-hmac-sha1-96", configuration])
381 plantestsuite("samba4.blackbox.kinit(fl2000dc:local)", "fl2000dc:local", [os.path.join(bbdir, "test_kinit.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$REALM', '$DOMAIN', '$PREFIX', "arcfour-hmac-md5", configuration])
382 plantestsuite("samba4.blackbox.kinit(fl2008r2dc:local)", "fl2008r2dc:local", [os.path.join(bbdir, "test_kinit.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$REALM', '$DOMAIN', '$PREFIX', "aes256-cts-hmac-sha1-96", configuration])
383 plantestsuite("samba4.blackbox.ktpass(dc)", "dc", [os.path.join(bbdir, "test_ktpass.sh"), '$PREFIX'])
384 plantestsuite("samba4.blackbox.passwords(dc:local)", "dc:local", [os.path.join(bbdir, "test_passwords.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$REALM', '$DOMAIN', "$PREFIX"])
385 plantestsuite("samba4.blackbox.export.keytab(dc:local)", "dc:local", [os.path.join(bbdir, "test_export_keytab.sh"), '$SERVER', '$USERNAME', '$REALM', '$DOMAIN', "$PREFIX"])
386 plantestsuite("samba4.blackbox.cifsdd(dc)", "dc", [os.path.join(samba4srcdir, "client/tests/test_cifsdd.sh"), '$SERVER', '$USERNAME', '$PASSWORD', "$DOMAIN"])
387 plantestsuite("samba4.blackbox.nmblookup(dc)", "dc", [os.path.join(samba4srcdir, "utils/tests/test_nmblookup.sh"), '$NETBIOSNAME', '$NETBIOSALIAS', '$SERVER', '$SERVER_IP'])
388 plantestsuite("samba4.blackbox.nmblookup(member)", "member", [os.path.join(samba4srcdir, "utils/tests/test_nmblookup.sh"), '$NETBIOSNAME', '$NETBIOSALIAS', '$SERVER', '$SERVER_IP'])
389 plantestsuite("samba4.blackbox.locktest(dc)", "dc", [os.path.join(samba4srcdir, "torture/tests/test_locktest.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$DOMAIN', '$PREFIX'])
390 plantestsuite("samba4.blackbox.masktest", "dc", [os.path.join(samba4srcdir, "torture/tests/test_masktest.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$DOMAIN', '$PREFIX'])
391 plantestsuite("samba4.blackbox.gentest(dc)", "dc", [os.path.join(samba4srcdir, "torture/tests/test_gentest.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$DOMAIN', "$PREFIX"])
392 plantestsuite("samba4.blackbox.wbinfo(dc:local)", "dc:local", [os.path.join(samba4srcdir, "../nsswitch/tests/test_wbinfo.sh"), '$DOMAIN', '$USERNAME', '$PASSWORD', "dc"])
393 plantestsuite("samba4.blackbox.wbinfo(member:local)", "member:local", [os.path.join(samba4srcdir, "../nsswitch/tests/test_wbinfo.sh"), '$DOMAIN', '$DC_USERNAME', '$DC_PASSWORD', "member"])
394 plantestsuite("samba4.blackbox.chgdcpass(dc)", "dc", [os.path.join(bbdir, "test_chgdcpass.sh"), '$SERVER', "LOCALDC\$", '$REALM', '$DOMAIN', '$PREFIX', "aes256-cts-hmac-sha1-96", '$SELFTEST_PREFIX/dc'])
395
396 # Tests using the "Simple" NTVFS backend
397 for t in ["base.rw1"]:
398     plantestsuite_loadlist("samba4.ntvfs.simple.%s" % t, "dc", [valgrindify(smb4torture), "$LISTOPT", "//$SERVER/simple", '-U$USERNAME%$PASSWORD', t])
399
400 # Domain Member Tests
401 plantestsuite_loadlist("samba4.rpc.echo against member server with local creds", "member", [valgrindify(smb4torture), "$LISTOPT", 'ncacn_np:$NETBIOSNAME', '-U$NETBIOSNAME/$USERNAME%$PASSWORD', 'rpc.echo'])
402 plantestsuite_loadlist("samba4.rpc.echo against member server with domain creds", "member", [valgrindify(smb4torture), "$LISTOPT", 'ncacn_np:$NETBIOSNAME', '-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD', 'rpc.echo'])
403 plantestsuite_loadlist("samba4.rpc.samr against member server with local creds", "member", [valgrindify(smb4torture), "$LISTOPT", 'ncacn_np:$NETBIOSNAME', '-U$NETBIOSNAME/$USERNAME%$PASSWORD', "rpc.samr"])
404 plantestsuite_loadlist("samba4.rpc.samr.users against member server with local creds", "member", [valgrindify(smb4torture), "$LISTOPT", 'ncacn_np:$NETBIOSNAME', '-U$NETBIOSNAME/$USERNAME%$PASSWORD', "rpc.samr.users"])
405 plantestsuite_loadlist("samba4.rpc.samr.passwords against member server with local creds", "member", [valgrindify(smb4torture), "$LISTOPT", 'ncacn_np:$NETBIOSNAME', '-U$NETBIOSNAME/$USERNAME%$PASSWORD', "rpc.samr.passwords"])
406 plantestsuite("samba4.blackbox.smbclient against member server with local creds", "member", [os.path.join(samba4srcdir, "client/tests/test_smbclient.sh"), '$NETBIOSNAME', '$USERNAME', '$PASSWORD', '$NETBIOSNAME', '$PREFIX'])
407
408 # RPC Proxy
409 plantestsuite_loadlist("samba4.rpc.echo against rpc proxy with domain creds", "rpc_proxy", [valgrindify(smb4torture), "$LISTOPT", 'ncacn_ip_tcp:$NETBIOSNAME', '-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD', "rpc.echo"])
410
411 # Tests SMB signing
412 for mech in [
413     "-k no",
414     "-k no --option=usespnego=no",
415     "-k no --option=gensec:spengo=no",
416     "-k yes",
417     "-k yes --option=gensec:fake_gssapi_krb5=yes --option=gensec:gssapi_krb5=no"]:
418     for signing in ["--signing=on", "--signing=required"]:
419         signoptions = "%s %s" % (mech, signing)
420         name = "smb.signing on with %s" % signoptions
421         plantestsuite_loadlist("samba4.%s" % name, "dc", [valgrindify(smb4torture), "$LISTOPT", '//$NETBIOSNAME/tmp', signoptions, '-U$USERNAME%$PASSWORD', 'base.xcopy'])
422
423 for mech in [
424     "-k no",
425     "-k no --option=usespnego=no",
426     "-k no --option=gensec:spengo=no",
427     "-k yes",
428     "-k yes --option=gensec:fake_gssapi_krb5=yes --option=gensec:gssapi_krb5=no"]:
429     signoptions = "%s --signing=off" % mech
430     name = "smb.signing on with %s" % signoptions
431     plantestsuite_loadlist("samba4.%s domain-creds" % name, "member", [valgrindify(smb4torture), "$LISTOPT", '//$NETBIOSNAME/tmp', signoptions, '-U$DC_USERNAME%$DC_PASSWORD', 'base.xcopy'])
432
433 for mech in [
434     "-k no",
435     "-k no --option=usespnego=no",
436     "-k no --option=gensec:spengo=no"]:
437     signoptions = "%s --signing=off" % mech
438     name = "smb.signing on with %s" % signoptions
439     plantestsuite_loadlist("samba4.%s local-creds" % name, "member", [valgrindify(smb4torture), "$LISTOPT", '//$NETBIOSNAME/tmp', signoptions, '-U$NETBIOSNAME/$USERNAME%$PASSWORD', 'base.xcopy'])
440 plantestsuite_loadlist("samba4.smb.signing --signing=yes anon", "dc", [valgrindify(smb4torture), "$LISTOPT", '//$NETBIOSNAME/tmp', '-k', 'no', '--signing=yes', '-U%', 'base.xcopy'])
441 plantestsuite_loadlist("samba4.smb.signing --signing=required anon", "dc", [valgrindify(smb4torture), "$LISTOPT", '//$NETBIOSNAME/tmp', '-k', 'no', '--signing=required', '-U%', 'base.xcopy'])
442 plantestsuite_loadlist("samba4.smb.signing --signing=no anon", "member",  [valgrindify(smb4torture), "$LISTOPT", '//$NETBIOSNAME/tmp', '-k', 'no', '--signing=no', '-U%', 'base.xcopy'])
443
444 nbt_tests = smb4torture_testsuites("nbt.")
445 for t in nbt_tests:
446     plansmbtorturetestsuite(t, "dc", "//$SERVER/_none_ -U\"$USERNAME%$PASSWORD\"")
447
448 wb_opts = ["--option=\"torture:strict mode=no\"", "--option=\"torture:timelimit=1\"", "--option=\"torture:winbindd_separator=/\"", "--option=\"torture:winbindd_netbios_name=$SERVER\"", "--option=\"torture:winbindd_netbios_domain=$DOMAIN\""]
449
450 winbind_struct_tests = smb4torture_testsuites("winbind.struct")
451 winbind_ndr_tests = smb4torture_testsuites("winbind.ndr")
452 for env in ["dc", "member"]:
453     for t in winbind_struct_tests:
454         plansmbtorturetestsuite(t, env, "%s //_none_/_none_" % " ".join(wb_opts))
455
456     for t in winbind_ndr_tests:
457         plansmbtorturetestsuite(t, env, "%s //_none_/_none_" % " ".join(wb_opts))
458
459 nsstest4 = binpath("nsstest")
460 if os.path.exists(nsstest4):
461     plantestsuite("samba4.nss.test using winbind(member)", "member", [valgrindify(nsstest4), os.path.join(samba4bindir, "shared/libnss_winbind.so")])
462 else:
463     skiptestsuite("samba4.nss.test using winbind(member)", "nsstest not available")
464
465 subunitrun = valgrindify(python) + " " + os.path.join(samba4srcdir, "scripting/bin/subunitrun")
466 def plansambapythontestsuite(name, env, path, module, environ={}, extra_args=[]):
467     environ = dict(environ)
468     environ["PYTHONPATH"] = "$PYTHONPATH:" + path
469     args = ["%s=%s" % item for item in environ.iteritems()]
470     args += [subunitrun, "$LISTOPT", module]
471     args += extra_args
472     plantestsuite(name, env, args)
473
474
475 plansambapythontestsuite("ldb.python", "none", "./lib/ldb/tests/python/", 'api')
476 planpythontestsuite("none", "samba.tests.credentials")
477 planpythontestsuite("none", "samba.tests.gensec")
478 planpythontestsuite("none", "samba.tests.registry")
479 plansambapythontestsuite("tdb.python", "none", "../lib/tdb/python/tests", 'simple')
480 planpythontestsuite("none", "samba.tests.auth")
481 planpythontestsuite("none", "samba.tests.security")
482 planpythontestsuite("none", "samba.tests.dcerpc.misc")
483 planpythontestsuite("none", "samba.tests.param")
484 planpythontestsuite("none", "samba.tests.upgrade")
485 planpythontestsuite("none", "samba.tests.core")
486 planpythontestsuite("none", "samba.tests.provision")
487 planpythontestsuite("none", "samba.tests.samba3")
488 planpythontestsuite("dc:local", "samba.tests.dcerpc.sam")
489 planpythontestsuite("dc:local", "samba.tests.dsdb")
490 planpythontestsuite("none", "samba.tests.netcmd")
491 planpythontestsuite("dc:local", "samba.tests.dcerpc.bare")
492 planpythontestsuite("dc:local", "samba.tests.dcerpc.unix")
493 planpythontestsuite("none", "samba.tests.dcerpc.rpc_talloc")
494 planpythontestsuite("none", "samba.tests.samdb")
495 planpythontestsuite("none", "samba.tests.hostconfig")
496 planpythontestsuite("none", "samba.tests.messaging")
497 planpythontestsuite("none", "samba.tests.samba3sam")
498 planpythontestsuite("none", "subunit")
499 planpythontestsuite("dc:local", "samba.tests.dcerpc.rpcecho")
500 plantestsuite_idlist("samba.tests.dcerpc.registry", "dc:local", [subunitrun, "$LISTOPT", '-U"$USERNAME%$PASSWORD"', "samba.tests.dcerpc.registry"])
501 plantestsuite("samba4.ldap.python(dc)", "dc", [python, os.path.join(samba4srcdir, "dsdb/tests/python/ldap.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '-W', '$DOMAIN'])
502 plantestsuite("samba4.tokengroups.python(dc)", "dc", [python, os.path.join(samba4srcdir, "dsdb/tests/python/token_group.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '-W', '$DOMAIN'])
503 plantestsuite("samba4.sam.python(dc)", "dc", [python, os.path.join(samba4srcdir, "dsdb/tests/python/sam.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '-W', '$DOMAIN'])
504 plansambapythontestsuite("samba4.schemaInfo.python(dc)", "dc", os.path.join(samba4srcdir, 'dsdb/tests/python'), 'dsdb_schema_info', extra_args=['-U"$DOMAIN/$DC_USERNAME%$DC_PASSWORD"'])
505 plantestsuite("samba4.urgent_replication.python(dc)", "dc", [python, os.path.join(samba4srcdir, "dsdb/tests/python/urgent_replication.py"), '$PREFIX_ABS/dc/private/sam.ldb'], allow_empty_output=True)
506 for env in ["dc", "fl2000dc", "fl2003dc", "fl2008r2dc"]:
507     plantestsuite("samba4.ldap_schema.python(%s)" % env, env, [python, os.path.join(samba4srcdir, "dsdb/tests/python/ldap_schema.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '-W', '$DOMAIN'])
508     plantestsuite("samba4.ldap.possibleInferiors.python(%s)" % env, env, [python, os.path.join(samba4srcdir, "dsdb/samdb/ldb_modules/tests/possibleinferiors.py"), "ldap://$SERVER", '-U"$USERNAME%$PASSWORD"', "-W", "$DOMAIN"])
509     plantestsuite("samba4.ldap.secdesc.python(%s)" % env, env, [python, os.path.join(samba4srcdir, "dsdb/tests/python/sec_descriptor.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '-W', '$DOMAIN'])
510     plantestsuite("samba4.ldap.acl.python(%s)" % env, env, [python, os.path.join(samba4srcdir, "dsdb/tests/python/acl.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '-W', '$DOMAIN'])
511     if env != "fl2000dc":
512         # This test makes excessively use of the "userPassword" attribute which
513         # isn't available on DCs with Windows 2000 domain function level -
514         # therefore skip it in that configuration
515         plantestsuite("samba4.ldap.passwords.python(%s)" % env, env, [python, os.path.join(samba4srcdir, "dsdb/tests/python/passwords.py"), "$SERVER", '-U"$USERNAME%$PASSWORD"', "-W", "$DOMAIN"])
516 planpythontestsuite("dc:local", "samba.tests.upgradeprovisionneeddc")
517 planpythontestsuite("none", "samba.tests.upgradeprovision")
518 planpythontestsuite("none", "samba.tests.xattr")
519 planpythontestsuite("none", "samba.tests.ntacls")
520 plantestsuite("samba4.deletetest.python(dc)", "dc", ['PYTHONPATH="$PYTHONPATH:../lib/subunit/python:../lib/testtools"', python, os.path.join(samba4srcdir, "dsdb/tests/python/deletetest.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '-W', '$DOMAIN'])
521 plansambapythontestsuite("samba4.policy.python", "none", "lib/policy/tests/python", 'bindings')
522 plantestsuite("samba4.blackbox.samba3dump", "none", [python, os.path.join(samba4srcdir, "scripting/bin/samba3dump"), os.path.join(samba4srcdir, "../testdata/samba3")], allow_empty_output=True)
523 plantestsuite("samba4.blackbox.upgrade", "none", ["rm -rf $PREFIX/upgrade;", python, os.path.join(samba4srcdir, "setup/upgrade_from_s3"), "--targetdir=$PREFIX/upgrade", os.path.normpath(os.path.join(samba4srcdir, "../testdata/samba3")), os.path.normpath(os.path.join(samba4srcdir, "../testdata/samba3/smb.conf"))], allow_empty_output=True)
524 plantestsuite("samba4.blackbox.provision.py", "none", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_provision.sh"), '$PREFIX/provision'])
525 plantestsuite("samba4.blackbox.upgradeprovision.py", "none", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_upgradeprovision.sh"), '$PREFIX/provision'])
526 plantestsuite("samba4.blackbox.setpassword.py", "none", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_setpassword.sh"), '$PREFIX/provision'])
527 plantestsuite("samba4.blackbox.newuser.py", "none", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_newuser.sh"), '$PREFIX/provision'])
528 plantestsuite("samba4.blackbox.group.py", "none", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_group.sh"), '$PREFIX/provision'])
529 plantestsuite("samba4.blackbox.spn.py(dc:local)", "dc:local", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_spn.sh"), '$PREFIX/dc'])
530 plantestsuite("samba4.ldap.bind(dc)", "dc", [python, os.path.join(samba4srcdir, "auth/credentials/tests/bind.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"'])
531
532 # DRS python tests
533 plansambapythontestsuite("samba4.drs.delete_object.python(vampire_dc)", "vampire_dc", os.path.join(samba4srcdir, 'torture/drs/python'), "delete_object", environ={'DC1': '$DC_SERVER', 'DC2': '$VAMPIRE_DC_SERVER'}, extra_args=['-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD'])
534 plansambapythontestsuite("samba4.drs.fsmo.python(vampire_dc)", "vampire_dc", os.path.join(samba4srcdir, 'torture/drs/python'), "fsmo", environ={'DC1': "$DC_SERVER", 'DC2': "$VAMPIRE_DC_SERVER"}, extra_args=['-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD'])
535 plansambapythontestsuite("samba4.drs.repl_schema.python(vampire_dc)", "vampire_dc", os.path.join(samba4srcdir, 'torture/drs/python'), "repl_schema", environ={'DC1': "$DC_SERVER", 'DC2': '$VAMPIRE_DC_SERVER'}, extra_args=['-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD'])
536
537 # This makes sure we test the rid allocation code
538 t = "rpc.samr.large-dc"
539 plantestsuite_loadlist("samba4.%s.one" % t, "vampire_dc", [valgrindify(smb4torture), "$LISTOPT", '$SERVER', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', t])
540 plantestsuite_loadlist("samba4.%s.two" % t, "vampire_dc", [valgrindify(smb4torture), "$LISTOPT", '$SERVER', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', t])
541
542 # some RODC testing
543 plantestsuite_loadlist("samba4.rpc.echo", "rodc", [smb4torture, "$LISTOPT", 'ncacn_np:$SERVER', "-k", "yes", '-U$USERNAME%$PASSWORD', '-W' '$DOMAIN', 'rpc.echo'])
544 plantestsuite("samba4.blackbox.provision-backend.py", "none", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_provision-backend.sh"), '$PREFIX/provision'])