'This test reads a line from the DB and parses it, it\'s objective is to
make sure that DB upgrades with update_scan_db.py do not break the code
at pykto.py.'

def test_parse_db_line_basic(self):

    config = Config(['/cgi-bin/'], [], [], [], [])
    url = URL('http://moth/')
    pykto_inst = self.w3afcore.plugins.get_plugin_inst('crawl', 'pykto')
    nikto_parser = NiktoTestParser(pykto_inst._db_file, config, url)
    line = u'"000003","0","1234576890ab","@CGIDIRScart32.exe","GET","200","","","","","request    cart32.exe/cart32clientlist","",""'
    nikto_tests = [i for i in nikto_parser._parse_db_line(line)]
    self.assertEqual(len(nikto_tests), 1)
    nikto_test = nikto_tests[0]
    self.assertEqual(nikto_test.id, '000003')
    self.assertEqual(nikto_test.osvdb, '0')
    self.assertEqual(nikto_test.tune, '1234576890ab')
    self.assertEqual(nikto_test.uri.url_string, 'http://moth/cgi-bin/cart32.exe')
    self.assertEqual(nikto_test.method, 'GET')
    self.assertEqual(nikto_test.match_1, 200)
    self.assertEqual(nikto_test.match_1_or, None)
    self.assertEqual(nikto_test.match_1_and, None)
    self.assertEqual(nikto_test.fail_1, None)
    self.assertEqual(nikto_test.fail_2, None)
    self.assertEqual(nikto_test.message, 'request    cart32.exe/cart32clientlist')
    self.assertEqual(nikto_test.data, '')
    self.assertEqual(nikto_test.headers, '')
    generator = nikto_parser.test_generator()
    cart32_test_from_db = [i for (i,) in generator if (i.id == '000003')][0]
    self.assertEqual(cart32_test_from_db.uri, nikto_test.uri)
    self.assertEqual(cart32_test_from_db.match_1, nikto_test.match_1)
    self.assertEqual(cart32_test_from_db.message, nikto_test.message)
