From 976082f35e350dcb22e397c0ec122cbf900613fb Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Thu, 14 Nov 1996 19:25:10 +0000 Subject: [PATCH] krb5_encode_test.c (PRS): Add the -p option to krb5_encode_test to change the sample principal value (to test encoding of different krb5 principals). ktest.c (ktest_make_sample_principal): Use krb5_parse_principal so that sample principal can be configured for different purposes. krb5_decode_test.c (main): krb5_encode_test.c (main): Check return value from krb5_init_context to make sure it succeeded. Makefile.in (check): Set KRB5_CONFIG to $(TOPSRC)/config-files/krb5.conf so that the tests work. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9412 dc483132-0cff-0310-8789-dd5450dbe970 --- src/tests/asn.1/ChangeLog | 17 +++++++++++++++++ src/tests/asn.1/Makefile.in | 12 +++++++++--- src/tests/asn.1/krb5_decode_test.c | 11 ++++++++--- src/tests/asn.1/krb5_encode_test.c | 15 +++++++++++---- src/tests/asn.1/ktest.c | 20 ++++---------------- src/tests/asn.1/ktest.h | 7 +++++++ 6 files changed, 56 insertions(+), 26 deletions(-) diff --git a/src/tests/asn.1/ChangeLog b/src/tests/asn.1/ChangeLog index 2155427c4..3e3898e89 100644 --- a/src/tests/asn.1/ChangeLog +++ b/src/tests/asn.1/ChangeLog @@ -1,3 +1,20 @@ +Thu Nov 14 14:13:41 1996 Theodore Ts'o + + * krb5_encode_test.c (PRS): Add the -p option to krb5_encode_test + to change the sample principal value (to test encoding of + different krb5 principals). + + * ktest.c (ktest_make_sample_principal): Use krb5_parse_principal + so that sample principal can be configured for different + purposes. + + * krb5_decode_test.c (main): + * krb5_encode_test.c (main): Check return value from + krb5_init_context to make sure it succeeded. + + * Makefile.in (check): Set KRB5_CONFIG to + $(TOPSRC)/config-files/krb5.conf so that the tests work. + Wed Jun 5 15:59:12 1996 Ezra Peisach * krb5_decode_test.c (main): For asn1_decode_enc_kdc_rep_part, diff --git a/src/tests/asn.1/Makefile.in b/src/tests/asn.1/Makefile.in index 07d9d6630..7511349c2 100644 --- a/src/tests/asn.1/Makefile.in +++ b/src/tests/asn.1/Makefile.in @@ -21,11 +21,17 @@ trval: $(srcdir)/trval.c $(CC) -o trval $(CFLAGS) -DSTANDALONE $(srcdir)/trval.c check:: krb5_decode_test krb5_encode_test - $(RUN_SETUP) ./krb5_decode_test + KRB5_CONFIG=$(SRCTOP)/config-files/krb5.conf ; \ + export KRB5_CONFIG ;\ + $(RUN_SETUP) ./krb5_decode_test $(RM) test.out - $(RUN_SETUP) ./krb5_encode_test > test.out + KRB5_CONFIG=$(SRCTOP)/config-files/krb5.conf ; \ + export KRB5_CONFIG ;\ + $(RUN_SETUP) ./krb5_encode_test > test.out cmp test.out $(srcdir)/reference_encode.out - $(RUN_SETUP) ./krb5_encode_test -t > test.out + KRB5_CONFIG=$(SRCTOP)/config-files/krb5.conf ; \ + export KRB5_CONFIG ;\ + $(RUN_SETUP) ./krb5_encode_test -t > test.out cmp test.out $(srcdir)/trval_reference.out $(RM) test.out diff --git a/src/tests/asn.1/krb5_decode_test.c b/src/tests/asn.1/krb5_decode_test.c index c65b92d17..0c9d507db 100644 --- a/src/tests/asn.1/krb5_decode_test.c +++ b/src/tests/asn.1/krb5_decode_test.c @@ -10,13 +10,18 @@ krb5_context test_context; int error_count = 0; -void main() +void main(argc, argv) + int argc; + char **argv; { krb5_data code; krb5_error_code retval; - krb5_init_context(&test_context); - krb5_init_ets(test_context); + retval = krb5_init_context(&test_context); + if (retval) { + com_err(argv[0], retval, "while initializing krb5"); + exit(1); + } #define setup(type,typestring,constructor)\ type ref, *var;\ diff --git a/src/tests/asn.1/krb5_encode_test.c b/src/tests/asn.1/krb5_encode_test.c index 5f2c84ae6..9cc3e93e8 100644 --- a/src/tests/asn.1/krb5_encode_test.c +++ b/src/tests/asn.1/krb5_encode_test.c @@ -58,14 +58,18 @@ void PRS(argc, argv) print_constructed_length, print_skip_context, print_skip_tagnum, print_context_shortcut; - while ((optchar = getopt(argc, argv, "t")) != EOF) { + while ((optchar = getopt(argc, argv, "tp:")) != EOF) { switch(optchar) { case 't': do_trval = 1; break; + case 'p': + sample_principal_name = optarg; + break; case '?': default: - fprintf(stderr, "Usage: %s [-t]\n", argv[0]); + fprintf(stderr, "Usage: %s [-t] [-p principal]\n", + argv[0]); exit(1); } } @@ -87,8 +91,11 @@ void main(argc, argv) PRS(argc, argv); - krb5_init_context(&test_context); - krb5_init_ets(test_context); + retval = krb5_init_context(&test_context); + if (retval) { + com_err(argv[0], retval, "while initializing krb5"); + exit(1); + } #define setup(value,type,typestring,constructor)\ retval = constructor(&(value));\ diff --git a/src/tests/asn.1/ktest.c b/src/tests/asn.1/ktest.c index db88fd97f..a4a2e069a 100644 --- a/src/tests/asn.1/ktest.c +++ b/src/tests/asn.1/ktest.c @@ -2,6 +2,8 @@ #include "utility.h" #include +char *sample_principal_name = "hftsai/extra@ATHENA.MIT.EDU"; + krb5_error_code ktest_make_sample_authenticator(a) krb5_authenticator * a; { @@ -31,22 +33,8 @@ krb5_error_code ktest_make_sample_principal(p) { krb5_error_code retval; - /*if(*p == NULL){*/ - *p = (krb5_principal)calloc(1,sizeof(krb5_principal_data)); - if(*p == NULL) return ENOMEM; - /*}*/ - retval = krb5_data_parse(&((*p)->realm),"ATHENA.MIT.EDU"); - if(retval) return retval; - (*p)->type = 1; - (*p)->length = 2; - (*p)->data = (krb5_data*)calloc(2,sizeof(krb5_data)); - if((*p)->data == NULL) return ENOMEM; - retval = krb5_data_parse(&((*p)->data[0]),"hftsai"); - if(retval) return retval; - retval = krb5_data_parse(&((*p)->data[1]),"extra"); - if(retval) return retval; - - return 0; + retval = krb5_parse_name(test_context, sample_principal_name, p); + return retval; } krb5_error_code ktest_make_sample_checksum(cs) diff --git a/src/tests/asn.1/ktest.h b/src/tests/asn.1/ktest.h index 87ba0db62..f1db33d89 100644 --- a/src/tests/asn.1/ktest.h +++ b/src/tests/asn.1/ktest.h @@ -91,6 +91,10 @@ krb5_error_code ktest_make_sample_etype_info KRB5_PROTOTYPE((krb5_etype_info_entry *** p)); krb5_error_code ktest_make_sample_pa_enc_ts KRB5_PROTOTYPE((krb5_pa_enc_ts *am)); +krb5_error_code ktest_make_sample_sam_challenge + KRB5_PROTOTYPE((krb5_sam_challenge * p)); +krb5_error_code ktest_make_sample_sam_response + KRB5_PROTOTYPE((krb5_sam_response * p)); /*----------------------------------------------------------------------*/ @@ -139,4 +143,7 @@ void ktest_destroy_etype_info_entry void ktest_destroy_etype_info KRB5_PROTOTYPE((krb5_etype_info_entry **info)); +extern krb5_context test_context; +extern char *sample_principal_name; + #endif -- 2.26.2