diff options
| author | Joseph Sutton <josephsutton@catalyst.net.nz> | 2023-06-15 14:33:37 +1200 |
|---|---|---|
| committer | Andrew Bartlett <abartlet@samba.org> | 2023-06-15 05:29:28 +0000 |
| commit | ba2e54d5c5fe22a3ba1481c890fc49bcdfa38781 (patch) | |
| tree | 06de57e8dd05944ffc7fe0c77f4961f0333e6584 /python/samba | |
| parent | 7f771070535bd12d5ad0644893607f5c47c615e9 (diff) | |
| download | samba-ba2e54d5c5fe22a3ba1481c890fc49bcdfa38781.tar.gz samba-ba2e54d5c5fe22a3ba1481c890fc49bcdfa38781.tar.bz2 samba-ba2e54d5c5fe22a3ba1481c890fc49bcdfa38781.zip | |
tests/auth_log: Ensure tests continue to pass when new log types are added
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python/samba')
| -rw-r--r-- | python/samba/tests/auth_log_base.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/python/samba/tests/auth_log_base.py b/python/samba/tests/auth_log_base.py index 9f611893cd6..36304ecf796 100644 --- a/python/samba/tests/auth_log_base.py +++ b/python/samba/tests/auth_log_base.py @@ -28,6 +28,22 @@ import os import re +def default_msg_filter(msg): + # When our authentication logging tests were written, these were the only + # supported message types. The tests were built on the assumption that no + # new types would be added, and violating this assumption will result in + # many tests failing as they receive messages that they weren’t + # expecting. To allow these tests to continue to pass, this default filter + # makes sure that only messages for which the tests are prepared pass + # though. + default_supported_types = { + "Authentication", + "Authorization", + } + + return msg['type'] in default_supported_types + + class NoMessageException(Exception): pass @@ -108,16 +124,22 @@ class AuthLogTestBase(samba.tests.TestCase): except IndexError: return False - def waitForMessages(self, isLastExpectedMessage, connection=None): + def waitForMessages(self, isLastExpectedMessage, connection=None, *, + msgFilter=default_msg_filter): """Wait for all the expected messages to arrive The connection is passed through to keep the connection alive until all the logging messages have been received. + + By default, only Authentication and Authorization messages will be + returned, so that old tests continue to pass. To receive all messages, + pass msgFilter=None. + """ messages = [] while True: try: - msg = self.nextMessage() + msg = self.nextMessage(msgFilter=msgFilter) except NoMessageException: return [] |
