Exemplo n.º 1
0
    def testMissingAttribute(self):
        """
        Test the parsing when attributes are missing, should get exceptions
        """

        config_file = get_test_config("rsv/rsv2.ini")
        configuration = configparser.SafeConfigParser()
        configuration.read(config_file)

        settings = rsv.RsvConfiguration(logger=global_logger)
        settings.rsv_meta_dir = RSV_META_DIR
        settings.parse_configuration(configuration)

        mandatory = ['enable_nagios']
        for option in mandatory:
            config_file = get_test_config("rsv/rsv1.ini")
            configuration = configparser.SafeConfigParser()
            configuration.read(config_file)
            configuration.remove_option('RSV', option)

            settings = rsv.RsvConfiguration(logger=global_logger)
            settings.rsv_meta_dir = RSV_META_DIR
            self.assertRaises(exceptions.SettingError,
                              settings.parse_configuration,
                              configuration)
Exemplo n.º 2
0
    def load_settings_from_files(self, *cfgfiles):
        configuration = configparser.SafeConfigParser()
        for cfgfile in cfgfiles:
            configuration.read(get_test_config(cfgfile))

        settings = rsv.RsvConfiguration(logger=global_logger)
        settings.rsv_meta_dir = RSV_META_DIR
        settings.parse_configuration(configuration)

        return settings
Exemplo n.º 3
0
    def load_settings_from_files(self, *cfgfiles):
        configuration = ConfigParser.SafeConfigParser()
        for cfgfile in cfgfiles:
            configuration.read(get_test_config(cfgfile))

        settings = rsv.RsvConfiguration(logger=global_logger)
        settings.rsv_meta_dir = RSV_META_DIR
        try:
            settings.parse_configuration(configuration)
        except Exception, e:
            self.fail("Received exception while parsing configuration: %s" % e)
Exemplo n.º 4
0
 def testGram(self):
     """
     Test RSV config no longer accepts gram_ce_hosts
     """
     config_parser = ConfigParser.SafeConfigParser()
     config_file = get_test_config("rsv/rsv_gram.ini")
     config_parser.read(config_file)
     settings = rsv.RsvConfiguration(logger=global_logger)
     settings.parse_configuration(config_parser)
     self.assertFalse(settings.check_attributes(settings.get_attributes()),
                      "gram_ce_hosts incorrectly flagged as correct")
Exemplo n.º 5
0
    def testMissingAttribute(self):
        """
        Test the parsing when attributes are missing, should get exceptions
        """

        # need to have rsv installed to get rsv tests working
        if not utilities.rpm_installed('rsv-core'):
            return
        config_file = get_test_config("rsv/rsv2.ini")
        configuration = ConfigParser.SafeConfigParser()
        configuration.read(config_file)

        settings = rsv.RsvConfiguration(logger=global_logger)
        settings.rsv_meta_dir = RSV_META_DIR
        try:
            settings.parse_configuration(configuration)
        except Exception, e:
            self.fail("Received exception while parsing configuration: %s" % e)
Exemplo n.º 6
0
        settings = rsv.RsvConfiguration(logger=global_logger)
        settings.rsv_meta_dir = RSV_META_DIR
        try:
            settings.parse_configuration(configuration)
        except Exception, e:
            self.fail("Received exception while parsing configuration: %s" % e)

        mandatory = ['enable_gratia', 'enable_nagios']
        for option in mandatory:
            config_file = get_test_config("rsv/rsv1.ini")
            configuration = ConfigParser.SafeConfigParser()
            configuration.read(config_file)
            configuration.remove_option('RSV', option)

            settings = rsv.RsvConfiguration(logger=global_logger)
            settings.rsv_meta_dir = RSV_META_DIR
            self.assertRaises(exceptions.SettingError,
                              settings.parse_configuration, configuration)

    def testInvalidKey(self):
        """
        Test the check_attributes with invalid key file
        """

        # need to have rsv installed to get rsv tests working
        if not utilities.rpm_installed('rsv-core'):
            return
        settings = self.load_settings_from_files("rsv/invalid_key.ini")
        attributes = settings.get_attributes()
        self.assertFalse(settings.check_attributes(attributes),