sss_idmap-tests.c revision 9fd2775fe1ced6ff6a9a3ff7db124fcb52dade5d
/*
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"
#define IDMAP_RANGE_MIN 1234
#define IDMAP_RANGE_MAX 9876
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 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;
"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 dom_sid.");
"Failed to convert struct 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 dom_sid.");
"Failed to convert struct 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 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]",
}
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);
}