diff options
| author | Joseph Sutton <josephsutton@catalyst.net.nz> | 2023-05-24 10:31:53 +1200 |
|---|---|---|
| committer | Andrew Bartlett <abartlet@samba.org> | 2023-06-14 22:57:35 +0000 |
| commit | 97a5ee4bbb7971ee98c0a8cf314cd39f655f2182 (patch) | |
| tree | 7bdcee9af58740ce2bb89e593a1e51ee669fbbb4 /python/samba | |
| parent | 1f74f9f366d7f107a89220a4a5951bc4daf18025 (diff) | |
| download | samba-97a5ee4bbb7971ee98c0a8cf314cd39f655f2182.tar.gz samba-97a5ee4bbb7971ee98c0a8cf314cd39f655f2182.tar.bz2 samba-97a5ee4bbb7971ee98c0a8cf314cd39f655f2182.zip | |
tests/auth_log: Factor out isRemote()
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>
Diffstat (limited to 'python/samba')
| -rw-r--r-- | python/samba/tests/auth_log_base.py | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/python/samba/tests/auth_log_base.py b/python/samba/tests/auth_log_base.py index 586719980cb..9c600ff1f39 100644 --- a/python/samba/tests/auth_log_base.py +++ b/python/samba/tests/auth_log_base.py @@ -83,6 +83,26 @@ class AuthLogTestBase(samba.tests.TestCase): super(AuthLogTestBase, self).setUp() type(self).discardMessages() + def isRemote(self, message): + if self.remoteAddress is None: + return True + + supported_types = { + "Authentication", + "Authorization", + } + message_type = message["type"] + if message_type in supported_types: + remote = message[message_type]["remoteAddress"] + else: + return False + + try: + addr = remote.split(":") + return addr[1] == self.remoteAddress + except IndexError: + return False + def waitForMessages(self, isLastExpectedMessage, connection=None): """Wait for all the expected messages to arrive The connection is passed through to keep the connection alive @@ -91,30 +111,10 @@ class AuthLogTestBase(samba.tests.TestCase): def completed(messages): for message in messages: - if isRemote(message) and isLastExpectedMessage(message): + if self.isRemote(message) and isLastExpectedMessage(message): return True return False - def isRemote(message): - if self.remoteAddress is None: - return True - - supported_types = { - "Authentication", - "Authorization", - } - message_type = message["type"] - if message_type in supported_types: - remote = message[message_type]["remoteAddress"] - else: - return False - - try: - addr = remote.split(":") - return addr[1] == self.remoteAddress - except IndexError: - return False - self.connection = connection start_time = time.time() @@ -125,7 +125,7 @@ class AuthLogTestBase(samba.tests.TestCase): return [] self.connection = None - return list(filter(isRemote, self.context["messages"])) + return list(filter(self.isRemote, self.context["messages"])) # Discard any previously queued messages. @classmethod |
