Exemple #1
0
def test_152_check_xattr_via_smb(request, xat):
    """
    Read xattr that was written via SSH and verify that
    data is same when viewed over SMB.
    """
    depends(request, ["SSH_XATTR_SET"])
    afptestfile = f'afp_xattr_testfile:{AFPXattr[xat]["smbname"]}'
    bytes = 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")
    xat_bytes = c.read(fd, 0, len(bytes) + 1)
    c.close(fd)
    c.disconnect()

    err = {"name": xat, "b64data": b64encode(bytes)}

    # Python base64 library appends a `\t` to end of byte string
    assert xat_bytes == bytes, str(err)
Exemple #2
0
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")
Exemple #3
0
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")