1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
14 * The Original Code is the PKIX-C library.
16 * The Initial Developer of the Original Code is
17 * Sun Microsystems, Inc.
18 * Portions created by the Initial Developer are
19 * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
22 * Sun Microsystems, Inc.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
40 * Test BuildResult Type
45 #include "testutil_nss.h"
47 static void *plContext
= NULL
;
50 testDestroy(void *goodObject
, void *equalObject
, void *diffObject
)
54 subTest("PKIX_BuildResult_Destroy");
56 PKIX_TEST_DECREF_BC(goodObject
);
57 PKIX_TEST_DECREF_BC(equalObject
);
58 PKIX_TEST_DECREF_BC(diffObject
);
67 void testGetValidateResult(
68 PKIX_BuildResult
*goodObject
,
69 PKIX_BuildResult
*equalObject
){
71 PKIX_ValidateResult
*goodValResult
= NULL
;
72 PKIX_ValidateResult
*equalValResult
= NULL
;
75 subTest("PKIX_BuildResult_GetValidateResult");
77 PKIX_TEST_EXPECT_NO_ERROR(PKIX_BuildResult_GetValidateResult
78 (goodObject
, &goodValResult
, NULL
));
80 PKIX_TEST_EXPECT_NO_ERROR(PKIX_BuildResult_GetValidateResult
81 (equalObject
, &equalValResult
, NULL
));
84 ((PKIX_PL_Object
*)goodValResult
,
85 (PKIX_PL_Object
*)equalValResult
,
91 PKIX_TEST_DECREF_AC(goodValResult
);
92 PKIX_TEST_DECREF_AC(equalValResult
);
98 void testGetCertChain(
99 PKIX_BuildResult
*goodObject
,
100 PKIX_BuildResult
*equalObject
){
102 PKIX_List
*goodChain
= NULL
;
103 PKIX_List
*equalChain
= NULL
;
105 PKIX_TEST_STD_VARS();
106 subTest("PKIX_BuildResult_GetCertChain");
108 PKIX_TEST_EXPECT_NO_ERROR(PKIX_BuildResult_GetCertChain
109 (goodObject
, &goodChain
, NULL
));
111 PKIX_TEST_EXPECT_NO_ERROR(PKIX_BuildResult_GetCertChain
112 (equalObject
, &equalChain
, NULL
));
115 ((PKIX_PL_Object
*)goodChain
,
116 (PKIX_PL_Object
*)equalChain
,
122 PKIX_TEST_DECREF_AC(goodChain
);
123 PKIX_TEST_DECREF_AC(equalChain
);
129 void printUsage(char *pName
){
130 printf("\nUSAGE: %s <central-data-dir>\n\n", pName
);
133 int test_buildresult(int argc
, char *argv
[]) {
135 PKIX_BuildResult
*goodObject
= NULL
;
136 PKIX_BuildResult
*equalObject
= NULL
;
137 PKIX_BuildResult
*diffObject
= NULL
;
138 PKIX_UInt32 actualMinorVersion
;
139 char *dirName
= NULL
;
142 char *goodInput
= "yassir2yassir";
143 char *diffInput
= "yassir2bcn";
145 char *expectedAscii
=
147 "\tValidateResult: \t\t"
149 "\tTrustAnchor: \t\t"
151 "\tTrusted CA Name: "
152 "CN=yassir,OU=bcn,OU=east,O=sun,C=us\n"
153 "\tTrusted CA PublicKey: ANSI X9.57 DSA Signature\n"
154 "\tInitial Name Constraints:(null)\n"
157 "ANSI X9.57 DSA Signature\n"
158 "\tPolicyTree: \t\t(null)\n"
163 "\tSerialNumber: 37bc65af\n"
164 "\tIssuer: CN=yassir,OU=bcn,OU=east,O=sun,C=us\n"
165 "\tSubject: CN=yassir,OU=bcn,OU=east,O=sun,C=us\n"
166 "\tValidity: [From: Thu Aug 19 16:14:39 1999\n"
167 "\t To: Fri Aug 18 16:14:39 2000]\n"
168 "\tSubjectAltNames: (null)\n"
169 "\tAuthorityKeyId: (null)\n"
170 "\tSubjectKeyId: (null)\n"
171 "\tSubjPubKeyAlgId: ANSI X9.57 DSA Signature\n"
172 "\tCritExtOIDs: (2.5.29.15, 2.5.29.19)\n"
173 "\tExtKeyUsages: (null)\n"
174 "\tBasicConstraint: CA(0)\n"
175 "\tCertPolicyInfo: (null)\n"
176 "\tPolicyMappings: (null)\n"
177 "\tExplicitPolicy: -1\n"
178 "\tInhibitMapping: -1\n"
179 "\tInhibitAnyPolicy:-1\n"
180 "\tNameConstraints: (null)\n"
184 "\tSerialNumber: 37bc66ec\n"
185 "\tIssuer: CN=yassir,OU=bcn,OU=east,O=sun,C=us\n"
186 "\tSubject: OU=bcn,OU=east,O=sun,C=us\n"
187 "\tValidity: [From: Thu Aug 19 16:19:56 1999\n"
188 "\t To: Fri Aug 18 16:19:56 2000]\n"
189 "\tSubjectAltNames: (null)\n"
190 "\tAuthorityKeyId: (null)\n"
191 "\tSubjectKeyId: (null)\n"
192 "\tSubjPubKeyAlgId: ANSI X9.57 DSA Signature\n"
193 "\tCritExtOIDs: (2.5.29.15, 2.5.29.19)\n"
194 "\tExtKeyUsages: (null)\n"
195 "\tBasicConstraint: CA(0)\n"
196 "\tCertPolicyInfo: (null)\n"
197 "\tPolicyMappings: (null)\n"
198 "\tExplicitPolicy: -1\n"
199 "\tInhibitMapping: -1\n"
200 "\tInhibitAnyPolicy:-1\n"
201 "\tNameConstraints: (null)\n"
206 PKIX_TEST_STD_VARS();
208 startTests("BuildResult");
210 PKIX_TEST_EXPECT_NO_ERROR(
211 PKIX_PL_NssContext_Create(0, PKIX_FALSE
, NULL
, &plContext
));
220 subTest("pkix_BuildResult_Create");
222 goodObject
= createBuildResult
223 (dirName
, goodInput
, diffInput
, goodInput
, diffInput
, plContext
);
224 equalObject
= createBuildResult
225 (dirName
, goodInput
, diffInput
, goodInput
, diffInput
, plContext
);
226 diffObject
= createBuildResult
227 (dirName
, diffInput
, goodInput
, diffInput
, goodInput
, plContext
);
229 testGetValidateResult(goodObject
, equalObject
);
230 testGetCertChain(goodObject
, equalObject
);
232 PKIX_TEST_EQ_HASH_TOSTR_DUP
236 NULL
, /* expectedAscii, */
240 testDestroy(goodObject
, equalObject
, diffObject
);
244 PKIX_Shutdown(plContext
);
248 endTests("BuildResult");