summaryrefslogtreecommitdiffstats
path: root/src/tests/cmocka/test_utils.c
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2014-11-21 18:07:10 +0100
committerJakub Hrozek <jhrozek@redhat.com>2014-11-25 13:28:39 +0100
commit4fa184e2c60b377fd71e0115a618bd68dc73627d (patch)
tree58e84cd4c984c579537e0451272f88d14dcfb9b9 /src/tests/cmocka/test_utils.c
parenteaaeaa7e00c3d4bfa792cc4d3c6770dc1e28ef0c (diff)
downloadsssd-4fa184e2c60b377fd71e0115a618bd68dc73627d.tar.gz
sssd-4fa184e2c60b377fd71e0115a618bd68dc73627d.tar.xz
sssd-4fa184e2c60b377fd71e0115a618bd68dc73627d.zip
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 <jhrozek@redhat.com>
Diffstat (limited to 'src/tests/cmocka/test_utils.c')
-rw-r--r--src/tests/cmocka/test_utils.c48
1 files changed, 48 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>.
*/
+#define _GNU_SOURCE
+#include <stdio.h>
#include <popt.h>
#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. */