test_negcache.c revision a95c006f748fa9df0dd81509b51974133d2786af
/*
SSSD
NSS Responder
Authors:
Pallavi Jha <pallavikumarijha@gmail.com>
Copyright (C) 2013 Red Hat
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdarg.h>
#include <stdlib.h>
#include <stddef.h>
#include <setjmp.h>
#include <errno.h>
#include <unistd.h>
#include <inttypes.h>
#include <cmocka.h>
#include "tests/cmocka/common_mock.h"
#include "tests/cmocka/common_mock_resp.h"
#include "responder/nss/nsssrv_private.h"
#include "sss_client/idmap/sss_nss_idmap.h"
#include "util/util_sss_idmap.h"
#include "lib/idmap/sss_idmap.h"
#include "util/util_sss_idmap.h"
#include "responder/common/responder.h"
#include "responder/common/negcache.h"
#define PORT 21
#define SID "S-1-2-3-4-5"
#define PROTO "TCP"
#define LIFETIME 200
#define SHORTSPAN 1
#define NAME "foo_name"
#define UID "U-1-2-3-4-5"
#define TESTS_PATH "tests_ncache"
#define TEST_CONF_DB "test_nss_conf.ldb"
#define TEST_DOM_NAME "nss_test"
#define TEST_SUBDOM_NAME "test.sub"
#define TEST_ID_PROVIDER "ldap"
/* register_cli_protocol_version is required in test since it links with
* responder_common.c module
*/
struct cli_protocol_version *register_cli_protocol_version(void)
{
static struct cli_protocol_version responder_test_cli_protocol_version[] = {
};
}
/* Mock NSS structure */
static struct nss_ctx *
{
enum idmap_error_code err;
if (!nctx) {
return NULL;
}
return NULL;
}
if (err != IDMAP_SUCCESS) {
return NULL;
}
return nctx;
}
/* responder context is duplicated here because linking
* with common_mock_resp.c would get us duplicates
*/
struct resp_ctx *
struct tevent_context *ev,
struct sss_domain_info *domains,
void *pvt_ctx)
{
return NULL;
}
return rctx;
}
struct test_state {
struct sss_nc_ctx *ctx;
};
{
int ret;
struct test_state *ts;
}
{
}
static void test_sss_ncache_init(void **state)
{
int ret;
struct sss_nc_ctx *ctx;
}
/* @test_sss_ncache_uid : test following functions
* sss_ncache_set_uid
* sss_ncache_check_uid
*/
static void test_sss_ncache_uid(void **state)
{
bool permanent;
struct test_state *ts;
/* test when uid not present in database */
/* test when uid is present in database */
permanent = true;
permanent = false;
/* test when ttl is -1 with uid present in database*/
ttl = -1;
}
/* @test_sss_ncache_gid : test following functions
* sss_ncache_set_gid
* sss_ncache_check_gid
*/
static void test_sss_ncache_gid(void **state)
{
bool permanent;
struct test_state *ts;
/* test when gid is not present in database */
/* test when gid is present in database */
permanent = true;
permanent = false;
/* test when ttl is -1 with gid present in database*/
ttl = -1;
}
/* @test_sss_ncache_sid : test following functions
* sss_ncache_set_sid
* sss_ncache_check_sid
*/
static void test_sss_ncache_sid(void **state)
{
bool permanent;
struct test_state *ts;
/*test when sid in not present in database */
/* test when sid is present in database */
permanent = true;
permanent = false;
/* test when ttl is -1 with sid present in database*/
ttl = -1;
}
/* @test_sss_ncache_user : test following functions
* sss_ncache_check_user
* sss_ncache_set_user
*/
static void test_sss_ncache_user(void **state)
{
bool permanent;
struct test_state *ts;
struct sss_domain_info *dom;
/* test when domain name is not present in database */
dom->case_sensitive = false;
dom->case_sensitive = true;
/* test when domain name is present in database */
permanent = true;
permanent = false;
/* test when ttl is -1 with domain name present in database */
ttl = -1;
}
/* @test_sss_ncache_group : test following functions
* sss_ncache_check_group
* sss_ncache_set_group
*/
static void test_sss_ncache_group(void **state)
{
bool permanent;
struct test_state *ts;
struct sss_domain_info *dom;
/* test when domain name is not present in database */
dom->case_sensitive = false;
dom->case_sensitive = true;
/* test when domain name is present in database */
permanent = true;
permanent = false;
/* test when ttl is -1 with domain name present in database */
ttl = -1;
}
/* @test_sss_ncache_netgr : test following functions
* sss_ncache_check_netgr
* sss_ncache_set_netgr
*/
static void test_sss_ncache_netgr(void **state)
{
bool permanent;
struct test_state *ts;
struct sss_domain_info *dom;
/* test when domain name is not present in database */
dom->case_sensitive = false;
dom->case_sensitive = true;
/* test when domain name is present in database */
permanent = true;
permanent = false;
/* test when ttl is -1 with domain name present in database */
ttl = -1;
}
/* @test_sss_ncache_service_name : test following functions
* sss_ncache_check_service
* sss_ncache_set_service_name
*/
static void test_sss_ncache_service_name(void **state)
{
bool permanent;
struct test_state *ts;
struct sss_domain_info *dom;
/* test when domain name and protocol are not present in database */
dom->case_sensitive = false;
dom->case_sensitive = true;
/* test when domain name and protocol are present in database */
permanent = true;
permanent = false;
/* test when ttl is -1 with domain name present in database */
ttl = -1;
}
/* @test_sss_ncache_service_port : test following functions
* sss_ncache_check_service_port
* sss_ncache_set_service_port
*/
static void test_sss_ncache_service_port(void **state)
{
bool permanent;
struct test_state *ts;
struct sss_domain_info *dom;
/* test when domain name, port and protocol are not present in database */
dom->case_sensitive = false;
PROTO);
dom->case_sensitive = true;
PROTO);
/* test when domain name, port and protocol are present in database */
permanent = true;
PROTO);
PROTO);
permanent = false;
PROTO);
PROTO);
/* test when ttl is -1 with domain name present in database */
ttl = -1;
PROTO);
}
static void test_sss_ncache_reset_permanent(void **state)
{
int ret;
struct test_state *ts;
}
static void test_sss_ncache_prepopulate(void **state)
{
int ret;
struct test_state *ts;
struct tevent_context *ev;
struct sss_nc_ctx *ncache;
struct sss_test_ctx *tc;
struct sss_domain_info *dom;
struct sss_test_conf_param params[] = {
{ "filter_users", "testuser1" },
{ "filter_groups", "testgroup1" },
};
}
int main(void)
{
int rv;
teardown),
teardown),
teardown),
};
return rv;
}