sss_idmap-tests.c revision 6469f42ca80bb9b955875d590485b0d9366491df
/*
SSSD - Test for idmap library
Authors:
Sumit Bose <sbose@redhat.com>
Copyright (C) 2012 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 <check.h>
#include "lib/idmap/sss_idmap.h"
#include "lib/idmap/sss_idmap_private.h"
#include "tests/common_check.h"
#define IDMAP_RANGE_MIN 1234
#define IDMAP_RANGE_MAX 9876
#define IDMAP_RANGE_MIN2 11234
#define IDMAP_RANGE_MAX2 19876
const char test_sid[] = "S-1-5-21-2127521184-1604012920-1887927527-72713";
0x00, 0x00, 0x00, 0xA0, 0x65, 0xCF, 0x7E, 0x78, 0x4B,
0x9B, 0x5F, 0xE7, 0x7C, 0x87, 0x70, 0x09, 0x1C, 0x01,
0x00};
struct dom_sid test_smb_sid = {1, 5, {0, 0, 0, 0, 0, 5}, {21, 2127521184, 1604012920, 1887927527, 72713, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
const char large_sid[] = "S-1-5-21-1-2-4294967295-1000";
const char too_large_sid[] = "S-1-5-21-1-2-4294967296-1000";
struct sss_idmap_ctx *idmap_ctx;
{
}
{
}
void idmap_ctx_setup(void)
{
enum idmap_error_code err;
&idmap_ctx);
}
void idmap_ctx_teardown(void)
{
enum idmap_error_code err;
}
void idmap_add_domain_setup(void)
{
enum idmap_error_code err;
}
{
size_t c;
const char *invalid[] = { "abc",
"S-1-2-3-4-5-6",
"S-1-5-21-1",
"S-1-5-21-1-2-123456789012345678",
"S-1-5-21-1+2+3",
"S-1-5-21-a-b-c",
"S-1-5-21-1-2-3-4",
NULL };
"is_domain_sid() returned true for [%s]", invalid[c]);
}
"is_domain_sid() returned true for [S-1-5-21-1-2-3]");
}
{
enum idmap_error_code err;
}
{
enum idmap_error_code err;
&ctx);
}
{
}
{
enum idmap_error_code err;
&range2);
"sss_idmap_add_domain added domain with the same name.");
&range2);
"sss_idmap_add_domain added domain with the same SID.");
&range);
"sss_idmap_add_domain added domain with the same range.");
&range2);
"sss_idmap_add_domain failed to add second domain.");
}
{
enum idmap_error_code err;
"sss_idmap_add_domain added domain with the same name.");
"sss_idmap_add_domain added domain with the same SID.");
"sss_idmap_add_domain failed to add second domain with " \
"external mapping and the same range.");
}
{
enum idmap_error_code err;
"unknown domain");
"RID out of range");
"sss_idmap_sid_to_unix returned wrong id, "
}
{
enum idmap_error_code err;
"sss_idmap_bin_sid_to_unix returned wrong id, "
}
{
enum idmap_error_code err;
"sss_idmap_dom_sid_to_unix returned wrong id, "
}
{
enum idmap_error_code err;
char *sid;
"id out of range");
"sss_idmap_unix_to_sid returned wrong SID, "
}
{
enum idmap_error_code err;
"id out of range");
"sss_idmap_unix_to_dom_sid returned wrong SID, "
}
{
enum idmap_error_code err;
"id out of range");
"sss_idmap_unix_to_bin_sid returned wrong SID, "
}
{
enum idmap_error_code err;
"Failed to convert binary SID to struct sss_dom_sid.");
"Failed to convert struct sss_dom_sid to binary SID.");
"Length of binary SIDs do not match.");
"Binary SIDs do not match.");
}
{
enum idmap_error_code err;
"Failed to convert SID string to struct sss_dom_sid.");
"Failed to convert struct sss_dom_sid to SID string.");
"Length of SID strings do not match.");
"SID strings do not match.");
}
{
enum idmap_error_code err;
"Failed to convert SID string with a UINT32_MAX component "
"to struct sss_dom_sid.");
"Failed to convert struct sss_dom_sid to SID string.");
"Length of SID strings do not match.");
"SID strings do not match, expected [%s], got [%s]",
"Trying to convert a SID with a too large component "
"did not return IDMAP_SID_INVALID");
}
{
enum idmap_error_code err;
"Failed to convert SID string to binary sid.");
"Size of binary SIDs do not match, got [%d], expected [%d]",
"Binary SIDs do not match");
}
{
enum idmap_error_code err;
&sid);
"Failed to convert binary SID to SID string.");
"expected [%s], get [%s]",
}
{
enum idmap_error_code err;
"Failed to convert samba dom_sid to struct sss_dom_sid.");
"Failed to convert struct sss_dom_sid to samba dom_sid.");
"Samba dom_sid-s do not match.");
}
{
enum idmap_error_code err;
"Failed to convert samba dom_sid to binary sid.");
"Size of binary SIDs do not match, got [%d], expected [%d]",
"Binary SIDs do not match.");
}
{
enum idmap_error_code err;
"Failed to convert binary sid to samba dom_sid.");
"Samba dom_sid structs do not match.");
}
{
enum idmap_error_code err;
"Failed to convert samba dom_sid to sid string.");
"expected [%s], get [%s]",
}
{
enum idmap_error_code err;
"Failed to convert binary sid to samba dom_sid.");
"Samba dom_sid structs do not match.");
}
Suite *idmap_test_suite (void)
{
suite_add_tcase(s, tc_init);
suite_add_tcase(s, tc_dom);
suite_add_tcase(s, tc_conv);
NULL);
suite_add_tcase(s, tc_map);
return s;
}
{
int number_failed;
Suite *s = idmap_test_suite();
/* If CK_VERBOSITY is set, use that, otherwise it defaults to CK_NORMAL */
srunner_free (sr);
}