EDDN/scripts/testing/gateway-responses/test-plain-correct-formdata.py
Athanasius 2a8eb8d021
Gateway: Add test scripts and supporting files
These are what I was using on my home server to test the prior code
changes to how the Gateway code reports errors.

Ultimately these should become a part of proper tests, but for now
they're at least in the repository for anyone to utilise.
2022-01-09 16:21:23 +00:00

30 lines
503 B
Python

#!/usr/bin/env python3
import json
import sys
import urllib3
if len(sys.argv) != 2:
print('test-sender.py <filename>')
sys.exit(-1)
with open(sys.argv[1], 'r') as f:
# Read from provided file
msg = f.read()
# Fake form-encode it
msg = 'data=' + msg
http = urllib3.PoolManager()
# Send that data as a POST body
r = http.request(
'POST',
'https://beta.eddn.edcd.io:4431/upload/',
body=msg
)
print(f'Response: {r.status!r}')
print(f'Body:\n{r.data.decode()}\n')