def test_008_set_up_testfiles(request, payload): depends(request, ["SHARE_HAS_SHADOW_COPIES"]) i = int(payload[-1]) offset = i * 2 * len(payload) c = SMB() c.connect(host=ip, share=SMB_NAME, username=SMB_USER, password=SMB_PWD, smb1=False) for f in to_check: fd = c.create_file(f, "w") c.write(fd, payload.encode(), offset) c.close(fd) fd = c.create_file(f'{f}:smb2_stream', 'w') c.write(fd, payload.encode(), offset) c.close(fd) sleep(5) result = POST("/zfs/snapshot/", { "dataset": dataset, "name": payload, "recursive": True, }) assert result.status_code == 200, results.text
def test_011_check_dos_ro_cred_handling(request): """ This test creates a file with readonly attribute set, then uses the open fd to write data to the file. """ depends(request, ["SHARE_IS_WRITABLE"]) c = SMB() c.connect(host=ip, share=SMB_NAME, username=SMB_USER, password=SMB_PWD, smb1=False) fd = c.create_file("RO_TEST", "w", "r") c.write(fd, b"TESTING123\n") c.disconnect()
def test_154_write_afp_xattr_via_smb(request, xat): """ Write xattr over SMB """ depends(request, ["XATTR_CHECK_SMB_UNLINK"]) afptestfile = f'afp_xattr_testfile:{AFPXattr[xat]["smbname"]}' payload = AFPXattr[xat][ "smb_bytes"] if xat == "org.netatalk.Metadata" else AFPXattr[xat][ "bytes"] c = SMB() c.connect(host=ip, share=SMB_NAME, username=SMB_USER, password=SMB_PWD, smb1=False) fd = c.create_file(afptestfile, "w") c.write(fd, payload) c.close(fd) c.disconnect()
def test_066_write_stream_large_offset_smb1(request): """ Append to our existing stream over SMB1 protocol. Specify an offset that will cause resuling xattr to exceed 64KiB default xattr size limit in Linux. """ depends(request, ["STREAM_WRITTEN_SMB1"]) c = SMB() c.connect(host=ip, share=SMB_NAME, username=SMB_USER, password=SMB_PWD, smb1=True) fd = c.create_file("streamstestfile:smb1_stream", "w") c.write(fd, b'test2', 131072) c.close(fd) fd2 = c.create_file("streamstestfile:smb1_stream", "w") contents = c.read(fd2, 131072, 5) c.close(fd2) c.disconnect() assert (contents.decode() == "test2")
def test_065_create_and_write_stream_smb1(request): """ Create our initial stream and write to it over SMB1 protocol. Start with offset 0. """ depends(request, ["STREAM_TESTFILE_CREATED"]) c = SMB() c.connect(host=ip, share=SMB_NAME, username=SMB_USER, password=SMB_PWD, smb1=True) fd = c.create_file("streamstestfile:smb1_stream", "w") c.write(fd, b'test1', 0) c.close(fd) fd2 = c.create_file("streamstestfile:smb1_stream", "w") contents = c.read(fd2, 0, 5) c.close(fd2) c.disconnect() assert (contents.decode() == "test1")