summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2010-03-14 18:31:56 -0400
committerStephen Gallagher <sgallagh@redhat.com>2010-04-12 09:22:15 -0400
commita298e5b4050a69238593017ccc774336eb332e16 (patch)
tree0cd8c51c177ac44a78926e2aec20f5096dda3a8f /src/tests
parent7ffaa2afb9e03a6f0b9c602c0f03b2074ea33eac (diff)
downloadsssd_unused-a298e5b4050a69238593017ccc774336eb332e16.tar.gz
sssd_unused-a298e5b4050a69238593017ccc774336eb332e16.tar.xz
sssd_unused-a298e5b4050a69238593017ccc774336eb332e16.zip
sysdb: convert sysdb_getpwuid
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/sysdb-tests.c64
1 files changed, 16 insertions, 48 deletions
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index acb96b2e..6633136d 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -356,31 +356,6 @@ static void test_getgrgid(void *pvt, int error, struct ldb_result *res)
}
}
-static void test_getpwuid(void *pvt, int error, struct ldb_result *res)
-{
- struct test_data *data = talloc_get_type(pvt, struct test_data);
- data->finished = true;
-
- if (error != EOK) {
- data->error = error;
- return;
- }
-
- switch (res->count) {
- case 0:
- data->error = ENOENT;
- break;
-
- case 1:
- data->username = ldb_msg_find_attr_as_string(res->msgs[0], SYSDB_NAME, 0);
- break;
-
- default:
- data->error = EFAULT;
- break;
- }
-}
-
static void test_enumgrent(void *pvt, int error, struct ldb_result *res)
{
struct test_data *data = talloc_get_type(pvt, struct test_data);
@@ -976,9 +951,10 @@ END_TEST
START_TEST (test_sysdb_getpwuid)
{
struct sysdb_test_ctx *test_ctx;
- struct test_data *data;
+ struct ldb_result *res;
+ const char *e_username;
+ const char *username;
int ret;
- const char *username = NULL;
/* Setup */
ret = setup_sysdb_tests(&test_ctx);
@@ -987,35 +963,27 @@ START_TEST (test_sysdb_getpwuid)
return;
}
- username = talloc_asprintf(test_ctx, "testuser%d", _i);
- if (username == NULL) {
- fail("Cannot allocate memory");
- return;
- }
-
- data = talloc_zero(test_ctx, struct test_data);
- data->ctx = test_ctx;
- data->uid = _i;
-
ret = sysdb_getpwuid(test_ctx,
test_ctx->sysdb,
- data->ctx->domain,
- data->uid,
- test_getpwuid,
- data);
- if (ret == EOK) {
- ret = test_loop(data);
- }
-
+ test_ctx->domain,
+ _i, &res);
if (ret) {
fail("sysdb_getpwuid failed for uid %d (%d: %s)",
- data->uid, ret, strerror(ret));
+ _i, ret, strerror(ret));
+ goto done;
+ }
+
+ username = ldb_msg_find_attr_as_string(res->msgs[0], SYSDB_NAME, 0);
+
+ e_username = talloc_asprintf(test_ctx, "testuser%d", _i);
+ if (username == NULL) {
+ fail("Cannot allocate memory");
goto done;
}
- fail_unless(strcmp(data->username, username) == 0,
+ fail_unless(strcmp(username, e_username) == 0,
"Did not find the expected username (found %s expected %s)",
- data->username, username);
+ username, e_username);
done:
talloc_free(test_ctx);
}