Ejemplo n.º 1
0
    def test_write(self):
        tempfilename = "/tmp/testfile-%s.cfg" % time.time()
        
        config = AVConfigParser(DEFAULT_SECTION)
        config.write(tempfilename)
        self.assertFalse(config.has_section(DEFAULT_SECTION))
        self.assertEqual(config.read(TEST_FILES_PATH + "ossim_setup1.conf"),AVConfigParserErrors.ALL_OK)
        del config
        
        config = AVConfigParser(DEFAULT_SECTION)
        self.assertFalse(config.has_section(DEFAULT_SECTION))
        self.assertEqual(config.read(tempfilename),AVConfigParserErrors.ALL_OK)
        del config
        
        os.remove(tempfilename)

        tempfilename = "/tmp/testfile2-%s.cfg" % time.time()
        config = AVConfigParser(DEFAULT_SECTION)
        self.assertEqual(config.read(TEST_FILES_PATH + "ossim_setup1.conf"),AVConfigParserErrors.ALL_OK)
        config.set("server","server_ip","192.168.7.99")
        config.set("sensor","interfaces","eth5")
        config.write(tempfilename)
        del config
        
        config = AVConfigParser(DEFAULT_SECTION)
        self.assertEqual(config.read(tempfilename),AVConfigParserErrors.ALL_OK)
        self.assertEqual(config.get_option("sensor","interfaces"),"eth5")
        self.assertEqual(config.get_option("server","server_ip"),"192.168.7.99")
        del config
        os.remove(tempfilename)
Ejemplo n.º 2
0
    def test_write(self):
        tempfilename = "/tmp/testfile-%s.cfg" % time.time()

        config = AVConfigParser(DEFAULT_SECTION)
        config.write(tempfilename)
        self.assertFalse(config.has_section(DEFAULT_SECTION))
        self.assertEqual(config.read(TEST_FILES_PATH + "ossim_setup1.conf"),
                         AVConfigParserErrors.ALL_OK)
        del config

        config = AVConfigParser(DEFAULT_SECTION)
        self.assertFalse(config.has_section(DEFAULT_SECTION))
        self.assertEqual(config.read(tempfilename),
                         AVConfigParserErrors.ALL_OK)
        del config

        os.remove(tempfilename)

        tempfilename = "/tmp/testfile2-%s.cfg" % time.time()
        config = AVConfigParser(DEFAULT_SECTION)
        self.assertEqual(config.read(TEST_FILES_PATH + "ossim_setup1.conf"),
                         AVConfigParserErrors.ALL_OK)
        config.set("server", "server_ip", "192.168.7.99")
        config.set("sensor", "interfaces", "eth5")
        config.write(tempfilename)
        del config

        config = AVConfigParser(DEFAULT_SECTION)
        self.assertEqual(config.read(tempfilename),
                         AVConfigParserErrors.ALL_OK)
        self.assertEqual(config.get_option("sensor", "interfaces"), "eth5")
        self.assertEqual(config.get_option("server", "server_ip"),
                         "192.168.7.99")
        del config
        os.remove(tempfilename)
Ejemplo n.º 3
0
 def test_set(self):
     config = AVConfigParser(DEFAULT_SECTION)
     self.assertEqual(config.read(TEST_FILES_PATH + "ossim_setup1.conf"),AVConfigParserErrors.ALL_OK)
     profile = config.get_option("expert","profile")
     self.assertTrue(config.set("expert","profile","Database"))
     self.assertEquals(config.get_option("expert","profile"),"Database")
     
     self.assertFalse(config.set("Nosection","novalue","value"))
     #Add a new option=value
     self.assertTrue(config.set(DEFAULT_SECTION,"novalue","value"))
Ejemplo n.º 4
0
    def test_set(self):
        config = AVConfigParser(DEFAULT_SECTION)
        self.assertEqual(config.read(TEST_FILES_PATH + "ossim_setup1.conf"),
                         AVConfigParserErrors.ALL_OK)
        profile = config.get_option("expert", "profile")
        self.assertTrue(config.set("expert", "profile", "Database"))
        self.assertEquals(config.get_option("expert", "profile"), "Database")

        self.assertFalse(config.set("Nosection", "novalue", "value"))
        #Add a new option=value
        self.assertTrue(config.set(DEFAULT_SECTION, "novalue", "value"))
Ejemplo n.º 5
0
    def test_get_option(self):
        config = AVConfigParser(DEFAULT_SECTION)
        self.assertEqual(config.get_option("expert","profile"),None)

        self.assertFalse(config.has_section(DEFAULT_SECTION))
        self.assertEqual(config.read(TEST_FILES_PATH + "ossim_setup1.conf"),AVConfigParserErrors.ALL_OK)

        self.assertEqual(config.get_option("expert","profile"),"server")
        self.assertEqual(config.get_option("unknownsection","profile"),None)
        self.assertEqual(config.get_option("","interface"),"eth0")
        self.assertEqual(config.get_option(DEFAULT_SECTION,"domain"),"alienvault")
        del config
Ejemplo n.º 6
0
    def test_get_option(self):
        config = AVConfigParser(DEFAULT_SECTION)
        self.assertEqual(config.get_option("expert", "profile"), None)

        self.assertFalse(config.has_section(DEFAULT_SECTION))
        self.assertEqual(config.read(TEST_FILES_PATH + "ossim_setup1.conf"),
                         AVConfigParserErrors.ALL_OK)

        self.assertEqual(config.get_option("expert", "profile"), "server")
        self.assertEqual(config.get_option("unknownsection", "profile"), None)
        self.assertEqual(config.get_option("", "interface"), "eth0")
        self.assertEqual(config.get_option(DEFAULT_SECTION, "domain"),
                         "alienvault")
        del config