File: test_clparser.py

package info (click to toggle)
wfuzz 2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 2,244 kB
  • sloc: python: 8,786; makefile: 49; sh: 4
file content (51 lines) | stat: -rw-r--r-- 2,397 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import unittest

from wfuzz.ui.console.clparser import CLParser


class CLParserTest(unittest.TestCase):
    def test_listplugins(self):
        with self.assertRaises(SystemExit) as cm:
            CLParser(['wfuzz', '-e', 'iterators']).parse_cl()

        self.assertEqual(cm.exception.code, 0)

    def test_ip_option(self):
        options = CLParser(['wfuzz', '--ip', '127.0.0.1']).parse_cl()

        self.assertEqual(options.data['connect_to_ip']['ip'], '127.0.0.1')
        self.assertEqual(options.data['connect_to_ip']['port'], '80')

        options = CLParser(['wfuzz', '--ip', '127.0.0.1:22']).parse_cl()

        self.assertEqual(options.data['connect_to_ip']['ip'], '127.0.0.1')
        self.assertEqual(options.data['connect_to_ip']['port'], '22')

        options = CLParser(['wfuzz', '--ip', '127.0.0.1:']).parse_cl()

        self.assertEqual(options.data['connect_to_ip']['ip'], '127.0.0.1')
        self.assertEqual(options.data['connect_to_ip']['port'], '80')

        with self.assertRaises(Exception) as cm:
            options = CLParser(['wfuzz', '--ip', ':80']).parse_cl()
        self.assertTrue("An IP must be specified" in str(cm.exception))

    def test_ze_zd_option(self):
        with self.assertRaises(Exception) as cm:
            options = CLParser(['wfuzz', '-z', 'range,0-10', '--zD', '0-10', 'url']).parse_cl()
        self.assertTrue("exclusive" in str(cm.exception))

        options = CLParser(['wfuzz', '-z', 'range', '--zD', '0-1', '--zE', 'md5', 'url']).parse_cl()
        self.assertEqual(options.data['payloads'], [('range', {'default': '0-1', 'encoder': ['md5']}, None)])

        options = CLParser(['wfuzz', '-z', 'range,0-1', '--zE', 'md5', 'url']).parse_cl()
        self.assertEqual(options.data['payloads'], [('range', {'default': '0-1', 'encoder': ['md5']}, None)])

        options = CLParser(['wfuzz', '-z', 'range', '--zD', '0-1', '--zE', 'md5', 'url']).parse_cl()
        self.assertEqual(options.data['payloads'], [('range', {'default': '0-1', 'encoder': ['md5']}, None)])

        options = CLParser(['wfuzz', '-z', 'range', '--zD', '0-1']).parse_cl()
        self.assertEqual(options.data['payloads'], [('range', {'default': '0-1', 'encoder': None}, None)])

        options = CLParser(['wfuzz', '-z', 'range,0-1']).parse_cl()
        self.assertEqual(options.data['payloads'], [('range', {'default': '0-1', 'encoder': None}, None)])