summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2015-03-09 17:26:54 +0100
committerJakub Hrozek <jhrozek@redhat.com>2015-03-12 09:49:05 +0100
commit9cc2223e0bc0478c1b47a47fd71bba7e7129492d (patch)
tree4423aeb87cbaa64fb289479da4b0b55ab13cc090 /src/tests
parent4e5e846de22407f825fe3b4040d79606818a2419 (diff)
downloadsssd-9cc2223e0bc0478c1b47a47fd71bba7e7129492d.tar.gz
sssd-9cc2223e0bc0478c1b47a47fd71bba7e7129492d.tar.xz
sssd-9cc2223e0bc0478c1b47a47fd71bba7e7129492d.zip
tests: ncache_hit must be an int to test UPNs
In order to detect faulty cases where negcache would be checked twice, we need to convert the ncache_hit to integer and check exact amounts of hits. Reviewed-by: Pavel Reichl <preichl@redhat.com>
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/cmocka/test_nss_srv.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/tests/cmocka/test_nss_srv.c b/src/tests/cmocka/test_nss_srv.c
index 4dbda3bd6..bf8bddb26 100644
--- a/src/tests/cmocka/test_nss_srv.c
+++ b/src/tests/cmocka/test_nss_srv.c
@@ -48,7 +48,7 @@ struct nss_test_ctx {
struct sss_cmd_table *nss_cmds;
struct nss_ctx *nctx;
- bool ncache_hit;
+ int ncache_hits;
};
const char *global_extra_attrs[] = {"phone", "mobile", NULL};
@@ -159,7 +159,7 @@ int __wrap_sss_ncache_check_user(struct sss_nc_ctx *ctx, int ttl,
ret = __real_sss_ncache_check_user(ctx, ttl, dom, name);
if (ret == EEXIST) {
- nss_test_ctx->ncache_hit = true;
+ nss_test_ctx->ncache_hits++;
}
return ret;
}
@@ -172,7 +172,7 @@ int __wrap_sss_ncache_check_uid(struct sss_nc_ctx *ctx, int ttl, uid_t uid)
ret = __real_sss_ncache_check_uid(ctx, ttl, uid);
if (ret == EEXIST) {
- nss_test_ctx->ncache_hit = true;
+ nss_test_ctx->ncache_hits++;
}
return ret;
}
@@ -347,7 +347,7 @@ void test_nss_getpwnam_neg(void **state)
mock_input_user_or_group("testuser_neg");
mock_account_recv_simple();
- assert_true(nss_test_ctx->ncache_hit == false);
+ assert_int_equal(nss_test_ctx->ncache_hits, 0);
ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWNAM,
nss_test_ctx->nss_cmds);
@@ -356,7 +356,7 @@ void test_nss_getpwnam_neg(void **state)
/* Wait until the test finishes with ENOENT */
ret = test_ev_loop(nss_test_ctx->tctx);
assert_int_equal(ret, ENOENT);
- assert_true(nss_test_ctx->ncache_hit == false);
+ assert_int_equal(nss_test_ctx->ncache_hits, 0);
/* Test that subsequent search for a nonexistent user yields
* ENOENT and Account callback is not called, on the other hand
@@ -373,7 +373,7 @@ void test_nss_getpwnam_neg(void **state)
ret = test_ev_loop(nss_test_ctx->tctx);
assert_int_equal(ret, ENOENT);
/* Negative cache was hit this time */
- assert_true(nss_test_ctx->ncache_hit == true);
+ assert_int_equal(nss_test_ctx->ncache_hits, 1);
}
static int test_nss_getpwnam_search_acct_cb(void *pvt)
@@ -791,7 +791,7 @@ void test_nss_getpwuid_neg(void **state)
mock_input_id(nss_test_ctx, id);
mock_account_recv_simple();
- assert_true(nss_test_ctx->ncache_hit == false);
+ assert_int_equal(nss_test_ctx->ncache_hits, 0);
ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWUID,
nss_test_ctx->nss_cmds);
@@ -800,7 +800,7 @@ void test_nss_getpwuid_neg(void **state)
/* Wait until the test finishes with ENOENT */
ret = test_ev_loop(nss_test_ctx->tctx);
assert_int_equal(ret, ENOENT);
- assert_true(nss_test_ctx->ncache_hit == false);
+ assert_int_equal(nss_test_ctx->ncache_hits, 0);
/* Test that subsequent search for a nonexistent id yields
* ENOENT and Account callback is not called, on the other hand
@@ -817,7 +817,7 @@ void test_nss_getpwuid_neg(void **state)
ret = test_ev_loop(nss_test_ctx->tctx);
assert_int_equal(ret, ENOENT);
/* Negative cache was hit this time */
- assert_true(nss_test_ctx->ncache_hit == true);
+ assert_int_equal(nss_test_ctx->ncache_hits, 1);
}
static int test_nss_getpwuid_search_acct_cb(void *pvt)