test_sysdb_sudo.c revision 23637e2fd2b1fe42bdd2335893a11ac8016f56bc
/*
Authors:
Petr Čech <pcech@redhat.com>
Copyright (C) 2016 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 <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <popt.h>
#include <ldb_module.h>
#include "tests/cmocka/common_mock.h"
#include "src/db/sysdb_sudo.h"
#include "src/db/sysdb_private.h"
#define TEST_CONF_DB "test_sysdb_sudorules.ldb"
#define TEST_DOM_NAME "test_domain.test"
#define TEST_CACHE_SUDO_TIMEOUT "20"
#define TEST_USER_NON_EXIST "no_user"
#define TEST_GROUP_NAME "test_sudo_group"
#define TEST_GID 10001
struct test_user {
const char *name;
{ "test_user2", 1002, 1002 },
{ "test_user3", 1003, 1003 } };
struct test_rule {
const char *name;
const char *host;
const char *as_user;
struct sysdb_test_ctx {
struct sss_test_ctx *tctx;
};
{
}
{
int gid;
for (int i = 0; i < 3; i++) {
}
}
{
}
{
for (int i = 0; i < 3; i++ ) {
}
}
{
"(objectClass=sudoRule)",
msgs_count = -1;
}
return msgs_count;
}
static int test_sysdb_setup(void **state)
{
struct sysdb_test_ctx *test_ctx;
return 0;
}
static int test_sysdb_teardown(void **state)
{
struct sysdb_test_ctx *test_ctx;
return 0;
}
void test_store_sudo(void **state)
{
char *filter;
const char *result;
struct sysdb_attrs *rule;
struct sysdb_test_ctx);
create_rule_attrs(rule, 0);
NULL);
NULL);
NULL);
}
void test_store_sudo_case_sensitive(void **state)
{
char *filter;
const char *result;
struct ldb_message_element *element;
struct sysdb_attrs *rule;
struct sysdb_test_ctx);
NULL);
NULL);
assert_int_equal(ret, 0);
}
void test_store_sudo_case_insensitive(void **state)
{
char *filter;
const char *result;
struct ldb_message_element *element;
struct sysdb_attrs *rule;
struct sysdb_test_ctx);
NULL);
NULL);
for (int i = 0; i < 3; i++) {
}
/* test there is no duplication of lowercase forms */
}
void test_sudo_purge_by_filter(void **state)
{
struct sysdb_attrs *rule;
char *delete_filter;
struct sysdb_test_ctx);
create_rule_attrs(rule, 0);
}
void test_sudo_purge_by_rules(void **state)
{
struct sysdb_attrs *rule;
struct sysdb_test_ctx);
create_rule_attrs(rule, 0);
}
void test_sudo_set_get_last_full_refresh(void **state)
{
struct sysdb_test_ctx);
}
void test_get_sudo_user_info(void **state)
{
char **groupnames = NULL;
struct sysdb_test_ctx);
/* User 1 has group. */
}
void test_get_sudo_user_info_nogroup(void **state)
{
char **groupnames = NULL;
struct sysdb_test_ctx);
/* User 0 hasn't group. */
}
void test_get_sudo_nouser(void **state)
{
char **groupnames = NULL;
struct sysdb_test_ctx);
TEST_USER_NON_EXIST, 0, &groupnames);
}
void test_set_sudo_rule_attr_add(void **state)
{
struct sysdb_attrs *rule;
struct sysdb_attrs *new_rule;
NULL };
char *filter;
const char *result;
struct sysdb_test_ctx);
create_rule_attrs(rule, 0);
"test_command");
NULL);
}
void test_set_sudo_rule_attr_replace(void **state)
{
struct sysdb_attrs *rule;
struct sysdb_attrs *new_rule;
char *filter;
const char *result;
struct sysdb_test_ctx);
create_rule_attrs(rule, 0);
}
void test_set_sudo_rule_attr_delete(void **state)
{
struct sysdb_attrs *rule;
struct sysdb_attrs *new_rule;
NULL };
char *filter;
const char *result;
struct sysdb_test_ctx);
create_rule_attrs(rule, 0);
"deleted");
}
void test_search_sudo_rules(void **state)
{
const char *filter;
const char *rule_names[num_rules];
const char *db_results[num_rules];
struct sysdb_test_ctx);
assert_non_null(tmp_rules[0]);
create_rule_attrs(tmp_rules[0], 0);
for (int i = 0; i < num_rules; ++i) {
}
db_results, num_rules));
talloc_zfree(tmp_rules[0]);
}
void test_filter_rules_by_time(void **state)
{
struct sysdb_attrs *tmp_attr;
struct sysdb_attrs **_rules;
struct sysdb_attrs **loaded_rules;
char buff[20];
struct sysdb_test_ctx);
assert_non_null(tmp_rules[0]);
create_rule_attrs(tmp_rules[0], 0);
/*
* We hit DST issue of time functions,
* so we use big time shift to avoid this.
*/
"(objectClass=sudoRule)",
&_num_rules, &_rules);
talloc_zfree(tmp_rules[0]);
}
{
int rv;
int opt;
struct poptOption long_options[] = {
};
const struct CMUnitTest tests[] = {
/* sysdb_sudo_store() */
/* sysdb_sudo_purge() */
/*
* sysdb_sudo_set_last_full_refresh()
* sysdb_sudo_get_last_full_refresh()
*/
/* sysdb_get_sudo_user_info() */
/* sysdb_set_sudo_rule_attr() */
/* sysdb_search_sudo_rules() */
/* sysdb_sudo_filter_rules_by_time() */
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
switch (opt) {
default:
return 1;
}
}
return rv;
}