|
1 |
|
2 This file contains test cases for javacertstoreplugin. |
|
3 Following classes are tested in these tests: |
|
4 CJavaCertStoreImpl, CJavaCertStoreToken and CJavaCertStoreTokenType |
|
5 |
|
6 Test environment: |
|
7 This unit test set uses actual java captain to retrieve certificate information |
|
8 from the javacertstore which extension plugin of the java captain. |
|
9 Purpose of the Extensionplugin (part of the test code) is stop javacertstore extension plugin |
|
10 from the java captain. This is needed because javacertstore caches its data and otherwise we |
|
11 would not have been able to change certificate data in the file system. |
|
12 |
|
13 |
|
14 /** |
|
15 * TEST CASE 1: |
|
16 * Name of the test: ReadCerts, readingCerts |
|
17 * Purpose: |
|
18 * Verifies that all except deleted certificates can be read. |
|
19 * This test case verifies that use cases 1 and 2 works properly. |
|
20 * Precondition: |
|
21 * All existing certificates has been deleted. |
|
22 * Steps: |
|
23 * 1. Store following certificates to the javacert folder: |
|
24 * - enabled, can not be removed, can be disabled |
|
25 * - enabled, can be removed, can be disabled |
|
26 * - disabled, can be removed, can be disabled |
|
27 * - deleted, can be removed, can be disabled |
|
28 * 2. - Read certificates using MCTWritableCertStore::List() operation. |
|
29 * - Read content of returned certificates by MCTWritableCertStore::Retrieve() |
|
30 * operation. |
|
31 * 3. - Call again MCTWritableCertStore::List() operation. |
|
32 * - Call again MCTWritableCertStore::Retrieve()operation for each certificate. |
|
33 * 4. - Stop javacertstore extension plugin and delete all certs from javacert folder. |
|
34 * - Read certificates using MCTWritableCertStore::List() operation. |
|
35 * Result: |
|
36 * 1. Certificates was stored successfully. |
|
37 * 2. - All certificates except deleted was returned by MCTWritableCertStore::List() |
|
38 * operation. |
|
39 * - All three certificates content was read successfully. |
|
40 * 3. - Certificates was returned properly. |
|
41 * - Certificates was read successfully. |
|
42 * 4. - Certs was removed and extension plugin was stopped successfully. |
|
43 * - Error was not occurred and length of the returned list was 0. |
|
44 * Postcondition: |
|
45 * All resources are freed. |
|
46 */ |
|
47 |
|
48 /** |
|
49 * TEST CASE 2: |
|
50 * Name of the test: ReadCerts, testDisablingCert |
|
51 * Purpose: |
|
52 * Verifies that certificate can be disabled. |
|
53 * This test case verifies that use case 3 works properly. |
|
54 * Precondition: |
|
55 * All existing certificates has been deleted. |
|
56 * Steps: |
|
57 * 1. Store certificate with following data to the javacert folder: |
|
58 * - enabled, can be removed, can be disabled |
|
59 * 2. Read certificates using MCTWritableCertStore::List() operation. |
|
60 * 3. Get "active" application associated to the cert by |
|
61 * MCTWritableCertStore::Applications() operation. |
|
62 * 4. Provide empty list to MCTWritableCertStore::SetApplicability() |
|
63 * operation. This illustrates that cert does not has any active application. |
|
64 * 5. Disable cert by MCTWritableCertStore::SetTrust() operation. |
|
65 * 6. Get "active" application associated to the cert by |
|
66 * MCTWritableCertStore::Applications() operation. |
|
67 * 7. Create a new CJavaCertStoreImpl object and call |
|
68 * MCTWritableCertStore::List() operation. |
|
69 * 8. Call MCTWritableCertStore::Applications() operation via CJavaCertStoreImpl |
|
70 * object created in step 7. |
|
71 * Result: |
|
72 * 1. Cert was stored successfully. |
|
73 * 2. Cert was read successfully. |
|
74 * 3. Applications() operation returns uid 0x101F9B28. |
|
75 * 4. SetApplicability() was called successfully. |
|
76 * 5. Cert was set to disabled state. |
|
77 * 6. Applications() operation returns empty list. |
|
78 * 7. List() operation returns disabled cert. |
|
79 * 8. Applications() operation returns empty list. |
|
80 * Postcondition: |
|
81 * All resources are freed. |
|
82 */ |
|
83 |
|
84 /** |
|
85 * TEST CASE 3: |
|
86 * Name of the test: ReadCerts, testEnablingCert |
|
87 * Purpose: |
|
88 * Verifies that disabled certificate can be enabled. |
|
89 * This test case verifies that use case 3 works properly. |
|
90 * Precondition: |
|
91 * All existing certificates has been deleted. |
|
92 * Steps: |
|
93 * 1. Store certificate with following data to the javacert folder: |
|
94 * - disabled, can be removed, can be disabled |
|
95 * 2. Read certificates using MCTWritableCertStore::List() operation. |
|
96 * 3. Get "active" application associated to the cert by |
|
97 * MCTWritableCertStore::Applications() operation. |
|
98 * 4. Provide 0x101F9B28 uid as argument to MCTWritableCertStore::SetApplicability() |
|
99 * operation. This illustrates that cert does one active application. |
|
100 * 5. Get "active" application associated to the cert by |
|
101 * MCTWritableCertStore::Applications() operation. |
|
102 * 6. Create a new CJavaCertStoreImpl object and call |
|
103 * MCTWritableCertStore::List() operation. |
|
104 * 7. Call MCTWritableCertStore::Applications() operation via CJavaCertStoreImpl |
|
105 * object created in step 7. |
|
106 * Result: |
|
107 * 1. Cert was stored successfully. |
|
108 * 2. Cert was read successfully. |
|
109 * 3. Applications() operation returns empty list. |
|
110 * 4. SetApplicability() was called successfully. |
|
111 * 5. Applications() operation returns uid 0x101F9B28. |
|
112 * 6. List() operation returns enabled cert. |
|
113 * 7. Applications() operation returns uid 0x101F9B28. |
|
114 * Postcondition: |
|
115 * All resources are freed. |
|
116 */ |
|
117 |
|
118 /** |
|
119 * TEST CASE 4: |
|
120 * Name of the test: ReadCerts, testDeletingCert |
|
121 * Purpose: |
|
122 * Verifies that cert can be deleted. |
|
123 * This test case verifies that use case 4 works properly. |
|
124 * Precondition: |
|
125 * All existing certificates has been deleted. |
|
126 * Steps: |
|
127 * 1. Store following certificates to the javacert folder: |
|
128 * - enabled, can be removed, can be disabled |
|
129 * - enabled, can be removed, can be disabled |
|
130 * - disabled, can be removed, can be disabled |
|
131 * 2. Read certificates using MCTWritableCertStore::List() operation. |
|
132 * 3. Remove one cert by MCTWritableCertStore::Remove() operation. |
|
133 * 4. Read certificates using MCTWritableCertStore::List() operation. |
|
134 * 5. Remove one cert by MCTWritableCertStore::Remove() operation. |
|
135 * 6. Read certificates using MCTWritableCertStore::List() operation. |
|
136 * 7. Remove last cert by MCTWritableCertStore::Remove() operation. |
|
137 * 8. Read certificates using MCTWritableCertStore::List() operation. |
|
138 * Result: |
|
139 * 1. Certs was stored successfully. |
|
140 * 2. Three certs was returned successfully. |
|
141 * 3. Cert was removed successfully. |
|
142 * 4. Two certs was returned successfully. |
|
143 * 5. Cert was removed successfully. |
|
144 * 6. One certs was returned successfully. |
|
145 * 7. Cert was removed successfully. |
|
146 * 8. Empty list was returned. |
|
147 * Postcondition: |
|
148 * All resources are freed. |
|
149 */ |
|
150 |
|
151 /** |
|
152 * TEST CASE 5: |
|
153 * Name of the test: ReadCerts, testsForValidateCertAttrFilter |
|
154 * Purpose: |
|
155 * Verifies that MCTWritableCertStore::List() operation validates |
|
156 * content of the CCertAttributeFilter object properly. |
|
157 * Precondition: |
|
158 * All existing certificates has been deleted. |
|
159 * Steps: |
|
160 * 1 - 6. Check that all relevant values of the CCertAttributeFilter object |
|
161 * is checked properly. More details information in the actual test case. |
|
162 * Result: |
|
163 * 1 - 6. Checks was done properly. |
|
164 * Postcondition: |
|
165 * All resources are freed. |
|
166 */ |
|
167 |
|
168 /** |
|
169 * TEST CASE 6: |
|
170 * Name of the test: ReadCerts, errorCasesForList |
|
171 * Purpose: |
|
172 * Verifies that MCTWritableCertStore::List() operation works properly in the |
|
173 * error cases. |
|
174 * Precondition: |
|
175 * All existing certificates has been deleted. |
|
176 * Steps: |
|
177 * 1. Call MCTWritableCertStore::List() operation twice. |
|
178 * 2. Call MCTWritableCertStore::CancelList() operation immediately after |
|
179 * MCTWritableCertStore::List() operation. |
|
180 * Result: |
|
181 * 1. Second call of List() operation fails to KErrInUse error. |
|
182 * 2. CancelList() operation cancels List() operation with KErrCancel error code. |
|
183 * Postcondition: |
|
184 * All resources are freed. |
|
185 */ |
|
186 |
|
187 /** |
|
188 * TEST CASE 7: |
|
189 * Name of the test: ReadCerts, errorCasesForAdd |
|
190 * Purpose: |
|
191 * Verifies that non-supported MCTWritableCertStore::Add() operation returns |
|
192 * KErrNotSupported all times when it is called. |
|
193 * Steps: |
|
194 * 1. Call MCTWritableCertStore::Add() operation. |
|
195 * Result: |
|
196 * 1. Add() operation returns KErrNotSupported. |
|
197 * Postcondition: |
|
198 * All resources are freed. |
|
199 */ |
|
200 |
|
201 /** |
|
202 * TEST CASE 8: |
|
203 * Name of the test: ReadCerts, errorCasesForRemove |
|
204 * Purpose: |
|
205 * Verifies that MCTWritableCertStore::Remove() operation manages error situations |
|
206 * properly. |
|
207 * Steps: |
|
208 * 1. Store following certificates to the javacert folder: |
|
209 * - enabled, can not be removed, can be disabled |
|
210 * 2. Read certificates using MCTWritableCertStore::List() operation. |
|
211 * 3. Pass CCTCertInfo object, which does not match to any cert, as argument to |
|
212 * CTWritableCertStore::Remove() operation. |
|
213 * 4. Pass CCTCertInfo object, returned by List() operation, as argument to |
|
214 * CTWritableCertStore::Remove() operation. I.e. CCTCertInfo object points to |
|
215 * non-removable cert. |
|
216 * Result: |
|
217 * 1. Cert was stored succesfully. |
|
218 * 2. Cert was read succcessfully. |
|
219 * 3. Remove() operation returns KErrArgument. |
|
220 * 4. Remove() operation returns KErrArgument. |
|
221 * Postcondition: |
|
222 * All resources are freed. |
|
223 */ |
|
224 |
|
225 /** |
|
226 * TEST CASE 9: |
|
227 * Name of the test: ReadCerts, testsForSetTrust |
|
228 * Purpose: |
|
229 * Verifies that MCTWritableCertStore::SetTrust() operation works properly in |
|
230 * all situations. |
|
231 * Steps: |
|
232 * 1. Store following certificates to the javacert folder: |
|
233 * - enabled, can not be removed, can not be disabled |
|
234 * 2. Pass CCTCertInfo object, which does not match to any cert, as argument to |
|
235 * CTWritableCertStore::SetTrust() operation. |
|
236 * 3. - Read cert using MCTWritableCertStore::List() operation. |
|
237 * 4. - Mark cert to "disable" by MCTWritableCertStore::SetApplicability() operation. |
|
238 * 5. - Try to disable cert by CTWritableCertStore::SetTrust() operation. Cert is not allowed |
|
239 * to disable. |
|
240 * Result: |
|
241 * 1. Cert was stored succesfully. |
|
242 * 2. SetTrust() operation returns KErrArgument. |
|
243 * 3. - Cert was read successfully. |
|
244 * 4. - Cert was marked successfully. |
|
245 * 5. - SetTrust() operation returns KErrArgument. |
|
246 * Postcondition: |
|
247 * All resources are freed. |
|
248 */ |
|
249 |
|
250 /** |
|
251 * TEST CASE 10: |
|
252 * Name of the test: ReadCerts, testsForGetCert |
|
253 * Purpose: |
|
254 * Verifies that non-supported MCTWritableCertStore::GetCert() operation returns proper |
|
255 * error. |
|
256 * Steps: |
|
257 * 1. Store following certificates to the javacert folder: |
|
258 * - enabled, can not be removed, can be disabled |
|
259 * 2. Try to retrieve CCTCertInfo using non-existing handle. |
|
260 * 3. Retrieve CCTCertInfo object by valid TCTTokenObjectHandle. |
|
261 * Result: |
|
262 * 1. Cert was stored succesfully. |
|
263 * 2. GetCert() operation returns KErrArgument. |
|
264 * 3. GetCert() operation returns KErrNone and returns CCTCertInfo object. |
|
265 * Postcondition: |
|
266 * All resources are freed. |
|
267 */ |
|
268 |
|
269 /** |
|
270 * TEST CASE 11: |
|
271 * Name of the test: ReadCerts, errorCasesForApplications |
|
272 * Purpose: |
|
273 * Verifies that MCTWritableCertStore::Applications() operation manages properly |
|
274 * error situations. |
|
275 * Steps: |
|
276 * 1. Pass CCTCertInfo object, which does not match to any cert, as argument to |
|
277 * CTWritableCertStore::Applications() operation. |
|
278 * Steps: |
|
279 * 1. Applications() operation returns KErrArgument. |
|
280 * Postcondition: |
|
281 * All resources are freed. |
|
282 */ |
|
283 |
|
284 /** |
|
285 * TEST CASE 12: |
|
286 * Name of the test: ReadCerts, testCasesForIsApplicable |
|
287 * Purpose: |
|
288 * Verifies that MCTWritableCertStore::IsApplicable() operation works properly. |
|
289 * Steps: |
|
290 * 1. Store following certificates to the javacert folder: |
|
291 * - disabled, can be removed, can be disabled |
|
292 * - enabled, can be removed, can be disabled |
|
293 * 2. Passing incorrect Uid as argument to MCTWritableCertStore::IsApplicable() operation. |
|
294 * 3. Pass CCTCertInfo object, which does not match to any cert, as argument to |
|
295 * CTWritableCertStore::IsApplicable() operation. |
|
296 * 4. - Read certs by MCTWritableCertStore::List() operation. |
|
297 * - Pass CCTCertInfo object, associated to disabled cert, as argument to |
|
298 * MCTWritableCertStore::IsApplicable() operation. |
|
299 * 5. - Delete disabled cert read in the step 4. |
|
300 * 6. Pass CCTCertInfo object, associated to deleted cert, as argument to |
|
301 * MCTWritableCertStore::IsApplicable() operation. |
|
302 * 7. Pass CCTCertInfo object, associated to enabled cert, as argument to |
|
303 * MCTWritableCertStore::IsApplicable() operation. |
|
304 * Result: |
|
305 * 1. Certs was stored successfully. |
|
306 * 2. IsApplicable() operation returns KErrNone. Value of the 'aIsApplicable' out |
|
307 * argument is EFalse. |
|
308 * 3. IsApplicable() operation returns KErrNone. Value of the 'aIsApplicable' out |
|
309 * argument is EFalse. |
|
310 * 4. - Cert was read successfully. |
|
311 * - IsApplicable() operation returns KErrNone. Value of the 'aIsApplicable' out |
|
312 * argument is EFalse. |
|
313 * 5. - Cert was deleted successfully. |
|
314 * 6. IsApplicable() operation returns KErrNone. Value of the 'aIsApplicable' out |
|
315 * argument is EFalse. |
|
316 * 7. IsApplicable() operation returns KErrNone. Value of the 'aIsApplicable' out |
|
317 * argument is ETrue. |
|
318 * Postcondition: |
|
319 * All resources are freed. |
|
320 */ |
|
321 |
|
322 /** |
|
323 * TEST CASE 13: |
|
324 * Name of the test: ReadCerts, testCasesForTrusted |
|
325 * Purpose: |
|
326 * Verifies that non-supported MCTWritableCertStore::Trusted() operation does not crash. |
|
327 * Steps: |
|
328 * 1. Store following certificates to the javacert folder: |
|
329 * - enabled, can be removed, can be disabled |
|
330 * 2. Passing CCTCertInfo object, which does not point to any cert, |
|
331 * as argument to Trusted() operation. |
|
332 * 3. Passing valid CCTCertInfo object as argument to Trusted() operation. |
|
333 * 4. Deleting cert. |
|
334 * 5. Call Trusted() operation to deleted cert. |
|
335 * Result: |
|
336 * 1. Cert was stored successfully. |
|
337 * 2. Trusted() operation returns KErrArgument. |
|
338 * 3. Trusted() operation returns KErrNone and sets ETrue to 'aTrusted' argument. |
|
339 * 4. Cert was deleted succesfully. |
|
340 * 5. Trusted() operation returns KErrArgument. |
|
341 * Postcondition: |
|
342 * All resources are freed. |
|
343 */ |
|
344 |
|
345 /** |
|
346 * TEST CASE 14: |
|
347 * Name of the test: ReadCerts, errorCasesForRetrieve |
|
348 * Purpose: |
|
349 * Verifies that MCTWritableCertStore::Retrieve() operation handles properly |
|
350 * error situations. |
|
351 * Steps: |
|
352 * 1. Store following certificates to the javacert folder: |
|
353 * - enabled, can be removed, can be disabled |
|
354 * - enabled, can be removed, can be disabled |
|
355 * 2. Call twice Retrieve() operation in the row. |
|
356 * 3. Pass CCTCertInfo object, which does not match to any cert, as argument to |
|
357 * Retrieve() operation. |
|
358 * Result: |
|
359 * 1. Certs was stored successfully. |
|
360 * 2. Second call of Retrieve() operation returns KErrInUse. |
|
361 * 3. Retrieve() operation returns KErrArgument. |
|
362 * Postcondition: |
|
363 * All resources are freed. |
|
364 */ |
|
365 |
|
366 /** |
|
367 * TEST CASE 15: |
|
368 * Name of the test: ReadCerts, errorCasesForSetApplicability |
|
369 * Purpose: |
|
370 * Verifies that MCTWritableCertStore::SetApplicability() operation handles properly |
|
371 * in error situations. |
|
372 * Steps: |
|
373 * 1. Store following certificate to the javacert folder: |
|
374 * - enabled, can be removed, can not be disabled |
|
375 * 2. Pass CertInfo object, as argument to SetApplicability() operation, |
|
376 * which does not match to any cert. |
|
377 * 3. Try to disable cert which cannot be disabled. |
|
378 * Result: |
|
379 * 1. Cert was stored successfully. |
|
380 * 2. SetApplicability() operation returns KErrArgument. |
|
381 * 3. SetApplicability() operation returns KErrArgument. |
|
382 * Postcondition: |
|
383 * All resources are freed. |
|
384 */ |
|
385 |
|
386 /** |
|
387 * TEST CASE 30: |
|
388 * Name of the test: TokenTests, testsForList |
|
389 * Purpose: |
|
390 * Verifies that CJavaCertStoreTokenType::List() operation works properly. |
|
391 * Steps: |
|
392 * 1. Call CJavaCertStoreTokenType::List() operation. |
|
393 * Result: |
|
394 * 1. - Check that one item is in the 'aTokens' list. |
|
395 * - Check that value of the item is "MIDP2 Trust Roots". |
|
396 * Postcondition: |
|
397 * All resources are freed. |
|
398 */ |
|
399 |
|
400 /** |
|
401 * TEST CASE 31: |
|
402 * Name of the test: TokenTests, testsForOpenToken |
|
403 * Purpose: |
|
404 * Verifies that both CJavaCertStoreTokenType::OpenToken() operation works properly. |
|
405 * Steps: |
|
406 * 1. Call CJavaCertStoreTokenType::OpenToken() operation with valid token info |
|
407 * descriptor. |
|
408 * 2. Call CJavaCertStoreTokenType::OpenToken() operation with unsupported token info |
|
409 * descriptor. |
|
410 * 3. Call unsupported CJavaCertStoreTokenType::OpenToken() operation(TCTTokenHandle version). |
|
411 * Result: |
|
412 * 1. OpenToken() operation returns MCTToken object properly. |
|
413 * 2. OpenToken() operation returns KErrNotSupported error code. |
|
414 * 3. OpenToken() operation returns KErrNotSupported error code. |
|
415 * Postcondition: |
|
416 * All resources are freed. |
|
417 */ |
|
418 |
|
419 /** |
|
420 * TEST CASE 32: |
|
421 * Name of the test: TokenTests, testsForDoGetInterface |
|
422 * Purpose: |
|
423 * Verifies that both CJavaCertStoreToken::DoGetInterface() operation works properly. |
|
424 * Steps: |
|
425 * 1. Call CJavaCertStoreToken::DoGetInterface() operation with KInterfaceCertStore uid. |
|
426 * 2. Call CJavaCertStoreToken::DoGetInterface() operation with |
|
427 * KInterfaceWritableCertStore uid. |
|
428 * 3. Call CJavaCertStoreToken::DoGetInterface() operation with unsupported uid. |
|
429 * Result: |
|
430 * 1. DoGetInterface() operation returns CJavaCertStoreImpl object. |
|
431 * 2. DoGetInterface() operation returns CJavaCertStoreImpl object. |
|
432 * 3. DoGetInterface() operation returns KErrNotSupported error code. |
|
433 * Postcondition: |
|
434 * All resources are freed. |
|
435 */ |
|
436 |
|
437 |