|
|
|
@ -84,6 +84,72 @@ static void TEST_empty_input(void)
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void TEST_pattern_empty_input(void)
|
|
|
|
|
{
|
|
|
|
|
int rc;
|
|
|
|
|
bool match;
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern(NULL, NULL, NULL, NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_INVAL);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("sub", NULL, NULL, NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_INVAL);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern(NULL, "topic", NULL, NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_INVAL);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern(NULL, NULL, "clientid", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_INVAL);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern(NULL, NULL, NULL, "username", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_INVAL);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("sub", "", "", "", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_INVAL);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("", "topic", "", "", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_INVAL);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("", "", "clientid", "", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_INVAL);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("", "", "", "username", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_INVAL);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("%c", "topic", NULL, NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("%u", "topic", NULL, NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("%c", "", "", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_INVAL);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("%u", "", NULL, "", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_INVAL);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%c/test", "test//test", "", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%u/test", "test//test", NULL, "", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ========================================================================
|
|
|
|
|
* VALID MATCHING AND NON-MATCHING
|
|
|
|
|
* ======================================================================== */
|
|
|
|
@ -181,6 +247,254 @@ static void TEST_invalid(void)
|
|
|
|
|
no_match_helper(MOSQ_ERR_INVAL, "/#a", "foo/bar");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ========================================================================
|
|
|
|
|
* PATTERNS
|
|
|
|
|
* ======================================================================== */
|
|
|
|
|
|
|
|
|
|
static void TEST_pattern_clientid(void)
|
|
|
|
|
{
|
|
|
|
|
int rc;
|
|
|
|
|
bool match;
|
|
|
|
|
|
|
|
|
|
/* Sole pattern */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("%c", "clientid", "clientid", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, true);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("%c", "clientid", "nomatch", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
/* Pattern at beginning */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("%c/test", "clientid/test", "clientid", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, true);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("%c/test", "clientid/test", "nomatch", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
/* Pattern at end */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%c", "test/clientid", "clientid", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, true);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%c", "test/clientid", "nomatch", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
/* Pattern in middle */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%c/test", "test/clientid/test", "clientid", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, true);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%c/test", "test/clientid/test", "nomatch", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
/* Repeated pattern */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%c/%c/test", "test/clientid/clientid/test", "clientid", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, true);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%c/%c/test", "test/clientid/clientid/test", "nomatch", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
/* Not a pattern */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%count", "test/clientid", "clientid", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void TEST_pattern_username(void)
|
|
|
|
|
{
|
|
|
|
|
int rc;
|
|
|
|
|
bool match;
|
|
|
|
|
|
|
|
|
|
/* Sole pattern */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("%u", "username", NULL, "username", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, true);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("%u", "username", NULL, "nomatch", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
/* Pattern at beginning */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("%u/test", "username/test", NULL, "username", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, true);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("%u/test", "username/test", NULL, "nomatch", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
/* Pattern at end */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%u", "test/username", NULL, "username", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, true);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%u", "test/username", NULL, "nomatch", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
/* Pattern in middle */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%u/test", "test/username/test", NULL, "username", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, true);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%u/test", "test/username/test", NULL, "nomatch", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
/* Repeated pattern */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%u/%u/test", "test/username/username/test", NULL, "username", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, true);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%u/%u/test", "test/username/username/test", NULL, "nomatch", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
/* Not a pattern */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%username", "test/username", NULL, "username", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void TEST_pattern_both(void)
|
|
|
|
|
{
|
|
|
|
|
int rc;
|
|
|
|
|
bool match;
|
|
|
|
|
|
|
|
|
|
/* Sole pattern */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("%u/%c", "username/clientid", "clientid", "username", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, true);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("%u/%c", "username/clientid", "clientid", "nomatch", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("%u/%c", "username/clientid", "nomatch", "username", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("%u/%c", "username/clientid", "nomatch", "nomatch", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
/* Pattern in middle */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%c/%u/test", "test/clientid/username/test", "clientid", "username", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, true);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%c/%u/test", "test/clientid/username/test", "clientid", "nomatch", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%c/%u/test", "test/clientid/username/test", "nomatch", "username", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%c/%u/test", "test/clientid/username/test", "nomatch", "nomatch", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
/* Repeated pattern */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%u/%c/%c/%u/test", "test/username/clientid/clientid/username/test", "clientid", "username", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, true);
|
|
|
|
|
|
|
|
|
|
/* Not a pattern */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("test/%username/%client", "test/username/clientid", "clientid", "username", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void TEST_pattern_wildcard(void)
|
|
|
|
|
{
|
|
|
|
|
int rc;
|
|
|
|
|
bool match;
|
|
|
|
|
|
|
|
|
|
/* Malicious */
|
|
|
|
|
/* ========= */
|
|
|
|
|
|
|
|
|
|
/* / in client id */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("%c", "clientid/test", "clientid/test", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
/* / in username */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("%u", "username/test", NULL, "username/test", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
/* + in client id */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("%c", "clientid", "+", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
/* + in username */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("username/%u/+", "username/test/+", NULL, "+", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
/* Valid */
|
|
|
|
|
/* ========= */
|
|
|
|
|
|
|
|
|
|
/* Ends in + */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("clientid/%c/+", "clientid/test/topic", "test", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, true);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("clientid/%c/+", "clientid/test/topic", "nomatch", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("username/%u/+", "username/test/topic", NULL, "test", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, true);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("username/%u/+", "username/test/topic", NULL, "nomatch", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
/* Ends in # */
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("clientid/%c/#", "clientid/test/topic", "test", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, true);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("clientid/%c/#", "clientid/test/topic", "nomatch", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("username/%u/#", "username/test/topic", NULL, "test", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, true);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("username/%u/#", "username/test/topic", NULL, "nomatch", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("clientid/%c/#", "clientid/test", "test", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, true);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("clientid/%c/#", "clientid/test", "nomatch", NULL, &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("pattern/%u/#", "pattern/username", NULL, "username", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, true);
|
|
|
|
|
|
|
|
|
|
rc = mosquitto_topic_matches_sub_with_pattern("username/%u/#", "username/test", NULL, "nomatch", &match);
|
|
|
|
|
CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
|
|
|
|
|
CU_ASSERT_EQUAL(match, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ========================================================================
|
|
|
|
|
* PUB TOPIC CHECK
|
|
|
|
|
* ======================================================================== */
|
|
|
|
@ -287,6 +601,11 @@ int init_util_topic_tests(void)
|
|
|
|
|
|| !CU_add_test(test_suite, "Pub topic: Invalid", TEST_pub_topic_invalid)
|
|
|
|
|
|| !CU_add_test(test_suite, "Sub topic: Valid", TEST_sub_topic_valid)
|
|
|
|
|
|| !CU_add_test(test_suite, "Sub topic: Invalid", TEST_sub_topic_invalid)
|
|
|
|
|
|| !CU_add_test(test_suite, "Pattern topic: Empty input", TEST_pattern_empty_input)
|
|
|
|
|
|| !CU_add_test(test_suite, "Pattern topic: clientid", TEST_pattern_clientid)
|
|
|
|
|
|| !CU_add_test(test_suite, "Pattern topic: username", TEST_pattern_username)
|
|
|
|
|
|| !CU_add_test(test_suite, "Pattern topic: both", TEST_pattern_both)
|
|
|
|
|
|| !CU_add_test(test_suite, "Pattern topic: wildcard", TEST_pattern_wildcard)
|
|
|
|
|
){
|
|
|
|
|
|
|
|
|
|
printf("Error adding util topic CUnit tests.\n");
|
|
|
|
|