Skip to content

Commit

Permalink
Added unit tests for isInFileJail function from #1066
Browse files Browse the repository at this point in the history
  • Loading branch information
martingalloar committed Apr 26, 2021
1 parent d187315 commit fb2a6fb
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/SMB_RPC/test_smbserver.py
Expand Up @@ -19,15 +19,26 @@

from six import StringIO, BytesIO, b

from impacket.smbserver import SimpleSMBServer
from impacket.smbserver import isInFileJail, SimpleSMBServer
from impacket.smbconnection import SMBConnection, SessionError, compute_lmhash, compute_nthash


class SMBServerUnitTests(unittest.TestCase):
"""Unit tests for the SMBServer
"""

pass
def test_isInFileJail(self):
"""Test validation of common prefix path.
"""
jail_path = "/tmp/jail_path"
self.assertTrue(isInFileJail(jail_path, "filename"))
self.assertTrue(isInFileJail(jail_path, "./filename"))
self.assertTrue(isInFileJail(jail_path, "../jail_path/filename"))

self.assertFalse(isInFileJail(jail_path, "/filename"))
self.assertFalse(isInFileJail(jail_path, "/tmp/filename"))
self.assertFalse(isInFileJail(jail_path, "../filename"))
self.assertFalse(isInFileJail(jail_path, "../../filename"))


class SimpleSMBServerFuncTests(unittest.TestCase):
Expand Down

0 comments on commit fb2a6fb

Please sign in to comment.