test_sss_idmap.c revision c377d4d604f1e7b35c484711f1084b7a761772b6
/*
Authors:
Sumit Bose <sbose@redhat.com>
Copyright (C) 2013 Red Hat
SSSD tests: Unit tests for libsss_idmap
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 "lib/idmap/sss_idmap.h"
#define TEST_RANGE_MIN 200000
#define TEST_RANGE_MAX 399999
#define TEST_DOM_NAME "test.dom"
#define TEST_DOM_SID "S-1-5-21-123-456-789"
#define TEST_FIRST_RID 0
#define TEST_EXT_MAPPING true
#define TEST_2_RANGE_MIN 600000
#define TEST_2_RANGE_MAX 799999
#define TEST_2_DOM_NAME "test2.dom"
#define TEST_2_DOM_SID "S-1-5-21-987-654-321"
#define TEST_2_FIRST_RID 1000000
#define TEST_2_EXT_MAPPING true
#define TEST_OFFSET 1000000
#define TEST_OFFSET_STR "1000000"
const int TEST_2922_MIN_ID = 1842600000;
const int TEST_2922_MAX_ID = 1842799999;
struct test_ctx {
struct sss_idmap_ctx *idmap_ctx;
};
{
}
{
}
static int test_sss_idmap_setup(void **state)
{
enum idmap_error_code err;
return 0;
}
bool second_domain, bool sec_slices)
{
struct sss_idmap_range range;
enum idmap_error_code err;
const char *name;
const char *sid;
if (second_domain) {
} else {
sid = TEST_DOM_SID;
}
if (sec_slices) {
} else {
NULL, 0, external_mapping);
}
if (sec_slices) {
} else {
}
return 0;
}
{
const int TEST_2922_DFL_SLIDE = 9212;
struct sss_idmap_range range;
enum idmap_error_code err;
const char *name;
const char *sid;
/* Pick a new slice. */
sid = TEST_DOM_SID;
&range);
/* Range computation should be deterministic. Lets validate that. */
NULL, 0, false /* No external mapping */);
return 0;
}
static int test_sss_idmap_setup_with_domains(void **state)
{
setup_ranges(test_ctx, false, false, false);
return 0;
}
static int test_sss_idmap_setup_with_domains_2922(void **state)
{
return 0;
}
static int test_sss_idmap_setup_with_domains_sec_slices(void **state)
{
setup_ranges(test_ctx, false, false, true);
return 0;
}
static int test_sss_idmap_setup_with_external_mappings(void **state)
{
setup_ranges(test_ctx, true, false, false);
return 0;
}
static int test_sss_idmap_setup_with_both(void **state)
{
setup_ranges(test_ctx, false, false, false);
setup_ranges(test_ctx, true, true, false);
return 0;
}
static int test_sss_idmap_teardown(void **state)
{
return 0;
}
void test_add_domain(void **state)
{
enum idmap_error_code err;
struct sss_idmap_range range;
&range);
&range);
false);
false);
true);
false);
false);
true);
}
void test_map_id(void **state)
{
enum idmap_error_code err;
&id);
}
/* ID mapping - bug in computing max id for slice range */
void test_map_id_2922(void **state)
{
/* Last SID = first SID + (default) rangesize -1 */
/* Last SID = first SID + rangesize */
enum idmap_error_code err;
/* Min UNIX ID to SID */
/* First SID to UNIX ID */
/* Max UNIX ID to SID */
/* Last SID to UNIX ID */
/* Max UNIX ID + 1 to SID */
&sid);
/* Last SID + 1 to UNIX ID */
/* Auto adding new ranges is disable in this test. */
}
void test_map_id_sec_slices(void **state)
{
enum idmap_error_code err;
&id);
}
void test_map_id_external(void **state)
{
enum idmap_error_code err;
&id);
}
void test_check_sid_id(void **state)
{
enum idmap_error_code err;
TEST_RANGE_MIN-1);
}
void test_has_algorithmic(void **state)
{
bool use_id_mapping;
enum idmap_error_code err;
TEST_DOM_SID"1",
}
void test_has_algorithmic_by_name(void **state)
{
bool use_id_mapping;
enum idmap_error_code err;
TEST_DOM_NAME"1",
}
void test_sss_idmap_check_collision_ex(void **state)
{
enum idmap_error_code err;
/* Same name, different SID */
/* Same SID, different name */
/* Same SID and name, no overlaps */
/* Same SID and name, different mappings */
/* Same SID and name, Overlapping RID range */
false,
false);
/* Different SID and name, Overlapping RID range */
false,
false);
/* Overlapping ranges with no external mapping */
false,
false);
/* Overlapping ranges with external mapping */
true,
true);
}
void test_sss_idmap_error_string(void **state)
{
size_t c;
for (c = IDMAP_SUCCESS; c < IDMAP_ERR_LAST; c++) {
}
}
{
int opt;
struct poptOption long_options[] = {
};
const struct CMUnitTest tests[] = {
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
switch(opt) {
default:
return 1;
}
}
}