test_utils.c revision 462db32918a05097652f8232cd6c8d78a826e63c
/*
Authors:
Sumit Bose <sbose@redhat.com>
Copyright (C) 2013 Red Hat
SSSD tests: Tests for utility functions
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 <popt.h>
#include "tests/cmocka/common_mock.h"
#include "test_utils.h"
#define TESTS_PATH "tests_utils"
#define TEST_CONF_DB "test_utils_conf.ldb"
#define TEST_SYSDB_FILE "cache_utils_test.ldb"
#define DOM_COUNT 10
#define DOMNAME_TMPL "name_%zu.dom"
#define FLATNAME_TMPL "name_%zu"
#define SID_TMPL "S-1-5-21-1-2-%zu"
#define USERNAME "sssduser"
#define UID 1234
#define DOMAIN "sssddomain"
#define ORIGINAL_HOME "/home/user"
#define FLATNAME "flatname"
#define HOMEDIR_SUBSTR "/mnt/home"
#define DUMMY "dummy"
#define DUMMY2 "dummy2"
struct dom_list_test_ctx {
struct sss_domain_info *dom_list;
};
void setup_dom_list(void **state)
{
struct dom_list_test_ctx *test_ctx;
size_t c;
}
}
void teardown_dom_list(void **state)
{
struct dom_list_test_ctx);
return;
}
}
void test_find_domain_by_name_null(void **state)
{
struct dom_list_test_ctx);
struct sss_domain_info *dom;
}
void test_find_domain_by_name(void **state)
{
struct dom_list_test_ctx);
struct sss_domain_info *dom;
size_t c;
char *name;
char *flat_name;
char *sid;
}
}
void test_find_domain_by_name_missing_flat_name(void **state)
{
struct dom_list_test_ctx);
struct sss_domain_info *dom;
size_t c;
char *name;
char *flat_name;
char *sid;
for (c = 0; c < mis; c++) {
}
if (c == mis - 1) {
} else {
}
if (c == mis - 1) {
} else {
}
if (c == mis - 1) {
} else {
}
}
}
void test_find_domain_by_name_disabled(void **state)
{
struct dom_list_test_ctx);
struct sss_domain_info *dom;
size_t c;
char *name;
char *flat_name;
char *sid;
for (c = 0; c < mis; c++) {
}
if (c == mis - 1) {
} else {
}
if (c == mis - 1) {
} else {
}
if (c == mis - 1) {
} else {
}
}
}
void test_find_domain_by_sid_null(void **state)
{
struct dom_list_test_ctx);
struct sss_domain_info *dom;
}
void test_find_domain_by_sid(void **state)
{
struct dom_list_test_ctx);
struct sss_domain_info *dom;
size_t c;
char *name;
char *flat_name;
char *sid;
}
}
void test_find_domain_by_sid_missing_sid(void **state)
{
struct dom_list_test_ctx);
struct sss_domain_info *dom;
size_t c;
char *name;
char *flat_name;
char *sid;
for (c = 0; c < mis; c++) {
}
if (c == mis - 1) {
} else {
}
}
}
void test_find_domain_by_sid_disabled(void **state)
{
struct dom_list_test_ctx);
struct sss_domain_info *dom;
size_t c;
char *name;
char *flat_name;
char *sid;
for (c = 0; c < mis; c++) {
}
if (c == mis - 1) {
} else {
}
}
}
struct name_init_test_ctx {
struct confdb_ctx *confdb;
};
#define GLOBAL_FULL_NAME_FORMAT "%1$s@%2$s"
#define GLOBAL_RE_EXPRESSION "(?P<name>[^@]+)@?(?P<domain>[^@]*$)"
#define TEST_DOMAIN_NAME "test.dom"
#define DOMAIN_FULL_NAME_FORMAT "%3$s\\%1$s"
#define DOMAIN_RE_EXPRESSION "(((?P<domain>[^\\\\]+)\\\\(?P<name>.+$))|" \
"((?P<name>[^@]+)@(?P<domain>.+$))|" \
"(^(?P<name>[^@\\\\]+)$))"
void confdb_test_setup(void **state)
{
struct name_init_test_ctx *test_ctx;
int ret;
const char *val[2];
val[0] = TEST_DOMAIN_NAME;
val[0] = GLOBAL_FULL_NAME_FORMAT;
val[0] = GLOBAL_RE_EXPRESSION;
val[0] = "ldap";
val[0] = DOMAIN_FULL_NAME_FORMAT;
val[0] = DOMAIN_RE_EXPRESSION;
}
void confdb_test_teardown(void **state)
{
struct name_init_test_ctx *test_ctx;
}
void test_sss_names_init(void **state)
{
struct name_init_test_ctx *test_ctx;
struct sss_names_ctx *names_ctx;
int ret;
&names_ctx);
}
void test_well_known_sid_to_name(void **state)
{
int ret;
const char *name;
const char *dom;
}
void test_name_to_well_known_sid(void **state)
{
int ret;
const char *sid;
}
#define TEST_SANITIZE_INPUT "TestUser@Test.Domain"
#define TEST_SANITIZE_LC_INPUT "testuser@test.domain"
void test_sss_filter_sanitize_for_dom(void **state)
{
struct dom_list_test_ctx *test_ctx;
int ret;
char *sanitized;
char *lc_sanitized;
struct sss_domain_info *dom;
dom->case_sensitive = true;
&sanitized, &lc_sanitized);
dom->case_sensitive = false;
&sanitized, &lc_sanitized);
}
struct sss_nss_homedir_ctx *homedir_ctx,
{
char *homedir;
} else {
}
}
void setup_homedir_ctx(void **state)
{
struct sss_nss_homedir_ctx *homedir_ctx;
struct sss_nss_homedir_ctx);
*state = homedir_ctx;
}
void teardown_homedir_ctx(void **state)
{
struct sss_nss_homedir_ctx);
if (homedir_ctx == NULL) {
return;
}
}
void test_expand_homedir_template_NULL(void **state)
{
char *homedir;
struct sss_nss_homedir_ctx *homedir_ctx;
/* following format strings requires data in homedir_ctx */
NULL };
int i;
/* missing data in homedir_ctx */
for (i = 0; format_strings[i] != NULL; ++i) {
}
/* flatname requires domain and username */
/* test unknown format string */
/* test malformed format string */
}
void test_expand_homedir_template(void **state)
{
struct sss_nss_homedir_ctx);
/* string without template */
/* test all format strings */
}
{
int opt;
int rv;
struct poptOption long_options[] = {
};
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
switch(opt) {
default:
return 1;
}
}
/* Even though normally the tests should clean up after themselves
* they might not after a failed run. Remove the old db to be sure */
if (rv == 0) {
}
return rv;
}