forked from AvinashSingh786/SecureRS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathperformance_test.py
More file actions
63 lines (51 loc) · 1.62 KB
/
Copy pathperformance_test.py
File metadata and controls
63 lines (51 loc) · 1.62 KB
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
import requests
from profile import profile
from time import sleep
import threading
import psutil
import hashlib
import datetime
API_KEY = "IAWMMTs0.cHddQPXa343hvAKcUY7FZHOyyT8Vo55h"
API_SECRET = "IAWMMTs0"
SUCCESS = 0
COUNTER = 1
@profile
def make_request(i):
global SUCCESS, COUNTER
name = "README.md"
hash_md5 = hashlib.md5()
with open(name, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
data = {
'ip': '192.168.1.120',
'machine': 'IronMachine',
'filename': str(datetime.datetime.now()),
'user': 'Avinash',
'rank': i,
'md5sum': hash_md5.hexdigest(),
'token': API_KEY
}
COUNTER += 1
files = {'pde': open(name, 'rb')}
# headers = { 'Api-Secret-Key': 'Zm4QsmdXsobX', 'Api-Token': 'f8000c5bb202edd77e994658f02949a2'} #old
headers = {'Api-Secret-Key': API_SECRET, 'Api-Token': API_KEY, 'MD5SUM': hash_md5.hexdigest(),
'X-Api-Key': API_KEY, 'Authorization': 'Token ' + API_KEY, 'Token': API_KEY}
# 'content-type': 'multipart/form-data',
r = requests.post("https://localhost:8000/pde/add/",
data=data, headers=headers, files=files, verify=False)
# r = requests.post("https://localhost:8000/pde/add/", data=data, headers=headers, files=files, verify=False)
print(r.text)
if "Success" in r.text:
SUCCESS += 1
def stats():
print("Success: ", SUCCESS)
def seq(c):
for i in range(c):
make_request(i)
def con(c):
for i in range(c):
threading.Thread(target=make_request, args=(i,)).start()
# con(10)
seq(1)
stats()