summaryrefslogtreecommitdiffstats
path: root/src/tests/cmocka
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2015-07-24 09:55:28 +0200
committerJakub Hrozek <jhrozek@redhat.com>2015-07-27 22:59:17 +0200
commitea6cfe4e1d7c84370bfcc86251ea10b2658b52d3 (patch)
treeeafb81d6345982af8fa78c7ae98dd8fb8f994120 /src/tests/cmocka
parent681fd36964b873135b2b8dd5200ddcfd1e420214 (diff)
downloadsssd-ea6cfe4e1d7c84370bfcc86251ea10b2658b52d3.tar.gz
sssd-ea6cfe4e1d7c84370bfcc86251ea10b2658b52d3.tar.xz
sssd-ea6cfe4e1d7c84370bfcc86251ea10b2658b52d3.zip
SYSDB: prepare for LOCAL view
Objects doesn't have to have overrideDN specified when using LOCAL view. Since the view is not stored on the server we do not want to contact LDAP therefore we special case LOCAL view saying that it is OK that this attribute is missing. Preparation for: https://fedorahosted.org/sssd/ticket/2584 Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Diffstat (limited to 'src/tests/cmocka')
-rw-r--r--src/tests/cmocka/test_sysdb_views.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/tests/cmocka/test_sysdb_views.c b/src/tests/cmocka/test_sysdb_views.c
index 123d4c5cb..83007b76a 100644
--- a/src/tests/cmocka/test_sysdb_views.c
+++ b/src/tests/cmocka/test_sysdb_views.c
@@ -281,6 +281,68 @@ void test_sysdb_add_overrides_to_object(void **state)
assert_int_equal(ldb_val_string_cmp(&el->values[1], "OVERRIDEKEY2"), 0);
}
+void test_sysdb_add_overrides_to_object_local(void **state)
+{
+ int ret;
+ struct ldb_message *orig;
+ struct ldb_message_element *el;
+ char *tmp_str;
+ struct sysdb_test_ctx *test_ctx = talloc_get_type_abort(*state,
+ struct sysdb_test_ctx);
+
+ orig = ldb_msg_new(test_ctx);
+ assert_non_null(orig);
+
+ tmp_str = talloc_strdup(orig, "ORIGNAME");
+ assert_non_null(tmp_str);
+ ret = ldb_msg_add_string(orig, SYSDB_NAME, tmp_str);
+ assert_int_equal(ret, EOK);
+
+ tmp_str = talloc_strdup(orig, "ORIGGECOS");
+ assert_non_null(tmp_str);
+ ret = ldb_msg_add_string(orig, SYSDB_GECOS, tmp_str);
+ assert_int_equal(ret, EOK);
+
+ test_ctx->domain->has_views = true;
+ test_ctx->domain->view_name = "LOCAL";
+
+ ret = sysdb_add_overrides_to_object(test_ctx->domain, orig, NULL, NULL);
+ assert_int_equal(ret, EOK);
+}
+
+void test_sysdb_add_overrides_to_object_missing_overridedn(void **state)
+{
+ int ret;
+ struct ldb_message *orig;
+ struct ldb_message_element *el;
+ char *tmp_str;
+ struct sysdb_test_ctx *test_ctx = talloc_get_type_abort(*state,
+ struct sysdb_test_ctx);
+
+ orig = ldb_msg_new(test_ctx);
+ assert_non_null(orig);
+
+ orig->dn = ldb_dn_new(orig, test_ctx->domain->sysdb->ldb,
+ "cn=somedn,dc=example,dc=com");
+ assert_non_null(orig->dn);
+
+ tmp_str = talloc_strdup(orig, "ORIGNAME");
+ assert_non_null(tmp_str);
+ ret = ldb_msg_add_string(orig, SYSDB_NAME, tmp_str);
+ assert_int_equal(ret, EOK);
+
+ tmp_str = talloc_strdup(orig, "ORIGGECOS");
+ assert_non_null(tmp_str);
+ ret = ldb_msg_add_string(orig, SYSDB_GECOS, tmp_str);
+ assert_int_equal(ret, EOK);
+
+ test_ctx->domain->has_views = true;
+ test_ctx->domain->view_name = "NON-LOCAL";
+
+ ret = sysdb_add_overrides_to_object(test_ctx->domain, orig, NULL, NULL);
+ assert_int_equal(ret, ENOENT);
+}
+
void test_split_ipa_anchor(void **state)
{
int ret;
@@ -923,6 +985,10 @@ int main(int argc, const char *argv[])
test_sysdb_setup, test_sysdb_teardown),
cmocka_unit_test_setup_teardown(test_sysdb_add_overrides_to_object,
test_sysdb_setup, test_sysdb_teardown),
+ cmocka_unit_test_setup_teardown(test_sysdb_add_overrides_to_object_local,
+ test_sysdb_setup, test_sysdb_teardown),
+ cmocka_unit_test_setup_teardown(test_sysdb_add_overrides_to_object_missing_overridedn,
+ test_sysdb_setup, test_sysdb_teardown),
cmocka_unit_test_setup_teardown(test_split_ipa_anchor,
test_sysdb_setup, test_sysdb_teardown),
cmocka_unit_test_setup_teardown(test_sysdb_delete_view_tree,