summaryrefslogtreecommitdiff
path: root/python/samba/tests
AgeCommit message (Collapse)AuthorFilesLines
2019-03-21selftest: Remove mention of --extra-python from commentAndrew Bartlett1-1/+1
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2019-03-14tests: Make IPv4 assumption explicitTim Beale1-2/+3
This test is asserting the expected number of *IPv4* addresses, not any interface address (including IPv6). It works currently because the selftest client doesn't have an IPv6 address in its smb.conf. This patch makes the IPv4 assumption explicit by importing interface_ips_v4() from the provision code. We need to tweak this to pass through an 'all_interfaces' flag, otherwise it filters out the loopback IP addresses that the testenv is using. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-12gpo: During restore clobber GPT.INI with a blank versionGarming Sam1-7/+14
Generally speaking, there is not much value to keeping this file. The display name does not ever seem to be used and the version only applies to the original domain or DC it was on. The command line option to revert this behaviour is mostly for the tests or for having a straight 1:1 backup-restore for pure restoration. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13806 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-12gpo: Add test for saving gPCXXXExtensionNames in backupGarming Sam1-0/+69
The test only checks that the LDAP values are equal before and after. The format and specifics should be up to the implementation -- and be amenable to changes later. As long as the extension doesn't match .SAMBABACKUP or .xml, it won't be detected by the tools. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13627 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-12gpo: Add tests to make sure that an empty gplink worksGarming Sam1-0/+34
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13564 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-12test/blackbox: py3 compatible print in documentation.Douglas Bagnall1-1/+1
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-07tests/auto_log_pass_change.py: only care about the last expected message ↵Joe Guo1-39/+16
other than exact messages count The messages count could be different because of racing condition. And we should only care about the last expected one. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett abartlet@samba.org Reviewed-by: Noel Power npower@samba.org
2019-03-05tests: Reduce likelihood of auth_log test locking up during CIAaron Haslett1-12/+13
We would sometimes see the auth_log test hang during a CI run. The CI job would eventually fail after consuming a costly 10 hours of CI runtime. We believe the problem is around the test creating multiple instances of the Messaging() context. This is a similar race condition to what was seen in 19f34b2161dee26. Currently a new Messaging() context is created for every test case. By using classmethods instead, the Messaging context is only created once per python test file execution (i.e. creation of the python class, rather than initialization of the python object, which happens for every test-case). This means the test will only create one Messaging() context, which should avoid any race conditions. Changes: + removed msg_ctxs - this wasn't actually used for anything. + use classmethods to setup and tear-down the Messaging() context (and tweak lp initialization accordingly). + fix discardMessages() - the loop wasn't actually discarding any messages previously (this may also have been the cause of the test hanging). Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org> Autobuild-User(master): Noel Power <npower@samba.org> Autobuild-Date(master): Tue Mar 5 13:10:43 UTC 2019 on sn-devel-144
2019-03-04tests: Work auth_log CLIENT_IP out from config instead of env varTim Beale2-1/+11
Instead of passing the CLIENT_IP to the auth_log tests, we can just work out the source-IP that the client will use from its smb.conf file. This only works for auth_log_pass_change, but not auth_log.py - the latter still needs to be run on the :local testenv for other reasons, so it doesn't use the client.conf. However, we can still update the base code to use the client.conf IP, as auth_log.py overrides self.remoteAddress anyway. The main advantage of this change is it avoids having hardcoded IP addresses in the selftest framework. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-04tests: Work audit_log CLIENT_IP out from config instead of env varTim Beale4-3/+11
Instead of passing the CLIENT_IP to the audit_log tests, we can just work out the source-IP that the client will use from its smb.conf file. Because the audit_log tests are all run on the non-local testenv, they'll already use the client.conf and the 127.0.0.11 address. The main advantage of this change is it avoids having hardcoded IP addresses in the selftest framework. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-04tests: Remove explicit SOCKET_WRAPPER usage from auth_log testsTim Beale2-2/+19
The auth-logging tests are an odd combination of server and client behaviour. On the one hand we want a IRPC connection to see the auth events being logged on the server. On the other hand, we want the auth events to appear to be happening on a client. Currently we hardcode in the use of a SOCKET_WRAPPER interface to make this happen. We can avoid this explicit socket wrapper usage by using the server smb.conf instead in the one place we actually want to act like the server (creating the IRPC connection). Then we can switch from using the 'ad_dc*:local' testenvs to use 'ad_dc*', in order to act like a client by default. The SERVERCONFFILE environment variable has already been added for the few cases where a test needs explicit access to the server's smb.conf. However, for samba.tests.auth_log, the samlogon test cases are still reliant on being run on the :local testenv, and so we can't switch them over just yet. This is because the samlogon is using the DC's machine creds underneath, which will fail on the non-local testenv. We could create separate machine creds for the client and use those, but this is a non-trivial rework of the test code. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-04tests: Remove redundant credentials from auth_log testsTim Beale3-9/+0
The LDB connection in these tests is to the direct sam.ldb file on disk, so the credentials are not actually needed (and in fact, weren't event initialized correctly). These tests always need to run on the DC itself (i.e. :local testenv) because they use ncalrpc connections. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-21selftest: Confirm new and old SDDL strings differ after a samba-tool dsacl setAndrew Bartlett1-0/+1
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Thu Feb 21 05:37:31 CET 2019 on sn-devel-144
2019-02-21selftest: Add test for samba-tool dsacl get, cross-checked with samba-tool ↵Andrew Bartlett1-0/+30
dsacl set Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2019-02-21Update dsacl.py - add_ace to handle/verify sddl parameter correctMartin Krämer1-0/+93
Test for samba-tool dsacl set --sddl parmeter Update tests.py - add dsacl (dsacl.py / samba-tool dsacl set) test Signed-off-by: <Martin Krämer mk.maddin@gmail.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-20s3 winbind auth_log: Tests for logon id logging.Gary Lockyer1-0/+442
Tests to validate that winbind generates a random logon_id and passes it in the netlogon call. This will allow the linking of the windbind authentication requests and the SamLogon request on the DC. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-20auth_log tests: Allow the remote address to be NoneGary Lockyer1-0/+3
Allow self.remoteAddress to be None, remote address filtering is not required for the winbind auth logging tests. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-14s2 decrpc samr: Add tests for QueryDomainInfoGary Lockyer1-0/+55
Add tests for the number of domain users, groups and aliases returned by QueryDomainInfo. These tests revealed that the existing code was not checking the returned elements to ensure they were part of the domain. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-11tests/user_check_password_script: add a test do disallow the username as ↵Stefan Metzmacher1-9/+25
password Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-01Tests for segfaults in python bindingsDouglas Bagnall1-0/+126
These tests run in a child process and are regarded as succeeding if they don't die by signal. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-01selftest: Move dns_hub.py into selftest directoryTim Beale1-154/+0
As dns_hub.py is now integral to the selftest environments, it seems to make sense for it to live under the selftest/ directory. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-01dns_hub: Fix flake8 warningsTim Beale1-5/+5
Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-01-29python/tests/dns*: make use of dns.DNS_RCODE/dns.DNS_OPCODEStefan Metzmacher2-4/+4
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2019-01-19python: dns_hub: do not crash if a socket failsDouglas Bagnall1-2/+2
We print the error and keep going. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-01-17dns_hub: Rename variable to avoid naming collision in exception handlerTim Beale1-2/+2
In dns_hup.py, we are both importing the socket module and declaring a variable called socket. When we try to catch a socket.error exception (defined by the module), Python thinks we're referring to the variable. As the variable has no attribute called 'error', Python throws an exception, e.g.: File "./bin/python/samba/tests/dns_forwarder_helpers/dns_hub.py", line 123, in handle except socket.error as err: AttributeError: 'socket' object has no attribute 'error' We can avoid this problem by calling the variable 'sock' instead. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Thu Jan 17 15:23:23 CET 2019 on sn-devel-144
2019-01-17tests: Switchover auth_log from s4 SMB client bindings to s4Tim Beale1-10/+23
The main changes required are: - we need to use an s3 loadparm instead of the standard s4 lp. - the s3 SMB bindings don't support the use_spnego/ntlmv2_auth params, however, we can set these in the loadparm instead, which will get the SMB client code to do what we want. Instead of passing in boolean parameters, we need to use yes/no strings that the lp will accept. (We always set these values because the underlying lp context is actually global, and setting a value is 'sticky' and will persist across test cases. These conf settings are only used by the SMB client code, and so will only affect the SMB test cases). - For the no_spnego_no_ntlmv2 test cases, we now explicitly force it to an SMBv1 connection. The s4 bindings only ever supported SMBv1 connections, so this is the same behaviour. The other test cases will now try to negotiate SMBv2 connections, however, the no_ntlmv2 test cases are explicitly checking for bare-NTLM (with the s3 bindings, it now ends up as NTLMSSP by default). Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Jan 17 04:47:56 CET 2019 on sn-devel-144
2019-01-17tests: Refactor auth_log SMB connection to be in a single placeTim Beale1-42/+20
This should not alter the behaviour of the tests at all. It just makes it easier to switch over the underlying SMB client bindings. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-01-17tests: Use MUST_USE_KERBEROS over AUTO_USE_KERBEROS in auth_log testsTim Beale1-0/+2
The s3 SMB client bindings seem slightly different to s4, in that they default to setting the CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS flag. This seems to fallback to finding a valid KRB TGT (from a previous successful test), which results in the connection succeeding rather than failing. Setting MUST_USE_KERBEROS explicitly avoids this behaviour. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-01-17tests: Relax auth_log SMB assertions to cover v1 *or* v2Tim Beale1-6/+6
The s4 Python bindings currently only support SMBv1 connections. If we change the bindings to support *either* v1 or v2, they'll end up negotiating v2. In which case the server is "SMB2", not "SMB", and these assertions fail. Long-term we want to get rid of SMBv1, so it makes sense to write the tests so that they pass against either v1 or v2. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-01-15python: dns_hub: Fix indentation of 'raise' on error.Jeremy Allison1-3/+1
Remove second socket.sendto(). Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2019-01-15selftest: add central dns forwarderVolker Lendecke1-0/+156
This is a small DNS server that has hard redirects to the different domain controllers based on domain names. This is required because future commits will avoid calling into libresolv's code which resolv_wrapper takes care of. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-01-14tests: Change ntaclsbackup tests over to use s3 Py bindingsTim Beale1-2/+2
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2019-01-12py:dcerpc/raw_protocol: add tests to demonstrate how security context ↵Stefan Metzmacher1-0/+967
multiplexing works Important things are this: - It's not required to use the bind time feature negotiation in order to use it, it's only a hint for the client, but nothing is really negotiated, unlike the request multiplexing with the DCERPC_PFC_FLAG_CONC_MPX. - There's special handling related to AUTH_LEVEL_CONNECT and requests without auth trailer - An security context is identified by the unique tuple of auth_type, auth_level and auth_context_id (all together!), not just the auth_context_id. - There's a limit of 2049 explicit authentication contexts. BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-01-12py:dcerpc/raw_testcase: add assertEqualsStrLower()Stefan Metzmacher1-0/+3
BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-01-12py:dcerpc/raw_protocol: demonstrate that \\pipe\lsarpc returns \\pipe\lsass ↵Stefan Metzmacher1-2/+4
as secondary_address BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-01-12py:dcerpc/raw_protocol: add test_assoc_group_fail3()Stefan Metzmacher1-0/+45
This demonstrates that assoc groups are only shared on the same transport (endpoint). BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-01-12py:dcerpc/raw_protocol: add test_assoc_group_ok2 to check assoc groups over ↵Stefan Metzmacher1-0/+31
ncacn_np BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-01-12py:dcerpc/raw_protocol: enable tests with the ↵Stefan Metzmacher1-9/+3
DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN bit BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-01-12py:dcerpc/raw_protocol: consistently call self.recv_pdu(timeout=0.01) after ↵Stefan Metzmacher1-1/+3
auth3 When we don't expect a FAULT, we should wait a little bit to check there's no response to auth3 request. This reduces the raw_procol test from 45s down to 35s total runtime against Windows. BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-01-12py:dcerpc/raw_protocol: add tests for delayed header signing activationStefan Metzmacher1-0/+186
BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-01-12py:dcerpc/raw_testcase: add pfc_flags_2nd and use_auth3 options to ↵Stefan Metzmacher1-2/+17
do_generic_bind() This makes it more flexible and allows to write complex tests in an easier fashion. BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-01-11selftest: Improve an error messageVolker Lendecke1-1/+2
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org> Autobuild-Date(master): Fri Jan 11 06:01:01 CET 2019 on sn-devel-144
2019-01-09s3:libsmb: Revert SMB Py bindings name back to libsmb_samba_internalTim Beale3-3/+3
In order to make it clear that the APIs in these Python bindings are unstable and should not be used by external consumers, this patch changes the name of the Python bindings back to libsmb_samba_internal. To make the Python code that uses these bindings (i.e. samba-tool, etc) look a little cleaner, we can just change the module name as we import it, e.g. from samba.samba3 import libsmb_samba_internal as libsmb Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Wed Jan 9 14:30:31 CET 2019 on sn-devel-144
2019-01-08traffic: assert json equality in learner testDouglas Bagnall1-0/+6
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-01-08traffic tests: use TestCaseInTempdir.mktemp()Douglas Bagnall3-45/+6
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-01-08python/tests: add TestCaseInTempdir.mktemp()Douglas Bagnall1-1/+16
This gives you a name of a temporary file within the test case's tempdir. Use it like this: with self.mktemp() as filename: self.check_run("samba-tool foo --output %s" % filename) self.assertStringsEqual(open(filename).read(), expected) and filename will flick out of existence when the with block ends. This is based on an idea used in the traffic_runner tests, which will soon be adapted to use this method. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-01-08traffic_replay: --old-scale to mimic the old traffic_replayDouglas Bagnall2-0/+14
traffic_replay had a broken sense of traffic scale. That is fixed, but in order to compare old and new tests, it helps to be able to approximate the old behaviour. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-01-08traffic: add option to reanimate dying conversationsDouglas Bagnall2-0/+19
The traffic model is generated from a window in time, which makes conversations appear to start and stop unnaturally at the window boundaries. When the window is short compared to the traffic replay time and the true expected conversation length, this has a significant distorting effect, leading to more conversations than would be expected to generate a given number of packets. To offset this slightly we add the --conversation-persistence option which tries to convert apparent death into a longish wait. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-01-08traffic: generate sparser descriptions of conversationsDouglas Bagnall1-5/+0
Rather than building all the packets at this point, we stick to the barest details of the packets (which is all the model gives us anyway). The advantage is that will take a lot less memory, which matters because this process forks into many clients that were sharing and mutate the conversation list. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-01-08traffic: new version of model with packet_rate, version numberDouglas Bagnall7-48/+130
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>