Skip to content

Commit

Permalink
tests: adapt sysdb-tests for disabling local provider
Browse files Browse the repository at this point in the history
local provider has mpg enabled by default but, as the local provider is
only conditionally built nowadays (and disabled by default) we have to
set mpg to true when running some tests and the local provider is not
built.

Also, we have to adapt functions that would be used to test and/or
internally take advantage of the automatically generated uid/gid for the
user as it's specific for local provider.

Related:
https://pagure.io/SSSD/sssd/issue/3304

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
  • Loading branch information
fidencio committed Jul 2, 2018
1 parent f1120bb commit 9d97810
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/tests/sysdb-tests.c
Expand Up @@ -680,6 +680,8 @@ START_TEST (test_sysdb_user_new_id)
const char *desc;
const char *desc_in = "testuser_new_id_desc";
const char *username = "testuser_newid";
uid_t uid;
gid_t gid;

/* Setup */
ret = setup_sysdb_tests(&test_ctx);
Expand All @@ -699,8 +701,16 @@ START_TEST (test_sysdb_user_new_id)
ret = sysdb_attrs_add_string(attrs, SYSDB_DESCRIPTION, desc_in);
fail_if(ret != EOK);

if (local_provider_is_built()) {
uid = 0;
gid = 0;
} else {
uid = 1234;
gid = 1234;
}

ret = sysdb_add_user(test_ctx->domain, fqname,
0, 0, fqname, "/", "/bin/bash",
uid, gid, fqname, "/", "/bin/bash",
NULL, attrs, 0, 0);
fail_if(ret != EOK, "Could not store user %s", fqname);

Expand Down Expand Up @@ -1095,6 +1105,9 @@ START_TEST(test_user_group_by_name)
* ldap provider differently with auto_private_groups.
*/
test_ctx->domain->provider = discard_const_p(char, "ldap");
if (!local_provider_is_built()) {
test_ctx->domain->mpg = true;
}

data = test_data_new_user(test_ctx, _i);
fail_if(data == NULL);
Expand Down Expand Up @@ -1336,6 +1349,10 @@ START_TEST (test_sysdb_enumgrent)
return;
}

if (!local_provider_is_built()) {
test_ctx->domain->mpg = true;
}

ret = sysdb_enumgrent(test_ctx,
test_ctx->domain,
&res);
Expand Down Expand Up @@ -1827,6 +1844,7 @@ START_TEST (test_sysdb_remove_nonexistent_group)
}
END_TEST

#ifdef BUILD_LOCAL_PROVIDER
START_TEST (test_sysdb_get_new_id)
{
struct sysdb_test_ctx *test_ctx;
Expand All @@ -1842,6 +1860,7 @@ START_TEST (test_sysdb_get_new_id)
fail_if(id != test_ctx->domain->id_min);
}
END_TEST
#endif

START_TEST (test_sysdb_store_custom)
{
Expand Down Expand Up @@ -7190,8 +7209,10 @@ Suite *create_sysdb_suite(void)

TCase *tc_sysdb = tcase_create("SYSDB Tests");

#ifdef BUILD_LOCAL_PROVIDER
/* test getting next id works */
tcase_add_test(tc_sysdb, test_sysdb_get_new_id);
#endif

/* Add a user with an automatic ID */
tcase_add_test(tc_sysdb, test_sysdb_user_new_id);
Expand Down

0 comments on commit 9d97810

Please sign in to comment.