diff --git a/nanomq/rest_api.c b/nanomq/rest_api.c index 1f670e946..3ee593b8c 100644 --- a/nanomq/rest_api.c +++ b/nanomq/rest_api.c @@ -3707,6 +3707,8 @@ post_mqtt_bridge_unsub(http_msg *msg, const char *name) node->sub_count--; nng_free(sub_topic->remote_topic, sub_topic->remote_topic_len); + nng_free(sub_topic->local_topic, + sub_topic->local_topic_len); nng_free(sub_topic, sizeof(topics)); break; } diff --git a/nanomq/tests/http_server_test.c b/nanomq/tests/http_server_test.c index f6361f320..5283c595b 100644 --- a/nanomq/tests/http_server_test.c +++ b/nanomq/tests/http_server_test.c @@ -299,8 +299,8 @@ test_put_bridges_unsub() "'http://localhost:8081/api/v4/bridges/unsub/emqx' " "--basic -u admin_test:pw_test -d '{" "\"data\": {" - "\"unsubscription\": [{\"remote_topic\": \"cmd/topic1\", \"local_topic\": \"cmd_lo/topic1\"}," - "{\"remote_topic\": \"cmd/topic2\", \"local_topic\": \"cmd_lo/topic2\"}]," + "\"unsubscription\": [{\"topic\": \"cmd/topic1\"}," + "{\"topic\": \"cmd/topic2\"}]," "\"unsub_properties\": {\"user_properties\": [{\"key\": " "\"key1\",\"value\": \"value1\"},{\"key\": " "\"key2\",\"value\": \"value2\"}]}}}'"; @@ -639,9 +639,8 @@ main() assert(test_get_bridges()); assert(test_get_bridge()); - // TODO: rest api need change for topic reflection in bridge. assert(test_put_bridges_sub()); - // assert(test_put_bridges_unsub()); // bridge unsub has to change for topic reflection + assert(test_put_bridges_unsub()); // the usage of unsub rest api may need further discussion. assert(test_put_bridges()); assert(test_post_rules());