add checks for Authenticator too
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11615 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -48,6 +48,11 @@
|
||||
|
||||
RCSID("$Id$");
|
||||
|
||||
static char *lha_princ[] = { "lha" };
|
||||
static char *lharoot_princ[] = { "lha", "root" };
|
||||
static char *datan_princ[] = { "host", "nutcracker.e.kth.se" };
|
||||
|
||||
|
||||
#define COMPARE_STRING(ac,bc,e) \
|
||||
do { if (strcmp((ac)->e, (bc)->e) != 0) return 1; } while(0)
|
||||
#define COMPARE_INTEGER(ac,bc,e) \
|
||||
@@ -56,7 +61,7 @@ RCSID("$Id$");
|
||||
do { if (memcmp((ac)->e, (bc)->e,len) != 0) return 1; } while(0)
|
||||
|
||||
static int
|
||||
cmp_Principal (void *a, void *b)
|
||||
cmp_principal (void *a, void *b)
|
||||
{
|
||||
Principal *pa = a;
|
||||
Principal *pb = b;
|
||||
@@ -87,18 +92,14 @@ test_principal (void)
|
||||
{ NULL, 54,
|
||||
"04<EFBFBD>&0$<24>\003\002\001\003<EFBFBD>\0350\e\e\004"
|
||||
"host\e\023nutcracker.e.kth.se<73>\n\e\bE.KTH.SE"
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
char *lha[] = { "lha" };
|
||||
char *lharoot[] = { "lha", "root" };
|
||||
char *datan[] = { "host", "nutcracker.e.kth.se" };
|
||||
|
||||
Principal values[] = {
|
||||
{ { KRB5_NT_PRINCIPAL, { 1, lha } }, "SU.SE" },
|
||||
{ { KRB5_NT_PRINCIPAL, { 2, lharoot } }, "SU.SE" },
|
||||
{ { KRB5_NT_SRV_HST, { 2, datan } }, "E.KTH.SE" }
|
||||
{ { KRB5_NT_PRINCIPAL, { 1, lha_princ } }, "SU.SE" },
|
||||
{ { KRB5_NT_PRINCIPAL, { 2, lharoot_princ } }, "SU.SE" },
|
||||
{ { KRB5_NT_SRV_HST, { 2, datan_princ } }, "E.KTH.SE" }
|
||||
};
|
||||
int i;
|
||||
int ntests = sizeof(tests) / sizeof(*tests);
|
||||
@@ -108,11 +109,72 @@ test_principal (void)
|
||||
asprintf (&tests[i].name, "Principal %d", i);
|
||||
}
|
||||
|
||||
return generic_test (tests, ntests, sizeof(int),
|
||||
return generic_test (tests, ntests, sizeof(Principal),
|
||||
(generic_encode)encode_Principal,
|
||||
(generic_length)length_Principal,
|
||||
(generic_decode)decode_Principal,
|
||||
cmp_Principal);
|
||||
cmp_principal);
|
||||
}
|
||||
|
||||
static int
|
||||
cmp_authenticator (void *a, void *b)
|
||||
{
|
||||
Authenticator *aa = a;
|
||||
Authenticator *ab = b;
|
||||
int i;
|
||||
|
||||
COMPARE_INTEGER(aa,ab,authenticator_vno);
|
||||
COMPARE_STRING(aa,ab,crealm);
|
||||
|
||||
COMPARE_INTEGER(aa,ab,cname.name_type);
|
||||
COMPARE_INTEGER(aa,ab,cname.name_string.len);
|
||||
|
||||
for (i = 0; i < aa->cname.name_string.len; i++)
|
||||
COMPARE_STRING(aa,ab,cname.name_string.val[i]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
test_authenticator (void)
|
||||
{
|
||||
struct test_case tests[] = {
|
||||
{ NULL, 63,
|
||||
"\x62\x3d\x30\x3b\xa0\x03\x02\x01\x05\xa1\x0a\x1b\x08"
|
||||
"\x45\x2e\x4b\x54\x48\x2e\x53\x45\xa2\x10\x30\x0e\xa0"
|
||||
"\x03\x02\x01\x01\xa1\x07\x30\x05\x1b\x03\x6c\x68\x61"
|
||||
"\xa4\x03\x02\x01\x0a\xa5\x11\x18\x0f\x31\x39\x37\x30"
|
||||
"\x30\x31\x30\x31\x30\x30\x30\x31\x33\x39\x5a"
|
||||
},
|
||||
{ NULL, 67,
|
||||
"\x62\x41\x30\x3f\xa0\x03\x02\x01\x05\xa1\x07\x1b\x05"
|
||||
"\x53\x55\x2e\x53\x45\xa2\x16\x30\x14\xa0\x03\x02\x01"
|
||||
"\x01\xa1\x0d\x30\x0b\x1b\x03\x6c\x68\x61\x1b\x04\x72"
|
||||
"\x6f\x6f\x74\xa4\x04\x02\x02\x01\x24\xa5\x11\x18\x0f"
|
||||
"\x31\x39\x37\x30\x30\x31\x30\x31\x30\x30\x31\x36\x33"
|
||||
"\x39\x5a"
|
||||
}
|
||||
};
|
||||
|
||||
Authenticator values[] = {
|
||||
{ 5, "E.KTH.SE", { KRB5_NT_PRINCIPAL, { 1, lha_princ } },
|
||||
NULL, 10, 99, NULL, NULL, NULL },
|
||||
{ 5, "SU.SE", { KRB5_NT_PRINCIPAL, { 2, lharoot_princ } },
|
||||
NULL, 292, 999, NULL, NULL, NULL }
|
||||
};
|
||||
int i;
|
||||
int ntests = sizeof(tests) / sizeof(*tests);
|
||||
|
||||
for (i = 0; i < ntests; ++i) {
|
||||
tests[i].val = &values[i];
|
||||
asprintf (&tests[i].name, "Authenticator %d", i);
|
||||
}
|
||||
|
||||
return generic_test (tests, ntests, sizeof(Authenticator),
|
||||
(generic_encode)encode_Authenticator,
|
||||
(generic_length)length_Authenticator,
|
||||
(generic_decode)decode_Authenticator,
|
||||
cmp_authenticator);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -121,6 +183,7 @@ main(int argc, char **argv)
|
||||
int ret = 0;
|
||||
|
||||
ret += test_principal ();
|
||||
ret += test_authenticator();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user