/*
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"
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 {
};
{
}
{
int gid;
for (int i = 0; i < 3; i++) {
}
}
{
}
{
for (int i = 0; i < 3; i++ ) {
}
}
{
"(objectClass=sudoRule)",
msgs_count = -1;
}
return msgs_count;
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
{
char *filter;
const char *result;
struct sysdb_test_ctx);
create_rule_attrs(rule, 0);
NULL);
NULL);
NULL);
}
{
char *filter;
const char *result;
struct sysdb_test_ctx);
NULL);
NULL);
assert_int_equal(ret, 0);
}
{
char *filter;
const char *result;
struct sysdb_test_ctx);
NULL);
NULL);
for (int i = 0; i < 3; i++) {
}
/* test there is no duplication of lowercase forms */
}
{
char *delete_filter;
struct sysdb_test_ctx);
create_rule_attrs(rule, 0);
}
{
struct sysdb_test_ctx);
create_rule_attrs(rule, 0);
}
{
struct sysdb_test_ctx);
}
{
const char *orig_username;
struct sysdb_test_ctx);
/* User 1 has group. */
}
{
const char *orig_username;
struct sysdb_test_ctx);
char *strdn;
char *safe_dn;
char *anchor;
char *group_fqname;
char *user_fqname;
/* Override user's name and primary UID */
/* Override user's secondary group name */
/* User must be searchable by their overriden name */
/* sysdb_get_sudo_user_info must return the original values, not the
* overriden one */
}
{
const char *orig_username;
struct sysdb_test_ctx);
/* User 0 hasn't group. */
}
{
struct sysdb_test_ctx);
}
{
NULL };
char *filter;
const char *result;
struct sysdb_test_ctx);
create_rule_attrs(rule, 0);
"test_command");
NULL);
}
{
char *filter;
const char *result;
struct sysdb_test_ctx);
create_rule_attrs(rule, 0);
}
{
NULL };
char *filter;
const char *result;
struct sysdb_test_ctx);
create_rule_attrs(rule, 0);
"deleted");
}
{
const char *filter;
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]);
}
{
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;
};
/* sysdb_sudo_store() */
/* sysdb_sudo_purge() */
/*
* sysdb_sudo_set_last_full_refresh()
* sysdb_sudo_get_last_full_refresh()
*/
/* sysdb_get_sudo_user_info() */
* the view allocates some data on the confdb and domain pointers,
* which would confuse the leak check
*/
/* sysdb_set_sudo_rule_attr() */
/* sysdb_search_sudo_rules() */
/* sysdb_sudo_filter_rules_by_time() */
};
/* Set debug level to invalid value so we can decide if -d 0 was used. */
switch (opt) {
default:
return 1;
}
}
return rv;
}