Move tar filter to file, add tests for it

This commit is contained in:
Sam Chow 2018-06-28 16:56:33 -04:00
parent db757edcd2
commit d7ffb54333
9 changed files with 83 additions and 32 deletions

View file

@ -102,7 +102,8 @@ class ValidatorContext(object):
def __init__(self, config, user_password=None, http_client=None, context=None,
url_scheme_and_hostname=None, jwt_auth_max=None, registry_title=None,
ip_resolver=None, feature_sec_scanner=False, is_testing=False,
uri_creator=None, config_provider=None, instance_keys=None):
uri_creator=None, config_provider=None, instance_keys=None,
skip_localstorage_validation=False):
self.config = config
self.user = get_authenticated_user()
self.user_password = user_password
@ -117,10 +118,11 @@ class ValidatorContext(object):
self.uri_creator = uri_creator
self.config_provider = config_provider
self.instance_keys = instance_keys
self.skip_localstorage_validation = skip_localstorage_validation
@classmethod
def from_app(cls, app, config, user_password, ip_resolver, instance_keys, client=None,
config_provider=None):
config_provider=None, skip_localstorage_validation=False):
"""
Creates a ValidatorContext from an app config, with a given config to validate
:param app: the Flask app to pull configuration information from
@ -146,4 +148,5 @@ class ValidatorContext(object):
is_testing=app.config.get('TESTING', False),
uri_creator=get_blob_download_uri_getter(app.test_request_context('/'), url_scheme_and_hostname),
config_provider=config_provider,
instance_keys=instance_keys)
instance_keys=instance_keys,
skip_localstorage_validation=skip_localstorage_validation)

View file

@ -12,6 +12,7 @@ class StorageValidator(BaseValidator):
client = validator_context.http_client
ip_resolver = validator_context.ip_resolver
config_provider = validator_context.config_provider
skip_localstorage_validation = validator_context.skip_localstorage_validation
replication_enabled = config.get('FEATURE_STORAGE_REPLICATION', False)
@ -20,6 +21,9 @@ class StorageValidator(BaseValidator):
raise ConfigValidationException('Storage configuration required')
for name, (storage_type, driver) in providers:
if skip_localstorage_validation and storage_type == 'LocalStorage':
continue
try:
if replication_enabled and storage_type == 'LocalStorage':
raise ConfigValidationException('Locally mounted directory not supported ' +