diff --git a/test/broker/01-connect-uname-password-success-no-tls.conf b/test/broker/01-connect-uname-password-success-no-tls.conf new file mode 100644 index 00000000..2cb39d14 --- /dev/null +++ b/test/broker/01-connect-uname-password-success-no-tls.conf @@ -0,0 +1,3 @@ +port 1888 +password_file 01-connect-uname-password-success-no-tls.pwfile +allow_anonymous false diff --git a/test/broker/01-connect-uname-password-success-no-tls.pwfile b/test/broker/01-connect-uname-password-success-no-tls.pwfile new file mode 100644 index 00000000..28b9bb2a --- /dev/null +++ b/test/broker/01-connect-uname-password-success-no-tls.pwfile @@ -0,0 +1 @@ +user:password diff --git a/test/broker/01-connect-uname-password-success-no-tls.py b/test/broker/01-connect-uname-password-success-no-tls.py new file mode 100755 index 00000000..19c509b5 --- /dev/null +++ b/test/broker/01-connect-uname-password-success-no-tls.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +# Test whether a connection is denied if it provides a correct username but +# incorrect password. + +import subprocess +import socket +import time + +import inspect, os, sys +# From http://stackoverflow.com/questions/279237/python-import-a-module-from-a-folder +cmd_subfolder = os.path.realpath(os.path.abspath(os.path.join(os.path.split(inspect.getfile( inspect.currentframe() ))[0],".."))) +if cmd_subfolder not in sys.path: + sys.path.insert(0, cmd_subfolder) + +import mosq_test + +rc = 1 +keepalive = 10 +connect_packet = mosq_test.gen_connect("connect-uname-pwd-test", keepalive=keepalive, username="user", password="password") +connack_packet = mosq_test.gen_connack(rc=0) + +broker = mosq_test.start_broker(filename=os.path.basename(__file__)) + +try: + sock = mosq_test.do_client_connect(connect_packet, connack_packet) + sock.close() + rc = 0 + +finally: + broker.terminate() + broker.wait() + if rc: + (stdo, stde) = broker.communicate() + print(stde) + +exit(rc) + diff --git a/test/broker/Makefile b/test/broker/Makefile index 7f44af75..510d90f9 100644 --- a/test/broker/Makefile +++ b/test/broker/Makefile @@ -1,3 +1,5 @@ +include ../../config.mk + .PHONY: all clean test .NOTPARALLEL: @@ -21,7 +23,12 @@ test : test-compile 01 02 03 04 05 06 07 08 09 10 ./01-connect-anon-denied.py ./01-connect-uname-no-password-denied.py ./01-connect-uname-password-denied.py +ifeq ($(WITH_TLS),yes) ./01-connect-uname-password-success.py +else + ./01-connect-uname-password-success-no-tls.py +endif + 02 : ./02-subscribe-qos0.py @@ -68,6 +75,7 @@ test : test-compile 01 02 03 04 05 06 07 08 09 10 ./07-will-null-topic.py 08 : +ifeq ($(WITH_TLS),yes) ./08-ssl-connect-no-auth.py ./08-ssl-connect-no-auth-wrong-ca.py ./08-ssl-connect-cert-auth.py @@ -80,6 +88,7 @@ test : test-compile 01 02 03 04 05 06 07 08 09 10 ./08-ssl-bridge.py ./08-tls-psk-pub.py ./08-tls-psk-bridge.py +endif 09 : ./09-plugin-auth-unpwd-success.py diff --git a/test/lib/Makefile b/test/lib/Makefile index aab2c657..694dbb8c 100644 --- a/test/lib/Makefile +++ b/test/lib/Makefile @@ -1,3 +1,5 @@ +include ../../config.mk + .PHONY: all test test-compile test-compile-c test-compile-cpp c cpp .NOTPARALLEL: @@ -36,11 +38,13 @@ c cpp : test-compile ./03-publish-b2c-qos1.py $@/03-publish-b2c-qos1.test ./03-publish-b2c-qos2.py $@/03-publish-b2c-qos2.test ./04-retain-qos0.py $@/04-retain-qos0.test +ifeq ($(WITH_TLS),yes) ./08-ssl-connect-no-auth.py $@/08-ssl-connect-no-auth.test ./08-ssl-connect-cert-auth.py $@/08-ssl-connect-cert-auth.test ./08-ssl-connect-cert-auth-enc.py $@/08-ssl-connect-cert-auth-enc.test ./08-ssl-bad-cacert.py $@/08-ssl-bad-cacert.test ./08-ssl-fake-cacert.py $@/08-ssl-fake-cacert.test +endif ./09-util-topic-matching.py $@/09-util-topic-matching.test ./09-util-topic-tokenise.py $@/09-util-topic-tokenise.test