forked from knownsec/pocsuite3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_request_raw.py
53 lines (47 loc) · 1.98 KB
/
test_request_raw.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
import unittest
from pocsuite3.api import requests
class TestCase(unittest.TestCase):
def test_get(self):
raw = '''
GET /get?a=1&b=2 HTTP/1.1
Host: httpbin.org
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: pocsuite v3.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Cookie: _gauges_unique_hour=1; _gauges_unique_day=1; _gauges_unique_month=1; _gauges_unique_year=1; _gauges_unique=1
'''
r = requests.httpraw(raw)
self.assertTrue(r.json()['args'] == {'a': '1', 'b': '2'})
def test_post(self):
raw = '''
POST /post HTTP/1.1
Host: httpbin.org
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: pocsuite v3.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Cookie: _gauges_unique_hour=1; _gauges_unique_day=1; _gauges_unique_month=1; _gauges_unique_year=1; _gauges_unique=1
a=1&b=2
'''
r = requests.httpraw(raw)
self.assertTrue(r.json()['data'] == 'a=1&b=2')
def test_json(self):
raw = '''
POST /post HTTP/1.1
Host: httpbin.org
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: pocsuite v3.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Cookie: _gauges_unique_hour=1; _gauges_unique_day=1; _gauges_unique_month=1; _gauges_unique_year=1; _gauges_unique=1
{"pocsuite":"v3.0"}
'''
r = requests.httpraw(raw)
self.assertTrue(r.json()['json'] == '{"pocsuite":"v3.0"}')