-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
executable file
·50 lines (40 loc) · 1.23 KB
/
test.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
#!/usr/bin/env python3
import requests
import tempfile
import string
import os
import time
from logger import *
from random import randint, choice
url = "http://localhost"
def get(path):
return requests.get(url + path)
def post(path, d):
return requests.post(url + path, data=d)
def get_random_data(len):
return "".join([choice(string.ascii_letters) for i in range(len)]).encode()
def main():
for _ in range(100):
op = randint(0,1)
if (op == 0) :
randdata = get_random_data(10)
f = tempfile.NamedTemporaryFile()
f.write(randdata)
f.flush()
req = get(f.name)
if req.status_code == 200 and req.text.encode() == randdata:
logger.success("GET")
else:
logger.error("GET")
else :
randdata = get_random_data(10)
path = "/tmp/" + get_random_data(5).decode()
req = post(path, randdata)
if req.status_code == 200 and open(path,"rb").read() == randdata:
logger.success("POST")
else:
logger.error("POST")
start = time.time()
main()
end = time.time()
print(end-start)