From b4b3d0642120ca05f63959fe2f317a6b93031929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Wed, 16 Aug 2017 10:51:47 +0200 Subject: [PATCH 70/93] TEST_NEGCACHE: Ensure root's uid and gid are always added to ncache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order to do so two new functions have been introduced and test_sss_ncache_prepopulate() has been modified in order to ensure that root's uid and gid are always added to the negative cache. Related: https://pagure.io/SSSD/sssd/issue/3460 Signed-off-by: Fabiano FidĂȘncio Reviewed-by: Jakub Hrozek --- src/tests/cmocka/test_negcache.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/tests/cmocka/test_negcache.c b/src/tests/cmocka/test_negcache.c index 163e4653e0aa423eb5ccc4206734dec3a40050e6..ba39f778d5ddc6a4e1708aef66fc2aa1c809f150 100644 --- a/src/tests/cmocka/test_negcache.c +++ b/src/tests/cmocka/test_negcache.c @@ -564,6 +564,24 @@ static int check_group_in_ncache(struct sss_nc_ctx *ctx, return ret; } +static int check_uid_in_ncache(struct sss_nc_ctx *ctx, + uid_t uid) +{ + int ret; + + ret = sss_ncache_check_uid(ctx, NULL, uid); + return ret; +} + +static int check_gid_in_ncache(struct sss_nc_ctx *ctx, + gid_t gid) +{ + int ret; + + ret = sss_ncache_check_gid(ctx, NULL, gid); + return ret; +} + static void test_sss_ncache_prepopulate(void **state) { int ret; @@ -636,6 +654,12 @@ static void test_sss_ncache_prepopulate(void **state) ret = check_group_in_ncache(ncache, dom, "root"); assert_int_equal(ret, EEXIST); + + ret = check_uid_in_ncache(ncache, 0); + assert_int_equal(ret, EEXIST); + + ret = check_gid_in_ncache(ncache, 0); + assert_int_equal(ret, EEXIST); } static void test_sss_ncache_default_domain_suffix(void **state) -- 2.14.1