From e22d84a534c0b093a31f8473e6c3cbabdb5f5c82 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Sun, 11 May 2014 16:18:28 +0200 Subject: IFP: Add a unit test for ifp_reply_objpath MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Stef Walter Reviewed-by: Pavel Březina --- src/tests/cmocka/test_ifp.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src') diff --git a/src/tests/cmocka/test_ifp.c b/src/tests/cmocka/test_ifp.c index 8d9b85635..650a94969 100644 --- a/src/tests/cmocka/test_ifp.c +++ b/src/tests/cmocka/test_ifp.c @@ -410,6 +410,32 @@ void ifp_test_req_teardown(void **state) assert_true(leak_check_teardown()); } +void test_reply_path(void **state) +{ + struct ifp_test_req_ctx *test_ctx = talloc_get_type_abort(*state, + struct ifp_test_req_ctx); + char *path; + + /* Doesn't need escaping */ + path = ifp_reply_objpath(test_ctx->ireq, PATH_BASE, "domname", NULL); + assert_non_null(path); + assert_string_equal(path, PATH_BASE"/domname"); + talloc_free(path); +} + +void test_reply_path_escape(void **state) +{ + struct ifp_test_req_ctx *test_ctx = talloc_get_type_abort(*state, + struct ifp_test_req_ctx); + char *path; + + /* A dot needs escaping */ + path = ifp_reply_objpath(test_ctx->ireq, PATH_BASE, "redhat.com", NULL); + assert_non_null(path); + assert_string_equal(path, PATH_BASE"/redhat_2ecom"); + talloc_free(path); +} + int main(int argc, const char *argv[]) { poptContext pc; @@ -428,6 +454,10 @@ int main(int argc, const char *argv[]) unit_test(test_attr_acl), unit_test(test_attr_allowed), unit_test(test_path_escape_unescape), + unit_test_setup_teardown(test_reply_path, + ifp_test_req_setup, ifp_test_req_teardown), + unit_test_setup_teardown(test_reply_path_escape, + ifp_test_req_setup, ifp_test_req_teardown), }; /* Set debug level to invalid value so we can deside if -d 0 was used. */ -- cgit