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 Netscape security libraries.
16 * The Initial Developer of the Original Code is
17 * Netscape Communications Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 1994-2000
19 * the Initial Developer. All Rights Reserved.
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 ValidateParams Type
45 #include "testutil_nss.h"
47 void *plContext
= NULL
;
50 testDestroy(void *goodObject
, void *equalObject
, void *diffObject
)
54 subTest("PKIX_ValidateParams_Destroy");
56 PKIX_TEST_DECREF_BC(goodObject
);
57 PKIX_TEST_DECREF_BC(equalObject
);
58 PKIX_TEST_DECREF_BC(diffObject
);
66 void testGetProcParams(
67 PKIX_ValidateParams
*goodObject
,
68 PKIX_ValidateParams
*equalObject
){
70 PKIX_ProcessingParams
*goodProcParams
= NULL
;
71 PKIX_ProcessingParams
*equalProcParams
= NULL
;
74 subTest("PKIX_ValidateParams_GetProcessingParams");
76 PKIX_TEST_EXPECT_NO_ERROR(PKIX_ValidateParams_GetProcessingParams
77 (goodObject
, &goodProcParams
, plContext
));
79 PKIX_TEST_EXPECT_NO_ERROR(PKIX_ValidateParams_GetProcessingParams
80 (equalObject
, &equalProcParams
, plContext
));
83 ((PKIX_PL_Object
*)goodProcParams
,
84 (PKIX_PL_Object
*)equalProcParams
,
90 PKIX_TEST_DECREF_AC(goodProcParams
);
91 PKIX_TEST_DECREF_AC(equalProcParams
);
97 void testGetCertChain(
98 PKIX_ValidateParams
*goodObject
,
99 PKIX_ValidateParams
*equalObject
){
101 PKIX_List
*goodChain
= NULL
;
102 PKIX_List
*equalChain
= NULL
;
104 PKIX_TEST_STD_VARS();
105 subTest("PKIX_ValidateParams_GetCertChain");
107 PKIX_TEST_EXPECT_NO_ERROR(PKIX_ValidateParams_GetCertChain
108 (goodObject
, &goodChain
, plContext
));
110 PKIX_TEST_EXPECT_NO_ERROR(PKIX_ValidateParams_GetCertChain
111 (equalObject
, &equalChain
, plContext
));
114 ((PKIX_PL_Object
*)goodChain
,
115 (PKIX_PL_Object
*)equalChain
,
121 PKIX_TEST_DECREF_AC(goodChain
);
122 PKIX_TEST_DECREF_AC(equalChain
);
127 void printUsage(char *pName
){
128 printf("\nUSAGE: %s <central-data-dir>\n\n", pName
);
131 int main(int argc
, char *argv
[]) {
133 PKIX_ValidateParams
*goodObject
= NULL
;
134 PKIX_ValidateParams
*equalObject
= NULL
;
135 PKIX_ValidateParams
*diffObject
= NULL
;
136 PKIX_List
*chain
= NULL
;
137 PKIX_UInt32 actualMinorVersion
;
139 char *dirName
= NULL
;
140 PKIX_Boolean useArenas
= PKIX_FALSE
;
142 char *goodInput
= "yassir2yassir";
143 char *diffInput
= "yassir2bcn";
145 char *expectedAscii
=
147 "\tProcessing Params: \n"
148 "\t********BEGIN PROCESSING PARAMS********\n"
151 "\tTrust Anchors: \n"
152 "\t********BEGIN LIST OF TRUST ANCHORS********\n"
155 "\tTrusted CA Name: "
156 "CN=yassir,OU=bcn,OU=east,O=sun,C=us\n"
157 "\tTrusted CA PublicKey: ANSI X9.57 DSA Signature\n"
158 "\tInitial Name Constraints:(null)\n"
161 "\tTrusted CA Name: OU=bcn,OU=east,O=sun,C=us\n"
162 "\tTrusted CA PublicKey: ANSI X9.57 DSA Signature\n"
163 "\tInitial Name Constraints:(null)\n"
166 "\t********END LIST OF TRUST ANCHORS********\n"
167 "\tDate: \t\t(null)\n"
168 "\tTarget Constraints: (null)\n"
169 "\tInitial Policies: (null)\n"
170 "\tQualifiers Rejected: FALSE\n"
171 "\tCert Stores: (EMPTY)\n"
172 "\tCRL Checking Enabled: 0\n"
175 "\t********END PROCESSING PARAMS********\n"
179 "\tSerialNumber: 37bc66ec\n"
180 "\tIssuer: CN=yassir,OU=bcn,OU=east,O=sun,C=us\n"
181 "\tSubject: OU=bcn,OU=east,O=sun,C=us\n"
182 "\tValidity: [From: Thu Aug 19 16:19:56 1999\n"
183 "\t To: Fri Aug 18 16:19:56 2000]\n"
184 "\tSubjectAltNames: (null)\n"
185 "\tAuthorityKeyId: (null)\n"
186 "\tSubjectKeyId: (null)\n"
187 "\tSubjPubKeyAlgId: ANSI X9.57 DSA Signature\n"
188 "\tCritExtOIDs: (2.5.29.15, 2.5.29.19)\n"
189 "\tExtKeyUsages: (null)\n"
190 "\tBasicConstraint: CA(0)\n"
191 "\tCertPolicyInfo: (null)\n"
192 "\tPolicyMappings: (null)\n"
193 "\tExplicitPolicy: -1\n"
194 "\tInhibitMapping: -1\n"
195 "\tInhibitAnyPolicy:-1\n"
196 "\tNameConstraints: (null)\n"
200 "\tSerialNumber: 37bc65af\n"
201 "\tIssuer: CN=yassir,OU=bcn,OU=east,O=sun,C=us\n"
202 "\tSubject: CN=yassir,OU=bcn,OU=east,O=sun,C=us\n"
203 "\tValidity: [From: Thu Aug 19 16:14:39 1999\n"
204 "\t To: Fri Aug 18 16:14:39 2000]\n"
205 "\tSubjectAltNames: (null)\n"
206 "\tAuthorityKeyId: (null)\n"
207 "\tSubjectKeyId: (null)\n"
208 "\tSubjPubKeyAlgId: ANSI X9.57 DSA Signature\n"
209 "\tCritExtOIDs: (2.5.29.15, 2.5.29.19)\n"
210 "\tExtKeyUsages: (null)\n"
211 "\tBasicConstraint: CA(0)\n"
212 "\tCertPolicyInfo: (null)\n"
213 "\tPolicyMappings: (null)\n"
214 "\tExplicitPolicy: -1\n"
215 "\tInhibitMapping: -1\n"
216 "\tInhibitAnyPolicy:-1\n"
217 "\tNameConstraints: (null)\n"
222 PKIX_TEST_STD_VARS();
224 startTests("ValidateParams");
226 useArenas
= PKIX_TEST_ARENAS_ARG(argv
[1]);
228 PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
229 (PKIX_TRUE
, /* nssInitNeeded */
244 subTest("PKIX_ValidateParams_Create");
245 chain
= createCertChain(dirName
, diffInput
, goodInput
, plContext
);
246 goodObject
= createValidateParams
258 equalObject
= createValidateParams
270 diffObject
= createValidateParams
283 testGetProcParams(goodObject
, equalObject
);
284 testGetCertChain(goodObject
, equalObject
);
286 PKIX_TEST_EQ_HASH_TOSTR_DUP
290 NULL
, /* expectedAscii, */
294 testDestroy(goodObject
, equalObject
, diffObject
);
298 PKIX_TEST_DECREF_AC(chain
);
300 PKIX_Shutdown(plContext
);
304 endTests("ValidateParams");