From fb1c8b426ac9eecdc85faaaa20f3d0ca1f0afaf6 Mon Sep 17 00:00:00 2001 From: Arnab Das Date: Wed, 27 May 2020 17:18:31 -0700 Subject: [PATCH] Set required client min & max dialect before test pike 0.2.26 --- pike/__init__.py | 2 +- pike/test/__init__.py | 22 ++++++++++++++-------- pike/test/ioctl.py | 15 +++++++-------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/pike/__init__.py b/pike/__init__.py index d58a1603..0298f27a 100644 --- a/pike/__init__.py +++ b/pike/__init__.py @@ -13,5 +13,5 @@ 'test', 'transport', ] -__version_info__ = (0, 2, 25) +__version_info__ = (0, 2, 26) __version__ = "{0}.{1}.{2}".format(*__version_info__) diff --git a/pike/test/__init__.py b/pike/test/__init__.py index dfb1c72d..353fef36 100644 --- a/pike/test/__init__.py +++ b/pike/test/__init__.py @@ -95,14 +95,7 @@ def __init__(self, *args, **kwargs): self.max_dialect = self.smb2constoption('PIKE_MAX_DIALECT') self._connections = [] self.default_client = model.Client() - if self.min_dialect is not None: - self.default_client.dialects = filter( - lambda d: d >= self.min_dialect, - self.default_client.dialects) - if self.max_dialect is not None: - self.default_client.dialects = filter( - lambda d: d <= self.max_dialect, - self.default_client.dialects) + self.set_client_dialect(self.min_dialect, self.max_dialect) if self.signing: self.default_client.security_mode = (smb2.SMB2_NEGOTIATE_SIGNING_ENABLED | smb2.SMB2_NEGOTIATE_SIGNING_REQUIRED) @@ -122,6 +115,19 @@ def error(self, *args, **kwargs): def critical(self, *args, **kwargs): self.logger.critical(*args, **kwargs) + def set_client_dialect(self, min_dialect=None, max_dialect=None, + client=None): + if client is None: + client = self.default_client + if (min_dialect is not None and + min(client.dialects) != min_dialect): + client.dialects = filter( + lambda d: d >= min_dialect, client.dialects) + if (max_dialect is not None and + max(client.dialects) != max_dialect): + client.dialects = filter( + lambda d: d <= max_dialect, client.dialects) + def tree_connect(self, client=None, resume=None): dialect_range = self.required_dialect() req_caps = self.required_capabilities() diff --git a/pike/test/ioctl.py b/pike/test/ioctl.py index 82d2d4da..fc1ab698 100644 --- a/pike/test/ioctl.py +++ b/pike/test/ioctl.py @@ -29,7 +29,7 @@ # # Abstract: # -# Test IOCTLs. Currently, only FSCTL_VALIDATE_NEGOTIATE_INFO +# Test IOCTLs # # Authors: Ki Anderson (kimberley.anderson@emc.com) # Paul Martin (paul.o.martin@emc.com) @@ -41,16 +41,16 @@ import pike.test as test import pike.ntstatus + class ValidateNegotiateInfo(test.PikeTest): def __init__(self, *args, **kwds): super(ValidateNegotiateInfo, self).__init__(*args, **kwds) - self.default_client.dialects = [ - smb2.DIALECT_SMB3_0, - smb2.DIALECT_SMB3_0_2] + self.set_client_dialect(smb2.DIALECT_SMB3_0, smb2.DIALECT_SMB3_0_2) # VALIDATE_NEGOTIATE_INFO fsctl succeeds for SMB3 @test.RequireDialect(smb2.DIALECT_SMB3_0, smb2.DIALECT_SMB3_0_2) def test_validate_negotiate_smb3(self): + self.set_client_dialect(smb2.DIALECT_SMB3_0, smb2.DIALECT_SMB3_0_2) chan, tree = self.tree_connect() chan.validate_negotiate_info(tree) @@ -58,12 +58,11 @@ def test_validate_negotiate_smb3(self): class QueryNetworkInterfaceInfo(test.PikeTest): def __init__(self, *args, **kwds): super(QueryNetworkInterfaceInfo, self).__init__(*args, **kwds) - self.default_client.dialects = [ - smb2.DIALECT_SMB3_0, - smb2.DIALECT_SMB3_0_2] + self.set_client_dialect(smb2.DIALECT_SMB3_0, smb2.DIALECT_SMB3_1_1) - @test.RequireDialect(smb2.DIALECT_SMB3_0, smb2.DIALECT_SMB3_0_2) + @test.RequireDialect(smb2.DIALECT_SMB3_0, smb2.DIALECT_SMB3_1_1) def test_query_interface_info_smb3(self): + self.set_client_dialect(smb2.DIALECT_SMB3_0, smb2.DIALECT_SMB3_1_1) chan, tree = self.tree_connect() try: chan.query_network_interface_info(tree)