kopia lustrzana https://github.com/Yakifo/amqtt
allow connections with username only
Section [MQTT-3.1.2-22] of the MQTT 3.1.1 only says that a password cannot be given without a user. The reverse should be allowed. Fixes #79.pull/113/head
rodzic
f71b99b086
commit
a3f982c4d2
|
@ -163,8 +163,6 @@ class BrokerProtocolHandler(ProtocolHandler):
|
|||
) # [MQTT-3.2.2-4] session_parent=0
|
||||
elif not connect.username_flag and connect.password_flag:
|
||||
connack = ConnackPacket.build(0, BAD_USERNAME_PASSWORD) # [MQTT-3.1.2-22]
|
||||
elif connect.username_flag and not connect.password_flag:
|
||||
connack = ConnackPacket.build(0, BAD_USERNAME_PASSWORD) # [MQTT-3.1.2-22]
|
||||
elif connect.username_flag and connect.username is None:
|
||||
error_msg = "Invalid username from %s" % (
|
||||
format_client_message(address=remote_address, port=remote_port)
|
||||
|
|
|
@ -111,6 +111,17 @@ async def test_connect_ws_secure():
|
|||
await broker.shutdown()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_connect_username_without_password():
|
||||
broker = Broker(broker_config, plugin_namespace="amqtt.test.plugins")
|
||||
await broker.start()
|
||||
client = MQTTClient()
|
||||
await client.connect("mqtt://alice@127.0.0.1/")
|
||||
assert client.session is not None
|
||||
await client.disconnect()
|
||||
await broker.shutdown()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_ping():
|
||||
broker = Broker(broker_config, plugin_namespace="amqtt.test.plugins")
|
||||
|
|
Ładowanie…
Reference in New Issue