summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2015-03-09 17:26:54 +0100
committerJakub Hrozek <jhrozek@redhat.com>2015-05-22 13:56:58 +0200
commiteb6be4e9c1bafcf86822f9300d4c79f9299e015a (patch)
treebf4706e795453214dbac447d68d22a338a86aea7
parentbe4569c92c2de86a71232e3f4b94caa1b13281e4 (diff)
downloadsssd-eb6be4e9c1bafcf86822f9300d4c79f9299e015a.tar.gz
sssd-eb6be4e9c1bafcf86822f9300d4c79f9299e015a.tar.xz
sssd-eb6be4e9c1bafcf86822f9300d4c79f9299e015a.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> (cherry picked from commit 9cc2223e0bc0478c1b47a47fd71bba7e7129492d)
-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 2406adfe2..0c68be3ec 100644
--- a/src/tests/cmocka/test_nss_srv.c
+++ b/src/tests/cmocka/test_nss_srv.c
@@ -49,7 +49,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};
@@ -160,7 +160,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;
}
@@ -173,7 +173,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;
}
@@ -348,7 +348,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);
@@ -357,7 +357,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
@@ -374,7 +374,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)
@@ -792,7 +792,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);
@@ -801,7 +801,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
@@ -818,7 +818,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)