summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2014-07-21 20:31:15 +0200
committerJakub Hrozek <jhrozek@redhat.com>2014-09-01 17:32:03 +0200
commit8cfd1e0d696a573a92ef011a64317b9054f5c45f (patch)
tree09d08dc729944797b03ec75ef03b5d7308a3796d
parent92d19f76449817dfb125da9510d478a30eed37bc (diff)
downloadsssd-8cfd1e0d696a573a92ef011a64317b9054f5c45f.tar.gz
sssd-8cfd1e0d696a573a92ef011a64317b9054f5c45f.tar.xz
sssd-8cfd1e0d696a573a92ef011a64317b9054f5c45f.zip
TESTS: Add unit tests for the GPO interface
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
-rw-r--r--src/tests/sysdb-tests.c100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index d24bd4f7d..75495ef3d 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -5535,6 +5535,101 @@ 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_by_guid(test_ctx, test_ctx->domain,
+ test_guid,
+ &result);
+ fail_if(ret != ENOENT, "GPO present in cache before store op");
+
+ ret = sysdb_gpo_get_gpos(test_ctx, test_ctx->domain, &result);
+ fail_if(ret != ENOENT, "GPO present in cache before store op");
+
+ ret = sysdb_gpo_store_gpo(test_ctx->domain,
+ test_guid, 1, 5, 0);
+ fail_if(ret != EOK, "Could not store a test GPO");
+
+ ret = sysdb_gpo_get_gpos(test_ctx, test_ctx->domain, &result);
+ fail_if(ret != EOK, "GPOs not in cache after store op");
+ fail_if(result == NULL);
+ fail_if(result->count != 1);
+
+ result = NULL;
+ ret = sysdb_gpo_get_gpo_by_guid(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);
+ talloc_free(test_ctx);
+}
+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_by_guid(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, 5, 0);
+ fail_if(ret != EOK, "Could not store a test GPO");
+
+ ret = sysdb_gpo_get_gpo_by_guid(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);
+
+ 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);
+ talloc_free(test_ctx);
+}
+END_TEST
+
START_TEST(test_confdb_list_all_domain_names_multi_dom)
{
int ret;
@@ -5944,6 +6039,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");