summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2017-03-02 17:54:46 +0100
committerJakub Hrozek <jhrozek@redhat.com>2017-03-03 17:36:03 +0100
commitafadeb1a530ff010a2f9a7552562576b843c874b (patch)
tree0c37a4464eb460268497b231f43c2b02840b989d /src/tests
parentc99bcc91e58988ff37403d362d4322469413c2ff (diff)
downloadsssd-afadeb1a530ff010a2f9a7552562576b843c874b.tar.gz
sssd-afadeb1a530ff010a2f9a7552562576b843c874b.tar.xz
sssd-afadeb1a530ff010a2f9a7552562576b843c874b.zip
SYSDB: When searching for UPNs, search either the whole DB or only the given domain
The search-by-UPN functions always searched for the whole domain. In some cases, the caller depends on the result coming from the domain specified by the 'domain' parameter. This is the case in the cache_req code at least. Even though it should be safe to just switch to always searching the whole domain, in order to allow us to examine the code carefully and test each codepath, let's introduce a boolean option to the search functions. Currently it defaults to false in all codepaths and as we test the individual ones, we can flip the option to true until we finally remove the option altogether. Reviewed-by: Sumit Bose <sbose@redhat.com>
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/cmocka/test_sysdb_ts_cache.c6
-rw-r--r--src/tests/sysdb-tests.c14
2 files changed, 10 insertions, 10 deletions
diff --git a/src/tests/cmocka/test_sysdb_ts_cache.c b/src/tests/cmocka/test_sysdb_ts_cache.c
index f5aab73f0..74badf8d5 100644
--- a/src/tests/cmocka/test_sysdb_ts_cache.c
+++ b/src/tests/cmocka/test_sysdb_ts_cache.c
@@ -1303,14 +1303,14 @@ static void test_user_byupn(void **state)
TEST_NOW_2);
assert_int_equal(ret, EOK);
- ret = sysdb_getpwupn(test_ctx, test_ctx->tctx->dom, TEST_USER_UPN, &res);
+ ret = sysdb_getpwupn(test_ctx, test_ctx->tctx->dom, false, TEST_USER_UPN, &res);
assert_int_equal(ret, EOK);
assert_int_equal(res->count, 1);
assert_ts_attrs_res(res, TEST_NOW_2 + TEST_CACHE_TIMEOUT, TEST_NOW_2);
talloc_free(res);
ret = sysdb_search_user_by_upn_res(test_ctx, test_ctx->tctx->dom,
- TEST_USER_UPN, pw_fetch_attrs,
+ false, TEST_USER_UPN, pw_fetch_attrs,
&res);
assert_int_equal(ret, EOK);
assert_int_equal(res->count, 1);
@@ -1318,7 +1318,7 @@ static void test_user_byupn(void **state)
talloc_free(res);
ret = sysdb_search_user_by_upn(test_ctx, test_ctx->tctx->dom,
- TEST_USER_UPN, pw_fetch_attrs,
+ false, TEST_USER_UPN, pw_fetch_attrs,
&msg);
assert_int_equal(ret, EOK);
assert_ts_attrs_msg(msg, TEST_NOW_2 + TEST_CACHE_TIMEOUT, TEST_NOW_2);
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index fe043f605..65692ba16 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -6253,12 +6253,12 @@ START_TEST(test_upn_basic)
attrs, NULL, -1, 0);
fail_unless(ret == EOK, "Could not store user.");
- ret = sysdb_search_user_by_upn(test_ctx, test_ctx->domain,
+ ret = sysdb_search_user_by_upn(test_ctx, test_ctx->domain, false,
"abc@def.ghi", NULL, &msg);
fail_unless(ret == ENOENT,
"sysdb_search_user_by_upn failed with non-existing UPN.");
- ret = sysdb_search_user_by_upn(test_ctx, test_ctx->domain,
+ ret = sysdb_search_user_by_upn(test_ctx, test_ctx->domain, false,
UPN_PRINC, NULL, &msg);
fail_unless(ret == EOK, "sysdb_search_user_by_upn failed.");
@@ -6290,7 +6290,7 @@ START_TEST(test_upn_basic_case)
return;
}
- ret = sysdb_search_user_by_upn(test_ctx, test_ctx->domain,
+ ret = sysdb_search_user_by_upn(test_ctx, test_ctx->domain, false,
UPN_PRINC_WRONG_CASE, NULL, &msg);
fail_unless(ret == EOK, "sysdb_search_user_by_upn failed.");
@@ -6322,7 +6322,7 @@ START_TEST(test_upn_canon)
return;
}
- ret = sysdb_search_user_by_upn(test_ctx, test_ctx->domain,
+ ret = sysdb_search_user_by_upn(test_ctx, test_ctx->domain, false,
UPN_CANON_PRINC, NULL, &msg);
fail_unless(ret == EOK, "sysdb_search_user_by_upn failed.");
@@ -6359,7 +6359,7 @@ START_TEST(test_upn_canon_case)
return;
}
- ret = sysdb_search_user_by_upn(test_ctx, test_ctx->domain,
+ ret = sysdb_search_user_by_upn(test_ctx, test_ctx->domain, false,
UPN_CANON_PRINC_WRONG_CASE, NULL, &msg);
fail_unless(ret == EOK, "sysdb_search_user_by_upn failed.");
@@ -6410,12 +6410,12 @@ START_TEST(test_upn_dup)
attrs, NULL, -1, 0);
fail_unless(ret == EOK, "Could not store user.");
- ret = sysdb_search_user_by_upn(test_ctx, test_ctx->domain,
+ ret = sysdb_search_user_by_upn(test_ctx, test_ctx->domain, false,
UPN_CANON_PRINC, NULL, &msg);
fail_unless(ret == EINVAL,
"sysdb_search_user_by_upn failed for duplicated UPN.");
- ret = sysdb_search_user_by_upn(test_ctx, test_ctx->domain,
+ ret = sysdb_search_user_by_upn(test_ctx, test_ctx->domain, false,
UPN_PRINC, NULL, &msg);
fail_unless(ret == EOK, "sysdb_search_user_by_upn failed.");