Add ASN.1 decoder test for krb5_pa_pac_req
authorGreg Hudson <ghudson@mit.edu>
Sat, 11 Feb 2012 23:24:58 +0000 (23:24 +0000)
committerGreg Hudson <ghudson@mit.edu>
Sat, 11 Feb 2012 23:24:58 +0000 (23:24 +0000)
Also, if decode_krb5_ap_rep_enc_part doesn't return the expected error
code in krb5_decode_test, exit with nonzero status.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25685 dc483132-0cff-0310-8789-dd5450dbe970

src/tests/asn.1/krb5_decode_test.c

index c85c77a8cd8d02c18b8275d14753f00cd113ffc0..811f230c6adfb44129c26f0018536554a0001f1c 100644 (file)
@@ -533,6 +533,7 @@ int main(argc, argv)
         retval = decode_krb5_ap_rep_enc_part(&code, &var);
         if (retval != ASN1_OVERRUN) {
             printf("ERROR: ");
+            error_count++;
         } else {
             printf("OK: ");
         }
@@ -900,6 +901,35 @@ int main(argc, argv)
         ktest_empty_pa_s4u_x509_user(&ref);
     }
 
+    /****************************************************************/
+    /* decode_pa_pac_req */
+    {
+        /* This type has no encoder and is very simple.  Test two
+         * hand-generated encodings. */
+        krb5_pa_pac_req *req1 = NULL, *req2 = NULL;
+        code = make_data("\x30\x05\xA0\x03\x01\x01\x00", 7);
+        retval = decode_krb5_pa_pac_req(&code, &req1);
+        if (retval) {
+            com_err(argv[0], retval, "while decoding PA-PAC-REQ");
+            exit(1);
+        }
+        code = make_data("\x30\x05\xA0\x03\x01\x01\xFF", 7);
+        retval = decode_krb5_pa_pac_req(&code, &req2);
+        if (retval) {
+            com_err(argv[0], retval, "while decoding PA-PAC-REQ");
+            exit(1);
+        }
+        if (req1->include_pac != 0 || req2->include_pac != 1) {
+            printf("ERROR: ");
+            error_count++;
+        } else {
+            printf("OK: ");
+        }
+        printf("pa_pac_rec\n");
+        free(req1);
+        free(req2);
+    }
+
     /****************************************************************/
     /* decode_ad_kdcissued */
     {