From a5156649d58df07f58e479076ea8a0b41b450ea4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 31 Aug 2022 12:38:23 +0200 Subject: [PATCH] tests: Test basic handling of SMB2_CREATE_TAG_POSIX MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme Autobuild-User(master): Ralph Böhme Autobuild-Date(master): Fri Sep 2 14:31:25 UTC 2022 on sn-devel-184 --- python/samba/tests/smb3unix.py | 59 ++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/python/samba/tests/smb3unix.py b/python/samba/tests/smb3unix.py index 04c451b251d..a825100d5b2 100644 --- a/python/samba/tests/smb3unix.py +++ b/python/samba/tests/smb3unix.py @@ -101,3 +101,62 @@ class Smb3UnixTests(samba.tests.TestCase): finally: self.disable_smb3unix() + + def test_posix_create_context(self): + try: + self.enable_smb3unix() + + c = libsmb.Conn( + os.getenv("SERVER_IP"), + "tmp", + self.lp, + self.creds, + posix=True) + self.assertTrue(c.have_posix()) + + cc_in=[(libsmb.SMB2_CREATE_TAG_POSIX,b'0000')] + fnum,_,cc_out = c.create_ex("",CreateContexts=cc_in) + self.assertEqual(cc_in[0][0],cc_out[0][0]) + + c.close(fnum) + + finally: + self.disable_smb3unix() + + def test_posix_create_context_noposix(self): + c = libsmb.Conn( + os.getenv("SERVER_IP"), + "tmp", + self.lp, + self.creds, + posix=True) + self.assertFalse(c.have_posix()) + + cc_in=[(libsmb.SMB2_CREATE_TAG_POSIX,b'0000')] + fnum,_,cc_out = c.create_ex("",CreateContexts=cc_in) + self.assertEqual(len(cc_out), 0) + + c.close(fnum) + + def test_posix_create_invalid_context_length(self): + try: + self.enable_smb3unix() + + c = libsmb.Conn( + os.getenv("SERVER_IP"), + "tmp", + self.lp, + self.creds, + posix=True) + self.assertTrue(c.have_posix()) + + cc_in=[(libsmb.SMB2_CREATE_TAG_POSIX,b'00000')] + + with self.assertRaises(NTSTATUSError) as cm: + fnum,_,cc_out = c.create_ex("",CreateContexts=cc_in) + + e = cm.exception + self.assertEqual(e.args[0], ntstatus.NT_STATUS_INVALID_PARAMETER) + + finally: + self.disable_smb3unix() -- 2.47.3