Import from 1.9a8 tarball
[mozilla-nss.git] / security / nss / cmd / libpkix / pkix / params / test_buildparams.c
blobf0711127a010254be02787fd445706b48810081b
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
12 * License.
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.
21 * Contributor(s):
22 * Sun Microsystems
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 ***** */
38 * test_buildparams.c
40 * Test BuildParams Type
44 #include "testutil.h"
45 #include "testutil_nss.h"
47 void *plContext = NULL;
49 static void
50 testDestroy(void *goodObject, void *equalObject, void *diffObject)
52 PKIX_TEST_STD_VARS();
54 subTest("PKIX_BuildParams_Destroy");
56 PKIX_TEST_DECREF_BC(goodObject);
57 PKIX_TEST_DECREF_BC(equalObject);
58 PKIX_TEST_DECREF_BC(diffObject);
60 cleanup:
62 PKIX_TEST_RETURN();
66 void testGetProcParams(
67 PKIX_BuildParams *goodObject,
68 PKIX_BuildParams *equalObject){
70 PKIX_ProcessingParams *goodProcParams = NULL;
71 PKIX_ProcessingParams *equalProcParams = NULL;
73 PKIX_TEST_STD_VARS();
74 subTest("PKIX_BuildParams_GetProcessingParams");
76 PKIX_TEST_EXPECT_NO_ERROR(PKIX_BuildParams_GetProcessingParams
77 (goodObject, &goodProcParams, NULL));
79 PKIX_TEST_EXPECT_NO_ERROR(PKIX_BuildParams_GetProcessingParams
80 (equalObject, &equalProcParams, NULL));
82 testEqualsHelper
83 ((PKIX_PL_Object *)goodProcParams,
84 (PKIX_PL_Object *)equalProcParams,
85 PKIX_TRUE,
86 plContext);
88 cleanup:
90 PKIX_TEST_DECREF_AC(goodProcParams);
91 PKIX_TEST_DECREF_AC(equalProcParams);
93 PKIX_TEST_RETURN();
96 void printUsage(char *pName){
97 printf("\nUSAGE: %s <central-data-dir>\n\n", pName);
100 int main(int argc, char *argv[]) {
102 PKIX_BuildParams *goodObject = NULL;
103 PKIX_BuildParams *equalObject = NULL;
104 PKIX_BuildParams *diffObject = NULL;
105 PKIX_UInt32 actualMinorVersion;
106 PKIX_UInt32 j = 0;
107 PKIX_Boolean useArenas = PKIX_FALSE;
109 char *dataCentralDir = NULL;
110 char *goodInput = "yassir2yassir";
111 char *diffInput = "yassir2bcn";
113 char *expectedAscii =
114 "[\n"
115 "\tProcessing Params: \n"
116 "\t********BEGIN PROCESSING PARAMS********\n"
117 "\t\t"
118 "[\n"
119 "\tTrust Anchors: \n"
120 "\t********BEGIN LIST OF TRUST ANCHORS********\n"
121 "\t\t"
122 "([\n"
123 "\tTrusted CA Name: "
124 "CN=yassir,OU=bcn,OU=east,O=sun,C=us\n"
125 "\tTrusted CA PublicKey: ANSI X9.57 DSA Signature\n"
126 "\tInitial Name Constraints:(null)\n"
127 "]\n"
128 ", [\n"
129 "\tTrusted CA Name: OU=bcn,OU=east,O=sun,C=us\n"
130 "\tTrusted CA PublicKey: ANSI X9.57 DSA Signature\n"
131 "\tInitial Name Constraints:(null)\n"
132 "]\n"
133 ")\n"
134 "\t********END LIST OF TRUST ANCHORS********\n"
135 "\tDate: \t\t(null)\n"
136 "\tTarget Constraints: (null)\n"
137 "\tInitial Policies: (null)\n"
138 "\tQualifiers Rejected: FALSE\n"
139 "\tCert Stores: (EMPTY)\n"
140 "\tResource Limits: (null)\n"
141 "\tCRL Checking Enabled: 0\n"
142 "]\n"
143 "\n"
144 "\t********END PROCESSING PARAMS********\n"
145 "]\n";
147 PKIX_TEST_STD_VARS();
149 startTests("BuildParams");
151 useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
153 PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
154 (PKIX_TRUE, /* nssInitNeeded */
155 useArenas,
156 PKIX_MAJOR_VERSION,
157 PKIX_MINOR_VERSION,
158 PKIX_MINOR_VERSION,
159 &actualMinorVersion,
160 &plContext));
162 if (argc < 2){
163 printUsage(argv[0]);
164 return (0);
167 dataCentralDir = argv[j+1];
169 subTest("PKIX_BuildParams_Create");
171 goodObject = createBuildParams
172 (dataCentralDir,
173 goodInput,
174 diffInput,
175 NULL,
176 NULL,
177 PKIX_FALSE,
178 plContext);
180 equalObject = createBuildParams
181 (dataCentralDir,
182 goodInput,
183 diffInput,
184 NULL,
185 NULL,
186 PKIX_FALSE,
187 plContext);
189 diffObject = createBuildParams
190 (dataCentralDir,
191 diffInput,
192 goodInput,
193 NULL,
194 NULL,
195 PKIX_FALSE,
196 plContext);
198 testGetProcParams(goodObject, equalObject);
200 PKIX_TEST_EQ_HASH_TOSTR_DUP
201 (goodObject,
202 equalObject,
203 diffObject,
204 expectedAscii,
205 BuildParams,
206 PKIX_FALSE);
208 testDestroy(goodObject, equalObject, diffObject);
210 cleanup:
212 PKIX_Shutdown(plContext);
214 PKIX_TEST_RETURN();
216 endTests("BuildParams");
218 return (0);