Ejemplo n.º 1
0
logger = logging.getLogger(__file__)
"""
    Verifies whether aktualizr is updatable after failure of object(s) download from Treehub/OSTree repo
    with follow-up successful download.

    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 follow-up successful metadata download.

Currently, it's tested against two types of metadata download/parsing failure:
    - download interruption - metadata file download is interrupted once|three times, after that it's successful
    - malformed json - aktualizr receives malformed json/metadata as a response to the first request for metadata,
      a response to subsequent request is successful

Note: Aktualizr doesn't send any installation report in manifest in case of metadata download failure
https://saeljira.it.here.com/browse/OTA-3730
"""


@with_uptane_backend(start_generic_server=True, port=8888)
@with_path(paths=['/1.root.json', '/root.json', '/targets.json'])
@with_director(handlers=[
    DownloadInterruptionHandler(number_of_failures=1),
    MalformedJsonHandler(number_of_failures=1),
    DownloadInterruptionHandler(number_of_failures=3),
])
@with_aktualizr(start=False, run_mode='full')
@with_install_manager()
def test_backend_failure_sanity_director_update_after_metadata_download_failure(
        install_mngr, director, aktualizr, **kwargs):
    with aktualizr:
        director.wait_for_install()
        # we have to stop director before terminating aktualizr since the later doesn't support graceful shutdown
        # (doesn't handle any signal (SIGTERM, SIGKILL, etc) what leads to receiving broken requests at director
        # https://saeljira.it.here.com/browse/OTA-3744
        director.stop()
    return director.is_install_successful(
    ) and install_mngr.are_images_installed()
Ejemplo n.º 3
0
from test_fixtures import with_aktualizr, with_uptane_backend, KeyStore, with_secondary, with_path,\
    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')
Ejemplo n.º 4
0
with follow-up successful metadata download.

Currently, it's tested against two types of metadata download/parsing failure:
    - download interruption - metadata file download is interrupted once|three times, after that it's successful
    - malformed json - aktualizr receives malformed json/metadata as a response to the first request for metadata,
      a response to subsequent request is successful

Note: Aktualizr doesn't send any installation report in manifest in case of metadata download failure
https://saeljira.it.here.com/browse/OTA-3730
"""


@with_uptane_backend(start_generic_server=True)
@with_path(paths=['/1.root.json', '/root.json', '/targets.json'])
@with_director(handlers=[
    DownloadInterruptionHandler(number_of_failures=1),
    MalformedJsonHandler(number_of_failures=1),
    DownloadInterruptionHandler(number_of_failures=3),
],
               start=False)
@with_aktualizr(start=False, run_mode='full')
@with_install_manager()
def test_backend_failure_sanity_director_update_after_metadata_download_failure(
        install_mngr, director, aktualizr, **kwargs):
    with director:
        with aktualizr:
            install_result = director.wait_for_install()
            install_result = install_result and install_mngr.are_images_installed(
            )
    return install_result