[SSSD] IFP: Implement methods to get and list domain objects

Jakub Hrozek jhrozek at redhat.com
Mon May 26 17:05:30 UTC 2014


On Thu, May 22, 2014 at 07:57:28PM +0200, Pavel Březina wrote:
> On 05/21/2014 11:03 PM, Jakub Hrozek wrote:
> >Hi,
> >
> >the attaches two patches implement DBus methods to retrieve SSSD domains
> >using the system bus as well as two example getters that leverage the
> >infrastructure to Get and GetAll the object properties.
> >
> >Pavel, I know you have a large patchset in a private tree that
> >implements the other getters and moves the domain methods into a
> >separate file. I'm fine with merging your and mine patches, I just
> >wanted to get the ball rolling on the list. Feel free to reply with your
> >patchset.
> 
> Hi,
> see the attachment.
> 
> I squash all my patches to these five - mainly discarded the moving
> the code around.
> 
> I kept you as the author for the methods as I made only very minor
> changes there. However, I took the ownership for the properties
> since there only very little of your original code remains there - I
> hope you don't mind.
> 
> The next three patches implements the SSSD components interface
> required for the OpenLMI provider. I'm sending it to this thread
> since it depends on the domain patches anyway - there is enough
> dependency fuzz already.
> 

> From 0f1e1adba39f203ad6405531a21d28d5c9bfa9ac Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina at redhat.com>
> Date: Mon, 5 May 2014 13:28:34 +0200
> Subject: [PATCH 3/5] confdb: add confdb_list_all_domain_names()

ACK.

See attached unit test I used for testing.
-------------- next part --------------
>From 7f9a50df936bbc3dccc1248fa720e4cd7ce40909 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Mon, 26 May 2014 19:04:41 +0200
Subject: [PATCH] tests: Add test for confdb_list_all_domain_names

---
 src/tests/sysdb-tests.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 87 insertions(+)

diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index 3e4d5f7f0f4e7ba887fab8ccf00d4f89771776f0..2802f2cba252cec44769bed0fa81253d9cd56101 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -4988,6 +4988,87 @@ END_TEST
 
 #endif /* BUILD_AUTOFS */
 
+START_TEST(test_confdb_list_all_domain_names)
+{
+    char *conf_db;
+    int ret;
+    TALLOC_CTX *tmp_ctx;
+    struct confdb_ctx *confdb;
+    char **names;
+
+    const char *val[2];
+    val[1] = NULL;
+
+    tmp_ctx = talloc_new(NULL);
+    ck_assert(tmp_ctx != NULL);
+
+    /* Create tests directory if it doesn't exist */
+    /* (relative to current dir) */
+    ret = mkdir(TESTS_PATH, 0775);
+    if (ret == -1 && errno != EEXIST) {
+        fail("Could not create %s directory", TESTS_PATH);
+        return;
+    }
+
+    conf_db = talloc_asprintf(tmp_ctx, "%s/%s", TESTS_PATH, TEST_CONF_FILE);
+    ck_assert(conf_db != NULL);
+
+    /* Make sure the test domain does not interfere with our testing */
+    ret = unlink(TESTS_PATH"/"TEST_CONF_FILE);
+    if (ret != EOK && errno != ENOENT) {
+        fail("Could not remove confdb %s\n", TESTS_PATH"/"TEST_CONF_FILE);
+        return;
+    }
+
+    /* Connect to the conf db */
+    ret = confdb_init(tmp_ctx, &confdb, conf_db);
+    ck_assert_int_eq(ret, EOK);
+
+    /* No domain */
+    ret = confdb_list_all_domain_names(tmp_ctx, confdb, &names);
+    ck_assert_int_eq(ret, EOK);
+    ck_assert(names != NULL);
+    ck_assert(names[0] == NULL);
+
+    /* One domain */
+    val[0] = "LOCAL";
+    ret = confdb_add_param(confdb, true,
+                           "config/sssd", "domains", val);
+    ck_assert_int_eq(ret, EOK);
+
+    val[0] = "local";
+    ret = confdb_add_param(confdb, true,
+                           "config/domain/LOCAL", "id_provider", val);
+    ck_assert_int_eq(ret, EOK);
+
+    ret = confdb_list_all_domain_names(tmp_ctx, confdb, &names);
+    ck_assert_int_eq(ret, EOK);
+    ck_assert(names != NULL);
+    ck_assert_str_eq(names[0], "LOCAL");
+    ck_assert(names[1] == NULL);
+
+    /* Two domains */
+    val[0] = "REMOTE";
+    ret = confdb_add_param(confdb, true,
+                           "config/sssd", "domains", val);
+    ck_assert_int_eq(ret, EOK);
+
+    val[0] = "local";
+    ret = confdb_add_param(confdb, true,
+                           "config/domain/REMOTE", "id_provider", val);
+    ck_assert_int_eq(ret, EOK);
+
+    ret = confdb_list_all_domain_names(tmp_ctx, confdb, &names);
+    ck_assert_int_eq(ret, EOK);
+    ck_assert(names != NULL);
+    ck_assert_str_eq(names[0], "LOCAL");
+    ck_assert_str_eq(names[1], "REMOTE");
+    ck_assert(names[2] == NULL);
+
+    talloc_free(tmp_ctx);
+}
+END_TEST
+
 Suite *create_sysdb_suite(void)
 {
     Suite *s = suite_create("sysdb");
@@ -5334,6 +5415,12 @@ Suite *create_sysdb_suite(void)
     suite_add_tcase(s, tc_autofs);
 #endif
 
+    /* ConfDB tests -- modify confdb, must always be last!! */
+    TCase *tc_confdb = tcase_create("confDB tests");
+
+    tcase_add_test(tc_confdb, test_confdb_list_all_domain_names);
+    suite_add_tcase(s, tc_confdb);
+
     return s;
 }
 
-- 
1.9.0



More information about the sssd-devel mailing list