예제 #1
0
    DownloadInterruptionHandler, MalformedJsonHandler, with_director, with_imagerepo, InstallManager,\
    with_install_manager, with_images, MalformedImageHandler, with_customrepo, SlowRetrievalHandler, \
    RedirectHandler, with_sysroot, with_treehub, TestRunner

logger = logging.getLogger(__file__)
"""
    Verifies whether aktualizr is updatable after malformed image is downloaded
    from a custom image server with follow-up successful download.
"""


@with_uptane_backend(start_generic_server=True)
@with_customrepo(handlers=[
    DownloadInterruptionHandler(number_of_failures=1,
                                url='/primary-image.img'),
    MalformedImageHandler(number_of_failures=1, url='/primary-image.img')
    # TODO: this test fails too, although httpclient.cc sets
    # CURLOPT_LOW_SPEED_TIME and CURLOPT_LOW_SPEED_TIME
    # https://saeljira.it.here.com/browse/OTA-3737
    #SlowRetrievalHandler(url='/primary-image.img')
])
@with_imagerepo()
@with_director(start=False)
@with_aktualizr(start=False, run_mode='full')
def test_customrepo_update_after_image_download_failure(
        uptane_repo, custom_repo, director, aktualizr, **kwargs):
    update_hash = uptane_repo.add_image(aktualizr.id,
                                        'primary-image.img',
                                        custom_url=custom_repo.base_url + '/' +
                                        'primary-image.img')
    Currently, it's tested against two types of object download failure:
    - download interruption - object download is interrupted once, after that it's successful
    - malformed object - object download is successful but it's malformed. It happens once after that it's successful
"""


@with_uptane_backend(start_generic_server=True)
@with_director()
@with_treehub(handlers=[
    DownloadInterruptionHandler(
        url=
        '/objects/41/5ce9717fc7a5f4d743a4f911e11bd3ed83930e46756303fd13a3eb7ed35892.filez'
    ),
    MalformedImageHandler(
        url=
        '/objects/41/5ce9717fc7a5f4d743a4f911e11bd3ed83930e46756303fd13a3eb7ed35892.filez'
    ),
    RedirectHandler(
        number_of_redirects=1000,
        url=
        '/objects/41/5ce9717fc7a5f4d743a4f911e11bd3ed83930e46756303fd13a3eb7ed35892.filez'
    ),

    # TODO: OSTree object download is not resilient to `Slow Retrieval Attack`
    # https://saeljira.it.here.com/browse/OTA-3737
    #SlowRetrievalHandler(url='/objects/6b/1604b586fcbe052bbc0bd9e1c8040f62e085ca2e228f37df957ac939dff361.filez'),
])
@with_sysroot()
@with_aktualizr(start=False, run_mode='once')
def test_treehub_update_after_image_download_failure(uptane_repo, aktualizr,
                                                     director, uptane_server,
Currently, it's tested against two types of image download failure:
    - download interruption - file download is interrupted once, after that it's successful
    - malformed image - image download is successful but it's malformed. It happens once after that it's successful
"""


@with_uptane_backend(start_generic_server=True)
@with_images(images_to_install=[(('primary-hw-ID-001', 'primary-ecu-id'),
                                 'primary-image.img')])
@with_imagerepo(handlers=[
    # TODO: test fails because aktualizr issues byte range request
    # that are not supported by server
    # https://saeljira.it.here.com/browse/OTA-3716
    #DownloadInterruptionHandler(number_of_failures=1, url='/targets/primary-image.img'),
    MalformedImageHandler(number_of_failures=1,
                          url='/targets/primary-image.img'),
])
@with_director(start=False)
@with_aktualizr(run_mode='full', id=('primary-hw-ID-001', 'primary-ecu-id'))
@with_install_manager()
def test_backend_failure_sanity_imagerepo_update_after_image_download_failure(
        install_mngr, director, aktualizr, **kwargs):
    with aktualizr:
        with director:
            install_result = director.wait_for_install()
            install_result = install_result and install_mngr.are_images_installed(
            )
    return install_result


"""