Skip to content

Commit

Permalink
Fix subscription matching for bool flags
Browse files Browse the repository at this point in the history
  • Loading branch information
frankosterfeld committed Nov 29, 2023
1 parent c19531d commit bca9473
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/majordomo/include/majordomo/SubscriptionMatcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class SubscriptionMatcher {
assert(filterIt->second);

const auto notifyIt = notificationQuery.find(key);
if (notifyIt == notificationQuery.end() && value) {
if (notifyIt == notificationQuery.end()) {
// specific/required subscription topic but not corresponding filter in notification set
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions src/majordomo/test/subscriptionmatcher_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ TEST_CASE("Test path and query", "[subscription_matcher][path_and_query]") {
matcher.addFilter<TestFilter2>("testKey2");
matcher.addFilter<TestFilter3>("testKey3");
matcher.addFilter<TestFilter4>("testKey4");
matcher.addFilter<TestFilter2>("testFlag1");
matcher.addFilter<TestFilter2>("testFlag2");

REQUIRE_FALSE(matcher(URI("/property1?testKey1"), URI("/property2?testKey1")));
REQUIRE(matcher(URI("/property?testKey1"), URI("/property?testKey1")));
Expand All @@ -91,6 +93,7 @@ TEST_CASE("Test path and query", "[subscription_matcher][path_and_query]") {
REQUIRE_FALSE(matcher(URI("/property?testKey3=bcd"), URI("/property?testKey3=abc")));
REQUIRE(matcher(URI("/property?testKey4=3.33"), URI("/property?testKey4=3.33")));
REQUIRE_FALSE(matcher(URI("/property?testKey4=3.33"), URI("/property?testKey4=3.44")));
REQUIRE_FALSE(matcher(URI("/property?testFlag1"), URI("/property?testFlag1&testFlag2")));
}

TEST_CASE("Test timing and context type matching", "[subscription_matcher]") {
Expand Down

0 comments on commit bca9473

Please sign in to comment.