summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2013-01-14 16:47:51 -0500
committerJakub Hrozek <jhrozek@redhat.com>2013-02-10 22:08:47 +0100
commit95e94691178297f2b8225a83d43ae388cab04b45 (patch)
tree5869555cf5490a7019b3f18d4fa647a9dae8b619 /src/tests
parent1187a07ed4207c1c326fdf83915dddfe472b8620 (diff)
downloadsssd-95e94691178297f2b8225a83d43ae388cab04b45.tar.gz
sssd-95e94691178297f2b8225a83d43ae388cab04b45.tar.bz2
sssd-95e94691178297f2b8225a83d43ae388cab04b45.zip
Remove sysdb_subdom completely
struct sss_domain_info is always used to represent domains now. Adjust tests accordingly.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/sysdb-tests.c112
1 files changed, 67 insertions, 45 deletions
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index 0d46fc0a..58198d50 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -4467,20 +4467,14 @@ START_TEST(test_sysdb_original_dn_case_insensitive)
}
END_TEST
-struct sysdb_subdom dom1 = { "DOM1.SUB", "dom1.sub", "dom1", "S-1" };
-struct sysdb_subdom dom2 = { "DOM2.SUB", "dom2.sub", "dom2", "S-2" };
-struct sysdb_subdom dom_t = { "TEST.SUB", "test.sub", "test", "S-3" };
-
START_TEST(test_sysdb_subdomain_create)
{
struct sysdb_test_ctx *test_ctx;
errno_t ret;
struct sss_domain_info **cur_subdomains = NULL;
size_t cur_subdomains_count;
- struct sysdb_subdom *new_subdom1 = &dom1;
- struct sysdb_subdom *new_subdom2 = &dom2;
- int num_subdom1 = 1;
- int num_subdom2 = 1;
+ struct sss_domain_info *new_subdom1;
+ struct sss_domain_info *new_subdom2;
ret = setup_sysdb_tests(&test_ctx);
fail_if(ret != EOK, "Could not set up the test");
@@ -4489,10 +4483,25 @@ START_TEST(test_sysdb_subdomain_create)
&cur_subdomains_count, &cur_subdomains);
fail_unless(ret == EOK, "sysdb_get_subdomains failed with [%d][%s]",
ret, strerror(ret));
- fail_unless(cur_subdomains != NULL, "No sub-domains returned.");
+ fail_unless(cur_subdomains != NULL, "Non zero sub-domains returned.");
fail_unless(cur_subdomains[0] == NULL, "No empty sub-domain list returned.");
- ret = sysdb_update_subdomains(test_ctx->domain, num_subdom1, new_subdom1);
+ test_ctx->domain->subdomains = talloc_array(test_ctx->domain,
+ struct sss_domain_info *, 2);
+ fail_unless(test_ctx->domain->subdomains != NULL,
+ "talloc_array_zero failed");
+
+ new_subdom1 = new_subdomain(test_ctx, test_ctx->domain,
+ "dom1.sub", "DOM1.SUB", "dom1", "S-1");
+ fail_unless(new_subdom1 != NULL, "Failed to create new subdomin.");
+ test_ctx->domain->subdomains[0] = new_subdom1;
+ test_ctx->domain->subdomain_count = 1;
+
+ ret = sysdb_subdomain_store(test_ctx->sysdb,
+ "dom1.sub", "DOM1.SUB", "dom1", "S-1");
+ fail_if(ret != EOK, "Could not set up the test (dom1)");
+
+ ret = sysdb_update_subdomains(test_ctx->domain);
fail_unless(ret == EOK, "sysdb_update_subdomains failed with [%d][%s]",
ret, strerror(ret));
@@ -4500,13 +4509,23 @@ START_TEST(test_sysdb_subdomain_create)
&cur_subdomains_count, &cur_subdomains);
fail_unless(ret == EOK, "sysdb_get_subdomains failed with [%d][%s]",
ret, strerror(ret));
- fail_unless(cur_subdomains != NULL, "No sub-domains returned.");
- fail_unless(cur_subdomains[0] != NULL, "Empyt sub-domain list returned.");
- fail_unless(strcmp(cur_subdomains[0]->name, new_subdom1[0].name) == 0,
- "Unexpected sub-domain found, expected [%s], got [%s]",
- new_subdom1[0].name, cur_subdomains[0]->name);
-
- ret = sysdb_update_subdomains(test_ctx->domain, num_subdom2, new_subdom2);
+ fail_if(cur_subdomains_count != 1, "Wrong number of sub-domains returned.");
+ fail_if(cur_subdomains[0] == NULL, "Empyt sub-domain list returned.");
+ fail_if(strcmp(cur_subdomains[0]->name, new_subdom1->name) != 0,
+ "Unexpected sub-domain found, expected [%s], got [%s]",
+ new_subdom1->name, cur_subdomains[0]->name);
+
+ new_subdom2 = new_subdomain(test_ctx, test_ctx->domain,
+ "dom2.sub", "DOM2.SUB", "dom2", "S-2");
+ fail_unless(new_subdom2 != NULL, "Failed to create new subdomin.");
+ test_ctx->domain->subdomains[1] = new_subdom2;
+ test_ctx->domain->subdomain_count = 2;
+
+ ret = sysdb_subdomain_store(test_ctx->sysdb,
+ "dom2.sub", "DOM2.SUB", "dom2", "S-2");
+ fail_if(ret != EOK, "Could not set up the test (dom2)");
+
+ ret = sysdb_update_subdomains(test_ctx->domain);
fail_unless(ret == EOK, "sysdb_update_subdomains failed with [%d][%s]",
ret, strerror(ret));
@@ -4514,13 +4533,16 @@ START_TEST(test_sysdb_subdomain_create)
&cur_subdomains_count, &cur_subdomains);
fail_unless(ret == EOK, "sysdb_get_subdomains failed with [%d][%s]",
ret, strerror(ret));
- fail_unless(cur_subdomains != NULL, "No sub-domains returned.");
- fail_unless(cur_subdomains[0] != NULL, "Empyt sub-domain list returned.");
- fail_unless(strcmp(cur_subdomains[0]->name, new_subdom2[0].name) == 0,
- "Unexpected sub-domain found, expected [%s], got [%s]",
- new_subdom2[0].name, cur_subdomains[0]->name);
+ fail_if(cur_subdomains_count != 2, "Wrong number of sub-domains returned.");
+ fail_if(cur_subdomains[1] == NULL, "Empyt sub-domain list returned.");
+ fail_if(strcmp(cur_subdomains[1]->name, new_subdom2->name) != 0,
+ "Unexpected sub-domain found, expected [%s], got [%s]",
+ new_subdom2->name, cur_subdomains[1]->name);
- ret = sysdb_update_subdomains(test_ctx->domain, 0, NULL);
+ test_ctx->domain->subdomain_count = 0;
+ talloc_zfree(test_ctx->domain->subdomains);
+
+ ret = sysdb_update_subdomains(test_ctx->domain);
fail_unless(ret == EOK, "sysdb_update_subdomains failed with [%d][%s]",
ret, strerror(ret));
@@ -4529,7 +4551,7 @@ START_TEST(test_sysdb_subdomain_create)
fail_unless(ret == EOK, "sysdb_get_subdomains failed with [%d][%s]",
ret, strerror(ret));
fail_unless(cur_subdomains != NULL, "No sub-domains returned.");
- fail_unless(cur_subdomains[0] == NULL, "No empty sub-domain list returned.");
+ fail_if(cur_subdomains[0] != NULL, "No empty sub-domain list returned.");
}
END_TEST
@@ -4537,8 +4559,6 @@ START_TEST(test_sysdb_subdomain_store_user)
{
struct sysdb_test_ctx *test_ctx;
errno_t ret;
- struct sysdb_subdom *test_subdom = &dom_t;
- int num_subdom = 1;
struct sss_domain_info *subdomain = NULL;
struct ldb_result *results = NULL;
struct ldb_dn *base_dn = NULL;
@@ -4547,14 +4567,16 @@ START_TEST(test_sysdb_subdomain_store_user)
ret = setup_sysdb_tests(&test_ctx);
fail_if(ret != EOK, "Could not set up the test");
- ret = sysdb_update_subdomains(test_ctx->domain, num_subdom, test_subdom);
+ subdomain = new_subdomain(test_ctx, test_ctx->domain,
+ "test.sub", "TEST.SUB", "test", "S-3");
+ fail_unless(subdomain != NULL, "Failed to create new subdomin.");
+ ret = sysdb_subdomain_create(subdomain);
+ fail_if(ret != EOK, "Could not set up the test (test subdom)");
+
+ ret = sysdb_update_subdomains(test_ctx->domain);
fail_unless(ret == EOK, "sysdb_update_subdomains failed with [%d][%s]",
ret, strerror(ret));
- subdomain = new_subdomain(test_ctx, test_ctx->domain, "test.sub",
- NULL, NULL, NULL);
- fail_unless(subdomain != NULL, "new_subdomain failed.");
-
ret = sysdb_store_user(subdomain->sysdb, subdomain, "subdomuser",
NULL, 12345, 0, "Sub Domain User",
"/home/subdomuser", "/bin/bash",
@@ -4594,8 +4616,6 @@ START_TEST(test_sysdb_subdomain_user_ops)
{
struct sysdb_test_ctx *test_ctx;
errno_t ret;
- struct sysdb_subdom *test_subdom = &dom_t;
- int num_subdom = 1;
struct sss_domain_info *subdomain = NULL;
struct ldb_message *msg = NULL;
struct ldb_dn *check_dn = NULL;
@@ -4603,14 +4623,16 @@ START_TEST(test_sysdb_subdomain_user_ops)
ret = setup_sysdb_tests(&test_ctx);
fail_if(ret != EOK, "Could not set up the test");
- ret = sysdb_update_subdomains(test_ctx->domain, num_subdom, test_subdom);
+ subdomain = new_subdomain(test_ctx, test_ctx->domain,
+ "test.sub", "TEST.SUB", "test", "S-3");
+ fail_unless(subdomain != NULL, "Failed to create new subdomin.");
+ ret = sysdb_subdomain_create(subdomain);
+ fail_if(ret != EOK, "Could not set up the test (test subdom)");
+
+ ret = sysdb_update_subdomains(test_ctx->domain);
fail_unless(ret == EOK, "sysdb_update_subdomains failed with [%d][%s]",
ret, strerror(ret));
- subdomain = new_subdomain(test_ctx, test_ctx->domain, "test.sub",
- NULL, NULL, NULL);
- fail_unless(subdomain != NULL, "new_subdomain failed.");
-
ret = sysdb_store_user(subdomain->sysdb, subdomain, "subdomuser",
NULL, 12345, 0, "Sub Domain User",
"/home/subdomuser", "/bin/bash",
@@ -4646,8 +4668,6 @@ START_TEST(test_sysdb_subdomain_group_ops)
{
struct sysdb_test_ctx *test_ctx;
errno_t ret;
- struct sysdb_subdom *test_subdom = &dom_t;
- int num_subdom = 1;
struct sss_domain_info *subdomain = NULL;
struct ldb_message *msg = NULL;
struct ldb_dn *check_dn = NULL;
@@ -4655,14 +4675,16 @@ START_TEST(test_sysdb_subdomain_group_ops)
ret = setup_sysdb_tests(&test_ctx);
fail_if(ret != EOK, "Could not set up the test");
- ret = sysdb_update_subdomains(test_ctx->domain, num_subdom, test_subdom);
+ subdomain = new_subdomain(test_ctx, test_ctx->domain,
+ "test.sub", "TEST.SUB", "test", "S-3");
+ fail_unless(subdomain != NULL, "Failed to create new subdomin.");
+ ret = sysdb_subdomain_create(subdomain);
+ fail_if(ret != EOK, "Could not set up the test (test subdom)");
+
+ ret = sysdb_update_subdomains(test_ctx->domain);
fail_unless(ret == EOK, "sysdb_update_subdomains failed with [%d][%s]",
ret, strerror(ret));
- subdomain = new_subdomain(test_ctx, test_ctx->domain, "test.sub",
- NULL, NULL, NULL);
- fail_unless(subdomain != NULL, "new_subdomain failed.");
-
ret = sysdb_store_group(subdomain->sysdb, subdomain,
"subdomgroup", 12345, NULL, -1, 0);
fail_unless(ret == EOK, "sysdb_store_domgroup failed.");