-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe2e_client_test.py
23 lines (18 loc) · 986 Bytes
/
e2e_client_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
# This client was used for testing and troubleshooting connectivity to the DoTproxy server.
# It sends a static dns request asking for `google.com` and returns the raw byte response
# from the DoTproxy server.
import socket
import logging
logging.basicConfig(level=logging.INFO)
MAX_BYTE_SIZE = 512
# not a very accurate test case. Response quite dynamic, but should contain the keyword if successful
def test_when_google_dns_is_queried_then_the_response_should_contain_google(query=1):
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock:
logging.debug(f'Conneting...')
sock.connect(('127.0.0.1', 53))
logging.debug(f'Query: {query} Connected...')
udp_message = b'\xbd[\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x06google\x03com\x00\x00\x01\x00\x01'
sock.send(udp_message)
response = sock.recv(MAX_BYTE_SIZE)
logging.debug(f'Query {query} Server responded with: {response}')
assert b'google' in response