test_negcache.c revision c02b8482375837b57cb618ed56d4bede0e006d9d
/*
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 CERT "MIIECTCCAvGgAwIBAgIBCTANBgkqhkiG9w0BAQsFADA0MRIwEAYDVQQKDAlJUEEuREVWRUwxHjAcBgNVBAMMFUNlcnRpZmljYXRlIEF1dGhvcml0eTAeFw0xNTA0MjgxMDIxMTFaFw0xNzA0MjgxMDIxMTFaMDIxEjAQBgNVBAoMCUlQQS5ERVZFTDEcMBoGA1UEAwwTaXBhLWRldmVsLmlwYS5kZXZlbDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALIykqtHuAwTVEofHikG/9BQy/dfeZFlsTkBg2qtnnc78w3XufbcnkpJp9Bmcsy/d9beqf5nlsxJ8TcjLsRQ9Ou6YtQjTfM3OILuOz8s0ICbF6qb66bd9hX/BrLO/9+KnpWFSR+E/YEmzgYyDTbKfBWBaGuPPrOi/K6vwkRYFZVA/FYZkYDtQhFmBO884HYzS4P6frRH3PvtRqWNCmaHpe97dGKsvnM2ybT+IMSB8/54GajQr3+BciRh2XaT4wvSTxkXM1fUgrDxqAP2AZmpuIyDyboZh+rWOwbrTPfx5SipELZG3uHhP8HMcr4qQ8b20LWgxCRuT73sIooHET350xUCAwEAAaOCASYwggEiMB8GA1UdIwQYMBaAFPKdQk4PxEglWC8czg+hPyLIVciRMDsGCCsGAQUFBwEBBC8wLTArBggrBgEFBQcwAYYfaHR0cDovL2lwYS1jYS5pcGEuZGV2ZWwvY2Evb2NzcDAOBgNVHQ8BAf8EBAMCBPAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMHQGA1UdHwRtMGswaaAxoC+GLWh0dHA6Ly9pcGEtY2EuaXBhLmRldmVsL2lwYS9jcmwvTWFzdGVyQ1JMLmJpbqI0pDIwMDEOMAwGA1UECgwFaXBhY2ExHjAcBgNVBAMMFUNlcnRpZmljYXRlIEF1dGhvcml0eTAdBgNVHQ4EFgQULSs/y/Wy/zIsqMIc3b2MgB7dMYIwDQYJKoZIhvcNAQELBQADggEBAJpHLlCnTR1TD8lxQgzl2n1JZOeryN/fAsGH0Vve2m8r5PC+ugnfAoULiuabBn1pOGxy/0x7Kg0/Iy8WRv8Fk7DqJCjXEqFXuFkZJfNDCtP9DzeNuMoV50iKoMfHS38BPFjXN+X/fSsBrA2fUWrlQCTmXlUN97gvQqxt5Slrxgukvxm9OSfu/sWz22LUvtJHupYwWv1iALgnXS86lAuVNYVALLxn34r58XsZlj5CSBMjBJWpaxEzgUdag3L2IPqOQXuPd0d8x11G9E/9gQquOSe2aiZjsdO/VYOCmzZsM2QPUMBVlBPDhfTVcWXQwN385uycW/ARtSzzSME2jKKWSIQ="
#define PROTO "TCP"
#define SHORTSPAN 1
#define NAME "foo_name"
#define TEST_CONF_DB "test_nss_conf.ldb"
#define TEST_DOM_NAME "nss_test"
#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;
}
if (err != IDMAP_SUCCESS) {
return NULL;
}
return nctx;
}
struct test_state {
struct sss_nc_ctx *ctx;
};
{
int ret;
struct test_state *ts;
return 0;
}
{
return 0;
}
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)
{
int ret;
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_sss_ncache_gid : test following functions
* sss_ncache_set_gid
* sss_ncache_check_gid
*/
static void test_sss_ncache_gid(void **state)
{
int ret;
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_sss_ncache_sid : test following functions
* sss_ncache_set_sid
* sss_ncache_check_sid
*/
static void test_sss_ncache_sid(void **state)
{
int ret;
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_sss_ncache_cert : test following functions
* sss_ncache_set_cert
* sss_ncache_check_cert_
*/
static void test_sss_ncache_cert(void **state)
{
int ret;
bool permanent;
struct test_state *ts;
/*test when cert in not present in database */
/* test when cert is present in database */
permanent = true;
permanent = false;
}
/* @test_sss_ncache_user : test following functions
* sss_ncache_check_user
* sss_ncache_set_user
*/
static void test_sss_ncache_user(void **state)
{
int ret;
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_sss_ncache_group : test following functions
* sss_ncache_check_group
* sss_ncache_set_group
*/
static void test_sss_ncache_group(void **state)
{
int ret;
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_sss_ncache_netgr : test following functions
* sss_ncache_check_netgr
* sss_ncache_set_netgr
*/
static void test_sss_ncache_netgr(void **state)
{
int ret;
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_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)
{
int ret;
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_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)
{
int ret;
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);
}
static void test_sss_ncache_reset_permanent(void **state)
{
int ret;
struct test_state *ts;
const bool permanent = true;
}
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[] = {
};
}
static void test_sss_ncache_default_domain_suffix(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[] = {
};
}
static void test_sss_ncache_reset_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_domain_info *dom2;
struct sss_test_conf_param params[] = {
};
"filter_users", nss_filter_users);
"filter_groups", nss_filter_groups);
/* Add another domain */
/* First domain should not be known, the second not */
/* First domain should not be known, the second not */
}
int main(void)
{
int rv;
const struct CMUnitTest tests[] = {
teardown),
teardown),
};
if (rv == 0) {
}
return rv;
}