File: test_request_raw.py

package info (click to toggle)
pocsuite3 2.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,996 kB
  • sloc: python: 16,816; asm: 911; java: 66; makefile: 30
file content (62 lines) | stat: -rw-r--r-- 2,255 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
52
53
54
55
56
57
58
59
60
61
62
import unittest
from pocsuite3.api import requests, init_pocsuite


class TestCase(unittest.TestCase):
    def setUp(self):
        init_pocsuite()

    def tearDown(self):
        pass

    @unittest.skip(reason='significant latency')
    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'})

    @unittest.skip(reason='significant latency')
    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')

    @unittest.skip(reason='significant latency')
    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"}')