Expected behavior
Encoding an MQTT 5 CONNECT message with hasUserName=false and hasPassword=true should succeed.
MQTT 5 allows sending a Password with no User Name, while MQTT 3.1.1 did not:
https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901044
This version of the protocol allows the sending of a Password with no User Name, where MQTT v3.1.1 did not.### Actual behavior
Actual behavior
MqttDecoder accepts this CONNECT message for MQTT 5, but encoding the same message fails.
EncoderException: Without a username, the password MUST be not set
Steps to reproduce
Encode an MQTT 5 CONNECT message with a password set and username unset.
Minimal yet complete reproducer code (or URL to code)
MqttConnectMessage message = MqttMessageBuilders.connect()
.clientId("client")
.protocolVersion(MqttVersion.MQTT_5)
.username(null)
.password("secret".getBytes(CharsetUtil.UTF_8))
.build();
EmbeddedChannel channel = new EmbeddedChannel(MqttEncoder.INSTANCE);
channel.writeOutbound(message);
Expected behavior
Encoding an MQTT 5 CONNECT message with
hasUserName=falseandhasPassword=trueshould succeed.MQTT 5 allows sending a Password with no User Name, while MQTT 3.1.1 did not:
https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901044
Actual behavior
MqttDecoderaccepts this CONNECT message for MQTT 5, but encoding the same message fails.Steps to reproduce
Encode an MQTT 5 CONNECT message with a password set and username unset.
Minimal yet complete reproducer code (or URL to code)