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
Пример #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
Пример #3
0
def main(step):

    d = make_workdir()
    reset_owncloud_account()

    URL = oc_webdav_url()

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

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

    # upload again matching the existing etag
    r = chunk_file_upload(filename, URL, header_if_match=r.headers['ETag'])
    os.remove(filename)
    file_download(os.path.basename(filename), URL, d)
    analyse_hashfiles(d)

    # upload again with a non-matching etag
    r = chunk_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(3.3))

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

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

    # upload again with a non-matching etag
    r = chunk_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()

    # we make client look like an Android client
    config.pycurl_USERAGENT = "Android-ownCloud"

    # this test should be run against the mobile endpoint of cernbox which may be convinently set in the config
    # for vanilla owncloud server mobile endpoint is the same as generic webdav endpoint
    webdav_endpoint = config.get('oc_mobile_webdav_endpoint',None)

    URL = oc_webdav_url(webdav_endpoint=webdav_endpoint)

    if webdav_endpoint is None:
        logger.warning('oc_mobile_webdav_endpoint was not defined, using standard endpoint, URL: %s',URL)

    # chunk size defined in the android source code
    # https://github.com/owncloud/android-library/blob/d7097983594347167b5bde3fa5b2b4ad1d843392/src/com/owncloud/android/lib/resources/files/ChunkedUploadRemoteFileOperation.java#L45
    # Note: specifying a different chunk size will result in corrupted file!
    # This is a hack until the android-client is properly fixed!

    ANDROID_CHUNKSIZE=1024*1000 

    filename=create_hashfile(d,size=int(5.5*ANDROID_CHUNKSIZE))

    # careful with the chunk size...
    r=chunk_file_upload(filename,URL,chunk_size=ANDROID_CHUNKSIZE,android_client_bug_900=True)
    file_download(os.path.basename(filename),URL,d)
    analyse_hashfiles(d)

    # upload again matching the existing etag
    r=chunk_file_upload(filename,URL,chunk_size=ANDROID_CHUNKSIZE,android_client_bug_900=True,header_if_match=r.headers['ETag'])
    analyse_hashfiles(d)

    # upload again with a non-matching etag
    r = chunk_file_upload(filename,URL,header_if_match='!@# does not exist 123')
    fatal_check(r.rc == 412) # precondition failed
        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

    logger.info('*** 2. upload with corrupted checksum value (files should be refused by the server)')

    filename1=create_hashfile(d,size=OWNCLOUD_CHUNK_SIZE(0.1))
Пример #7
0
    # 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

    logger.info(
        '*** 2. upload with corrupted checksum value (files should be refused by the server)'
    )