Skip to content

Commit

Permalink
Add new test cases for test_smb.py (#1760)
Browse files Browse the repository at this point in the history
* remove spaces

* add remained functions to test_getData() in test_smb.py

* add new test case test_queryInfo() in test_smb.py
  • Loading branch information
NtAlexio2 authored Jul 10, 2024
1 parent f827c8c commit 3c15e00
Showing 1 changed file with 21 additions and 6 deletions.
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

0 comments on commit 3c15e00

Please sign in to comment.