Add test for first packet not being CONNECT.

pull/1203/head
Roger A. Light 7 years ago
parent dab6452a1d
commit ef724e6d33

@ -0,0 +1,35 @@
#!/usr/bin/env python
# Test whether a first packet of non-CONNECT is rejected.
from mosq_test_helper import *
rc = 1
mid = 2
publish_packet = mosq_test.gen_publish("pub/qos1/test", qos=1, mid=mid, payload="message")
puback_packet = mosq_test.gen_puback(mid)
port = mosq_test.get_port()
broker = mosq_test.start_broker(filename=os.path.basename(__file__), port=port)
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(5)
sock.connect(("localhost", port))
sock.send(publish_packet)
data = sock.recv(1)
sock.close()
if len(data) == 0:
rc = 0
except socket.error:
rc = 0
finally:
broker.terminate()
broker.wait()
(stdo, stde) = broker.communicate()
if rc:
print(stde)
exit(rc)

@ -18,6 +18,7 @@ ptest : test-compile
test : test-compile 01 02 03 04 05 06 07 08 09 10 11 12
01 :
./01-connect-bad-packet.py
./01-connect-duplicate.py
./01-connect-duplicate-v5.py
./01-connect-success.py

@ -7,6 +7,7 @@ import sys
max_running = 10
tests = [
#(ports required, 'path'),
(1, './01-connect-bad-packet.py'),
(1, './01-connect-duplicate.py'),
(1, './01-connect-duplicate-v5.py'),
(1, './01-connect-success.py'),

Loading…
Cancel
Save