diff options
author | Simo Sorce <simo@redhat.com> | 2013-01-14 20:30:04 -0500 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2013-02-10 22:08:47 +0100 |
commit | bba1a5fd62cffcae076d1351df5a83fbc4a6ec17 (patch) | |
tree | 8dbc22a528ccda8cc889a5297df2edb1919d86e6 /src/tests/pac_responder-tests.c | |
parent | 1f800ebb0f190854b8296146174f3d696a426333 (diff) | |
download | sssd-bba1a5fd62cffcae076d1351df5a83fbc4a6ec17.tar.gz sssd-bba1a5fd62cffcae076d1351df5a83fbc4a6ec17.tar.xz sssd-bba1a5fd62cffcae076d1351df5a83fbc4a6ec17.zip |
Change the way domains are linked.
- Use a double-linked list for domains and subdomains.
- Never remove a subdomain, simply mark it as disabled if it becomes
unused.
- Rework the way subdomains are refreshed.
Now sysdb_update_subdomains() actually updates the current subdomains
and marks as disabled the ones not found in the sysdb or add new ones
found. It never removes them.
Removal of missing domains from sysdb is deferred to the providers,
which will perform it at refresh time, for the ipa provider that is
done by ipa_subdomains_write_mappings() now.
sysdb_update_subdomains() is then used to update the memory hierarchy
of the subdomains.
- Removes sysdb_get_subdomains()
- Removes copy_subdomain()
- Add sysdb_subdomain_delete()
Diffstat (limited to 'src/tests/pac_responder-tests.c')
-rw-r--r-- | src/tests/pac_responder-tests.c | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/src/tests/pac_responder-tests.c b/src/tests/pac_responder-tests.c index 7d352a0e8..847dbe009 100644 --- a/src/tests/pac_responder-tests.c +++ b/src/tests/pac_responder-tests.c @@ -98,15 +98,7 @@ void pac_setup(void) { fail_unless(pac_ctx->rctx->domains->domain_id != NULL, "talloc_strdup failed."); - pac_ctx->rctx->domains->subdomain_count = 1; - pac_ctx->rctx->domains->subdomains = talloc_zero_array(pac_ctx->rctx->domains, - struct sss_domain_info *, - pac_ctx->rctx->domains->subdomain_count); - fail_unless(pac_ctx->rctx->domains->subdomains != NULL, - "talloc_array_zero failed"); - - sd = talloc_zero(pac_ctx->rctx->domains->subdomains, - struct sss_domain_info); + sd = talloc_zero(pac_ctx->rctx->domains, struct sss_domain_info); fail_unless(sd != NULL, "talloc_zero failed."); sd->name = talloc_strdup(sd, "remote.dom"); @@ -118,7 +110,7 @@ void pac_setup(void) { sd->domain_id = talloc_strdup(sd, test_remote_dom_sid_str); fail_unless(sd->domain_id != NULL, "talloc_strdup failed"); - pac_ctx->rctx->domains->subdomains[0] = sd; + pac_ctx->rctx->domains->subdomains = sd; err = sss_idmap_init(idmap_talloc, pac_ctx, idmap_talloc_free, &pac_ctx->idmap_ctx); @@ -285,8 +277,8 @@ END_TEST #define NUM_DOMAINS 10 START_TEST(pac_test_find_domain_by_id) { + struct sss_domain_info *domains; struct sss_domain_info *dom; - struct sss_domain_info **domains; size_t c; char *id; @@ -296,33 +288,30 @@ START_TEST(pac_test_find_domain_by_id) dom = find_domain_by_id(NULL, "id"); fail_unless(dom == NULL, "Domain returned without domain list."); - domains = talloc_zero_array(global_talloc_context, struct sss_domain_info *, - NUM_DOMAINS); + domains = NULL; for (c = 0; c < NUM_DOMAINS; c++) { - domains[c] = talloc_zero(domains, struct sss_domain_info); - fail_unless(domains[c] != NULL, "talloc_zero failed."); - - domains[c]->domain_id = talloc_asprintf(domains[c], - "ID-of-domains-%zu", c); - fail_unless(domains[c]->domain_id != NULL, "talloc_asprintf failed."); - if (c > 0) { - domains[c-1]->next = domains[c]; - } + dom = talloc_zero(domains, struct sss_domain_info); + fail_unless(dom != NULL, "talloc_zero failed."); + + dom->domain_id = talloc_asprintf(dom, "ID-of-domains-%zu", c); + fail_unless(dom->domain_id != NULL, "talloc_aprintf failed."); + + DLIST_ADD(domains, dom); } - dom = find_domain_by_id(domains[0], NULL); + dom = find_domain_by_id(domains, NULL); fail_unless(dom == NULL, "Domain returned without search domain."); - dom = find_domain_by_id(domains[0], "DOES-NOT_EXISTS"); + dom = find_domain_by_id(domains, "DOES-NOT_EXISTS"); fail_unless(dom == NULL, "Domain returned with non existing id."); for (c = 0; c < NUM_DOMAINS; c++) { id = talloc_asprintf(global_talloc_context, "ID-of-domains-%zu", c); fail_unless(id != NULL, "talloc_asprintf failed.\n"); - dom = find_domain_by_id(domains[0], id); - fail_unless(dom == domains[c], "Wrong domain returned for id [%s].", - id); + dom = find_domain_by_id(domains, id); + fail_unless((strcmp(dom->domain_id, id) == 0), + "Wrong domain returned for id [%s].", id); talloc_free(id); } |