Extract app from torrent handling code

Fixes https://jira.coreos.com/browse/QUAY-969
This commit is contained in:
Joseph Schorr 2018-06-14 17:29:39 -04:00
parent c92c0ca5e1
commit 0fdefd78e9
7 changed files with 63 additions and 53 deletions

View file

@ -3,9 +3,7 @@ import logging
from hashlib import sha1
from util.config.validators import BaseValidator, ConfigValidationException
# Temporarily removed because registry.torrent imports from app, add encoded_jwt back once extracted
# TODO(jschorr): extract app from following package and re-enable jwt_from_infohash in validator
# from util.registry.torrent import jwt_from_infohash
from util.registry.torrent import jwt_from_infohash, TorrentConfiguration
logger = logging.getLogger(__name__)
@ -33,8 +31,10 @@ class BittorrentValidator(BaseValidator):
'port': 80,
}
# encoded_jwt = jwt_from_infohash(params['info_hash'])
# params['jwt'] = encoded_jwt
torrent_config = TorrentConfiguration.for_testing(validator_context.instance_keys, announce_url,
validator_context.registry_title)
encoded_jwt = jwt_from_infohash(torrent_config, params['info_hash'])
params['jwt'] = encoded_jwt
resp = client.get(announce_url, timeout=5, params=params)
logger.debug('Got tracker response: %s: %s', resp.status_code, resp.text)