From e059cf814b9ad47355edeb62673ec7cb3e2ccae9 Mon Sep 17 00:00:00 2001 From: zanefisher Date: Fri, 13 Sep 2013 17:39:29 -0400 Subject: [PATCH] More integration test tidying-up --- tests/integration/test_endless_data_attack.py | 6 +++--- tests/integration/test_indefinite_freeze_attack.py | 8 ++++---- tests/integration/test_mix_and_match_attack.py | 6 +++--- tests/integration/test_replay_attack.py | 10 +++++----- tests/integration/test_slow_retrieval_attack.py | 6 +++--- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/integration/test_endless_data_attack.py b/tests/integration/test_endless_data_attack.py index 6af5dafd..d54de3c7 100755 --- a/tests/integration/test_endless_data_attack.py +++ b/tests/integration/test_endless_data_attack.py @@ -37,7 +37,7 @@ import urllib import tuf -import tuf.interposition.urllib_tuf as urllib_tuf +import tuf.interposition import tuf.tests.util_test_tools as util_test_tools @@ -49,7 +49,7 @@ class EndlessDataAttack(Exception): def _download(url, filename, using_tuf=False): if using_tuf: - urllib_tuf.urlretrieve(url, filename) + tuf.interposition.urllib_tuf.urlretrieve(url, filename) else: urllib.urlretrieve(url, filename) @@ -126,7 +126,7 @@ def test_arbitrary_package_attack(using_tuf=False, TIMESTAMP=False): # Client downloads (tries to download) the file. try: - _download(url=url_to_repo, filename=downloaded_file, using_tuf) + _download(url_to_repo, downloaded_file, using_tuf) except Exception, exception: # Because we are extending the true timestamp TUF metadata with invalid # JSON, we except to catch an error about invalid metadata JSON. diff --git a/tests/integration/test_indefinite_freeze_attack.py b/tests/integration/test_indefinite_freeze_attack.py index 21a3ac4f..a1550b97 100755 --- a/tests/integration/test_indefinite_freeze_attack.py +++ b/tests/integration/test_indefinite_freeze_attack.py @@ -28,7 +28,7 @@ import tuf import tuf.formats -import tuf.interposition.urllib_tuf as urllib_tuf +import tuf.interposition import tuf.repo.signerlib as signerlib import tuf.tests.util_test_tools as util_test_tools @@ -63,7 +63,7 @@ def _remake_timestamp(metadata_dir, keyids): def _download(url, filename, using_tuf=False): if using_tuf: - urllib_tuf.urlretrieve(url, filename) + tuf.interposition.urllib_tuf.urlretrieve(url, filename) else: urllib.urlretrieve(url, filename) @@ -119,7 +119,7 @@ def test_indefinite_freeze_attack(using_tuf=False): # Client performs initial download. try: - _download(url=url_to_repo, filename=downloaded_file, using_tuf) + _download(url_to_repo, downloaded_file, using_tuf) except tuf.ExpiredMetadataError: msg = ('Metadata has expired too soon, extend expiration period. '+ 'Current expiration is set to: '+repr(EXPIRATION)+' second(s).') @@ -130,7 +130,7 @@ def test_indefinite_freeze_attack(using_tuf=False): # Try downloading again, this should raise an error. try: - _download(url=url_to_repo, filename=downloaded_file, using_tuf) + _download(url_to_repo, downloaded_file, using_tuf) except tuf.ExpiredMetadataError, error: pass else: diff --git a/tests/integration/test_mix_and_match_attack.py b/tests/integration/test_mix_and_match_attack.py index 9ebc6340..fad46ade 100755 --- a/tests/integration/test_mix_and_match_attack.py +++ b/tests/integration/test_mix_and_match_attack.py @@ -126,7 +126,7 @@ def test_mix_and_match_attack(using_tuf=False): # Client's initial download. - _download(url=url_to_file, filename=downloaded_file, using_tuf) + _download(url_to_file, downloaded_file, using_tuf) # Stage 2 # ------- @@ -139,7 +139,7 @@ def test_mix_and_match_attack(using_tuf=False): util_test_tools.tuf_refresh_repo(root_repo, keyids) # Client downloads the patched file. - _download(url=url_to_file, filename=downloaded_file, using_tuf) + _download(url_to_file, downloaded_file, using_tuf) downloaded_content = util_test_tools.read_file_content(downloaded_file) @@ -163,7 +163,7 @@ def test_mix_and_match_attack(using_tuf=False): # Client tries to downloads the newly patched file. try: - _download(url=url_to_file, filename=downloaded_file, using_tuf) + _download(url_to_file, downloaded_file, using_tuf) except tuf.MetadataNotAvailableError: pass diff --git a/tests/integration/test_replay_attack.py b/tests/integration/test_replay_attack.py index 746a47e0..504b6165 100755 --- a/tests/integration/test_replay_attack.py +++ b/tests/integration/test_replay_attack.py @@ -38,7 +38,7 @@ import urllib import tempfile -import tuf.interposition.urllib_tuf as urllib_tuf +import tuf.interposition import tuf.tests.util_test_tools as util_test_tools @@ -54,7 +54,7 @@ class ReplayAttackAlert(Exception): def _download(url, filename, using_tuf=False): if using_tuf: - urllib_tuf.urlretrieve(url, filename) + tuf.interposition.urllib_tuf.urlretrieve(url, filename) else: urllib.urlretrieve(url, filename) @@ -114,7 +114,7 @@ def test_replay_attack(using_tuf=False): # Client performs initial update. - _download(url=url_to_repo, filename=downloaded_file, using_tuf) + _download(url_to_repo, downloaded_file, using_tuf) # Downloads are stored in the same directory '{root_repo}/downloads/' # for regular and tuf clients. @@ -132,7 +132,7 @@ def test_replay_attack(using_tuf=False): # Client downloads the patched file. - _download(url=url_to_repo, filename=downloaded_file, using_tuf) + _download(url_to_repo, downloaded_file, using_tuf) # Content of the downloaded file. downloaded_content = util_test_tools.read_file_content(downloaded_file) @@ -157,7 +157,7 @@ def test_replay_attack(using_tuf=False): # Client downloads the file once more. - _download(url=url_to_repo, filename=downloaded_file, using_tuf) + _download(url_to_repo, downloaded_file, using_tuf) # Check whether the attack succeeded by inspecting the content of the # update. The update should contain 'Test NOT A'. diff --git a/tests/integration/test_slow_retrieval_attack.py b/tests/integration/test_slow_retrieval_attack.py index cee4234c..7596cbb8 100755 --- a/tests/integration/test_slow_retrieval_attack.py +++ b/tests/integration/test_slow_retrieval_attack.py @@ -49,7 +49,7 @@ import urllib -import tuf.interposition.urllib_tuf as urllib_tuf +import tuf.interposition import tuf.tests.util_test_tools as util_test_tools @@ -60,7 +60,7 @@ class SlowRetrievalAttackAlert(Exception): def _download(url, filename, using_tuf=False): if using_tuf: try: - urllib_tuf.urlretrieve(url, filename) + tuf.interposition.urllib_tuf.urlretrieve(url, filename) except tuf.NoWorkingMirrorError, exception: slow_retrieval = False for mirror_url, mirror_error in exception.mirror_errors.iteritems(): @@ -124,7 +124,7 @@ def test_slow_retrieval_attack(using_tuf=False, mode=None): # Client tries to download. # NOTE: if TUF is enabled the metadata files will be downloaded first. - proc = Process(target=_download, args=(url_to_file, downloaded_file, TUF)) + proc = Process(target=_download, args=(url_to_file, downloaded_file, using_tuf)) proc.start() proc.join(WAIT_TIME)