summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2013-10-24 11:44:11 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-10-25 15:33:56 +0200
commita5c75692c17498a61babb7045db2dc3f25b0d1af (patch)
treee9ee03d42af210320b561eb554637712890d77a9 /src/tests
parenta8e5bd27abc0d820baa256116fab02917e09df81 (diff)
downloadsssd-a5c75692c17498a61babb7045db2dc3f25b0d1af.tar.gz
sssd-a5c75692c17498a61babb7045db2dc3f25b0d1af.tar.xz
sssd-a5c75692c17498a61babb7045db2dc3f25b0d1af.zip
idmap: add sss_idmap_domain_by_name_has_algorithmic_mapping()
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/cmocka/test_sss_idmap.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/tests/cmocka/test_sss_idmap.c b/src/tests/cmocka/test_sss_idmap.c
index 2f6a67d7d..53ed35a97 100644
--- a/src/tests/cmocka/test_sss_idmap.c
+++ b/src/tests/cmocka/test_sss_idmap.c
@@ -367,6 +367,44 @@ void test_has_algorithmic(void **state)
assert_false(use_id_mapping);
}
+void test_has_algorithmic_by_name(void **state)
+{
+ struct test_ctx *test_ctx;
+ bool use_id_mapping;
+ enum idmap_error_code err;
+
+ test_ctx = talloc_get_type(*state, struct test_ctx);
+
+ assert_non_null(test_ctx);
+
+ err = sss_idmap_domain_by_name_has_algorithmic_mapping(NULL, NULL, &use_id_mapping);
+ assert_int_equal(err, IDMAP_ERROR);
+
+ err = sss_idmap_domain_by_name_has_algorithmic_mapping(NULL, TEST_DOM_SID,
+ &use_id_mapping);
+ assert_int_equal(err, IDMAP_CONTEXT_INVALID);
+
+ err = sss_idmap_domain_by_name_has_algorithmic_mapping(test_ctx->idmap_ctx, NULL,
+ &use_id_mapping);
+ assert_int_equal(err, IDMAP_ERROR);
+
+ err = sss_idmap_domain_by_name_has_algorithmic_mapping(test_ctx->idmap_ctx,
+ TEST_DOM_NAME"1",
+ &use_id_mapping);
+ assert_int_equal(err, IDMAP_NAME_UNKNOWN);
+
+ err = sss_idmap_domain_by_name_has_algorithmic_mapping(test_ctx->idmap_ctx,
+ TEST_DOM_NAME,
+ &use_id_mapping);
+ assert_int_equal(err, IDMAP_SUCCESS);
+ assert_true(use_id_mapping);
+
+ err = sss_idmap_domain_by_name_has_algorithmic_mapping(test_ctx->idmap_ctx,
+ TEST_2_DOM_NAME,
+ &use_id_mapping);
+ assert_int_equal(err, IDMAP_SUCCESS);
+ assert_false(use_id_mapping);
+}
int main(int argc, const char *argv[])
{
@@ -396,6 +434,9 @@ int main(int argc, const char *argv[])
unit_test_setup_teardown(test_has_algorithmic,
test_sss_idmap_setup_with_both,
test_sss_idmap_teardown),
+ unit_test_setup_teardown(test_has_algorithmic_by_name,
+ test_sss_idmap_setup_with_both,
+ test_sss_idmap_teardown),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */