mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-28 23:00:55 +00:00
Fix mallformed (nullish) messages handling (#4347)
Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
This commit is contained in:
@@ -139,6 +139,10 @@ describe('Frontend', () => {
|
||||
{ retain: false, qos: 0 },
|
||||
expect.any(Function)
|
||||
);
|
||||
mockWSClient.events.message(undefined);
|
||||
mockWSClient.events.message("");
|
||||
mockWSClient.events.message(null);
|
||||
await flushPromises();
|
||||
|
||||
// Received message on socket
|
||||
expect(mockWSClient.implementation.send).toHaveBeenCalledTimes(4);
|
||||
|
||||
@@ -66,6 +66,18 @@ describe('Publish', () => {
|
||||
expect(MQTT.publish.mock.calls[0][2]).toStrictEqual({"qos": 0, "retain": false});
|
||||
});
|
||||
|
||||
it('Should corretly handle mallformed messages', async () => {
|
||||
await MQTT.events.message('zigbee2mqtt/foo', undefined);
|
||||
await MQTT.events.message('zigbee2mqtt/foo', null);
|
||||
await MQTT.events.message('zigbee2mqtt/foo', "");
|
||||
|
||||
await MQTT.events.message('zigbee2mqtt/bulb_color/set', undefined);
|
||||
await MQTT.events.message('zigbee2mqtt/bulb_color/set', null);
|
||||
await MQTT.events.message('zigbee2mqtt/bulb_color/set', "");
|
||||
await flushPromises();
|
||||
expectNothingPublished();
|
||||
});
|
||||
|
||||
it('Should publish messages to zigbee devices when there is no converters', async () => {
|
||||
await MQTT.events.message('zigbee2mqtt/bulb_color/set', stringify({brightness_no: '200'}));
|
||||
await flushPromises();
|
||||
|
||||
Reference in New Issue
Block a user