OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 /* | 4 /* |
5 * test_authorityinfoaccess.c | 5 * test_authorityinfoaccess.c |
6 * | 6 * |
7 * Test Authority InfoAccess Type | 7 * Test Authority InfoAccess Type |
8 * | 8 * |
9 */ | 9 */ |
10 | 10 |
11 | |
12 | |
13 #include "testutil.h" | 11 #include "testutil.h" |
14 #include "testutil_nss.h" | 12 #include "testutil_nss.h" |
15 | 13 |
16 static void *plContext = NULL; | 14 static void *plContext = NULL; |
17 | 15 |
18 int test_authorityinfoaccess(int argc, char *argv[]) { | 16 int test_authorityinfoaccess(int argc, char *argv[]) { |
19 | 17 |
20 PKIX_PL_Cert *cert = NULL; | 18 PKIX_PL_Cert *cert = NULL; |
21 PKIX_PL_Cert *certDiff = NULL; | 19 PKIX_PL_Cert *certDiff = NULL; |
22 PKIX_List *aiaList = NULL; | 20 PKIX_List *aiaList = NULL; |
23 PKIX_List *siaList = NULL; | 21 PKIX_List *siaList = NULL; |
24 PKIX_PL_InfoAccess *aia = NULL; | 22 PKIX_PL_InfoAccess *aia = NULL; |
25 PKIX_PL_InfoAccess *aiaDup = NULL; | 23 PKIX_PL_InfoAccess *aiaDup = NULL; |
26 PKIX_PL_InfoAccess *aiaDiff = NULL; | 24 PKIX_PL_InfoAccess *aiaDiff = NULL; |
27 char *certPathName = NULL; | 25 char *certPathName = NULL; |
28 char *dirName = NULL; | 26 char *dirName = NULL; |
29 PKIX_UInt32 actualMinorVersion; | 27 PKIX_UInt32 actualMinorVersion; |
30 PKIX_UInt32 size, i; | 28 PKIX_UInt32 size, i; |
31 PKIX_UInt32 j = 0; | 29 PKIX_UInt32 j = 0; |
32 char *expectedAscii = "[method:caIssuers, location:ldap:" | 30 char *expectedAscii = |
33 "//betty.nist.gov/cn=CA,ou=Basic%20LDAP%20URI%20OU1," | 31 "[method:caIssuers, location:ldap:" |
34 "o=Test%20Certificates,c=US?cACertificate;binary," | 32 "//betty.nist.gov/cn=CA,ou=Basic%20LDAP%20URI%20OU1," |
35 "crossCertificatePair;binary]"; | 33 "o=Test%20Certificates,c=US?cACertificate;binary," |
| 34 "crossCertificatePair;binary]"; |
36 | 35 |
37 PKIX_TEST_STD_VARS(); | 36 PKIX_TEST_STD_VARS(); |
38 | 37 |
39 startTests("AuthorityInfoAccess"); | 38 startTests("AuthorityInfoAccess"); |
40 | 39 |
41 PKIX_TEST_EXPECT_NO_ERROR( | 40 PKIX_TEST_EXPECT_NO_ERROR( |
42 PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext)); | 41 PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext)); |
43 | 42 |
44 if (argc < 5+j) { | 43 if (argc < 5 + j) { |
45 printf("Usage: %s <test-purpose> <cert> <diff-cert>\n", argv[0])
; | 44 printf("Usage: %s <test-purpose> <cert> <diff-cert>\n", argv[0]); |
46 } | 45 } |
47 | 46 |
48 dirName = argv[2+j]; | 47 dirName = argv[2 + j]; |
49 certPathName = argv[3+j]; | 48 certPathName = argv[3 + j]; |
50 | 49 |
51 subTest("Creating Cert with Authority Info Access"); | 50 subTest("Creating Cert with Authority Info Access"); |
52 cert = createCert(dirName, certPathName, plContext); | 51 cert = createCert(dirName, certPathName, plContext); |
53 | 52 |
54 certPathName = argv[4+j]; | 53 certPathName = argv[4 + j]; |
55 | 54 |
56 subTest("Creating Cert with Subject Info Access"); | 55 subTest("Creating Cert with Subject Info Access"); |
57 certDiff = createCert(dirName, certPathName, plContext); | 56 certDiff = createCert(dirName, certPathName, plContext); |
58 | 57 |
59 subTest("Getting Authority Info Access"); | 58 subTest("Getting Authority Info Access"); |
60 PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Cert_GetAuthorityInfoAccess | 59 PKIX_TEST_EXPECT_NO_ERROR( |
61 (cert, &aiaList, plContext)); | 60 PKIX_PL_Cert_GetAuthorityInfoAccess(cert, &aiaList, plContext)); |
62 | 61 |
63 PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_GetLength | 62 PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_GetLength(aiaList, &size, plContext)); |
64 (aiaList, &size, plContext)); | |
65 | 63 |
66 if (size != 1) { | 64 if (size != 1) { |
67 pkixTestErrorMsg = "unexpected number of AIA"; | 65 pkixTestErrorMsg = "unexpected number of AIA"; |
68 goto cleanup; | 66 goto cleanup; |
69 } | 67 } |
70 · | |
71 PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_GetItem | |
72 (aiaList, 0, (PKIX_PL_Object **) &aia, plContext)); | |
73 | 68 |
74 PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_GetItem | 69 PKIX_TEST_EXPECT_NO_ERROR( |
75 (aiaList, 0, (PKIX_PL_Object **) &aiaDup, plContext)); | 70 PKIX_List_GetItem(aiaList, 0, (PKIX_PL_Object **)&aia, plContext)); |
76 | 71 |
77 subTest("Getting Subject Info Access as difference comparison"); | 72 PKIX_TEST_EXPECT_NO_ERROR( |
78 PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Cert_GetSubjectInfoAccess | 73 PKIX_List_GetItem(aiaList, 0, (PKIX_PL_Object **)&aiaDup, plContext)); |
79 (certDiff, &siaList, plContext)); | |
80 | 74 |
81 PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_GetLength | 75 subTest("Getting Subject Info Access as difference comparison"); |
82 (siaList, &size, plContext)); | 76 PKIX_TEST_EXPECT_NO_ERROR( |
| 77 PKIX_PL_Cert_GetSubjectInfoAccess(certDiff, &siaList, plContext)); |
83 | 78 |
84 if (size != 1) { | 79 PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_GetLength(siaList, &size, plContext)); |
85 pkixTestErrorMsg = "unexpected number of AIA"; | |
86 goto cleanup; | |
87 } | |
88 · | |
89 PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_GetItem | |
90 (siaList, 0, (PKIX_PL_Object **) &aiaDiff, plContext)); | |
91 | 80 |
92 subTest("Checking: Equal, Hash and ToString"); | 81 if (size != 1) { |
93 PKIX_TEST_EQ_HASH_TOSTR_DUP | 82 pkixTestErrorMsg = "unexpected number of AIA"; |
94 (aia, aiaDup, aiaDiff, expectedAscii, InfoAccess, PKIX_FALSE); | 83 goto cleanup; |
| 84 } |
95 | 85 |
| 86 PKIX_TEST_EXPECT_NO_ERROR( |
| 87 PKIX_List_GetItem(siaList, 0, (PKIX_PL_Object **)&aiaDiff, plContext)); |
96 | 88 |
| 89 subTest("Checking: Equal, Hash and ToString"); |
| 90 PKIX_TEST_EQ_HASH_TOSTR_DUP(aia, aiaDup, aiaDiff, expectedAscii, InfoAccess, |
| 91 PKIX_FALSE); |
97 | 92 |
98 cleanup: | 93 cleanup: |
99 | 94 |
100 PKIX_TEST_DECREF_AC(aia); | 95 PKIX_TEST_DECREF_AC(aia); |
101 PKIX_TEST_DECREF_AC(aiaDup); | 96 PKIX_TEST_DECREF_AC(aiaDup); |
102 PKIX_TEST_DECREF_AC(aiaDiff); | 97 PKIX_TEST_DECREF_AC(aiaDiff); |
103 PKIX_TEST_DECREF_AC(aiaList); | 98 PKIX_TEST_DECREF_AC(aiaList); |
104 PKIX_TEST_DECREF_AC(siaList); | 99 PKIX_TEST_DECREF_AC(siaList); |
105 PKIX_TEST_DECREF_AC(cert); | 100 PKIX_TEST_DECREF_AC(cert); |
106 PKIX_TEST_DECREF_AC(certDiff); | 101 PKIX_TEST_DECREF_AC(certDiff); |
107 ····· | |
108 PKIX_Shutdown(plContext); | |
109 | 102 |
110 PKIX_TEST_RETURN(); | 103 PKIX_Shutdown(plContext); |
111 | 104 |
112 endTests("Authorityinfoaccess"); | 105 PKIX_TEST_RETURN(); |
113 | 106 |
114 return (0); | 107 endTests("Authorityinfoaccess"); |
| 108 |
| 109 return (0); |
115 } | 110 } |
OLD | NEW |