[SSSD] [PATCH] TESTS: Add unit tests for the GPO interface
Jakub Hrozek
jhrozek at redhat.com
Tue Jul 22 11:31:05 UTC 2014
On Tue, Jul 22, 2014 at 01:25:50PM +0200, Jakub Hrozek wrote:
> Hi,
>
> I used the attached patch to exercise Yassir's new additions to the
> sysdb API.
Sorry there was one useless hunk in Makefile.am. A new patch is
attached.
-------------- next part --------------
>From 4ebcf633f07b58c1256751a74a0b0d7643e93989 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Mon, 21 Jul 2014 20:31:15 +0200
Subject: [PATCH] TESTS: Add unit tests for the GPO interface
---
src/tests/sysdb-tests.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 96 insertions(+)
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index d24bd4f7d4f0e8f85afa7c98da8edc0635b2e328..032ec84c0cc0d2d75640204875b154222ed3f16d 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -5535,6 +5535,97 @@ START_TEST(test_upn_dup)
}
END_TEST
+START_TEST(test_gpo_store_retrieve)
+{
+ struct sysdb_test_ctx *test_ctx;
+ errno_t ret;
+ struct ldb_result *result = NULL;
+ const char *guid;
+ int version;
+ static const char *test_guid = "3610EDA5-77EF-11D2-8DC5-00C04FA31A66";
+
+ ret = setup_sysdb_tests(&test_ctx);
+ fail_if(ret != EOK, "Could not set up the test");
+
+ ret = sysdb_gpo_get_gpo(test_ctx, test_ctx->domain,
+ test_guid,
+ &result);
+ fail_if(ret != ENOENT, "GPO present in cache before store op");
+
+ ret = sysdb_gpo_store_gpo(test_ctx->domain,
+ test_guid, 1);
+ fail_if(ret != EOK, "Could not store a test GPO");
+
+ ret = sysdb_gpo_get_gpo(test_ctx, test_ctx->domain,
+ test_guid, &result);
+ fail_if(ret != EOK, "GPO not in cache after store op");
+ fail_if(result == NULL);
+ fail_if(result->count != 1);
+
+ guid = ldb_msg_find_attr_as_string(result->msgs[0],
+ SYSDB_GPO_GUID_ATTR, NULL);
+ ck_assert_str_eq(guid, test_guid);
+
+ version = ldb_msg_find_attr_as_uint(result->msgs[0],
+ SYSDB_GPO_VERSION_ATTR, 0);
+ ck_assert_int_eq(version, 1);
+}
+END_TEST
+
+START_TEST(test_gpo_replace)
+{
+ struct sysdb_test_ctx *test_ctx;
+ errno_t ret;
+ struct ldb_result *result = NULL;
+ const char *guid;
+ int version;
+ static const char *test_guid = "3610EDA5-77EF-11D2-8DC5-00C04FA31A66";
+
+ ret = setup_sysdb_tests(&test_ctx);
+ fail_if(ret != EOK, "Could not setup the test");
+
+ ret = sysdb_gpo_get_gpo(test_ctx, test_ctx->domain,
+ test_guid, &result);
+ fail_if(ret != EOK, "GPO not in cache after store op");
+ fail_if(result == NULL);
+ fail_if(result->count != 1);
+
+ guid = ldb_msg_find_attr_as_string(result->msgs[0],
+ SYSDB_GPO_GUID_ATTR, NULL);
+ ck_assert_str_eq(guid, test_guid);
+
+ version = ldb_msg_find_attr_as_uint(result->msgs[0],
+ SYSDB_GPO_VERSION_ATTR, 0);
+ ck_assert_int_eq(version, 1);
+
+ /* Modify the version */
+ ret = sysdb_gpo_store_gpo(test_ctx->domain,
+ test_guid, 2);
+ fail_if(ret != EOK, "Could not store a test GPO");
+
+ ret = sysdb_gpo_get_gpo(test_ctx, test_ctx->domain,
+ test_guid, &result);
+ fail_if(ret != EOK, "GPO not in cache after modify op");
+ fail_if(result == NULL);
+ fail_if(result->count != 1);
+
+ ret = sysdb_gpo_get_gpo(test_ctx, test_ctx->domain,
+ test_guid, &result);
+ fail_if(ret != EOK, "GPO not in cache after store op");
+ fail_if(result == NULL);
+ fail_if(result->count != 1);
+
+ guid = ldb_msg_find_attr_as_string(result->msgs[0],
+ SYSDB_GPO_GUID_ATTR, NULL);
+ ck_assert_str_eq(guid, test_guid);
+
+ version = ldb_msg_find_attr_as_uint(result->msgs[0],
+ SYSDB_GPO_VERSION_ATTR, 0);
+ ck_assert_int_eq(version, 2);
+
+}
+END_TEST
+
START_TEST(test_confdb_list_all_domain_names_multi_dom)
{
int ret;
@@ -5944,6 +6035,11 @@ Suite *create_sysdb_suite(void)
suite_add_tcase(s, tc_upn);
+ TCase *tc_gpo = tcase_create("SYSDB GPO tests");
+ tcase_add_test(tc_gpo, test_gpo_store_retrieve);
+ tcase_add_test(tc_gpo, test_gpo_replace);
+ suite_add_tcase(s, tc_gpo);
+
/* ConfDB tests -- modify confdb, must always be last!! */
TCase *tc_confdb = tcase_create("confDB tests");
--
1.9.3
More information about the sssd-devel
mailing list