Skip to content

Commit

Permalink
1660 - Cannot create/update ISO repo without feed.
Browse files Browse the repository at this point in the history
  • Loading branch information
ipanova committed Feb 11, 2016
1 parent f214c5e commit 983d412
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 61 deletions.
19 changes: 1 addition & 18 deletions plugins/pulp_rpm/plugins/importers/iso/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,7 @@ def _validate_feed_url(config):
Make sure the feed_url is a string, if it is set.
"""
feed_url = config.get(importer_constants.KEY_FEED)
# feed_urls are not required if all of the other feed related settings are None
dependencies = [
importer_constants.KEY_MAX_SPEED, importer_constants.KEY_MAX_DOWNLOADS,
importer_constants.KEY_PROXY_PASS, importer_constants.KEY_PROXY_PORT,
importer_constants.KEY_PROXY_HOST, importer_constants.KEY_PROXY_USER,
importer_constants.KEY_UNITS_REMOVE_MISSING, importer_constants.KEY_SSL_CA_CERT,
importer_constants.KEY_SSL_CLIENT_CERT, importer_constants.KEY_SSL_CLIENT_KEY,
importer_constants.KEY_VALIDATE]
if not feed_url and all([config.get(setting) is None for setting in dependencies]):
return
elif not feed_url:
msg = _(
'The configuration parameter <%(name)s> is required when any of the following other '
'parameters are defined: ' + ', '.join(dependencies) + '.')
msg = msg % {'name': importer_constants.KEY_FEED}
raise configuration_utils.ValidationError(msg)

if not isinstance(feed_url, basestring):
if feed_url and not isinstance(feed_url, basestring):
msg = _('<%(feed_url)s> must be a string.')
msg = msg % {'feed_url': importer_constants.KEY_FEED}
raise configuration_utils.ValidationError(msg)
Expand Down
44 changes: 1 addition & 43 deletions plugins/test/unit/plugins/importers/iso/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,49 +52,7 @@ def test_invalid_config(self):
self.assertTrue(status is False)
self.assertEqual(error_message,
'<%(feed)s> must be a string.' % {'feed': importer_constants.KEY_FEED})

def test_required_when_other_parameters_are_present(self):
for parameters in [
{importer_constants.KEY_MAX_SPEED: '1024'}, {importer_constants.KEY_MAX_DOWNLOADS: 2},
{importer_constants.KEY_PROXY_PASS: 'flock_of_seagulls',
importer_constants.KEY_PROXY_USER: 'big_kahuna_burger',
importer_constants.KEY_PROXY_HOST: 'http://test.com'},
{importer_constants.KEY_PROXY_HOST: 'http://test.com',
importer_constants.KEY_PROXY_PORT: '3037'},
{importer_constants.KEY_PROXY_HOST: 'http://test.com'},
{importer_constants.KEY_UNITS_REMOVE_MISSING: True},
{importer_constants.KEY_SSL_CA_CERT: 'cert'},
{importer_constants.KEY_SSL_CLIENT_CERT: 'cert'},
{importer_constants.KEY_SSL_CLIENT_CERT: 'cert',
importer_constants.KEY_SSL_CLIENT_KEY: 'key'},
{importer_constants.KEY_VALIDATE: True}]:
# Each of the above configurations should cause the validator to complain about the
# feed_url
# missing
config = importer_mocks.get_basic_config(**parameters)
status, error_message = configuration.validate(config)
self.assertTrue(status is False)
self.assertEqual(
error_message,
'The configuration parameter <%(feed)s> is required when any of the following '
'other '
'parameters are defined: %(max_speed)s, %(num_threads)s, %(proxy_pass)s, '
'%(proxy_port)s, '
'%(proxy_host)s, %(proxy_user)s, %(remove_missing_units)s, %(ssl_ca_cert)s, '
'%(ssl_client_cert)s, %(ssl_client_key)s, %(validate_units)s.' % {
'feed': importer_constants.KEY_FEED,
'max_speed': importer_constants.KEY_MAX_SPEED,
'num_threads': importer_constants.KEY_MAX_DOWNLOADS,
'proxy_pass': importer_constants.KEY_PROXY_PASS,
'proxy_port': importer_constants.KEY_PROXY_PORT,
'proxy_host': importer_constants.KEY_PROXY_HOST,
'proxy_user': importer_constants.KEY_PROXY_USER,
'remove_missing_units': importer_constants.KEY_UNITS_REMOVE_MISSING,
'ssl_ca_cert': importer_constants.KEY_SSL_CA_CERT,
'ssl_client_cert': importer_constants.KEY_SSL_CLIENT_CERT,
'ssl_client_key': importer_constants.KEY_SSL_CLIENT_KEY,
'validate_units': importer_constants.KEY_VALIDATE})


def test_valid(self):
config = importer_mocks.get_basic_config(
**{importer_constants.KEY_FEED: "http://test.com/feed"})
Expand Down

0 comments on commit 983d412

Please sign in to comment.