From 4fa184e2c60b377fd71e0115a618bd68dc73627d Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Fri, 21 Nov 2014 18:07:10 +0100 Subject: AD/IPA: add krb5_confd_path configuration option With this new parameter the directory where Kerberos configuration snippets are created can be specified. Fixes https://fedorahosted.org/sssd/ticket/2473 Reviewed-by: Jakub Hrozek --- src/tests/cmocka/test_utils.c | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src/tests/cmocka/test_utils.c') diff --git a/src/tests/cmocka/test_utils.c b/src/tests/cmocka/test_utils.c index d9781377b..5dc00c4cc 100644 --- a/src/tests/cmocka/test_utils.c +++ b/src/tests/cmocka/test_utils.c @@ -20,6 +20,8 @@ along with this program. If not, see . */ +#define _GNU_SOURCE +#include #include #include "tests/cmocka/common_mock.h" @@ -983,6 +985,51 @@ void test_add_strings_lists(void **state) talloc_free(res); } +void test_sss_write_krb5_conf_snippet(void **state) +{ + int ret; + char buf[PATH_MAX]; + char *cwd; + char *path; + char *file; + + ret = sss_write_krb5_conf_snippet(NULL); + assert_int_equal(ret, EINVAL); + + ret = sss_write_krb5_conf_snippet("abc"); + assert_int_equal(ret, EINVAL); + + ret = sss_write_krb5_conf_snippet(""); + assert_int_equal(ret, EOK); + + ret = sss_write_krb5_conf_snippet("none"); + assert_int_equal(ret, EOK); + + cwd = getcwd(buf, PATH_MAX); + assert_non_null(cwd); + + ret = asprintf(&path, "%s/%s", cwd, TESTS_PATH); + assert_true(ret > 0); + + ret = asprintf(&file, "%s/%s/localauth_plugin", cwd, TESTS_PATH); + assert_true(ret > 0); + + ret = sss_write_krb5_conf_snippet(path); + assert_int_equal(ret, EOK); + + /* Check if writing a second time will work as well */ + ret = sss_write_krb5_conf_snippet(path); + assert_int_equal(ret, EOK); + +#ifdef HAVE_KRB5_LOCALAUTH_PLUGIN + ret = unlink(file); + assert_int_equal(ret, EOK); +#endif + + free(file); + free(path); +} + int main(int argc, const char *argv[]) { poptContext pc; @@ -1030,6 +1077,7 @@ int main(int argc, const char *argv[]) unit_test_setup_teardown(test_add_strings_lists, setup_add_strings_lists, teardown_add_strings_lists), + unit_test(test_sss_write_krb5_conf_snippet), }; /* Set debug level to invalid value so we can deside if -d 0 was used. */ -- cgit