selftest/tests.py: test pam_winbind with a lot of username variations
[metze/samba/wip.git] / 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 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, 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 and makes
13 # it possible to run the testsuite against other servers, such as
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 from selftesthelpers import bindir, srcdir, python
23 from selftesthelpers import planpythontestsuite, samba4srcdir
24 from selftesthelpers import plantestsuite, bbdir
25 from selftesthelpers import configuration, valgrindify
26 from selftesthelpers import skiptestsuite
27
28 try:
29     config_h = os.environ["CONFIG_H"]
30 except KeyError:
31     samba4bindir = bindir()
32     config_h = os.path.join(samba4bindir, "default/include/config.h")
33
34 # check available features
35 config_hash = dict()
36 f = open(config_h, 'r')
37 try:
38     lines = f.readlines()
39     config_hash = dict((x[0], ' '.join(x[1:]))
40                        for x in map(lambda line: line.strip().split(' ')[1:],
41                                     list(filter(lambda line: (line[0:7] == '#define') and (len(line.split(' ')) > 2), lines))))
42 finally:
43     f.close()
44
45 have_man_pages_support = ("XSLTPROC_MANPAGES" in config_hash)
46 with_pam = ("WITH_PAM" in config_hash)
47 pam_wrapper_so_path = config_hash["LIBPAM_WRAPPER_SO_PATH"]
48 pam_set_items_so_path = config_hash["PAM_SET_ITEMS_SO_PATH"]
49
50 planpythontestsuite("none", "samba.tests.source")
51 if have_man_pages_support:
52     planpythontestsuite("none", "samba.tests.docs")
53
54 try:
55     import testscenarios
56 except ImportError:
57     skiptestsuite("subunit", "testscenarios not available")
58 else:
59     planpythontestsuite("none", "subunit.tests.test_suite")
60 planpythontestsuite("none", "samba.tests.blackbox.ndrdump")
61 planpythontestsuite("none", "samba.tests.blackbox.check_output")
62 planpythontestsuite("none", "api", name="ldb.python", extra_path=['lib/ldb/tests/python'])
63 planpythontestsuite("none", "samba.tests.credentials")
64 planpythontestsuite("none", "samba.tests.registry")
65 planpythontestsuite("ad_dc_ntvfs:local", "samba.tests.auth")
66 planpythontestsuite("none", "samba.tests.get_opt")
67 planpythontestsuite("none", "samba.tests.security")
68 planpythontestsuite("none", "samba.tests.dcerpc.misc")
69 planpythontestsuite("none", "samba.tests.dcerpc.integer")
70 planpythontestsuite("none", "samba.tests.param")
71 planpythontestsuite("none", "samba.tests.upgrade")
72 planpythontestsuite("none", "samba.tests.core")
73 planpythontestsuite("none", "samba.tests.common")
74 planpythontestsuite("none", "samba.tests.provision")
75 planpythontestsuite("none", "samba.tests.password_quality")
76 planpythontestsuite("none", "samba.tests.strings")
77 planpythontestsuite("none", "samba.tests.netcmd")
78 planpythontestsuite("none", "samba.tests.dcerpc.rpc_talloc")
79 planpythontestsuite("none", "samba.tests.dcerpc.array")
80 planpythontestsuite("none", "samba.tests.dcerpc.string_tests")
81 planpythontestsuite("none", "samba.tests.hostconfig")
82 planpythontestsuite("ad_dc_ntvfs:local", "samba.tests.messaging")
83 planpythontestsuite("none", "samba.tests.s3param")
84 planpythontestsuite("none", "samba.tests.s3passdb")
85 planpythontestsuite("none", "samba.tests.s3registry")
86 planpythontestsuite("none", "samba.tests.s3windb")
87 planpythontestsuite("none", "samba.tests.s3idmapdb")
88 planpythontestsuite("none", "samba.tests.samba3sam")
89 planpythontestsuite(
90     "none", "wafsamba.tests.test_suite",
91     extra_path=[os.path.join(samba4srcdir, "..", "buildtools"),
92                 os.path.join(samba4srcdir, "..", "third_party", "waf")])
93
94
95 def cmdline(script, *args):
96     """
97     Prefix PYTHON env var and append --configurefile option to abs script path.
98
99     script.sh arg1 arg2
100     -->
101     PYTHON=python /path/to/bbdir/script.sh arg1 arg2 \
102     --configurefile $SMB_CONF_FILE
103     """
104     return [
105         "PYTHON=%s" % python,
106         os.path.join(bbdir, script),
107     ] + list(args) + [configuration]
108
109
110 plantestsuite(
111     "samba4.blackbox.demote-saveddb", "none",
112     cmdline('demote-saveddb.sh', '$PREFIX_ABS/demote'))
113
114 plantestsuite(
115     "samba4.blackbox.dbcheck.alpha13", "none",
116     cmdline('dbcheck-oldrelease.sh', '$PREFIX_ABS/provision',
117             'alpha13'))
118
119 # same test as above but skip member link checks
120 plantestsuite(
121     "samba4.blackbox.dbcheck.alpha13.quick", "none",
122     cmdline('dbcheck-oldrelease.sh', '$PREFIX_ABS/provision',
123             'alpha13', '--quick-membership-checks'))
124
125 plantestsuite(
126     "samba4.blackbox.dbcheck.release-4-0-0", "none",
127     cmdline('dbcheck-oldrelease.sh', '$PREFIX_ABS/provision',
128             'release-4-0-0'))
129
130 # same test as above but skip member link checks
131 plantestsuite(
132     "samba4.blackbox.dbcheck.release-4-0-0.quick", "none",
133     cmdline('dbcheck-oldrelease.sh', '$PREFIX_ABS/provision',
134             'release-4-0-0', '--quick-membership-checks'))
135
136 plantestsuite(
137     "samba4.blackbox.dbcheck.release-4-1-0rc3", "none",
138     cmdline('dbcheck-oldrelease.sh', '$PREFIX_ABS/provision',
139             'release-4-1-0rc3'))
140
141 # same test as above but skip member link checks
142 plantestsuite(
143     "samba4.blackbox.dbcheck.release-4-1-0rc3.quick", "none",
144     cmdline('dbcheck-oldrelease.sh', '$PREFIX_ABS/provision',
145             'release-4-1-0rc3', '--quick-membership-checks'))
146
147 plantestsuite(
148     "samba4.blackbox.dbcheck.release-4-1-6-partial-object", "none",
149     cmdline('dbcheck-oldrelease.sh', '$PREFIX_ABS/provision',
150             'release-4-1-6-partial-object'))
151
152 # same test as above but skip member link checks
153 plantestsuite(
154     "samba4.blackbox.dbcheck.release-4-1-6-partial-object.quick", "none",
155     cmdline('dbcheck-oldrelease.sh', '$PREFIX_ABS/provision',
156             'release-4-1-6-partial-object', '--quick-membership-checks'))
157
158 plantestsuite(
159     "samba4.blackbox.dbcheck.release-4-5-0-pre1", "none",
160     cmdline('dbcheck-oldrelease.sh', '$PREFIX_ABS/provision',
161             'release-4-5-0-pre1'))
162
163 # same test as above but skip member link checks
164 plantestsuite(
165     "samba4.blackbox.dbcheck.release-4-5-0-pre1.quick", "none",
166     cmdline('dbcheck-oldrelease.sh', '$PREFIX_ABS/provision',
167             'release-4-5-0-pre1', '--quick-membership-checks'))
168
169 plantestsuite(
170     "samba4.blackbox.upgradeprovision.alpha13", "none",
171     cmdline('upgradeprovision-oldrelease.sh', '$PREFIX_ABS/provision',
172             'alpha13'))
173
174 plantestsuite(
175     "samba4.blackbox.upgradeprovision.release-4-0-0", "none",
176     cmdline('upgradeprovision-oldrelease.sh', '$PREFIX_ABS/provision',
177             'release-4-0-0'))
178
179 plantestsuite(
180     "samba4.blackbox.tombstones-expunge.release-4-5-0-pre1", "none",
181     cmdline('tombstones-expunge.sh', '$PREFIX_ABS/provision',
182             'release-4-5-0-pre1'))
183
184 plantestsuite(
185     "samba4.blackbox.dbcheck-links.release-4-5-0-pre1", "none",
186     cmdline('dbcheck-links.sh', '$PREFIX_ABS/provision',
187             'release-4-5-0-pre1'))
188
189 plantestsuite(
190     "samba4.blackbox.runtime-links.release-4-5-0-pre1", "none",
191     cmdline('runtime-links.sh', '$PREFIX_ABS/provision',
192             'release-4-5-0-pre1'))
193
194 plantestsuite(
195     "samba4.blackbox.schemaupgrade", "none",
196     cmdline('schemaupgrade.sh', '$PREFIX_ABS/provision'))
197
198 plantestsuite(
199     "samba4.blackbox.functionalprep", "none",
200     cmdline('functionalprep.sh', '$PREFIX_ABS/provision'))
201
202 planpythontestsuite("none", "samba.tests.upgradeprovision")
203 planpythontestsuite("none", "samba.tests.xattr")
204 planpythontestsuite("none", "samba.tests.ntacls")
205 planpythontestsuite("none", "samba.tests.policy")
206 planpythontestsuite("none", "samba.tests.kcc.graph")
207 planpythontestsuite("none", "samba.tests.kcc.graph_utils")
208 planpythontestsuite("none", "samba.tests.kcc.ldif_import_export")
209 planpythontestsuite("none", "samba.tests.graph")
210 plantestsuite("wafsamba.duplicate_symbols", "none", [os.path.join(srcdir(), "buildtools/wafsamba/test_duplicate_symbol.sh")])
211 planpythontestsuite("none", "samba.tests.glue")
212 planpythontestsuite("none", "samba.tests.tdb_util")
213 planpythontestsuite("none", "samba.tests.samdb_api")
214
215 if with_pam:
216     env = "ad_member"
217     options = [
218         {
219             "description": "krb5",
220             "pam_options": "krb5_auth krb5_ccache_type=FILE",
221         },
222         {
223             "description": "default",
224             "pam_options": "",
225         },
226     ]
227     for o in options:
228         description = o["description"]
229         pam_options = "'%s'" % o["pam_options"]
230
231         plantestsuite("samba.tests.pam_winbind(local+%s)" % description, env,
232                       [os.path.join(srcdir(), "python/samba/tests/test_pam_winbind.sh"),
233                        valgrindify(python), pam_wrapper_so_path,
234                        "$SERVER", "$USERNAME", "$PASSWORD",
235                        pam_options])
236         plantestsuite("samba.tests.pam_winbind(domain1+%s)" % description, env,
237                       [os.path.join(srcdir(), "python/samba/tests/test_pam_winbind.sh"),
238                        valgrindify(python), pam_wrapper_so_path,
239                        "$DOMAIN", "$DC_USERNAME", "$DC_PASSWORD",
240                        pam_options])
241         plantestsuite("samba.tests.pam_winbind(domain2+%s)" % description, env,
242                       [os.path.join(srcdir(), "python/samba/tests/test_pam_winbind.sh"),
243                        valgrindify(python), pam_wrapper_so_path,
244                        "$REALM", "$DC_USERNAME", "$DC_PASSWORD",
245                        pam_options])
246         plantestsuite("samba.tests.pam_winbind(domain3+%s)" % description, env,
247                       [os.path.join(srcdir(), "python/samba/tests/test_pam_winbind.sh"),
248                        valgrindify(python), pam_wrapper_so_path,
249                        "''", "${DC_USERNAME}@${DOMAIN}", "$DC_PASSWORD",
250                        pam_options])
251         plantestsuite("samba.tests.pam_winbind(domain4+%s)" % description, env,
252                       [os.path.join(srcdir(), "python/samba/tests/test_pam_winbind.sh"),
253                        valgrindify(python), pam_wrapper_so_path,
254                        "''", "${DC_USERNAME}@${REALM}", "$DC_PASSWORD",
255                        pam_options])
256         plantestsuite("samba.tests.pam_winbind(domain5+%s)" % description, env,
257                       [os.path.join(srcdir(), "python/samba/tests/test_pam_winbind.sh"),
258                        valgrindify(python), pam_wrapper_so_path,
259                        "$REALM", "${DC_USERNAME}@${DOMAIN}", "$DC_PASSWORD",
260                        pam_options])
261         plantestsuite("samba.tests.pam_winbind(domain6+%s)" % description, env,
262                       [os.path.join(srcdir(), "python/samba/tests/test_pam_winbind.sh"),
263                        valgrindify(python), pam_wrapper_so_path,
264                        "$DOMAIN", "${DC_USERNAME}@${REALM}", "$DC_PASSWORD",
265                        pam_options])
266
267         for authtok_options in ["", "use_authtok", "try_authtok"]:
268             _pam_options = "'%s %s'" % (o["pam_options"], authtok_options)
269             _description = "%s %s" % (description, authtok_options)
270             plantestsuite("samba.tests.pam_winbind_chauthtok(domain+%s)" % _description, env,
271                           [os.path.join(srcdir(), "python/samba/tests/test_pam_winbind_chauthtok.sh"),
272                            valgrindify(python), pam_wrapper_so_path, pam_set_items_so_path,
273                            "$DOMAIN", "TestPamOptionsUser", "oldp@ssword0", "newp@ssword0",
274                            _pam_options, 'yes',
275                            "$DC_SERVER", "$DC_USERNAME", "$DC_PASSWORD"])
276
277         plantestsuite("samba.tests.pam_winbind_warn_pwd_expire(domain+%s)" % description, env,
278                       [os.path.join(srcdir(), "python/samba/tests/test_pam_winbind_warn_pwd_expire.sh"),
279                        valgrindify(python), pam_wrapper_so_path,
280                        "$DOMAIN", "alice", "Secret007",
281                        pam_options])
282
283
284 plantestsuite("samba.unittests.krb5samba", "none",
285               [os.path.join(bindir(), "default/testsuite/unittests/test_krb5samba")])
286 plantestsuite("samba.unittests.sambafs_srv_pipe", "none",
287               [os.path.join(bindir(), "default/testsuite/unittests/test_sambafs_srv_pipe")])
288 plantestsuite("samba.unittests.lib_util_modules", "none",
289               [os.path.join(bindir(), "default/testsuite/unittests/test_lib_util_modules")])
290
291 plantestsuite("samba.unittests.smb1cli_session", "none",
292               [os.path.join(bindir(), "default/libcli/smb/test_smb1cli_session")])
293
294 plantestsuite("samba.unittests.talloc_keep_secret", "none",
295               [os.path.join(bindir(), "default/lib/util/test_talloc_keep_secret")])
296
297 plantestsuite("samba.unittests.tldap", "none",
298               [os.path.join(bindir(), "default/source3/test_tldap")])
299 plantestsuite("samba.unittests.rfc1738", "none",
300               [os.path.join(bindir(), "default/lib/util/test_rfc1738")])
301 plantestsuite("samba.unittests.kerberos", "none",
302               [os.path.join(bindir(), "test_kerberos")])
303 plantestsuite("samba.unittests.ms_fnmatch", "none",
304               [os.path.join(bindir(), "default/lib/util/test_ms_fnmatch")])
305 plantestsuite("samba.unittests.byteorder", "none",
306               [os.path.join(bindir(), "default/lib/util/test_byteorder")])
307 plantestsuite("samba.unittests.ntlm_check", "none",
308               [os.path.join(bindir(), "default/libcli/auth/test_ntlm_check")])
309 plantestsuite("samba.unittests.rc4_passwd_buffer", "none",
310               [os.path.join(bindir(), "default/libcli/auth/test_rc4_passwd_buffer")])
311 plantestsuite("samba.unittests.test_registry_regfio", "none",
312               [os.path.join(bindir(), "default/source3/test_registry_regfio")])
313 plantestsuite("samba.unittests.test_oLschema2ldif", "none",
314               [os.path.join(bindir(), "default/source4/utils/oLschema2ldif/test_oLschema2ldif")])