summaryrefslogtreecommitdiff
path: root/python/samba/tests/auth_log_base.py
AgeCommit message (Collapse)AuthorFilesLines
2024-02-29pytest:auth_log_base: use string_is_guid()Douglas Bagnall1-8/+3
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-11-30python: tests: update all super calls to python 3 style in testsRob van der Linde1-1/+1
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> [abartlet@samba.org Some python2 style super() calls remain due to being an actual, even if reasonable, behaviour change]
2023-06-15tests/auth_log: Ensure tests continue to pass when new log types are addedJoseph Sutton1-2/+24
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-15tests/auth_log: Add support for new ‘KDC Authorization’ log typeJoseph Sutton1-0/+1
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-14tests/auth_log: Refactor waitForMessages() to use nextMessage()Joseph Sutton1-15/+8
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Wed Jun 14 23:55:42 UTC 2023 on atb-devel-224
2023-06-14tests/auth_log: Add method to fetch the next relevant message from the ↵Joseph Sutton1-0/+38
messaging bus Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-14tests/auth_log: Factor out isRemote()Joseph Sutton1-22/+22
This makes waitForMessages() easier to read. View with ‘git show -b’. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-05-29tests/auth_log: Add missing call to tearDownClass()Joseph Sutton1-0/+2
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-05-29tests/auth_log: Remove unnecessary checkJoseph Sutton1-4/+3
This attribute is always truthy. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-05-29tests/auth_log: Call discardMessages() on classJoseph Sutton1-1/+1
This makes it clearer that discardMessages() operates on the class. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-05-29tests/auth_log: Make discardMessages() more reliableJoseph Sutton1-4/+13
It can take two or three calls to msg_ctx.loop_once() before a message comes in. Make sure we get all of the messages. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-05-29tests/auth_log: Correctly get lp_ctxJoseph Sutton1-1/+1
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-05-29tests/auth_log: Remove unneeded len() callJoseph Sutton1-1/+1
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-05-29tests/auth_log: Rename ‘self’ parameter to ‘cls’Joseph Sutton1-5/+5
This method operates on the class, not on an instance of that class. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-05-29tests/auth_log: Rename ‘self’ parameter to ‘cls’Joseph Sutton1-5/+5
This method operates on the class, not on an instance of that class. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-05-29tests/auth_log: Correctly check for GUIDJoseph Sutton1-1/+1
Pattern.match() only checks the starting portion of the string. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-05-29tests/auth_log: Pre-compile GUID regexJoseph Sutton1-2/+3
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-05-24tests/auth_log: Simplify isRemote()Joseph Sutton1-5/+7
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-05-24tests/auth_log: Rename ‘self’ parameter to ‘cls’Joseph Sutton1-10/+10
This method operates on the class, not on an instance of the class. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-05-24tests/auth_log: Call setUpClass() method of base classJoseph Sutton1-0/+2
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-05-24tests/auth_log: Don’t silently override remoteAddressJoseph Sutton1-1/+0
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-10-21python: Remove unused imports in auth_log testsJoseph Sutton1-1/+0
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2021-04-28python: remove all 'from __future__ import print_function'Douglas Bagnall1-1/+0
This made Python 2's print behave like Python 3's print(). In some cases, where we had: from __future__ import print_function """Intended module documentation...""" this will have the side effect of making the intended module documentation work as the actual module documentation (i.e. becoming __doc__), because it is once again the first statement in the module. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@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 Beale1-0/+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: Remove explicit SOCKET_WRAPPER usage from auth_log testsTim Beale1-1/+9
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-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>
2018-12-20tests (audit_auth)_log: PEP8 cleanup.Gary Lockyer1-0/+1
Remove Flake8 warnings from the audit and authentication JSON log tests. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-12-10python/samba/tests: Fix auth_log messaging problems in py3Noel Power1-0/+3
Some tests (especially samba.tests.auth_log_netlogon_bad_creds) are failing due to not receiving expected messages. There seems to be some timing issue or race around the messaging bus being set up and getting the expected events resulting from the failed netlogon. Specifically the the order of destruction of the messaging.Messaging() c-py objects is different under python2. Under python2 all of the messaging.Messaging() objects are destructed *after* all the tests are run. Note: each instance of the TestCase has it's own Messaging() instance which is created by TestCaseXYZ.setUp, so it appears the unittest destroys the test instances when all the tests have run whereas in python3 we see each messaging.Messaging() instance destroyed after each test runs. Ok, what difference does that make ? well it seems in python3 because each Messaging() instance is destructed after a test runs that the associated messaging_dgm_destroy() also runs, this destroys the global_dgm_context context which means when the next test runs the whole messaging infrastructure needs to be built again when the next Messaging() object is created. On the server-side this seems to result in attempts to send messages to the listener failing first with get_event_server: Failed to find 'auth_event' registered on the message bus to send JSON audit events to: NT_STATUS_CONNECTION_REFUSED and subsequently with get_event_server: Failed to find 'auth_event' registered on the message bus to send JSON audit events to: NT_STATUS_UNSUCCESSFUL client doesn't get any more messages, test fails :-( So, what's the difference in python2, well because the destructors for the (4 in the case of netlogon_bad_creds) instances of Messagaging() don't run till the end of the tests this doesn't happen and the global_dgm_context never gets destroyed untill all the tests complete. There is some race condition at play here, a simple sleep at the start of a failing test fixes the problem. But... ok that isn't a possible solution here, instead I have adjusted the base auth tests to store the Messaging() objects in a global list forcing them to remain in scope until the tests are complete. This ensure the behaviour is consistent across python2 & python3. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-12-10PY3: wrap filter calls with list where list is expectedNoel Power1-1/+1
filter in PY2 returns list in PY3 it returns an iterator Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-05-31auth tests: irpc remove "auth_event" name on completionGary Lockyer1-0/+1
Remove the "auth_event" name on completion of tests to prevent issues with tests using messaging. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-05-10auth logging tests: Clean up flake8 warningsGary Lockyer1-15/+12
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-05-10auth logging tests: Add tests for sessionIdGary Lockyer1-0/+8
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-03-23samba python tests: convert print func to be py2/py3 compatibleNoel Power1-1/+2
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2017-07-24tests auth_log: Modify existing tests to handle NETLOGON messagesGary Lockyer1-0/+17
Modify the existing tests to ignore auth logging for NETLOGON messages. NETLOGON authentication is logged once per session, and is tested separately. Ignoring it in these tests avoids order dependencies. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12865 Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2017-03-29auth log tests: password change testsGary Lockyer1-6/+8
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
2017-03-29auth_log: Add tests by listening for JSON messages over the message busAndrew Bartlett1-0/+102
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Pair-programmed-by: Gary Lockyer <gary@catalyst.net.nz>