def main(step):

    d = make_workdir()
    reset_owncloud_account()

    URL = oc_webdav_url()

    logger.info('*** 0. upload without the checksum (files should be accepted by the server)')

    filename1=create_hashfile(d,size=OWNCLOUD_CHUNK_SIZE(0.1))
    filename2=create_hashfile(d,size=OWNCLOUD_CHUNK_SIZE(3.3))

    # upload the file without a checksum and then download it to get the checksum type used by the server
    file_upload(filename1,URL)
    chunk_file_upload(filename2,URL)

    file_download(os.path.basename(filename1),URL,d)
    r=file_download(os.path.basename(filename2),URL,d)

    analyse_hashfiles(d) # make sure that files uploaded without a checksum are not corrupted

    logger.info('Got checksum from the server: %s', r.headers['OC-Checksum'])

    try:
        active_server_checksum_type = r.headers['OC-Checksum'].strip().split(':')[0]
    except KeyError,x:
        logger.warning('Checksum not enabled for %s',oc_webdav_url(hide_password=True))
        return
Exemplo n.º 2
0
def main(step):

    d = make_workdir()
    reset_owncloud_account()

    URL = oc_webdav_url()

    logger.info(
        '*** 0. upload without the checksum (files should be accepted by the server)'
    )

    filename1 = create_hashfile(d, size=OWNCLOUD_CHUNK_SIZE(0.1))
    filename2 = create_hashfile(d, size=OWNCLOUD_CHUNK_SIZE(3.3))

    # upload the file without a checksum and then download it to get the checksum type used by the server
    file_upload(filename1, URL)
    chunk_file_upload(filename2, URL)

    file_download(os.path.basename(filename1), URL, d)
    r = file_download(os.path.basename(filename2), URL, d)

    analyse_hashfiles(
        d
    )  # make sure that files uploaded without a checksum are not corrupted

    logger.info('Got checksum from the server: %s', r.headers['OC-Checksum'])

    try:
        active_server_checksum_type = r.headers['OC-Checksum'].strip().split(
            ':')[0]
    except KeyError, x:
        logger.warning('Checksum not enabled for %s',
                       oc_webdav_url(hide_password=True))
        return
def main(step):

    d = make_workdir()
    reset_owncloud_account()

    URL = oc_webdav_url()

    filename=create_hashfile(d,size=OWNCLOUD_CHUNK_SIZE(0.3))

    r=file_upload(filename,URL)
    file_download(os.path.basename(filename),URL,d)
    analyse_hashfiles(d)

    # upload again matching the existing etag
    r=file_upload(filename,URL,header_if_match=r.headers['ETag'])
    analyse_hashfiles(d)

    # upload again with a non-matching etag
    r = file_upload(filename,URL,header_if_match='!@# does not exist 123')
    fatal_check(r.rc == 412) # precondition failed
Exemplo n.º 4
0
def main(step):

    d = make_workdir()
    reset_owncloud_account()

    URL = oc_webdav_url()

    filename = create_hashfile(d, size=OWNCLOUD_CHUNK_SIZE(0.3))

    r = file_upload(filename, URL)
    file_download(os.path.basename(filename), URL, d)
    analyse_hashfiles(d)

    # upload again matching the existing etag
    r = file_upload(filename, URL, header_if_match=r.headers['ETag'])
    analyse_hashfiles(d)

    # upload again with a non-matching etag
    r = file_upload(filename, URL, header_if_match='!@# does not exist 123')
    fatal_check(r.rc == 412)  # precondition failed
def main(step):

    d = make_workdir()
    reset_owncloud_account()

    URL = oc_webdav_url()

    filename=create_hashfile(d,size=OWNCLOUD_CHUNK_SIZE(0.3))
    time.sleep(2)
    mtime = int(os.path.getmtime(filename))
    total_size = os.path.getsize(filename)
    r=file_upload(filename,URL)

    check_propfind_response(URL,filename,mtime,total_size)

    filename=create_hashfile(d,size=OWNCLOUD_CHUNK_SIZE(3.3))
    time.sleep(2)
    mtime = int(os.path.getmtime(filename))
    total_size = os.path.getsize(filename)
    r=chunk_file_upload(filename,URL)

    check_propfind_response(URL,filename,mtime,total_size)
def main(step):

    d = make_workdir()
    reset_owncloud_account()

    URL = oc_webdav_url()

    filename = create_hashfile(d, size=OWNCLOUD_CHUNK_SIZE(0.3))
    time.sleep(2)
    mtime = int(os.path.getmtime(filename))
    total_size = os.path.getsize(filename)
    r = file_upload(filename, URL)

    check_propfind_response(URL, filename, mtime, total_size)

    filename = create_hashfile(d, size=OWNCLOUD_CHUNK_SIZE(3.3))
    time.sleep(2)
    mtime = int(os.path.getmtime(filename))
    total_size = os.path.getsize(filename)
    r = chunk_file_upload(filename, URL)

    check_propfind_response(URL, filename, mtime, total_size)
    try:
        active_server_checksum_type = r.headers['OC-Checksum'].strip().split(':')[0]
    except KeyError,x:
        logger.warning('Checksum not enabled for %s',oc_webdav_url(hide_password=True))
        return

    # now check the checksum type supported on the server
    logger.info('Server supports %s checksum',repr(active_server_checksum_type))
    smashbox.protocol.enable_checksum(active_server_checksum_type)

    logger.info('*** 1. upload with correct checksum (files should be accepted by the server)')

    filename1=create_hashfile(d,size=OWNCLOUD_CHUNK_SIZE(0.1))
    filename2=create_hashfile(d,size=OWNCLOUD_CHUNK_SIZE(3.3))

    file_upload(filename1,URL)
    chunk_file_upload(filename2,URL)

    file_download(os.path.basename(filename1),URL,d)
    file_download(os.path.basename(filename2),URL,d)

    analyse_hashfiles(d)   

    # pass around  incorrect checksum (of the type supported by the server)
    # the puts should be failing

    def corrupted_checksum(fn):
        c = smashbox.protocol.compute_checksum(fn)
        c = c[:-1]+chr(ord(c[-1])+1)
        return c
Exemplo n.º 8
0
                       oc_webdav_url(hide_password=True))
        return

    # now check the checksum type supported on the server
    logger.info('Server supports %s checksum',
                repr(active_server_checksum_type))
    smashbox.protocol.enable_checksum(active_server_checksum_type)

    logger.info(
        '*** 1. upload with correct checksum (files should be accepted by the server)'
    )

    filename1 = create_hashfile(d, size=OWNCLOUD_CHUNK_SIZE(0.1))
    filename2 = create_hashfile(d, size=OWNCLOUD_CHUNK_SIZE(3.3))

    file_upload(filename1, URL)
    chunk_file_upload(filename2, URL)

    file_download(os.path.basename(filename1), URL, d)
    file_download(os.path.basename(filename2), URL, d)

    analyse_hashfiles(d)

    # pass around  incorrect checksum (of the type supported by the server)
    # the puts should be failing

    def corrupted_checksum(fn):
        c = smashbox.protocol.compute_checksum(fn)
        c = c[:-1] + chr(ord(c[-1]) + 1)
        return c