From: Volker Lendecke Date: Wed, 31 Aug 2022 10:38:23 +0000 (+0200) Subject: tests: Test basic handling of SMB2_CREATE_TAG_POSIX X-Git-Tag: talloc-2.4.0~1216 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a5156649d58df07f58e479076ea8a0b41b450ea4;p=thirdparty%2Fsamba.git tests: Test basic handling of SMB2_CREATE_TAG_POSIX 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 --- 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()