Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new test cases for test_smb.py #1760

Merged
merged 3 commits into from
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions tests/SMB_RPC/test_smb.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_connection(self):
self.assertEqual(credentials, (self.username, self.password, self.domain, '', '', '', None, None))
smb.logoff()
del(smb)

def test_close_connection(self):
smb = self.create_connection()
smb.login(self.username, self.password, self.domain)
Expand Down Expand Up @@ -156,7 +156,7 @@ def test_createFile(self):
smb.deleteFile(self.share, self.file + '.bak')
smb.disconnectTree(tid)
smb.logoff()

def test_readwriteFile(self):
smb = self.create_connection()
smb.login(self.username, self.password, self.domain)
Expand All @@ -176,9 +176,8 @@ def test_readwriteFile(self):
smb.closeFile(tid, fid)
smb.deleteFile(self.share, self.file)
smb.disconnectTree(tid)

smb.logoff()

def test_createdeleteDirectory(self):
smb = self.create_connection()
smb.login(self.username, self.password, self.domain)
Expand All @@ -194,7 +193,7 @@ def test_createdeleteDirectory(self):
smb.deleteDirectory(self.share, nested_dir)
smb.deleteDirectory(self.share, self.directory)
smb.logoff()

def test_getData(self):
smb = self.create_connection()
smb.login(self.username, self.password, self.domain)
Expand All @@ -205,6 +204,8 @@ def test_getData(self):
smb.getServerOS()
smb.doesSupportNTLMv2()
smb.isLoginRequired()
smb.isSigningRequired()
smb.getIOCapabilities()
smb.logoff()

def test_getServerName(self):
Expand Down Expand Up @@ -266,7 +267,21 @@ def test_getSessionKey(self):
smb.login(self.username, self.password, self.domain)
smb.getSessionKey()
smb.logoff()


def test_queryInfo(self):
smb = self.create_connection()
smb.login(self.username, self.password, self.domain)
tid = smb.connectTree(self.share)
fid = smb.createFile(tid, self.file)
file_info = smb.queryInfo(tid, fid)
self.assertEqual(file_info["AllocationSize"], 0)
self.assertEqual(file_info["EndOfFile"], 0)
self.assertEqual(file_info["Directory"], 0)
smb.closeFile(tid,fid)
smb.deleteFile(self.share, self.file)
smb.disconnectTree(tid)
smb.logoff()

def __is_socket_opened(self, s):
# We assume that if socket is selectable, it's open; and if it were not, it's closed.
# Note: this method is accurate as long as the file descriptor used for the socket is not re-used
Expand Down
Loading