diff options
author | Jan Cholasta <jcholast@redhat.com> | 2012-09-25 04:27:38 -0400 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2012-10-05 10:51:54 +0200 |
commit | 2d6836a90bd326391782a5753f70e8ba666b5def (patch) | |
tree | b69421bd93196be2779fe58684c5f6b8a1a90496 /src/tests | |
parent | 67ca9e7c006d8619f446c018eabf29eab1368ba5 (diff) | |
download | sssd-2d6836a90bd326391782a5753f70e8ba666b5def.tar.gz sssd-2d6836a90bd326391782a5753f70e8ba666b5def.tar.bz2 sssd-2d6836a90bd326391782a5753f70e8ba666b5def.zip |
SSH: Refactor sysdb and related code
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/sysdb_ssh-tests.c | 47 |
1 files changed, 11 insertions, 36 deletions
diff --git a/src/tests/sysdb_ssh-tests.c b/src/tests/sysdb_ssh-tests.c index 2d5bd8e2..f914993c 100644 --- a/src/tests/sysdb_ssh-tests.c +++ b/src/tests/sysdb_ssh-tests.c @@ -164,19 +164,19 @@ struct test_data { const char *hostname; const char *alias; - struct ldb_message **hosts; + struct ldb_message *host; struct sysdb_attrs *attrs; - - size_t count; }; static int test_sysdb_store_ssh_host(struct test_data *data) { int ret; + time_t now = time(NULL); ret = sysdb_store_ssh_host(data->ctx->sysdb, data->hostname, data->alias, + now, data->attrs); return ret; } @@ -189,14 +189,15 @@ static int test_sysdb_delete_ssh_host(struct test_data *data) return ret; } -static int test_sysdb_search_ssh_hosts(struct test_data *data) +static int test_sysdb_get_ssh_host(struct test_data *data) { int ret; const char *attrs[] = { SYSDB_NAME, NULL }; - ret = sysdb_search_ssh_hosts(data->ctx, data->ctx->sysdb, - data->hostname, attrs, - &data->hosts, &data->count); + ret = sysdb_get_ssh_host(data->ctx, data->ctx->sysdb, + data->hostname, attrs, + &data->host); + return ret; } @@ -235,18 +236,6 @@ START_TEST (store_one_host_test) return; } - ret = sysdb_attrs_add_string(data->attrs, SYSDB_OBJECTCLASS, "testClass"); - if (ret != EOK) { - fail("Could not add attribute."); - return; - } - - ret = sysdb_attrs_add_string(data->attrs, SYSDB_NAME, TEST_HOSTNAME); - if (ret != EOK) { - fail("Could not add attribute."); - return; - } - ret = test_sysdb_store_ssh_host(data); fail_if(ret != EOK, "Could not store host into database"); @@ -324,7 +313,7 @@ START_TEST (delete_nonexistent_host_test) } END_TEST -START_TEST (sysdb_search_ssh_host_test) +START_TEST (sysdb_get_ssh_host_test) { struct sysdb_test_ctx *test_ctx; struct test_data *data; @@ -359,20 +348,6 @@ START_TEST (sysdb_search_ssh_host_test) return; } - ret = sysdb_attrs_add_string(data->attrs, SYSDB_OBJECTCLASS, "testClass"); - if (ret != EOK) { - fail("Could not add attribute."); - talloc_free(test_ctx); - return; - } - - ret = sysdb_attrs_add_string(data->attrs, SYSDB_NAME, TEST_HOSTNAME); - if (ret != EOK) { - fail("Could not add attribute."); - talloc_free(test_ctx); - return; - } - ret = test_sysdb_store_ssh_host(data); if (ret != EOK) { fail("Could not store host '%s' to database", TEST_HOSTNAME); @@ -380,7 +355,7 @@ START_TEST (sysdb_search_ssh_host_test) return; } - ret = test_sysdb_search_ssh_hosts(data); + ret = test_sysdb_get_ssh_host(data); fail_if(ret != EOK, "Could not find host '%s'",TEST_HOSTNAME); talloc_free(test_ctx); @@ -396,7 +371,7 @@ Suite *create_sysdb_ssh_suite(void) tcase_add_test(tc_sysdb_ssh, store_one_host_test); tcase_add_test(tc_sysdb_ssh, delete_existing_host_test); tcase_add_test(tc_sysdb_ssh, delete_nonexistent_host_test); - tcase_add_test(tc_sysdb_ssh, sysdb_search_ssh_host_test); + tcase_add_test(tc_sysdb_ssh, sysdb_get_ssh_host_test); suite_add_tcase(s, tc_sysdb_ssh); return s; } |