More integration test tidying-up

This commit is contained in:
zanefisher 2013-09-13 17:39:29 -04:00
parent a397e208cd
commit e059cf814b
5 changed files with 18 additions and 18 deletions

View file

@ -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.

View file

@ -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:

View file

@ -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

View file

@ -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'.

View file

@ -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)