예제 #1
0
    def test_clear(self):
        
        url = URL('http://w3af.com/a/b/c.php')
        request = HTTPRequest(url, data='a=1')
        hdr = Headers([('Content-Type', 'text/html')])
        res = HTTPResponse(200, '<html>', hdr, url, url)
        
        h1 = HistoryItem()
        h1.request = request
        res.set_id(1)
        h1.response = res
        h1.save()

        table_name = h1.get_table_name()
        db = get_default_temp_db_instance()
        
        self.assertTrue(db.table_exists(table_name))
        
        clear_result = h1.clear()
        
        self.assertTrue(clear_result)
        self.assertFalse(os.path.exists(h1._session_dir),
                         '%s exists.' % h1._session_dir)
        
        # Changed the meaning of clear a little bit... now it simply removes
        # all rows from the table, not the table itself
        self.assertTrue(db.table_exists(table_name))        
예제 #2
0
파일: test_history.py 프로젝트: zxchmf/w3af
    def test_clear(self):
        url = URL('http://w3af.com/a/b/c.php')
        request = HTTPRequest(url, data='a=1')
        hdr = Headers([('Content-Type', 'text/html')])
        res = HTTPResponse(200, '<html>', hdr, url, url)

        h1 = HistoryItem()
        h1.request = request
        res.set_id(1)
        h1.response = res
        h1.save()

        table_name = h1.get_table_name()
        db = get_default_temp_db_instance()

        self.assertTrue(db.table_exists(table_name))

        clear_result = h1.clear()

        self.assertTrue(clear_result)
        self.assertFalse(os.path.exists(h1._session_dir),
                         '%s exists.' % h1._session_dir)

        # Changed the meaning of clear a little bit... now it simply removes
        # all rows from the table, not the table itself
        self.assertTrue(db.table_exists(table_name))
예제 #3
0
    def __init__(self, table_prefix=None, dump=None, load=None):
        """
        :param table_prefix: The DBMS table prefix, mostly for debugging.
        :param dump: The function to use to serialize the object
        :param load: The function to use to deserialize the object
        """
        self.db = get_default_temp_db_instance()

        prefix = '' if table_prefix is None else ('%s_' % table_prefix)
        self.table_name = 'disk_list_' + prefix + rand_alpha(30)

        self.dump = dump
        self.load = load

        # Create table
        # DO NOT add the AUTOINCREMENT flag to the table creation since that
        # will break __getitem__ when an item is removed, see:
        #     http://www.sqlite.org/faq.html#q1
        columns = [('index_', 'INTEGER'),
                   ('eq_attrs', 'TEXT'),
                   ('pickle', 'BLOB')]
        pks = ['index_']
        
        self.db.create_table(self.table_name, columns, pks)
        self.db.create_index(self.table_name, ['eq_attrs'])
        self.db.commit()

        self._state = OPEN
예제 #4
0
    def __init__(self, table_prefix=None, dump=None, load=None):
        """
        :param table_prefix: The DBMS table prefix, mostly for debugging.
        :param dump: The function to use to serialize the object
        :param load: The function to use to deserialize the object
        """
        self.db = get_default_temp_db_instance()

        prefix = '' if table_prefix is None else ('%s_' % table_prefix)
        self.table_name = 'disk_list_' + prefix + rand_alpha(30)

        self.dump = dump
        self.load = load

        # Create table
        # DO NOT add the AUTOINCREMENT flag to the table creation since that
        # will break __getitem__ when an item is removed, see:
        #     http://www.sqlite.org/faq.html#q1
        columns = [('index_', 'INTEGER'), ('eq_attrs', 'TEXT'),
                   ('pickle', 'BLOB')]
        pks = ['index_']

        self.db.create_table(self.table_name, columns, pks)
        self.db.create_index(self.table_name, ['eq_attrs'])
        self.db.commit()

        self._state = OPEN
예제 #5
0
    def test_default_db(self):
        db = get_default_temp_db_instance()
        db.create_table('TEST', [('id', 'INT'), ('data', 'TEXT')]).result()

        db.execute('INSERT INTO TEST VALUES (1,"a")').result()

        self.assertIn((1, 'a'), db.select('SELECT * from TEST'))
        self.assertEqual((1, 'a'), db.select_one('SELECT * from TEST'))
예제 #6
0
 def test_default_db(self):
     db = get_default_temp_db_instance()
     db.create_table('TEST', set([('id', 'INT'), ('data', 'TEXT')])).result()
     
     db.execute('INSERT INTO TEST VALUES (1,"a")').result()
     
     self.assertIn(('1', 'a'), db.select('SELECT * from TEST'))
     self.assertEqual(('1', 'a'), db.select_one('SELECT * from TEST'))
예제 #7
0
 def test_remove_table(self):
     disk_list = DiskList()
     table_name = disk_list.table_name
     db = get_default_temp_db_instance()
     
     self.assertTrue(db.table_exists(table_name))
     
     disk_list.cleanup()
     
     self.assertFalse(db.table_exists(table_name))
