diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2014-05-11 16:18:28 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-05-22 17:16:17 +0200 |
commit | e22d84a534c0b093a31f8473e6c3cbabdb5f5c82 (patch) | |
tree | 7402f0cef3efebe96640d1a97fd475b5c427d546 /src | |
parent | 78f2f0bbb999d40782f8beb940f79bc522cdcb2d (diff) | |
download | sssd-e22d84a534c0b093a31f8473e6c3cbabdb5f5c82.tar.gz sssd-e22d84a534c0b093a31f8473e6c3cbabdb5f5c82.tar.xz sssd-e22d84a534c0b093a31f8473e6c3cbabdb5f5c82.zip |
IFP: Add a unit test for ifp_reply_objpath
Reviewed-by: Stef Walter <stefw@redhat.com>
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/tests/cmocka/test_ifp.c | 30 |
1 files changed, 30 insertions, 0 deletions
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. */ |