1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-24 13:57:43 +03:00

tests: test SMB3 POSIX append-IO behaviour

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Ralph Boehme 2024-11-28 12:12:26 +01:00 committed by Jeremy Allison
parent ec3e1927ba
commit e18a5381a8
2 changed files with 47 additions and 0 deletions

View File

@ -543,3 +543,49 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests):
c.close(dh)
self.clean_file(c, '\\test_copy_chunk_posix_src')
self.clean_file(c, '\\test_copy_chunk_posix_dst')
def test_append(self):
"""
Test append-io behaviour
"""
(wc, pc) = self.connections()
self.clean_file(pc, '\\test_append')
wire_mode = libsmb.unix_mode_to_wire(0o644)
ph,*_ = pc.create_ex('\\test_append',
DesiredAccess=security.SEC_FILE_APPEND_DATA | security.SEC_FILE_READ_DATA,
CreateDisposition=libsmb.FILE_CREATE,
ShareAccess=libsmb.FILE_SHARE_READ|libsmb.FILE_SHARE_WRITE,
CreateContexts=[posix_context(wire_mode)])
wh,*_ = wc.create_ex('\\test_append',
DesiredAccess=security.SEC_FILE_APPEND_DATA,
ShareAccess=libsmb.FILE_SHARE_READ|libsmb.FILE_SHARE_WRITE,
CreateDisposition=libsmb.FILE_OPEN)
wc.write(wh, buffer=b"hello", offset=0)
wc.write(wh, buffer=b"h", offset=0)
try:
pc.write(ph, buffer=b"world", offset=0)
except Exception as e:
self.assertEqual(e.args[0], ntstatus.NT_STATUS_INVALID_PARAMETER)
pass
else:
pc.close(ph)
wc.close(wh)
self.clean_file(pc, '\\test_append')
self.fail("Write with offset=0 must fail on POSIX handle in append mode")
pc.write(ph, buffer=b" world", offset=libsmb.VFS_PWRITE_APPEND_OFFSET)
info = pc.qfileinfo(ph, libsmb.FSCC_FILE_POSIX_INFORMATION);
self.assertEqual(info['size'], 11)
data = pc.read(ph, 0, 11)
self.assertEqual(data, b'hello world')
pc.close(ph)
wc.close(wh)
self.clean_file(pc, '\\test_append')

View File

@ -0,0 +1 @@
^samba.tests.smb3unix.samba.tests.smb3unix.Smb3UnixTests.test_append\(fileserver_smb1\)