File: test_clparser.py

package info (click to toggle)
wfuzz 3.1.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,648 kB
  • sloc: python: 13,161; makefile: 59; sh: 4
file content (74 lines) | stat: -rw-r--r-- 2,668 bytes parent folder | download | duplicates (3)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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)],
        )