d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech/*
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech Authors:
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech Petr Čech <pcech@redhat.com>
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech Copyright (C) 2016 Red Hat
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech This program is free software; you can redistribute it and/or modify
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech it under the terms of the GNU General Public License as published by
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech the Free Software Foundation; either version 3 of the License, or
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech (at your option) any later version.
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech This program is distributed in the hope that it will be useful,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech but WITHOUT ANY WARRANTY; without even the implied warranty of
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech GNU General Public License for more details.
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech You should have received a copy of the GNU General Public License
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech along with this program. If not, see <http://www.gnu.org/licenses/>.
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech*/
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech#include <stdarg.h>
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech#include <stddef.h>
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech#include <setjmp.h>
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech#include <cmocka.h>
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech#include <popt.h>
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech#include "tests/common.h"
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech#include "responder/common/negcache.h"
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech#include "responder/common/negcache_files.h"
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech#include "responder/common/responder.h"
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech#define TIMEOUT 10000
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech#define TESTS_PATH "tp_" BASE_FILE_STEM
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek#define TEST_CONF_DB "test_negcache_confdb.ldb"
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech#define TEST_DOM_NAME "test_domain.test"
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech#define TEST_LOCAL_USER_NAME_1 "foobar"
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech#define TEST_LOCAL_USER_NAME_2 "sssd"
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech#define TEST_LOCAL_USER_UID_1 10001
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech#define TEST_LOCAL_USER_UID_2 123
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech#define TEST_LOCAL_GROUP_NAME_1 "foogroup"
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech#define TEST_LOCAL_GROUP_NAME_2 "sssd"
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech#define TEST_LOCAL_GID_1 10001
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech#define TEST_LOCAL_GID_2 123
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechstruct test_user {
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech const char *name;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech uid_t uid;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech gid_t gid;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech} users[] = { { "test_user1", 1001, 50001 },
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech { "test_user2", 1002, 50002 } };
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozekstatic void create_users(TALLOC_CTX *mem_ctx,
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek struct sss_domain_info *domain)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech errno_t ret;
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek char *fqname;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech for (int i = 0; i < 2; i++) {
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek fqname = sss_create_internal_fqname(mem_ctx,
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek users[i].name,
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek domain->name);
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek assert_non_null(fqname);
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sysdb_add_user(domain, users[i].name, users[i].uid, users[i].gid,
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek fqname, NULL, "/bin/bash", domain->name,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech NULL, 30, time(NULL));
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek talloc_free(fqname);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech }
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechstruct test_group {
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech const char *name;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech gid_t gid;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech} groups[] = { { "test_group1", 50001 },
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech { "test_group2", 50002 } };
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechstruct ncache_test_ctx {
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct sss_test_ctx *tctx;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct sss_nc_ctx *ncache;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech};
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozekstatic void create_groups(TALLOC_CTX *mem_ctx,
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek struct sss_domain_info *domain)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech errno_t ret;
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek char *fqname;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech for (int i = 0; i < 2; i++) {
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek fqname = sss_create_internal_fqname(mem_ctx,
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek groups[i].name,
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek domain->name);
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek assert_non_null(fqname);
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek ret = sysdb_add_group(domain, fqname, groups[i].gid,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech NULL, 30, time(NULL));
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek talloc_free(fqname);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech }
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech/* register_cli_protocol_version is required in test since it links with
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech * responder_common.c module
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech */
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechstruct cli_protocol_version *register_cli_protocol_version(void)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech static struct cli_protocol_version responder_test_cli_protocol_version[] = {
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech { 0, NULL, NULL }
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech };
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech return responder_test_cli_protocol_version;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechstatic int test_ncache_setup(void **state)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct ncache_test_ctx *test_ctx;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_true(leak_check_setup());
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ctx = talloc_zero(global_talloc_context, struct ncache_test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_non_null(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_dom_suite_setup(TESTS_PATH);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ctx->tctx = create_dom_test_ctx(test_ctx, TESTS_PATH, TEST_CONF_DB,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech TEST_DOM_NAME, "ipa", NULL);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_non_null(test_ctx->tctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek create_groups(test_ctx, test_ctx->tctx->dom);
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek create_users(test_ctx, test_ctx->tctx->dom);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech check_leaks_push(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech *state = (void *)test_ctx;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech return 0;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechstatic int test_ncache_teardown(void **state)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct ncache_test_ctx *test_ctx;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_true(check_leaks_pop(test_ctx));
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech talloc_zfree(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_true(leak_check_teardown());
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech return 0;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozekstatic int set_user_in_ncache(struct sss_nc_ctx *ctx, bool permanent,
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek struct sss_domain_info *dom, const char *name)
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek{
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek char *fqdn;
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek int ret;
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek fqdn = sss_create_internal_fqname(ctx, name, dom->name);
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek ret = sss_ncache_set_user(ctx, permanent, dom, fqdn);
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek talloc_free(fqdn);
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek return ret;
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek}
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozekstatic int set_group_in_ncache(struct sss_nc_ctx *ctx, bool permanent,
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek struct sss_domain_info *dom, const char *name)
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek{
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek char *fqdn;
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek int ret;
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek fqdn = sss_create_internal_fqname(ctx, name, dom->name);
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek ret = sss_ncache_set_group(ctx, permanent, dom, fqdn);
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek talloc_free(fqdn);
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek return ret;
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek}
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozekstatic int check_user_in_ncache(struct sss_nc_ctx *ctx,
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek struct sss_domain_info *dom,
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek const char *name)
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek{
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek char *fqdn;
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek int ret;
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek fqdn = sss_create_internal_fqname(ctx, name, dom->name);
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek ret = sss_ncache_check_user(ctx, dom, fqdn);
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek talloc_free(fqdn);
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek return ret;
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek}
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozekstatic int check_group_in_ncache(struct sss_nc_ctx *ctx,
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek struct sss_domain_info *dom,
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek const char *name)
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek{
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek char *fqdn;
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek int ret;
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek fqdn = sss_create_internal_fqname(ctx, name, dom->name);
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek ret = sss_ncache_check_group(ctx, dom, fqdn);
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek talloc_free(fqdn);
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek return ret;
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek}
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech/* user utils */
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechstatic void set_users(struct ncache_test_ctx *test_ctx)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech int ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek ret = set_user_in_ncache(test_ctx->ncache, false, test_ctx->tctx->dom,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech users[0].name);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek ret = set_user_in_ncache(test_ctx->ncache, false, test_ctx->tctx->dom,
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek TEST_LOCAL_USER_NAME_1);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechstatic void check_users(struct ncache_test_ctx *test_ctx,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech int case_a, int case_b, int case_c, int case_d)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech int ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek ret = check_user_in_ncache(test_ctx->ncache, test_ctx->tctx->dom,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech users[0].name);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, case_a);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek ret = check_user_in_ncache(test_ctx->ncache, test_ctx->tctx->dom,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech users[1].name);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, case_b);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek ret = check_user_in_ncache(test_ctx->ncache, test_ctx->tctx->dom,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech TEST_LOCAL_USER_NAME_1);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, case_c);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek ret = check_user_in_ncache(test_ctx->ncache, test_ctx->tctx->dom,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech TEST_LOCAL_USER_NAME_2);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, case_d);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech/* user tests */
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechvoid test_ncache_nocache_user(void **state)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech errno_t ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct ncache_test_ctx *test_ctx;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_non_null(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_init(test_ctx, 0, 0, &test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech set_users(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech check_users(test_ctx, ENOENT, ENOENT, ENOENT, ENOENT);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech talloc_zfree(test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechvoid test_ncache_local_user(void **state)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech errno_t ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct ncache_test_ctx *test_ctx;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_non_null(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_init(test_ctx, 0, TIMEOUT, &test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech set_users(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech check_users(test_ctx, ENOENT, ENOENT, EEXIST, ENOENT);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech talloc_zfree(test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechvoid test_ncache_domain_user(void **state)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech errno_t ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct ncache_test_ctx *test_ctx;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_non_null(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_init(test_ctx, TIMEOUT, 0, &test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech set_users(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech check_users(test_ctx, EEXIST, ENOENT, EEXIST, ENOENT);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech talloc_zfree(test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechvoid test_ncache_both_user(void **state)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech errno_t ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct ncache_test_ctx *test_ctx;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_non_null(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_init(test_ctx, TIMEOUT, TIMEOUT, &test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech set_users(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech check_users(test_ctx, EEXIST, ENOENT, EEXIST, ENOENT);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech talloc_zfree(test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech/* uid utils */
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechstatic void set_uids(struct ncache_test_ctx *test_ctx)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech int ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_set_uid(test_ctx->ncache, false, test_ctx->tctx->dom,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech users[0].uid);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_set_uid(test_ctx->ncache, false, test_ctx->tctx->dom,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech TEST_LOCAL_USER_UID_1);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechstatic void check_uids(struct ncache_test_ctx *test_ctx,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech int case_a, int case_b, int case_c, int case_d)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech int ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_check_uid(test_ctx->ncache, test_ctx->tctx->dom,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech users[0].uid);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, case_a);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_check_uid(test_ctx->ncache, test_ctx->tctx->dom,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech users[1].uid);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, case_b);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_check_uid(test_ctx->ncache, test_ctx->tctx->dom,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech TEST_LOCAL_USER_UID_1);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, case_c);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_check_uid(test_ctx->ncache, test_ctx->tctx->dom,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech TEST_LOCAL_USER_UID_2);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, case_d);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech/* uid tests */
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechvoid test_ncache_nocache_uid(void **state)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech errno_t ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct ncache_test_ctx *test_ctx;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_non_null(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_init(test_ctx, 0, 0, &test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech set_uids(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech check_uids(test_ctx, ENOENT, ENOENT, ENOENT, ENOENT);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech talloc_zfree(test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechvoid test_ncache_local_uid(void **state)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech errno_t ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct ncache_test_ctx *test_ctx;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_non_null(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_init(test_ctx, 0, TIMEOUT, &test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech set_uids(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech check_uids(test_ctx, ENOENT, ENOENT, EEXIST, ENOENT);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech talloc_zfree(test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechvoid test_ncache_domain_uid(void **state)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech errno_t ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct ncache_test_ctx *test_ctx;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_non_null(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_init(test_ctx, TIMEOUT, 0, &test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech set_uids(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech check_uids(test_ctx, EEXIST, ENOENT, EEXIST, ENOENT);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech talloc_zfree(test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechvoid test_ncache_both_uid(void **state)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech errno_t ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct ncache_test_ctx *test_ctx;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_non_null(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_init(test_ctx, TIMEOUT, TIMEOUT, &test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech set_uids(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech check_uids(test_ctx, EEXIST, ENOENT, EEXIST, ENOENT);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech talloc_zfree(test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech/* group utils */
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechstatic void set_groups(struct ncache_test_ctx *test_ctx)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech int ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek ret = set_group_in_ncache(test_ctx->ncache, false, test_ctx->tctx->dom,
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek groups[0].name);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek ret = set_group_in_ncache(test_ctx->ncache, false, test_ctx->tctx->dom,
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek TEST_LOCAL_GROUP_NAME_1);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechstatic void check_groups(struct ncache_test_ctx *test_ctx,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech int case_a, int case_b, int case_c, int case_d)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech int ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek ret = check_group_in_ncache(test_ctx->ncache, test_ctx->tctx->dom,
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek groups[0].name);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, case_a);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek ret = check_group_in_ncache(test_ctx->ncache, test_ctx->tctx->dom,
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek groups[1].name);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, case_b);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek ret = check_group_in_ncache(test_ctx->ncache, test_ctx->tctx->dom,
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek TEST_LOCAL_GROUP_NAME_1);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, case_c);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek ret = check_group_in_ncache(test_ctx->ncache, test_ctx->tctx->dom,
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek TEST_LOCAL_GROUP_NAME_2);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, case_d);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech/* group tests */
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechvoid test_ncache_nocache_group(void **state)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech errno_t ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct ncache_test_ctx *test_ctx;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_non_null(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_init(test_ctx, 0, 0, &test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech set_groups(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech check_groups(test_ctx, ENOENT, ENOENT, ENOENT, ENOENT);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech talloc_zfree(test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechvoid test_ncache_local_group(void **state)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech errno_t ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct ncache_test_ctx *test_ctx;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_non_null(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_init(test_ctx, 0, TIMEOUT, &test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech set_groups(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech check_groups(test_ctx, ENOENT, ENOENT, EEXIST, ENOENT);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech talloc_zfree(test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechvoid test_ncache_domain_group(void **state)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech errno_t ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct ncache_test_ctx *test_ctx;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_non_null(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_init(test_ctx, TIMEOUT, 0, &test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech set_groups(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech check_groups(test_ctx, EEXIST, ENOENT, EEXIST, ENOENT);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech talloc_zfree(test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechvoid test_ncache_both_group(void **state)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech errno_t ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct ncache_test_ctx *test_ctx;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_non_null(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_init(test_ctx, TIMEOUT, TIMEOUT, &test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech set_groups(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech check_groups(test_ctx, EEXIST, ENOENT, EEXIST, ENOENT);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech talloc_zfree(test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech/* gid utils */
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechstatic void set_gids(struct ncache_test_ctx *test_ctx)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech int ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_set_gid(test_ctx->ncache, false, test_ctx->tctx->dom,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech users[0].gid);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_set_gid(test_ctx->ncache, false, test_ctx->tctx->dom,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech TEST_LOCAL_GID_1);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechstatic void check_gids(struct ncache_test_ctx *test_ctx,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech int case_a, int case_b, int case_c, int case_d)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech int ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_check_gid(test_ctx->ncache, test_ctx->tctx->dom,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech users[0].gid);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, case_a);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_check_gid(test_ctx->ncache, test_ctx->tctx->dom,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech users[1].gid);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, case_b);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_check_gid(test_ctx->ncache, test_ctx->tctx->dom,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech TEST_LOCAL_GID_1);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, case_c);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_check_gid(test_ctx->ncache, test_ctx->tctx->dom,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech TEST_LOCAL_GID_2);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, case_d);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech/* uid tests */
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechvoid test_ncache_nocache_gid(void **state)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech errno_t ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct ncache_test_ctx *test_ctx;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_non_null(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_init(test_ctx, 0, 0, &test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech set_gids(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech check_gids(test_ctx, ENOENT, ENOENT, ENOENT, ENOENT);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech talloc_zfree(test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechvoid test_ncache_local_gid(void **state)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech errno_t ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct ncache_test_ctx *test_ctx;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_non_null(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_init(test_ctx, 0, TIMEOUT, &test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech set_gids(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech check_gids(test_ctx, ENOENT, ENOENT, EEXIST, ENOENT);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech talloc_zfree(test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechvoid test_ncache_domain_gid(void **state)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech errno_t ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct ncache_test_ctx *test_ctx;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_non_null(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_init(test_ctx, TIMEOUT, 0, &test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech set_gids(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech check_gids(test_ctx, EEXIST, ENOENT, EEXIST, ENOENT);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech talloc_zfree(test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechvoid test_ncache_both_gid(void **state)
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech errno_t ret;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct ncache_test_ctx *test_ctx;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_non_null(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech ret = sss_ncache_init(test_ctx, TIMEOUT, TIMEOUT, &test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech assert_int_equal(ret, EOK);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech set_gids(test_ctx);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech check_gids(test_ctx, EEXIST, ENOENT, EEXIST, ENOENT);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech talloc_zfree(test_ctx->ncache);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech}
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cechint main(int argc, const char *argv[])
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech{
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech int rv;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech poptContext pc;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech int opt;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech struct poptOption long_options[] = {
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech POPT_AUTOHELP
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech SSSD_DEBUG_OPTS
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech POPT_TABLEEND
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech };
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech const struct CMUnitTest tests[] = {
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech /* user */
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech cmocka_unit_test_setup_teardown(test_ncache_nocache_user,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_setup,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_teardown),
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech cmocka_unit_test_setup_teardown(test_ncache_local_user,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_setup,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_teardown),
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech cmocka_unit_test_setup_teardown(test_ncache_domain_user,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_setup,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_teardown),
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech cmocka_unit_test_setup_teardown(test_ncache_both_user,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_setup,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_teardown),
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech /* uid */
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech cmocka_unit_test_setup_teardown(test_ncache_nocache_uid,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_setup,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_teardown),
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech cmocka_unit_test_setup_teardown(test_ncache_local_uid,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_setup,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_teardown),
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech cmocka_unit_test_setup_teardown(test_ncache_domain_uid,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_setup,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_teardown),
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech cmocka_unit_test_setup_teardown(test_ncache_both_uid,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_setup,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_teardown),
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech /* group */
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech cmocka_unit_test_setup_teardown(test_ncache_nocache_group,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_setup,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_teardown),
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech cmocka_unit_test_setup_teardown(test_ncache_local_group,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_setup,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_teardown),
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech cmocka_unit_test_setup_teardown(test_ncache_domain_group,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_setup,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_teardown),
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech cmocka_unit_test_setup_teardown(test_ncache_both_group,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_setup,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_teardown),
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech /* gid */
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech cmocka_unit_test_setup_teardown(test_ncache_nocache_gid,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_setup,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_teardown),
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech cmocka_unit_test_setup_teardown(test_ncache_local_gid,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_setup,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_teardown),
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech cmocka_unit_test_setup_teardown(test_ncache_domain_gid,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_setup,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_teardown),
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech cmocka_unit_test_setup_teardown(test_ncache_both_gid,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_setup,
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_ncache_teardown),
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech };
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
49dd8ee2834d9477418961dbaffa4a03cfa9fd1eRené Genz /* Set debug level to invalid value so we can decide if -d 0 was used. */
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech debug_level = SSSDBG_INVALID;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech pc = poptGetContext(argv[0], argc, argv, long_options, 0);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech while ((opt = poptGetNextOpt(pc)) != -1) {
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech switch (opt) {
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech default:
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech fprintf(stderr, "\nInvalid option %s: %s\n\n",
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech poptBadOption(pc, 0), poptStrerror(opt));
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech poptPrintUsage(pc, stderr, 0);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech return 1;
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech }
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech }
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech poptFreeContext(pc);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech DEBUG_CLI_INIT(debug_level);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech tests_set_cwd();
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech rv = cmocka_run_group_tests(tests, NULL, NULL);
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech
d9e88bddc99bae0542b2179c9b94c968855b0fd0Petr Cech return rv;
27bf39ed3e197497cf4aca58038d788ea5b5ddbcJakub Hrozek}