def test_enhancements(plugin, domains):
 supported = plugin.supported_enhancements()
 if ('redirect' not in supported):
  logger.error('The plugin and this program support no common enhancements')
  return False
 for domain in domains:
  try:
   plugin.enhance(domain, 'redirect')
   plugin.save()
  except le_errors.PluginError as error:
   logger.warning('Plugin failed to enable redirect for %s:', domain)
   logger.warning('%s', error)
  except le_errors.Error as error:
   logger.error('An error occurred while enabling redirect for %s:', domain)
   logger.exception(error)
 if (not _save_and_restart(plugin, 'enhanced')):
  return False
 success = True
 for domain in domains:
  verify = functools.partial(validator.Validator().redirect, 'localhost', plugin.http_port, headers={'Host': domain})
  if (not _try_until_true(verify)):
   logger.error('Improper redirect for domain %s', domain)
   success = False
 if success:
  logger.info('Enhancments test succeeded')
 return success

def test_enhancements ( plugin , domains ) : supported = plugin . supported_enhancements ( ) if ( 'redirect' not in supported ) : logger . error ( 'The plugin and this program support no common enhancements' ) return False for domain in domains : try : plugin . enhance ( domain , 'redirect' ) plugin . save ( ) except le_errors . PluginError as error : logger . warning ( 'Plugin failed to enable redirect for %s:' , domain ) logger . warning ( '%s' , error ) except le_errors . Error as error : logger . error ( 'An error occurred while enabling redirect for %s:' , domain ) logger . exception ( error ) if ( not _save_and_restart ( plugin , 'enhanced' ) ) : return False success = True for domain in domains : verify = functools . partial ( validator . Validator ( ) . redirect , 'localhost' , plugin . http_port , headers = { 'Host' : domain } ) if ( not _try_until_true ( verify ) ) : logger . error ( 'Improper redirect for domain %s' , domain ) success = False if success : logger . info ( 'Enhancments test succeeded' ) return success
tests supported enhancements returning true if successful .