Skip to content

Commit

Permalink
Merge pull request #81 from isi-adas/BR_BUG_271821_PSCALE_10700_PIKE_…
Browse files Browse the repository at this point in the history
…0_2_x

Set required client min & max dialect before test
  • Loading branch information
isi-mfurer authored May 28, 2020
2 parents c39b779 + fb1c8b4 commit 0a87cdb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pike/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
'test',
'transport',
]
__version_info__ = (0, 2, 25)
__version_info__ = (0, 2, 26)
__version__ = "{0}.{1}.{2}".format(*__version_info__)
22 changes: 14 additions & 8 deletions pike/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down
15 changes: 7 additions & 8 deletions pike/test/ioctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#
# Abstract:
#
# Test IOCTLs. Currently, only FSCTL_VALIDATE_NEGOTIATE_INFO
# Test IOCTLs
#
# Authors: Ki Anderson ([email protected])
# Paul Martin ([email protected])
Expand All @@ -41,29 +41,28 @@
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)


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)
Expand Down

0 comments on commit 0a87cdb

Please sign in to comment.