예제 #8
0
    def test_remove_table(self):
        disk_dict = DiskDict()
        table_name = disk_dict.table_name
        db = get_default_temp_db_instance()

        self.assertTrue(db.table_exists(table_name))

        disk_dict.cleanup()

        self.assertFalse(db.table_exists(table_name))
예제 #9
0
    def test_table_name_with_prefix(self):
        _unittest = 'unittest'
        disk_set = DiskSet(_unittest)

        self.assertIn(_unittest, disk_set.table_name)
        db = get_default_temp_db_instance()

        self.assertTrue(db.table_exists(disk_set.table_name))

        disk_set.cleanup()

        self.assertFalse(db.table_exists(disk_set.table_name))
예제 #10
0
    def test_table_name_with_prefix(self):
        _unittest = 'unittest'
        disk_list = DiskList(_unittest)

        self.assertIn(_unittest, disk_list.table_name)
        db = get_default_temp_db_instance()

        self.assertTrue(db.table_exists(disk_list.table_name))

        disk_list.cleanup()

        self.assertFalse(db.table_exists(disk_list.table_name))
예제 #11
0
    def test_remove_table(self):
        disk_set = DiskSet()
        disk_set.add(1)
        disk_set.add(2)

        table_name = disk_set.table_name
        db = get_default_temp_db_instance()

        self.assertTrue(db.table_exists(table_name))

        disk_set.cleanup()

        self.assertFalse(db.table_exists(table_name))
예제 #12
0
파일: disk_dict.py 프로젝트: intfrr/Tortazo
    def __init__(self):
        self.db = get_default_temp_db_instance()

        self.table_name = rand_alpha(30)

        # Create table
        # DO NOT add the AUTOINCREMENT flag to the table creation since that
        # will break __getitem__ when an item is removed, see:
        #     http://www.sqlite.org/faq.html#q1
        columns = [('index_', 'INTEGER'), ('key', 'BLOB'), ('value', 'BLOB')]
        pks = ['index_']

        self.db.create_table(self.table_name, columns, pks)
        self.db.create_index(self.table_name, ['key'])
        self.db.commit()
예제 #13
0
    def __init__(self):
        self.db = get_default_temp_db_instance()

        self.table_name = rand_alpha(30)

        # Create table
        # DO NOT add the AUTOINCREMENT flag to the table creation since that
        # will break __getitem__ when an item is removed, see:
        #     http://www.sqlite.org/faq.html#q1
        columns = [('index_', 'INTEGER'),
                   ('eq_attrs', 'TEXT'),
                   ('pickle', 'BLOB')]
        pks = ['index_']
        
        self.db.create_table(self.table_name, columns, pks)
        self.db.create_index(self.table_name, ['eq_attrs',])
        self.db.commit()
예제 #14
0
    def __init__(self, table_prefix=None):
        self.db = get_default_temp_db_instance()

        prefix = '' if table_prefix is None else ('%s_' % table_prefix)
        self.table_name = 'disk_dict_' + prefix + rand_alpha(30)

        # Create table
        # DO NOT add the AUTOINCREMENT flag to the table creation since that
        # will break __getitem__ when an item is removed, see:
        #     http://www.sqlite.org/faq.html#q1
        columns = [('index_', 'INTEGER'),
                   ('key', 'BLOB'),
                   ('value', 'BLOB')]
        pks = ['index_']
        
        self.db.create_table(self.table_name, columns, pks)
        self.db.create_index(self.table_name, ['key'])
        self.db.commit()
예제 #15
0
    def __init__(self, table_prefix=None):
        self.db = get_default_temp_db_instance()

        prefix = '' if table_prefix is None else ('%s_' % table_prefix)
        self.table_name = 'disk_list_' + prefix + rand_alpha(30)

        # Create table
        # DO NOT add the AUTOINCREMENT flag to the table creation since that
        # will break __getitem__ when an item is removed, see:
        #     http://www.sqlite.org/faq.html#q1
        columns = [('index_', 'INTEGER'), ('eq_attrs', 'TEXT'),
                   ('pickle', 'BLOB')]
        pks = ['index_']

        self.db.create_table(self.table_name, columns, pks)
        self.db.create_index(self.table_name, ['eq_attrs'])
        self.db.commit()

        self._state = OPEN
예제 #16
0
 def test_get_default_temp_db_instance(self):
     self.assertEqual(id(get_default_temp_db_instance()),
                      id(get_default_temp_db_instance()))
예제 #17
0
 def test_get_default_temp_db_instance(self):
     self.assertEqual(id(get_default_temp_db_instance()),
                      id(get_default_temp_db_instance()))    
예제 #18
0
파일: history.py 프로젝트: 0x554simon/w3af
 def __init__(self):
     self._db = get_default_temp_db_instance()
     
     self._session_dir = os.path.join(get_temp_dir(),
                                      self._db.get_file_name() + '_traces')
예제 #19
0
파일: history.py 프로젝트: woverines/w3af
    def __init__(self):
        self._db = get_default_temp_db_instance()

        self._session_dir = os.path.join(get_temp_dir(),
                                         self._db.get_file_name() + '_traces')