def TestAutomaticSecurityUpdates()

in image_test/configuration/linux/redhat.py [0:0]


  def TestAutomaticSecurityUpdates(self):
    # the following command returns zero if package is installed
    utils.Execute(['yum', 'list', 'installed', 'yum-cron'])

    # service returns zero if service exists and is running
    utils.Execute(['service', 'yum-cron', 'status'])

    # check yum-cron configuration
    # Now this part is, unfortunately, different between RedHat 6 and 7
    yum_cron_file, configs = self.GetYumCronConfig()

    for key in configs:
      command = ['grep', key, yum_cron_file]
      rc, output = utils.Execute(command, capture_output=True)
      # get clean text after '=' token
      cur_value = generic_distro.RemoveCommentAndStrip(
          output[output.find('=') + 1:]
      )
      if configs[key] != cur_value:
        raise Exception('Yum-cron config "%s" is "%s" but expected "%s"' % (
            key, cur_value, configs[key]))