forked from xmendez/wfuzz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_relativeurl.py
135 lines (126 loc) · 4.49 KB
/
test_relativeurl.py
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import pytest
# Python 2 and 3: urlib.parse
from wfuzz.fuzzrequest import FuzzRequest
@pytest.fixture
def full_fuzzreq(request):
http_req, http_response = request.param
fr = FuzzRequest()
fr.update_from_raw_http(http_req, "http", http_response, None)
return fr
@pytest.mark.parametrize(
"full_fuzzreq, expected_result",
[
(
(
"GET /a HTTP/1.1\n"
"Host: www.wfuzz.org\n"
"Content-Type: application/x-www-form-urlencoded\n"
"User-Agent: Wfuzz/2.1\n",
"HTTP/1.0 301 Moved Permanently\n"
"Server: SimpleHTTP/0.6 Python/3.6.5\n"
"Date: Tue, 21 Apr 2020 21:10:53 GMT\n"
"Location: /recursive_dir/a/\n",
),
"http://www.wfuzz.org/recursive_dir/a/",
),
(
(
"GET /a HTTP/1.1\n"
"Host: www.wfuzz.org\n"
"Content-Type: application/x-www-form-urlencoded\n"
"User-Agent: Wfuzz/2.1\n",
"HTTP/1.1 301 Moved Permanently\n"
"Date: Fri, 24 Apr 2020 11:17:51 GMT\n"
"Server: Apache/2.4.41 () OpenSSL/1.0.2k-fips\n"
"Strict-Transport-Security: max-age=31536000; includeSubdomains; preload\n"
"Location: https://www.wfuzz.org/\n"
"Content-Type: text/html; charset=iso-8859-1\n",
),
None,
),
(
(
"GET /a HTTP/1.1\n"
"Host: www.wfuzz.org\n"
"Content-Type: application/x-www-form-urlencoded\n"
"User-Agent: Wfuzz/2.1\n",
"HTTP/1.0 404 File not found\n"
"Server: SimpleHTTP/0.6 Python/3.6.5\n"
"Date: Fri, 24 Apr 2020 12:37:54 GMT\n"
"Connection: close\n"
"Content-Type: text/html;charset=utf-8\n"
"Content-Length: 469\n",
),
None,
),
],
indirect=["full_fuzzreq"],
)
def test_relative_url(full_fuzzreq, expected_result):
assert full_fuzzreq.recursive_url == expected_result
@pytest.mark.parametrize(
"full_fuzzreq, expected_result",
[
(
(
"GET /a HTTP/1.1\n"
"Host: www.wfuzz.org\n"
"Content-Type: application/x-www-form-urlencoded\n"
"User-Agent: Wfuzz/2.1\n",
"HTTP/1.0 301 Moved Permanently\n"
"Server: SimpleHTTP/0.6 Python/3.6.5\n"
"Date: Tue, 21 Apr 2020 21:10:53 GMT\n"
"Location: /recursive_dir/a/\n",
),
True,
),
(
(
"GET /a HTTP/1.1\n"
"Host: www.wfuzz.org\n"
"Content-Type: application/x-www-form-urlencoded\n"
"User-Agent: Wfuzz/2.1\n",
"HTTP/1.1 301 Moved Permanently\n"
"Date: Fri, 24 Apr 2020 11:17:51 GMT\n"
"Server: Apache/2.4.41 () OpenSSL/1.0.2k-fips\n"
"Strict-Transport-Security: max-age=31536000; includeSubdomains; preload\n"
"Location: https://www.wfuzz.org/\n"
"Content-Type: text/html; charset=iso-8859-1\n",
),
False,
),
(
(
"GET /a HTTP/1.1\n"
"Host: www.wfuzz.org\n"
"Content-Type: application/x-www-form-urlencoded\n"
"User-Agent: Wfuzz/2.1\n",
"HTTP/1.0 404 File not found\n"
"Server: SimpleHTTP/0.6 Python/3.6.5\n"
"Date: Fri, 24 Apr 2020 12:37:54 GMT\n"
"Connection: close\n"
"Content-Type: text/html;charset=utf-8\n"
"Content-Length: 469\n",
),
False,
),
(
(
"GET /a/ HTTP/1.1\n"
"Host: www.wfuzz.org\n"
"Content-Type: application/x-www-form-urlencoded\n"
"User-Agent: Wfuzz/2.1\n",
"HTTP/1.0 200\n"
"Server: SimpleHTTP/0.6 Python/3.6.5\n"
"Date: Fri, 24 Apr 2020 12:37:54 GMT\n"
"Connection: close\n"
"Content-Type: text/html;charset=utf-8\n"
"Content-Length: 469\n",
),
True,
),
],
indirect=["full_fuzzreq"],
)
def test_is_path(full_fuzzreq, expected_result):
assert full_fuzzreq.is_path == expected_result