コード例 #1
0
ファイル: test_target.py プロジェクト: chenbremer/w3af-1
    def test_verify_url(self):
        ctarget = CoreTarget()

        self.assertRaises(BaseFrameworkException, ctarget._verify_url,
                          URL_KLASS('ftp://www.google.com/'))
        
        self.assertTrue(ctarget._verify_url(URL_KLASS('http://www.google.com/')))
        self.assertTrue(ctarget._verify_url(URL_KLASS('http://www.google.com:39/')))
コード例 #2
0
    def test_factory_ok(self):
        input_file = self.INPUT_FILE
        output_file = self.INPUT_FILE

        data = {
            BOOL: [('true', True)],
            INT: [('1', 1)],
            POSITIVE_INT: [('2', 2)],
            FLOAT: [('1.0', 1.0)],
            STRING: [('hello world', 'hello world')],
            URL: [('http://moth/', URL_KLASS('http://moth/'))],
            URL_LIST:
            [('http://moth/1 , http://moth/2',
              [URL_KLASS('http://moth/1'),
               URL_KLASS('http://moth/2')])],
            IPPORT: [('127.0.0.1:8080', '127.0.0.1:8080')],
            LIST: [('a,b,c', ['a', 'b', 'c'])],
            REGEX: [('.*', '.*')],
            COMBO: [(['a', 'b', 'c'], 'a')],
            INPUT_FILE: [(input_file, input_file)],
            OUTPUT_FILE: [(output_file, output_file)],
            PORT: [('12345', 12345)],
            IP: [('127.0.0.1', '127.0.0.1'), (None, None)]
        }

        for _type in data:
            for user_value, parsed_value in data[_type]:
                opt = opt_factory('name', user_value, 'desc', _type, 'help',
                                  'tab1')

                self.assertEqual(opt.get_name(), 'name')
                self.assertEqual(opt.get_desc(), 'desc')
                self.assertEqual(opt.get_type(), _type)
                self.assertEqual(opt.get_default_value(), parsed_value)
                self.assertEqual(opt.get_value(), parsed_value)
                self.assertEqual(opt.get_help(), 'help')
                self.assertEqual(opt.get_tabid(), 'tab1')

                self.assertIsInstance(opt.get_name(), basestring)
                self.assertIsInstance(opt.get_desc(), basestring)
                self.assertIsInstance(opt.get_type(), basestring)
                self.assertIsInstance(opt.get_help(), basestring)
コード例 #3
0
ファイル: test_target.py プロジェクト: llcoolj1/w3af-kali
    def test_verify_file_target(self):
        ctarget = w3af_core_target()

        target_file = '/tmp/moth.target'
        target = 'file://%s' % target_file

        target_file_handler = file(target_file, 'w')
        target_file_handler.write('http://moth/1\n')
        target_file_handler.write('http://moth/2\n')
        target_file_handler.close()

        options = ctarget.get_options()
        options['target'].set_value(target)
        ctarget.set_options(options)

        moth1 = URL_KLASS('http://moth/1')
        moth2 = URL_KLASS('http://moth/2')

        self.assertIn(moth1, cf.cf.get('targets'))
        self.assertIn(moth2, cf.cf.get('targets'))
コード例 #4
0
    def test_factory_already_converted_type(self):
        data = {
            BOOL: (True, True),
            INT: (1, 1),
            FLOAT: (1.0, 1.0),
            STRING: ('hello world', 'hello world'),
            URL: (URL_KLASS('http://moth/'), URL_KLASS('http://moth/')),
            URL_LIST:
            ([URL_KLASS('http://moth/1'),
              URL_KLASS('http://moth/2')],
             [URL_KLASS('http://moth/1'),
              URL_KLASS('http://moth/2')]),
            LIST: (['a', 'b', 'c'], ['a', 'b', 'c']),
            PORT: (12345, 12345)
        }

        for _type, (user_value, parsed_value) in data.iteritems():
            opt = opt_factory('name', user_value, 'desc', _type)

            self.assertEqual(opt.get_name(), 'name')
            self.assertEqual(opt.get_desc(), 'desc')
            self.assertEqual(opt.get_type(), _type)
            self.assertEqual(opt.get_default_value(), parsed_value)
            self.assertEqual(opt.get_value(), parsed_value)

            self.assertIsInstance(opt.get_name(), basestring)
            self.assertIsInstance(opt.get_desc(), basestring)
            self.assertIsInstance(opt.get_type(), basestring)
            self.assertIsInstance(opt.get_help(), basestring)