|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <stdio.h> |
|
19 #include <string> |
|
20 #include <memory> |
|
21 #include <unistd.h> |
|
22 #include <e32cmn.h> |
|
23 #include <e32des8.h> |
|
24 |
|
25 #include "TestHarness.h" |
|
26 #include "testexecutor.h" |
|
27 #include "securitycommsmessagedefs.h" |
|
28 #include "testdata.h" |
|
29 #include "testutils.h" |
|
30 #include "javacertstoretokentype.h" |
|
31 #include "javacertstoretoken.h" |
|
32 #include "javacertstoreimpl.h" |
|
33 #include "testfailedexception.h" |
|
34 #include "commsmsgsender.h" |
|
35 |
|
36 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
37 #include <securitydefs.h> |
|
38 #else |
|
39 #include <securitydefs.h> |
|
40 #include <securitydefsconst.h> |
|
41 #endif |
|
42 |
|
43 using namespace std; |
|
44 using namespace java::security; |
|
45 |
|
46 _LIT(KMIDP2TrustRoot, "Java Trust Root"); |
|
47 |
|
48 TEST_GROUP(ReadCerts) |
|
49 { |
|
50 TEST_SETUP() |
|
51 { |
|
52 } |
|
53 |
|
54 TEST_TEARDOWN() |
|
55 { |
|
56 } |
|
57 }; |
|
58 |
|
59 // |
|
60 // TEST CASE 1 |
|
61 // |
|
62 TEST(ReadCerts,readingCerts) |
|
63 { |
|
64 printf("+readingCerts\n"); |
|
65 |
|
66 try |
|
67 { |
|
68 //Starting java captain. |
|
69 TestUtils::StartJavaCaptain(); |
|
70 |
|
71 //Stopping javacertstore extension plugin of the java captain. |
|
72 CommsMsgSender commsMsgSender; |
|
73 commsMsgSender.SendStopJavaCertStorePlugin(); |
|
74 |
|
75 //Deleting all existing |
|
76 auto_ptr<CTestData> testData(CTestData::NewL()); |
|
77 testData->DeleteTestDataL(); |
|
78 |
|
79 //# 1 |
|
80 //Create certificates + metadata. |
|
81 list<CertMetaData> listOfCerts; |
|
82 { |
|
83 CertMetaData tmpObj(STATE_ENABLED,"enabledcert1",false,true,"1","content1"); |
|
84 listOfCerts.push_back(tmpObj); |
|
85 } |
|
86 { |
|
87 CertMetaData tmpObj(STATE_ENABLED,"enabledcert2",true,true,"2","content12"); |
|
88 listOfCerts.push_back(tmpObj); |
|
89 } |
|
90 { |
|
91 CertMetaData tmpObj(STATE_DISABLED,"disabledcert1",true,true,"3","content123"); |
|
92 listOfCerts.push_back(tmpObj); |
|
93 } |
|
94 { |
|
95 CertMetaData tmpObj(STATE_DELETED,"deletedcert1",true,true,"4","content1234"); |
|
96 listOfCerts.push_back(tmpObj); |
|
97 } |
|
98 testData->StoreTestData(listOfCerts); |
|
99 |
|
100 auto_ptr<CTestExecutor> testExecutor(new CTestExecutor()); |
|
101 auto_ptr<CJavaCertStoreTokenType> certStoreTokenType |
|
102 (static_cast<CJavaCertStoreTokenType*>(CJavaCertStoreTokenType::New2L())); |
|
103 auto_ptr<CJavaCertStoreToken> certStoreToken |
|
104 (CJavaCertStoreToken::New(0x1234,*certStoreTokenType.get())); |
|
105 auto_ptr<CJavaCertStoreImpl> certStoreObj(CJavaCertStoreImpl::NewL(*certStoreToken.get())); |
|
106 |
|
107 //# 2 |
|
108 //Reading certificates. |
|
109 { |
|
110 RMPointerArray<CCTCertInfo> certInfoArray; |
|
111 auto_ptr<CCertAttributeFilter> attrFilter(TestUtils::GetFilterObj()); |
|
112 certStoreObj->List(certInfoArray,*attrFilter.get(),testExecutor->GetRequestStatus()); |
|
113 CActiveScheduler::Start(); |
|
114 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
115 |
|
116 CHECK(3 == certInfoArray.Count()); |
|
117 TestUtils::CheckResultOfList(listOfCerts,certInfoArray); |
|
118 |
|
119 for (TInt i = 0; i < certInfoArray.Count(); i++) |
|
120 { |
|
121 auto_ptr<HBufC8> certContentBuf(HBufC8::NewL(certInfoArray[i]->Size())); |
|
122 TPtr8 certContentPtr(certContentBuf->Des()); |
|
123 certStoreObj->Retrieve(*certInfoArray[i],certContentPtr,testExecutor->GetRequestStatus()); |
|
124 testExecutor->Activate(); |
|
125 CActiveScheduler::Start(); |
|
126 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
127 TestUtils::CheckContentOfCert(listOfCerts,certContentBuf.get()); |
|
128 } |
|
129 certInfoArray.Close(); |
|
130 } |
|
131 |
|
132 //# 3 |
|
133 //Recall list() operation to check that objects are returned correctly from |
|
134 //cache memory. |
|
135 { |
|
136 RMPointerArray<CCTCertInfo> certInfoArray; |
|
137 auto_ptr<CCertAttributeFilter> attrFilter(TestUtils::GetFilterObj()); |
|
138 certStoreObj->List(certInfoArray,*attrFilter.get(),testExecutor->GetRequestStatus()); |
|
139 testExecutor->Activate(); |
|
140 CActiveScheduler::Start(); |
|
141 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
142 |
|
143 CHECK(3 == certInfoArray.Count()); |
|
144 TestUtils::CheckResultOfList(listOfCerts,certInfoArray); |
|
145 |
|
146 for (TInt i = 0; i < certInfoArray.Count(); i++) |
|
147 { |
|
148 auto_ptr<HBufC8> certContentBuf(HBufC8::NewL(certInfoArray[i]->Size())); |
|
149 TPtr8 certContentPtr(certContentBuf->Des()); |
|
150 certStoreObj->Retrieve(*certInfoArray[i],certContentPtr,testExecutor->GetRequestStatus()); |
|
151 testExecutor->Activate(); |
|
152 CActiveScheduler::Start(); |
|
153 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
154 TestUtils::CheckContentOfCert(listOfCerts,certContentBuf.get()); |
|
155 } |
|
156 certInfoArray.Close(); |
|
157 } |
|
158 |
|
159 //# 4 |
|
160 //Reading certificates in the situation when certificate folder is empty. |
|
161 { |
|
162 CommsMsgSender commsMsgSender; |
|
163 commsMsgSender.SendStopJavaCertStorePlugin(); |
|
164 sleep(2); |
|
165 testData->DeleteTestDataL(); |
|
166 RMPointerArray<CCTCertInfo> certInfoArray; |
|
167 auto_ptr<CCertAttributeFilter> attrFilter(TestUtils::GetFilterObj()); |
|
168 auto_ptr<CJavaCertStoreImpl> certStoreObj2(CJavaCertStoreImpl::NewL(*certStoreToken.get())); |
|
169 certStoreObj2->List(certInfoArray,*attrFilter.get(),testExecutor->GetRequestStatus()); |
|
170 testExecutor->Activate(); |
|
171 CActiveScheduler::Start(); |
|
172 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
173 int count = certInfoArray.Count(); |
|
174 CHECK(0 == count); |
|
175 certInfoArray.Close(); |
|
176 } |
|
177 |
|
178 printf("-readingCerts\n"); |
|
179 } |
|
180 catch (TestFailedException& ex) |
|
181 { |
|
182 printf("readingCerts() ERROR: %s",ex.toString().c_str()); |
|
183 CHECK(false); |
|
184 } |
|
185 catch (...) |
|
186 { |
|
187 printf("readingCerts() Unexpected exception caught"); |
|
188 CHECK(false); |
|
189 } |
|
190 } |
|
191 |
|
192 // |
|
193 // TEST CASE 2 |
|
194 // |
|
195 TEST(ReadCerts,testDisablingCert) |
|
196 { |
|
197 printf("+testDisablingCert\n"); |
|
198 try |
|
199 { |
|
200 //Starting java captain. |
|
201 TestUtils::StartJavaCaptain(); |
|
202 |
|
203 //Stopping javacertstore extension plugin of the java captain. |
|
204 CommsMsgSender commsMsgSender; |
|
205 commsMsgSender.SendStopJavaCertStorePlugin(); |
|
206 sleep(2); |
|
207 |
|
208 //Deleting all existing |
|
209 auto_ptr<CTestData> testData(CTestData::NewL()); |
|
210 testData->DeleteTestDataL(); |
|
211 |
|
212 //# 1 |
|
213 //Create certificates + metadata. |
|
214 list<CertMetaData> listOfCerts; |
|
215 { |
|
216 CertMetaData tmpObj(STATE_ENABLED,"enabledcert2",true,true,"2","content12"); |
|
217 listOfCerts.push_back(tmpObj); |
|
218 } |
|
219 testData->StoreTestData(listOfCerts); |
|
220 |
|
221 auto_ptr<CTestExecutor> testExecutor(new CTestExecutor()); |
|
222 auto_ptr<CJavaCertStoreTokenType> certStoreTokenType |
|
223 (static_cast<CJavaCertStoreTokenType*>(CJavaCertStoreTokenType::New2L())); |
|
224 auto_ptr<CJavaCertStoreToken> certStoreToken |
|
225 (CJavaCertStoreToken::New(0x1234,*certStoreTokenType.get())); |
|
226 |
|
227 { |
|
228 //# 2 |
|
229 //List certificates. |
|
230 auto_ptr<CJavaCertStoreImpl> certStoreObj(CJavaCertStoreImpl::NewL(*certStoreToken.get())); |
|
231 RMPointerArray<CCTCertInfo> certInfoArray; |
|
232 auto_ptr<CCertAttributeFilter> attrFilter(TestUtils::GetFilterObj()); |
|
233 certStoreObj->List(certInfoArray,*attrFilter.get(),testExecutor->GetRequestStatus()); |
|
234 CActiveScheduler::Start(); |
|
235 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
236 CHECK(1 == certInfoArray.Count()); |
|
237 |
|
238 //# 3 |
|
239 //Getting apps associated to certificate. |
|
240 RArray<TUid> uidList; |
|
241 certStoreObj->Applications(*certInfoArray[0],uidList,testExecutor->GetRequestStatus()); |
|
242 testExecutor->Activate(); |
|
243 CActiveScheduler::Start(); |
|
244 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
245 CHECK(1 == uidList.Count()); |
|
246 CHECK(KMidletInstallApplicabilityUid == uidList[0]); |
|
247 uidList.Close(); |
|
248 |
|
249 //# 4 |
|
250 //Providing list of active apps to plugin by SetApplicability() operation. |
|
251 //List is empty in the disabling case. |
|
252 RArray<TUid> uidList2; |
|
253 certStoreObj->SetApplicability(*certInfoArray[0],uidList2,testExecutor->GetRequestStatus()); |
|
254 testExecutor->Activate(); |
|
255 CActiveScheduler::Start(); |
|
256 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
257 uidList2.Close(); |
|
258 |
|
259 //# 5 |
|
260 //Disabling certificate in the cert store by SetTrust() operation. |
|
261 certStoreObj->SetTrust(*certInfoArray[0],ETrue,testExecutor->GetRequestStatus()); |
|
262 testExecutor->Activate(); |
|
263 CActiveScheduler::Start(); |
|
264 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
265 |
|
266 //# 6 |
|
267 //Verfying that Applications() operation returns empty list after disabling. |
|
268 RArray<TUid> uidList3; |
|
269 certStoreObj->Applications(*certInfoArray[0],uidList3,testExecutor->GetRequestStatus()); |
|
270 testExecutor->Activate(); |
|
271 CActiveScheduler::Start(); |
|
272 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
273 CHECK(0 == uidList3.Count()); |
|
274 certInfoArray.Close(); |
|
275 uidList3.Close(); |
|
276 } |
|
277 |
|
278 { |
|
279 //# 7 |
|
280 //Retrieve certificates through a new CJavaCertStoreImpl object. |
|
281 auto_ptr<CJavaCertStoreImpl> certStoreObj(CJavaCertStoreImpl::NewL(*certStoreToken.get())); |
|
282 RMPointerArray<CCTCertInfo> certInfoArray; |
|
283 auto_ptr<CCertAttributeFilter> attrFilter(TestUtils::GetFilterObj()); |
|
284 certStoreObj->List(certInfoArray,*attrFilter.get(),testExecutor->GetRequestStatus()); |
|
285 testExecutor->Activate(); |
|
286 CActiveScheduler::Start(); |
|
287 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
288 CHECK(1 == certInfoArray.Count()); |
|
289 |
|
290 //# 8 |
|
291 //Check that Applications() operation returns empty list. |
|
292 RArray<TUid> uidList; |
|
293 certStoreObj->Applications(*certInfoArray[0],uidList,testExecutor->GetRequestStatus()); |
|
294 testExecutor->Activate(); |
|
295 CActiveScheduler::Start(); |
|
296 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
297 CHECK(0 == uidList.Count()); |
|
298 certInfoArray.Close(); |
|
299 uidList.Close(); |
|
300 } |
|
301 |
|
302 printf("-testDisablingCert\n"); |
|
303 } |
|
304 catch (TestFailedException& ex) |
|
305 { |
|
306 printf("testDisablingCert() ERROR: %s",ex.toString().c_str()); |
|
307 CHECK(false); |
|
308 } |
|
309 catch (...) |
|
310 { |
|
311 printf("testDisablingCert() Unexpected exception caught"); |
|
312 CHECK(false); |
|
313 } |
|
314 } |
|
315 |
|
316 // |
|
317 // TEST CASE 3 |
|
318 // |
|
319 TEST(ReadCerts,testEnablingCert) |
|
320 { |
|
321 printf("+testEnablingCert\n"); |
|
322 try |
|
323 { |
|
324 //Starting java captain. |
|
325 TestUtils::StartJavaCaptain(); |
|
326 |
|
327 //Stopping javacertstore extension plugin of the java captain. |
|
328 CommsMsgSender commsMsgSender; |
|
329 commsMsgSender.SendStopJavaCertStorePlugin(); |
|
330 sleep(2); |
|
331 |
|
332 //Deleting all existing |
|
333 auto_ptr<CTestData> testData(CTestData::NewL()); |
|
334 testData->DeleteTestDataL(); |
|
335 |
|
336 //# 1 |
|
337 //Create certificates + metadata. |
|
338 list<CertMetaData> listOfCerts; |
|
339 { |
|
340 CertMetaData tmpObj(STATE_DISABLED,"enabledcert2",true,true,"2","content12"); |
|
341 listOfCerts.push_back(tmpObj); |
|
342 } |
|
343 testData->StoreTestData(listOfCerts); |
|
344 |
|
345 auto_ptr<CTestExecutor> testExecutor(new CTestExecutor()); |
|
346 auto_ptr<CJavaCertStoreTokenType> certStoreTokenType |
|
347 (static_cast<CJavaCertStoreTokenType*>(CJavaCertStoreTokenType::New2L())); |
|
348 auto_ptr<CJavaCertStoreToken> certStoreToken |
|
349 (CJavaCertStoreToken::New(0x1234,*certStoreTokenType.get())); |
|
350 |
|
351 { |
|
352 //# 2 |
|
353 //List certificates. |
|
354 auto_ptr<CJavaCertStoreImpl> certStoreObj(CJavaCertStoreImpl::NewL(*certStoreToken.get())); |
|
355 RMPointerArray<CCTCertInfo> certInfoArray; |
|
356 auto_ptr<CCertAttributeFilter> attrFilter(TestUtils::GetFilterObj()); |
|
357 certStoreObj->List(certInfoArray,*attrFilter.get(),testExecutor->GetRequestStatus()); |
|
358 CActiveScheduler::Start(); |
|
359 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
360 CHECK(1 == certInfoArray.Count()); |
|
361 |
|
362 //# 3 |
|
363 //Getting apps associated to certificate. Returned list is empty because only cert |
|
364 //has been already disabled. |
|
365 RArray<TUid> uidList; |
|
366 certStoreObj->Applications(*certInfoArray[0],uidList,testExecutor->GetRequestStatus()); |
|
367 testExecutor->Activate(); |
|
368 CActiveScheduler::Start(); |
|
369 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
370 CHECK(0 == uidList.Count()); |
|
371 uidList.Close(); |
|
372 |
|
373 //# 4 |
|
374 //Providing list of active apps to plugin by SetApplicability() operation. |
|
375 RArray<TUid> uidList2; |
|
376 uidList2.Append(KMidletInstallApplicabilityUid); |
|
377 certStoreObj->SetApplicability(*certInfoArray[0],uidList2,testExecutor->GetRequestStatus()); |
|
378 testExecutor->Activate(); |
|
379 CActiveScheduler::Start(); |
|
380 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
381 uidList2.Close(); |
|
382 |
|
383 //# 5 |
|
384 //Verifing that Applications() operation appends active app to the list after enabling. |
|
385 RArray<TUid> uidList3; |
|
386 certStoreObj->Applications(*certInfoArray[0],uidList3,testExecutor->GetRequestStatus()); |
|
387 testExecutor->Activate(); |
|
388 CActiveScheduler::Start(); |
|
389 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
390 CHECK(1 == uidList3.Count()); |
|
391 CHECK(KMidletInstallApplicabilityUid == uidList3[0]); |
|
392 certInfoArray.Close(); |
|
393 uidList3.Close(); |
|
394 } |
|
395 |
|
396 { |
|
397 //# 6 |
|
398 //Retrieve certificates through new CJavaCertStoreImpl object. |
|
399 auto_ptr<CJavaCertStoreImpl> certStoreObj(CJavaCertStoreImpl::NewL(*certStoreToken.get())); |
|
400 RMPointerArray<CCTCertInfo> certInfoArray; |
|
401 auto_ptr<CCertAttributeFilter> attrFilter(TestUtils::GetFilterObj()); |
|
402 certStoreObj->List(certInfoArray,*attrFilter.get(),testExecutor->GetRequestStatus()); |
|
403 testExecutor->Activate(); |
|
404 CActiveScheduler::Start(); |
|
405 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
406 CHECK(1 == certInfoArray.Count()); |
|
407 |
|
408 //# 7 |
|
409 //Check that Applications() operation appends active app to the list. |
|
410 RArray<TUid> uidList; |
|
411 certStoreObj->Applications(*certInfoArray[0],uidList,testExecutor->GetRequestStatus()); |
|
412 testExecutor->Activate(); |
|
413 CActiveScheduler::Start(); |
|
414 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
415 CHECK(1 == uidList.Count()); |
|
416 CHECK(KMidletInstallApplicabilityUid == uidList[0]); |
|
417 certInfoArray.Close(); |
|
418 uidList.Close(); |
|
419 } |
|
420 |
|
421 printf("-testEnablingCert\n"); |
|
422 } |
|
423 catch (TestFailedException& ex) |
|
424 { |
|
425 printf("testEnablingCert() ERROR: %s",ex.toString().c_str()); |
|
426 CHECK(false); |
|
427 } |
|
428 catch (...) |
|
429 { |
|
430 printf("testEnablingCert() Unexpected exception caught"); |
|
431 CHECK(false); |
|
432 } |
|
433 } |
|
434 |
|
435 // |
|
436 // TEST CASE 4 |
|
437 // |
|
438 TEST(ReadCerts,testDeletingCert) |
|
439 { |
|
440 printf("+testDeletingCert\n"); |
|
441 try |
|
442 { |
|
443 //Starting java captain. |
|
444 TestUtils::StartJavaCaptain(); |
|
445 |
|
446 //Stopping javacertstore extension plugin of the java captain. |
|
447 CommsMsgSender commsMsgSender; |
|
448 commsMsgSender.SendStopJavaCertStorePlugin(); |
|
449 sleep(2); |
|
450 |
|
451 //Deleting all existing |
|
452 auto_ptr<CTestData> testData(CTestData::NewL()); |
|
453 testData->DeleteTestDataL(); |
|
454 |
|
455 //# 1 |
|
456 //Create certificates + metadata. |
|
457 list<CertMetaData> listOfCerts; |
|
458 { |
|
459 CertMetaData tmpObj(STATE_ENABLED,"enabledcert1",true,true,"1","content1"); |
|
460 listOfCerts.push_back(tmpObj); |
|
461 } |
|
462 { |
|
463 CertMetaData tmpObj(STATE_ENABLED,"enabledcert2",true,true,"2","content12"); |
|
464 listOfCerts.push_back(tmpObj); |
|
465 } |
|
466 { |
|
467 CertMetaData tmpObj(STATE_DISABLED,"disabledcert1",true,true,"3","content123"); |
|
468 listOfCerts.push_back(tmpObj); |
|
469 } |
|
470 testData->StoreTestData(listOfCerts); |
|
471 |
|
472 auto_ptr<CTestExecutor> testExecutor(new CTestExecutor()); |
|
473 auto_ptr<CJavaCertStoreTokenType> certStoreTokenType |
|
474 (static_cast<CJavaCertStoreTokenType*>(CJavaCertStoreTokenType::New2L())); |
|
475 auto_ptr<CJavaCertStoreToken> certStoreToken |
|
476 (CJavaCertStoreToken::New(0x1234,*certStoreTokenType.get())); |
|
477 |
|
478 { |
|
479 //# 2 |
|
480 //List certificates. |
|
481 auto_ptr<CJavaCertStoreImpl> certStoreObj(CJavaCertStoreImpl::NewL(*certStoreToken.get())); |
|
482 RMPointerArray<CCTCertInfo> certInfoArray; |
|
483 auto_ptr<CCertAttributeFilter> attrFilter(TestUtils::GetFilterObj()); |
|
484 certStoreObj->List(certInfoArray,*attrFilter.get(),testExecutor->GetRequestStatus()); |
|
485 CActiveScheduler::Start(); |
|
486 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
487 CHECK(3 == certInfoArray.Count()); |
|
488 |
|
489 //# 3 |
|
490 //Remove first cert. |
|
491 certStoreObj->Remove(*certInfoArray[0],testExecutor->GetRequestStatus()); |
|
492 testExecutor->Activate(); |
|
493 CActiveScheduler::Start(); |
|
494 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
495 certInfoArray.Close(); |
|
496 |
|
497 //# 4 |
|
498 //List certificates. Only two should be returned by List() operation. |
|
499 //certInfoArray.ResetAndDestroy(); |
|
500 RMPointerArray<CCTCertInfo> certInfoArray2; |
|
501 certStoreObj->List(certInfoArray2,*attrFilter.get(),testExecutor->GetRequestStatus()); |
|
502 testExecutor->Activate(); |
|
503 CActiveScheduler::Start(); |
|
504 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
505 CHECK(2 == certInfoArray2.Count()); |
|
506 |
|
507 //# 5 |
|
508 //Remove second cert. |
|
509 certStoreObj->Remove(*certInfoArray2[0],testExecutor->GetRequestStatus()); |
|
510 testExecutor->Activate(); |
|
511 CActiveScheduler::Start(); |
|
512 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
513 certInfoArray2.Close(); |
|
514 |
|
515 //# 6 |
|
516 //List certificates. Only one should be returned by List() operation. |
|
517 //certInfoArray.ResetAndDestroy(); |
|
518 RMPointerArray<CCTCertInfo> certInfoArray3; |
|
519 certStoreObj->List(certInfoArray3,*attrFilter.get(),testExecutor->GetRequestStatus()); |
|
520 testExecutor->Activate(); |
|
521 CActiveScheduler::Start(); |
|
522 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
523 CHECK(1 == certInfoArray3.Count()); |
|
524 |
|
525 //# 7 |
|
526 //Remove last cert. |
|
527 certStoreObj->Remove(*certInfoArray3[0],testExecutor->GetRequestStatus()); |
|
528 testExecutor->Activate(); |
|
529 CActiveScheduler::Start(); |
|
530 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
531 certInfoArray3.Close(); |
|
532 |
|
533 //# 8 |
|
534 //List certificates. Only one should be returned by List() operation. |
|
535 //certInfoArray.ResetAndDestroy(); |
|
536 RMPointerArray<CCTCertInfo> certInfoArray4; |
|
537 certStoreObj->List(certInfoArray4,*attrFilter.get(),testExecutor->GetRequestStatus()); |
|
538 testExecutor->Activate(); |
|
539 CActiveScheduler::Start(); |
|
540 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
541 CHECK(0 == certInfoArray4.Count()); |
|
542 certInfoArray4.Close(); |
|
543 } |
|
544 |
|
545 printf("-testDeletingCert\n"); |
|
546 } |
|
547 catch (TestFailedException& ex) |
|
548 { |
|
549 printf("testDeletingCert() ERROR: %s",ex.toString().c_str()); |
|
550 CHECK(false); |
|
551 } |
|
552 catch (...) |
|
553 { |
|
554 printf("testDeletingCert() Unexpected exception caught"); |
|
555 CHECK(false); |
|
556 } |
|
557 } |
|
558 |
|
559 // |
|
560 // TEST CASE 5 |
|
561 // |
|
562 TEST(ReadCerts,testsForValidateCertAttrFilter) |
|
563 { |
|
564 printf("+testsForValidateCertAttrFilter\n"); |
|
565 try |
|
566 { |
|
567 //Starting java captain. |
|
568 TestUtils::StartJavaCaptain(); |
|
569 |
|
570 //Stopping javacertstore extension plugin of the java captain. |
|
571 CommsMsgSender commsMsgSender; |
|
572 commsMsgSender.SendStopJavaCertStorePlugin(); |
|
573 sleep(2); |
|
574 |
|
575 //Deleting all existing |
|
576 auto_ptr<CTestData> testData(CTestData::NewL()); |
|
577 testData->DeleteTestDataL(); |
|
578 |
|
579 auto_ptr<CTestExecutor> testExecutor(new CTestExecutor()); |
|
580 auto_ptr<CJavaCertStoreTokenType> certStoreTokenType |
|
581 (static_cast<CJavaCertStoreTokenType*>(CJavaCertStoreTokenType::New2L())); |
|
582 auto_ptr<CJavaCertStoreToken> certStoreToken |
|
583 (CJavaCertStoreToken::New(0x1234,*certStoreTokenType.get())); |
|
584 auto_ptr<CJavaCertStoreImpl> certStoreObj(CJavaCertStoreImpl::NewL(*certStoreToken.get())); |
|
585 |
|
586 //# 1 |
|
587 //Not supported uid(0x101F9B29). |
|
588 { |
|
589 RMPointerArray<CCTCertInfo> certInfoArray; |
|
590 std::auto_ptr< CCertAttributeFilter> filterObj(CCertAttributeFilter::NewL()); |
|
591 TUid uid = TUid::Uid(0x101F9B29); |
|
592 filterObj->SetUid(uid); |
|
593 filterObj->SetFormat(EX509Certificate); |
|
594 filterObj->SetOwnerType(ECACertificate); |
|
595 filterObj->SetLabel(KMIDP2TrustRoot()); |
|
596 certStoreObj->List(certInfoArray,*filterObj.get(),testExecutor->GetRequestStatus()); |
|
597 CActiveScheduler::Start(); |
|
598 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
599 CHECK(0 == certInfoArray.Count()); |
|
600 certInfoArray.Close(); |
|
601 } |
|
602 |
|
603 //# 2 |
|
604 //Not supported certificate format(EWTLSCertificate). |
|
605 { |
|
606 RMPointerArray<CCTCertInfo> certInfoArray; |
|
607 std::auto_ptr< CCertAttributeFilter> filterObj(CCertAttributeFilter::NewL()); |
|
608 filterObj->SetUid(KMidletInstallApplicabilityUid); |
|
609 filterObj->SetFormat(EWTLSCertificate); |
|
610 filterObj->SetOwnerType(ECACertificate); |
|
611 filterObj->SetLabel(KMIDP2TrustRoot()); |
|
612 certStoreObj->List(certInfoArray,*filterObj.get(),testExecutor->GetRequestStatus()); |
|
613 testExecutor->Activate(); |
|
614 CActiveScheduler::Start(); |
|
615 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
616 CHECK(0 == certInfoArray.Count()); |
|
617 certInfoArray.Close(); |
|
618 } |
|
619 |
|
620 //# 3 |
|
621 //Not supported owner type(EUserCertificate). |
|
622 { |
|
623 RMPointerArray<CCTCertInfo> certInfoArray; |
|
624 std::auto_ptr< CCertAttributeFilter> filterObj(CCertAttributeFilter::NewL()); |
|
625 filterObj->SetUid(KMidletInstallApplicabilityUid); |
|
626 filterObj->SetFormat(EX509Certificate); |
|
627 filterObj->SetOwnerType(EUserCertificate); |
|
628 filterObj->SetLabel(KMIDP2TrustRoot()); |
|
629 certStoreObj->List(certInfoArray,*filterObj.get(),testExecutor->GetRequestStatus()); |
|
630 testExecutor->Activate(); |
|
631 CActiveScheduler::Start(); |
|
632 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
633 CHECK(0 == certInfoArray.Count()); |
|
634 certInfoArray.Close(); |
|
635 } |
|
636 |
|
637 //# 4 |
|
638 //Adding subject key to filter object. |
|
639 { |
|
640 RMPointerArray<CCTCertInfo> certInfoArray; |
|
641 std::auto_ptr< CCertAttributeFilter> filterObj(CCertAttributeFilter::NewL()); |
|
642 filterObj->SetUid(KMidletInstallApplicabilityUid); |
|
643 filterObj->SetFormat(EX509Certificate); |
|
644 filterObj->SetOwnerType(ECACertificate); |
|
645 filterObj->SetLabel(KMIDP2TrustRoot()); |
|
646 TKeyIdentifier keyIdent = _L8("blaah"); |
|
647 filterObj->SetSubjectKeyId(keyIdent); |
|
648 certStoreObj->List(certInfoArray,*filterObj.get(),testExecutor->GetRequestStatus()); |
|
649 testExecutor->Activate(); |
|
650 CActiveScheduler::Start(); |
|
651 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
652 CHECK(0 == certInfoArray.Count()); |
|
653 certInfoArray.Close(); |
|
654 } |
|
655 |
|
656 //# 5 |
|
657 //Adding issuer key to filter object. |
|
658 { |
|
659 RMPointerArray<CCTCertInfo> certInfoArray; |
|
660 std::auto_ptr< CCertAttributeFilter> filterObj(CCertAttributeFilter::NewL()); |
|
661 filterObj->SetUid(KMidletInstallApplicabilityUid); |
|
662 filterObj->SetFormat(EX509Certificate); |
|
663 filterObj->SetOwnerType(ECACertificate); |
|
664 filterObj->SetLabel(KMIDP2TrustRoot()); |
|
665 TKeyIdentifier keyIdent = _L8("blaah"); |
|
666 filterObj->SetIssuerKeyId(keyIdent); |
|
667 certStoreObj->List(certInfoArray,*filterObj.get(),testExecutor->GetRequestStatus()); |
|
668 testExecutor->Activate(); |
|
669 CActiveScheduler::Start(); |
|
670 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
671 CHECK(0 == certInfoArray.Count()); |
|
672 certInfoArray.Close(); |
|
673 } |
|
674 |
|
675 //# 6 |
|
676 //Not supported label. |
|
677 { |
|
678 RMPointerArray<CCTCertInfo> certInfoArray; |
|
679 std::auto_ptr< CCertAttributeFilter> filterObj(CCertAttributeFilter::NewL()); |
|
680 filterObj->SetUid(KMidletInstallApplicabilityUid); |
|
681 filterObj->SetFormat(EX509Certificate); |
|
682 filterObj->SetOwnerType(ECACertificate); |
|
683 filterObj->SetLabel(_L("blaah")); |
|
684 certStoreObj->List(certInfoArray,*filterObj.get(),testExecutor->GetRequestStatus()); |
|
685 testExecutor->Activate(); |
|
686 CActiveScheduler::Start(); |
|
687 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
688 CHECK(0 == certInfoArray.Count()); |
|
689 certInfoArray.Close(); |
|
690 } |
|
691 |
|
692 printf("-testsForValidateCertAttrFilter\n"); |
|
693 } |
|
694 catch (TestFailedException& ex) |
|
695 { |
|
696 printf("testsForValidateCertAttrFilter() ERROR: %s",ex.toString().c_str()); |
|
697 CHECK(false); |
|
698 } |
|
699 catch (...) |
|
700 { |
|
701 printf("testsForValidateCertAttrFilter() Unexpected exception caught"); |
|
702 CHECK(false); |
|
703 } |
|
704 } |
|
705 |
|
706 // |
|
707 // TEST CASE 6 |
|
708 // |
|
709 TEST(ReadCerts,errorCasesForList) |
|
710 { |
|
711 printf("+errorCasesForList\n"); |
|
712 try |
|
713 { |
|
714 //Starting java captain. |
|
715 TestUtils::StartJavaCaptain(); |
|
716 |
|
717 //Stopping javacertstore extension plugin of the java captain. |
|
718 CommsMsgSender commsMsgSender; |
|
719 commsMsgSender.SendStopJavaCertStorePlugin(); |
|
720 sleep(2); |
|
721 |
|
722 //Deleting all existing |
|
723 auto_ptr<CTestData> testData(CTestData::NewL()); |
|
724 testData->DeleteTestDataL(); |
|
725 |
|
726 auto_ptr<CTestExecutor> testExecutor(new CTestExecutor()); |
|
727 auto_ptr<CJavaCertStoreTokenType> certStoreTokenType |
|
728 (static_cast<CJavaCertStoreTokenType*>(CJavaCertStoreTokenType::New2L())); |
|
729 auto_ptr<CJavaCertStoreToken> certStoreToken |
|
730 (CJavaCertStoreToken::New(0x1234,*certStoreTokenType.get())); |
|
731 auto_ptr<CJavaCertStoreImpl> certStoreObj(CJavaCertStoreImpl::NewL(*certStoreToken.get())); |
|
732 auto_ptr<CCertAttributeFilter> attrFilter(TestUtils::GetFilterObj()); |
|
733 |
|
734 { |
|
735 //# 1 |
|
736 //Calling List() operation two times in the row. |
|
737 RMPointerArray<CCTCertInfo> certInfoArray1; |
|
738 RMPointerArray<CCTCertInfo> certInfoArray2; |
|
739 auto_ptr<CTestExecutor> testExecutor2(new CTestExecutor()); |
|
740 certStoreObj->List(certInfoArray1,*attrFilter.get(),testExecutor2->GetRequestStatus()); |
|
741 auto_ptr<CTestExecutor> testExecutor3(new CTestExecutor()); |
|
742 certStoreObj->List(certInfoArray2,*attrFilter.get(),testExecutor3->GetRequestStatus()); |
|
743 certStoreObj->CancelList(); |
|
744 certInfoArray1.Close(); |
|
745 certInfoArray2.Close(); |
|
746 } |
|
747 |
|
748 { |
|
749 //# 2 |
|
750 //Calling CancelList() immediately after List() operation. |
|
751 RMPointerArray<CCTCertInfo> certInfoArray1; |
|
752 certStoreObj->List(certInfoArray1,*attrFilter.get(),testExecutor->GetRequestStatus()); |
|
753 certStoreObj->CancelList(); |
|
754 CActiveScheduler::Start(); |
|
755 CHECK(KErrCancel == testExecutor->GetErrorCode()); |
|
756 certInfoArray1.Close(); |
|
757 } |
|
758 |
|
759 printf("-errorCasesForList\n"); |
|
760 } |
|
761 catch (TestFailedException& ex) |
|
762 { |
|
763 printf("errorCasesForList() ERROR: %s",ex.toString().c_str()); |
|
764 CHECK(false); |
|
765 } |
|
766 catch (...) |
|
767 { |
|
768 printf("errorCasesForList() Unexpected exception caught"); |
|
769 CHECK(false); |
|
770 } |
|
771 } |
|
772 |
|
773 // |
|
774 // TEST CASE 7 |
|
775 // |
|
776 TEST(ReadCerts,errorCasesForAdd) |
|
777 { |
|
778 printf("+errorCasesForAdd\n"); |
|
779 try |
|
780 { |
|
781 //Starting java captain. |
|
782 TestUtils::StartJavaCaptain(); |
|
783 |
|
784 //Stopping javacertstore extension plugin of the java captain. |
|
785 CommsMsgSender commsMsgSender; |
|
786 commsMsgSender.SendStopJavaCertStorePlugin(); |
|
787 sleep(2); |
|
788 |
|
789 //Deleting all existing |
|
790 auto_ptr<CTestData> testData(CTestData::NewL()); |
|
791 testData->DeleteTestDataL(); |
|
792 |
|
793 auto_ptr<CTestExecutor> testExecutor(new CTestExecutor()); |
|
794 auto_ptr<CJavaCertStoreTokenType> certStoreTokenType |
|
795 (static_cast<CJavaCertStoreTokenType*>(CJavaCertStoreTokenType::New2L())); |
|
796 auto_ptr<CJavaCertStoreToken> certStoreToken |
|
797 (CJavaCertStoreToken::New(0x1234,*certStoreTokenType.get())); |
|
798 auto_ptr<CJavaCertStoreImpl> certStoreObj(CJavaCertStoreImpl::NewL(*certStoreToken.get())); |
|
799 auto_ptr<CCertAttributeFilter> attrFilter(TestUtils::GetFilterObj()); |
|
800 |
|
801 { |
|
802 //# 1 |
|
803 //Calling not supported Add() operation. |
|
804 certStoreObj->Add(_L("someLabel"),EX509Certificate,ECACertificate,NULL,NULL,_L8("some"), |
|
805 testExecutor->GetRequestStatus()); |
|
806 CActiveScheduler::Start(); |
|
807 CHECK(KErrNotSupported == testExecutor->GetErrorCode()); |
|
808 } |
|
809 |
|
810 printf("-errorCasesForAdd\n"); |
|
811 } |
|
812 catch (TestFailedException& ex) |
|
813 { |
|
814 printf("errorCasesForAdd() ERROR: %s",ex.toString().c_str()); |
|
815 CHECK(false); |
|
816 } |
|
817 catch (...) |
|
818 { |
|
819 printf("errorCasesForAdd() Unexpected exception caught"); |
|
820 CHECK(false); |
|
821 } |
|
822 } |
|
823 |
|
824 // |
|
825 // TEST CASE 8 |
|
826 // |
|
827 TEST(ReadCerts,errorCasesForRemove) |
|
828 { |
|
829 printf("+errorCasesForRemove\n"); |
|
830 try |
|
831 { |
|
832 //Starting java captain. |
|
833 TestUtils::StartJavaCaptain(); |
|
834 |
|
835 //Stopping javacertstore extension plugin of the java captain. |
|
836 CommsMsgSender commsMsgSender; |
|
837 commsMsgSender.SendStopJavaCertStorePlugin(); |
|
838 sleep(2); |
|
839 |
|
840 //Deleting all existing |
|
841 auto_ptr<CTestData> testData(CTestData::NewL()); |
|
842 testData->DeleteTestDataL(); |
|
843 |
|
844 //# 1 |
|
845 //Create certificates + metadata. |
|
846 list<CertMetaData> listOfCerts; |
|
847 { |
|
848 CertMetaData tmpObj(STATE_ENABLED,"enabledcert1",false,true,"1","content1"); |
|
849 listOfCerts.push_back(tmpObj); |
|
850 } |
|
851 testData->StoreTestData(listOfCerts); |
|
852 |
|
853 auto_ptr<CTestExecutor> testExecutor(new CTestExecutor()); |
|
854 auto_ptr<CJavaCertStoreTokenType> certStoreTokenType |
|
855 (static_cast<CJavaCertStoreTokenType*>(CJavaCertStoreTokenType::New2L())); |
|
856 auto_ptr<CJavaCertStoreToken> certStoreToken |
|
857 (CJavaCertStoreToken::New(0x1234,*certStoreTokenType.get())); |
|
858 auto_ptr<CJavaCertStoreImpl> certStoreObj(CJavaCertStoreImpl::NewL(*certStoreToken.get())); |
|
859 auto_ptr<CCertAttributeFilter> attrFilter(TestUtils::GetFilterObj()); |
|
860 |
|
861 RMPointerArray<CCTCertInfo> certInfoArray; |
|
862 { |
|
863 //# 2 |
|
864 //List certificates. |
|
865 certStoreObj->List(certInfoArray,*attrFilter.get(),testExecutor->GetRequestStatus()); |
|
866 CActiveScheduler::Start(); |
|
867 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
868 CHECK(1 == certInfoArray.Count()); |
|
869 } |
|
870 |
|
871 { |
|
872 //# 3 |
|
873 //Passing CCTCertInfo object, which does not match to any cert, as argument to |
|
874 //Remove() operation. |
|
875 CCTCertInfo* certInfo(CCTCertInfo::NewL(KMIDP2TrustRoot,EX509Certificate, |
|
876 ECACertificate,10,NULL,NULL, |
|
877 certStoreObj->Token(),2,true)); |
|
878 certStoreObj->Remove(*certInfo,testExecutor->GetRequestStatus()); |
|
879 testExecutor->Activate(); |
|
880 CActiveScheduler::Start(); |
|
881 CHECK(KErrArgument == testExecutor->GetErrorCode()); |
|
882 certInfo->Release(); |
|
883 } |
|
884 |
|
885 { |
|
886 //# 4 |
|
887 //Passing CCTCertInfo object, which points to non-deletable, as argument to |
|
888 //Remove() operation. |
|
889 certStoreObj->Remove(*certInfoArray[0],testExecutor->GetRequestStatus()); |
|
890 testExecutor->Activate(); |
|
891 CActiveScheduler::Start(); |
|
892 CHECK(KErrArgument == testExecutor->GetErrorCode()); |
|
893 } |
|
894 certInfoArray.Close(); |
|
895 |
|
896 printf("-errorCasesForRemove\n"); |
|
897 } |
|
898 catch (TestFailedException& ex) |
|
899 { |
|
900 printf("errorCasesForRemove() ERROR: %s",ex.toString().c_str()); |
|
901 CHECK(false); |
|
902 } |
|
903 catch (...) |
|
904 { |
|
905 printf("errorCasesForRemove() Unexpected exception caught"); |
|
906 CHECK(false); |
|
907 } |
|
908 } |
|
909 |
|
910 // |
|
911 // TEST CASE 9 |
|
912 // |
|
913 TEST(ReadCerts,testsForSetTrust) |
|
914 { |
|
915 printf("+testsForSetTrust\n"); |
|
916 |
|
917 try |
|
918 { |
|
919 //Starting java captain. |
|
920 TestUtils::StartJavaCaptain(); |
|
921 |
|
922 //Stopping javacertstore extension plugin of the java captain. |
|
923 CommsMsgSender commsMsgSender; |
|
924 commsMsgSender.SendStopJavaCertStorePlugin(); |
|
925 sleep(2); |
|
926 |
|
927 //Deleting all existing |
|
928 auto_ptr<CTestData> testData(CTestData::NewL()); |
|
929 testData->DeleteTestDataL(); |
|
930 |
|
931 //# 1 |
|
932 //Create certificates + metadata. |
|
933 list<CertMetaData> listOfCerts; |
|
934 { |
|
935 CertMetaData tmpObj(STATE_ENABLED,"enabledcert1",true,false,"1","content1"); |
|
936 listOfCerts.push_back(tmpObj); |
|
937 } |
|
938 testData->StoreTestData(listOfCerts); |
|
939 |
|
940 auto_ptr<CTestExecutor> testExecutor(new CTestExecutor()); |
|
941 auto_ptr<CJavaCertStoreTokenType> certStoreTokenType |
|
942 (static_cast<CJavaCertStoreTokenType*>(CJavaCertStoreTokenType::New2L())); |
|
943 auto_ptr<CJavaCertStoreToken> certStoreToken |
|
944 (CJavaCertStoreToken::New(0x1234,*certStoreTokenType.get())); |
|
945 auto_ptr<CJavaCertStoreImpl> certStoreObj(CJavaCertStoreImpl::NewL(*certStoreToken.get())); |
|
946 auto_ptr<CCertAttributeFilter> attrFilter(TestUtils::GetFilterObj()); |
|
947 |
|
948 { |
|
949 //# 2 |
|
950 //Passing CCTCertInfo object, which does not match to any cert, as argument to |
|
951 //SetTrust() operation. |
|
952 CCTCertInfo* certInfo(CCTCertInfo::NewL(KMIDP2TrustRoot,EX509Certificate, |
|
953 ECACertificate,10,NULL,NULL, |
|
954 certStoreObj->Token(),2,true)); |
|
955 certStoreObj->SetTrust(*certInfo,ETrue,testExecutor->GetRequestStatus()); |
|
956 CActiveScheduler::Start(); |
|
957 CHECK(KErrArgument == testExecutor->GetErrorCode()); |
|
958 certInfo->Release(); |
|
959 } |
|
960 |
|
961 { |
|
962 //# 3 |
|
963 //Try to set trusted cert to non-trusted. |
|
964 ////Try to disable cert which is not allowed to disable. |
|
965 RMPointerArray<CCTCertInfo> certInfoArray; |
|
966 certStoreObj->List(certInfoArray,*attrFilter.get(),testExecutor->GetRequestStatus()); |
|
967 testExecutor->Activate(); |
|
968 CActiveScheduler::Start(); |
|
969 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
970 CHECK(1 == certInfoArray.Count()); |
|
971 |
|
972 certStoreObj->SetTrust(*certInfoArray[0],EFalse,testExecutor->GetRequestStatus()); |
|
973 testExecutor->Activate(); |
|
974 CActiveScheduler::Start(); |
|
975 CHECK(KErrArgument == testExecutor->GetErrorCode()); |
|
976 certInfoArray.Close(); |
|
977 } |
|
978 |
|
979 printf("-testsForSetTrust\n"); |
|
980 } |
|
981 catch (TestFailedException& ex) |
|
982 { |
|
983 printf("testsForSetTrust() ERROR: %s",ex.toString().c_str()); |
|
984 CHECK(false); |
|
985 } |
|
986 catch (...) |
|
987 { |
|
988 printf("testsForSetTrust() Unexpected exception caught"); |
|
989 CHECK(false); |
|
990 } |
|
991 } |
|
992 |
|
993 // |
|
994 // TEST CASE 10 |
|
995 // |
|
996 TEST(ReadCerts,testsForGetCert) |
|
997 { |
|
998 printf("+testsForGetCert\n"); |
|
999 |
|
1000 try |
|
1001 { |
|
1002 //Starting java captain. |
|
1003 TestUtils::StartJavaCaptain(); |
|
1004 |
|
1005 //Stopping javacertstore extension plugin of the java captain. |
|
1006 CommsMsgSender commsMsgSender; |
|
1007 commsMsgSender.SendStopJavaCertStorePlugin(); |
|
1008 sleep(2); |
|
1009 |
|
1010 //Deleting all existing |
|
1011 auto_ptr<CTestData> testData(CTestData::NewL()); |
|
1012 testData->DeleteTestDataL(); |
|
1013 |
|
1014 //# 1 |
|
1015 //Create certificates + metadata. |
|
1016 list<CertMetaData> listOfCerts; |
|
1017 { |
|
1018 CertMetaData tmpObj(STATE_ENABLED,"enabledcert1",false,true,"1","content1"); |
|
1019 listOfCerts.push_back(tmpObj); |
|
1020 } |
|
1021 testData->StoreTestData(listOfCerts); |
|
1022 |
|
1023 auto_ptr<CTestExecutor> testExecutor(new CTestExecutor()); |
|
1024 auto_ptr<CJavaCertStoreTokenType> certStoreTokenType |
|
1025 (static_cast<CJavaCertStoreTokenType*>(CJavaCertStoreTokenType::New2L())); |
|
1026 auto_ptr<CJavaCertStoreToken> certStoreToken |
|
1027 (CJavaCertStoreToken::New(0x1234,*certStoreTokenType.get())); |
|
1028 auto_ptr<CJavaCertStoreImpl> certStoreObj(CJavaCertStoreImpl::NewL(*certStoreToken.get())); |
|
1029 auto_ptr<CCertAttributeFilter> attrFilter(TestUtils::GetFilterObj()); |
|
1030 |
|
1031 { |
|
1032 //# 2 |
|
1033 //Try to retrieve CCTCertInfo using non-existing handle. |
|
1034 CCTCertInfo* retCert = NULL; |
|
1035 TCTTokenHandle tmpObj; |
|
1036 TCTTokenObjectHandle tmpHandle(tmpObj,2); |
|
1037 certStoreObj->GetCert(retCert,tmpHandle,testExecutor->GetRequestStatus()); |
|
1038 CActiveScheduler::Start(); |
|
1039 CHECK(KErrArgument == testExecutor->GetErrorCode()); |
|
1040 } |
|
1041 |
|
1042 { |
|
1043 //# 3 |
|
1044 //Get CCTCertInfo object by TCTTokenObjectHandle. |
|
1045 RMPointerArray<CCTCertInfo> certInfoArray; |
|
1046 auto_ptr<CCertAttributeFilter> attrFilter(TestUtils::GetFilterObj()); |
|
1047 certStoreObj->List(certInfoArray,*attrFilter.get(),testExecutor->GetRequestStatus()); |
|
1048 testExecutor->Activate(); |
|
1049 CActiveScheduler::Start(); |
|
1050 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
1051 CHECK(1 == certInfoArray.Count()); |
|
1052 |
|
1053 CCTCertInfo* retCert = NULL; |
|
1054 TCTTokenHandle tmpObj; |
|
1055 TCTTokenObjectHandle tmpHandle(tmpObj,0); |
|
1056 certStoreObj->GetCert(retCert,tmpHandle,testExecutor->GetRequestStatus()); |
|
1057 testExecutor->Activate(); |
|
1058 CActiveScheduler::Start(); |
|
1059 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
1060 CHECK(8 != retCert->Size()); |
|
1061 certInfoArray.Close(); |
|
1062 retCert->Release(); |
|
1063 } |
|
1064 |
|
1065 printf("-testsForGetCert\n"); |
|
1066 } |
|
1067 catch (TestFailedException& ex) |
|
1068 { |
|
1069 printf("testsForGetCert() ERROR: %s",ex.toString().c_str()); |
|
1070 CHECK(false); |
|
1071 } |
|
1072 catch (...) |
|
1073 { |
|
1074 printf("testsForGetCert() Unexpected exception caught"); |
|
1075 CHECK(false); |
|
1076 } |
|
1077 } |
|
1078 |
|
1079 // |
|
1080 // TEST CASE 11 |
|
1081 // |
|
1082 TEST(ReadCerts,errorCasesForApplications) |
|
1083 { |
|
1084 printf("+errorCasesForApplications\n"); |
|
1085 |
|
1086 try |
|
1087 { |
|
1088 |
|
1089 //Starting java captain. |
|
1090 TestUtils::StartJavaCaptain(); |
|
1091 |
|
1092 //Stopping javacertstore extension plugin of the java captain. |
|
1093 CommsMsgSender commsMsgSender; |
|
1094 commsMsgSender.SendStopJavaCertStorePlugin(); |
|
1095 sleep(2); |
|
1096 |
|
1097 //Deleting all existing |
|
1098 auto_ptr<CTestData> testData(CTestData::NewL()); |
|
1099 testData->DeleteTestDataL(); |
|
1100 |
|
1101 auto_ptr<CTestExecutor> testExecutor(new CTestExecutor()); |
|
1102 auto_ptr<CJavaCertStoreTokenType> certStoreTokenType |
|
1103 (static_cast<CJavaCertStoreTokenType*>(CJavaCertStoreTokenType::New2L())); |
|
1104 auto_ptr<CJavaCertStoreToken> certStoreToken |
|
1105 (CJavaCertStoreToken::New(0x1234,*certStoreTokenType.get())); |
|
1106 auto_ptr<CJavaCertStoreImpl> certStoreObj(CJavaCertStoreImpl::NewL(*certStoreToken.get())); |
|
1107 auto_ptr<CCertAttributeFilter> attrFilter(TestUtils::GetFilterObj()); |
|
1108 |
|
1109 //# 1 |
|
1110 //Pass CCTCertInfo object, which does not match to any cert, as argument to |
|
1111 //Applications() operation. |
|
1112 CCTCertInfo* certInfo(CCTCertInfo::NewL(KMIDP2TrustRoot,EX509Certificate, |
|
1113 ECACertificate,10,NULL,NULL, |
|
1114 certStoreObj->Token(),2,true)); |
|
1115 RArray<TUid> uidList; |
|
1116 certStoreObj->Applications(*certInfo,uidList,testExecutor->GetRequestStatus()); |
|
1117 CActiveScheduler::Start(); |
|
1118 CHECK(KErrArgument == testExecutor->GetErrorCode()); |
|
1119 certInfo->Release(); |
|
1120 |
|
1121 printf("-errorCasesForApplications\n"); |
|
1122 } |
|
1123 catch (TestFailedException& ex) |
|
1124 { |
|
1125 printf("errorCasesForApplications() ERROR: %s",ex.toString().c_str()); |
|
1126 CHECK(false); |
|
1127 } |
|
1128 catch (...) |
|
1129 { |
|
1130 printf("errorCasesForApplications() Unexpected exception caught"); |
|
1131 CHECK(false); |
|
1132 } |
|
1133 } |
|
1134 |
|
1135 // |
|
1136 // TEST CASE 12 |
|
1137 // |
|
1138 TEST(ReadCerts,testCasesForIsApplicable) |
|
1139 { |
|
1140 printf("+testCasesForIsApplicable\n"); |
|
1141 |
|
1142 try |
|
1143 { |
|
1144 //Starting java captain. |
|
1145 TestUtils::StartJavaCaptain(); |
|
1146 |
|
1147 //Stopping javacertstore extension plugin of the java captain. |
|
1148 CommsMsgSender commsMsgSender; |
|
1149 commsMsgSender.SendStopJavaCertStorePlugin(); |
|
1150 sleep(2); |
|
1151 |
|
1152 //Deleting all existing |
|
1153 auto_ptr<CTestData> testData(CTestData::NewL()); |
|
1154 testData->DeleteTestDataL(); |
|
1155 |
|
1156 //# 1 |
|
1157 //Create certificates + metadata. |
|
1158 list<CertMetaData> listOfCerts; |
|
1159 { |
|
1160 CertMetaData tmpObj(STATE_DISABLED,"disabledcert1",true,true,"1","content1"); |
|
1161 listOfCerts.push_back(tmpObj); |
|
1162 } |
|
1163 { |
|
1164 CertMetaData tmpObj(STATE_ENABLED,"enabledcert1",true,true,"2","content12"); |
|
1165 listOfCerts.push_back(tmpObj); |
|
1166 } |
|
1167 testData->StoreTestData(listOfCerts); |
|
1168 |
|
1169 auto_ptr<CTestExecutor> testExecutor(new CTestExecutor()); |
|
1170 auto_ptr<CJavaCertStoreTokenType> certStoreTokenType |
|
1171 (static_cast<CJavaCertStoreTokenType*>(CJavaCertStoreTokenType::New2L())); |
|
1172 auto_ptr<CJavaCertStoreToken> certStoreToken |
|
1173 (CJavaCertStoreToken::New(0x1234,*certStoreTokenType.get())); |
|
1174 auto_ptr<CJavaCertStoreImpl> certStoreObj(CJavaCertStoreImpl::NewL(*certStoreToken.get())); |
|
1175 auto_ptr<CCertAttributeFilter> attrFilter(TestUtils::GetFilterObj()); |
|
1176 |
|
1177 { |
|
1178 //# 2 |
|
1179 //Passing incorrect Uid as argument to IsApplicable() operation. |
|
1180 CCTCertInfo* certInfo(CCTCertInfo::NewL(KMIDP2TrustRoot,EX509Certificate, |
|
1181 ECACertificate,10,NULL,NULL, |
|
1182 certStoreObj->Token(),2,true)); |
|
1183 TUid tmpUid = TUid::Uid(0x101F9B); |
|
1184 TBool isApplicable; |
|
1185 certStoreObj->IsApplicable(*certInfo,tmpUid,isApplicable,testExecutor->GetRequestStatus()); |
|
1186 CActiveScheduler::Start(); |
|
1187 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
1188 if (isApplicable) |
|
1189 CHECK(false); |
|
1190 certInfo->Release(); |
|
1191 } |
|
1192 |
|
1193 { |
|
1194 //# 3 |
|
1195 //Pass CCTCertInfo object, which does not match to any cert, as argument to |
|
1196 //IsApplicable() operation. |
|
1197 CCTCertInfo* certInfo(CCTCertInfo::NewL(KMIDP2TrustRoot,EX509Certificate, |
|
1198 ECACertificate,10,NULL,NULL, |
|
1199 certStoreObj->Token(),2,true)); |
|
1200 TBool isApplicable; |
|
1201 certStoreObj->IsApplicable(*certInfo,KMidletInstallApplicabilityUid, |
|
1202 isApplicable,testExecutor->GetRequestStatus()); |
|
1203 testExecutor->Activate(); |
|
1204 CActiveScheduler::Start(); |
|
1205 CHECK(KErrArgument == testExecutor->GetErrorCode()); |
|
1206 certInfo->Release(); |
|
1207 } |
|
1208 |
|
1209 { |
|
1210 //# 4 |
|
1211 //Ask applicability of disabled cert. |
|
1212 RMPointerArray<CCTCertInfo> certInfoArray; |
|
1213 testExecutor->Activate(); |
|
1214 certStoreObj->List(certInfoArray,*attrFilter.get(),testExecutor->GetRequestStatus()); |
|
1215 //testExecutor->Activate(); |
|
1216 CActiveScheduler::Start(); |
|
1217 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
1218 CHECK(2 == certInfoArray.Count()); |
|
1219 |
|
1220 TBool isApplicable = ETrue; |
|
1221 certStoreObj->IsApplicable(*certInfoArray[1],KMidletInstallApplicabilityUid, |
|
1222 isApplicable,testExecutor->GetRequestStatus()); |
|
1223 testExecutor->Activate(); |
|
1224 CActiveScheduler::Start(); |
|
1225 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
1226 if (isApplicable) |
|
1227 CHECK(false); |
|
1228 |
|
1229 //# 5 |
|
1230 //Delete cert. |
|
1231 certStoreObj->Remove(*certInfoArray[1],testExecutor->GetRequestStatus()); |
|
1232 testExecutor->Activate(); |
|
1233 CActiveScheduler::Start(); |
|
1234 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
1235 |
|
1236 //# 6 |
|
1237 //Ask applicability of deleted cert. |
|
1238 isApplicable = ETrue; |
|
1239 certStoreObj->IsApplicable(*certInfoArray[1],KMidletInstallApplicabilityUid, |
|
1240 isApplicable,testExecutor->GetRequestStatus()); |
|
1241 testExecutor->Activate(); |
|
1242 CActiveScheduler::Start(); |
|
1243 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
1244 if (isApplicable) |
|
1245 CHECK(false); |
|
1246 |
|
1247 //# 7 |
|
1248 //Ask applicability of enabled cert. |
|
1249 isApplicable = EFalse; |
|
1250 certStoreObj->IsApplicable(*certInfoArray[0],KMidletInstallApplicabilityUid, |
|
1251 isApplicable,testExecutor->GetRequestStatus()); |
|
1252 testExecutor->Activate(); |
|
1253 CActiveScheduler::Start(); |
|
1254 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
1255 if (!isApplicable) |
|
1256 CHECK(false); |
|
1257 certInfoArray.Close(); |
|
1258 } |
|
1259 |
|
1260 printf("-testCasesForIsApplicable\n"); |
|
1261 } |
|
1262 catch (TestFailedException& ex) |
|
1263 { |
|
1264 printf("testCasesForIsApplicable() ERROR: %s",ex.toString().c_str()); |
|
1265 CHECK(false); |
|
1266 } |
|
1267 catch (...) |
|
1268 { |
|
1269 printf("testCasesForIsApplicable() Unexpected exception caught"); |
|
1270 CHECK(false); |
|
1271 } |
|
1272 } |
|
1273 |
|
1274 // |
|
1275 // TEST CASE 13 |
|
1276 // |
|
1277 TEST(ReadCerts,testCasesForTrusted) |
|
1278 { |
|
1279 printf("+testCasesForTrusted\n"); |
|
1280 |
|
1281 try |
|
1282 { |
|
1283 //Starting java captain. |
|
1284 TestUtils::StartJavaCaptain(); |
|
1285 |
|
1286 //Stopping javacertstore extension plugin of the java captain. |
|
1287 CommsMsgSender commsMsgSender; |
|
1288 commsMsgSender.SendStopJavaCertStorePlugin(); |
|
1289 sleep(2); |
|
1290 |
|
1291 //Deleting all existing |
|
1292 auto_ptr<CTestData> testData(CTestData::NewL()); |
|
1293 testData->DeleteTestDataL(); |
|
1294 |
|
1295 //# 1 |
|
1296 //Create certificates + metadata. |
|
1297 list<CertMetaData> listOfCerts; |
|
1298 { |
|
1299 CertMetaData tmpObj(STATE_ENABLED,"enabledcert1",true,true,"1","content1"); |
|
1300 listOfCerts.push_back(tmpObj); |
|
1301 } |
|
1302 testData->StoreTestData(listOfCerts); |
|
1303 |
|
1304 auto_ptr<CTestExecutor> testExecutor(new CTestExecutor()); |
|
1305 auto_ptr<CJavaCertStoreTokenType> certStoreTokenType |
|
1306 (static_cast<CJavaCertStoreTokenType*>(CJavaCertStoreTokenType::New2L())); |
|
1307 auto_ptr<CJavaCertStoreToken> certStoreToken |
|
1308 (CJavaCertStoreToken::New(0x1234,*certStoreTokenType.get())); |
|
1309 auto_ptr<CJavaCertStoreImpl> certStoreObj(CJavaCertStoreImpl::NewL(*certStoreToken.get())); |
|
1310 auto_ptr<CCertAttributeFilter> attrFilter(TestUtils::GetFilterObj()); |
|
1311 |
|
1312 { |
|
1313 //# 2 |
|
1314 //Passing CCTCertInfo object, which does not point to any cert, |
|
1315 //as argument to Trusted() operation. |
|
1316 CCTCertInfo* certInfo(CCTCertInfo::NewL(KMIDP2TrustRoot,EX509Certificate, |
|
1317 ECACertificate,10,NULL,NULL, |
|
1318 certStoreObj->Token(),2,true)); |
|
1319 TBool retFlag; |
|
1320 certStoreObj->Trusted(*certInfo,retFlag,testExecutor->GetRequestStatus()); |
|
1321 CActiveScheduler::Start(); |
|
1322 CHECK(KErrArgument == testExecutor->GetErrorCode()); |
|
1323 if (!retFlag) |
|
1324 { |
|
1325 CHECK(false); |
|
1326 } |
|
1327 certInfo->Release(); |
|
1328 } |
|
1329 |
|
1330 { |
|
1331 //# 3 |
|
1332 //Passing valid CCTCertInfo object as argument to Trusted() operation. |
|
1333 RMPointerArray<CCTCertInfo> certInfoArray; |
|
1334 auto_ptr<CCertAttributeFilter> attrFilter(TestUtils::GetFilterObj()); |
|
1335 certStoreObj->List(certInfoArray,*attrFilter.get(),testExecutor->GetRequestStatus()); |
|
1336 testExecutor->Activate(); |
|
1337 CActiveScheduler::Start(); |
|
1338 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
1339 CHECK(1 == certInfoArray.Count()); |
|
1340 |
|
1341 TBool retFlag; |
|
1342 certStoreObj->Trusted(*certInfoArray[0],retFlag,testExecutor->GetRequestStatus()); |
|
1343 testExecutor->Activate(); |
|
1344 CActiveScheduler::Start(); |
|
1345 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
1346 CHECK(retFlag); |
|
1347 |
|
1348 //# 4 |
|
1349 //Deleting cert. |
|
1350 certStoreObj->Remove(*certInfoArray[0],testExecutor->GetRequestStatus()); |
|
1351 testExecutor->Activate(); |
|
1352 CActiveScheduler::Start(); |
|
1353 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
1354 |
|
1355 //# 5 |
|
1356 //Call Trusted() to deleted cert. |
|
1357 certStoreObj->Trusted(*certInfoArray[0],retFlag,testExecutor->GetRequestStatus()); |
|
1358 testExecutor->Activate(); |
|
1359 CActiveScheduler::Start(); |
|
1360 CHECK(KErrArgument == testExecutor->GetErrorCode()); |
|
1361 |
|
1362 certInfoArray.Close(); |
|
1363 } |
|
1364 |
|
1365 printf("-testCasesForTrusted\n"); |
|
1366 } |
|
1367 catch (TestFailedException& ex) |
|
1368 { |
|
1369 printf("testCasesForTrusted() ERROR: %s",ex.toString().c_str()); |
|
1370 CHECK(false); |
|
1371 } |
|
1372 catch (...) |
|
1373 { |
|
1374 printf("testCasesForTrusted() Unexpected exception caught"); |
|
1375 CHECK(false); |
|
1376 } |
|
1377 } |
|
1378 |
|
1379 // |
|
1380 // TEST CASE 14 |
|
1381 // |
|
1382 TEST(ReadCerts,errorCasesForRetrieve) |
|
1383 { |
|
1384 printf("+errorCasesForRetrieve\n"); |
|
1385 |
|
1386 try |
|
1387 { |
|
1388 //Starting java captain. |
|
1389 TestUtils::StartJavaCaptain(); |
|
1390 |
|
1391 //Stopping javacertstore extension plugin of the java captain. |
|
1392 CommsMsgSender commsMsgSender; |
|
1393 commsMsgSender.SendStopJavaCertStorePlugin(); |
|
1394 sleep(2); |
|
1395 |
|
1396 //Deleting all existing |
|
1397 auto_ptr<CTestData> testData(CTestData::NewL()); |
|
1398 testData->DeleteTestDataL(); |
|
1399 |
|
1400 //# 1 |
|
1401 //Create certificates + metadata. |
|
1402 list<CertMetaData> listOfCerts; |
|
1403 { |
|
1404 CertMetaData tmpObj(STATE_ENABLED,"enablecert1",true,true,"1","content1"); |
|
1405 listOfCerts.push_back(tmpObj); |
|
1406 } |
|
1407 { |
|
1408 CertMetaData tmpObj(STATE_ENABLED,"enabledcert2",true,true,"2","content12"); |
|
1409 listOfCerts.push_back(tmpObj); |
|
1410 } |
|
1411 testData->StoreTestData(listOfCerts); |
|
1412 |
|
1413 auto_ptr<CTestExecutor> testExecutor(new CTestExecutor()); |
|
1414 auto_ptr<CJavaCertStoreTokenType> certStoreTokenType |
|
1415 (static_cast<CJavaCertStoreTokenType*>(CJavaCertStoreTokenType::New2L())); |
|
1416 auto_ptr<CJavaCertStoreToken> certStoreToken |
|
1417 (CJavaCertStoreToken::New(0x1234,*certStoreTokenType.get())); |
|
1418 auto_ptr<CJavaCertStoreImpl> certStoreObj(CJavaCertStoreImpl::NewL(*certStoreToken.get())); |
|
1419 auto_ptr<CCertAttributeFilter> attrFilter(TestUtils::GetFilterObj()); |
|
1420 |
|
1421 { |
|
1422 //# 2 |
|
1423 //Call twice Retrieve() operation in the row. |
|
1424 RMPointerArray<CCTCertInfo> certInfoArray; |
|
1425 certStoreObj->List(certInfoArray,*attrFilter.get(),testExecutor->GetRequestStatus()); |
|
1426 CActiveScheduler::Start(); |
|
1427 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
1428 CHECK(2 == certInfoArray.Count()); |
|
1429 |
|
1430 auto_ptr<HBufC8> certContentBuf(HBufC8::NewL(certInfoArray[0]->Size())); |
|
1431 TPtr8 certContentPtr(certContentBuf->Des()); |
|
1432 auto_ptr<HBufC8> certContentBuf2(HBufC8::NewL(certInfoArray[1]->Size())); |
|
1433 TPtr8 certContentPtr2(certContentBuf2->Des()); |
|
1434 auto_ptr<CTestExecutor> testExecutor2(new CTestExecutor()); |
|
1435 certStoreObj->Retrieve(*certInfoArray[0],certContentPtr,testExecutor2->GetRequestStatus()); |
|
1436 auto_ptr<CTestExecutor> testExecutor3(new CTestExecutor()); |
|
1437 certStoreObj->Retrieve(*certInfoArray[1],certContentPtr2,testExecutor3->GetRequestStatus()); |
|
1438 certStoreObj->CancelRetrieve(); |
|
1439 certInfoArray.Close(); |
|
1440 certStoreObj->CancelRetrieve(); |
|
1441 } |
|
1442 |
|
1443 { |
|
1444 //# 3 |
|
1445 //Pass CCTCertInfo object, which does not match to any cert, as argument to |
|
1446 //Retrieve() operation. |
|
1447 CCTCertInfo* certInfo(CCTCertInfo::NewL(KMIDP2TrustRoot,EX509Certificate, |
|
1448 ECACertificate,10,NULL,NULL, |
|
1449 certStoreObj->Token(),4,true)); |
|
1450 auto_ptr<HBufC8> certContentBuf(HBufC8::NewL(100)); |
|
1451 TPtr8 certContentPtr(certContentBuf->Des()); |
|
1452 certStoreObj->Retrieve(*certInfo,certContentPtr,testExecutor->GetRequestStatus()); |
|
1453 testExecutor->Activate(); |
|
1454 CActiveScheduler::Start(); |
|
1455 CHECK(KErrArgument == testExecutor->GetErrorCode()); |
|
1456 certInfo->Release(); |
|
1457 } |
|
1458 |
|
1459 printf("-errorCasesForRetrieve\n"); |
|
1460 } |
|
1461 catch (TestFailedException& ex) |
|
1462 { |
|
1463 printf("errorCasesForRetrieve() ERROR: %s",ex.toString().c_str()); |
|
1464 CHECK(false); |
|
1465 } |
|
1466 catch (...) |
|
1467 { |
|
1468 printf("errorCasesForRetrieve() Unexpected exception caught"); |
|
1469 CHECK(false); |
|
1470 } |
|
1471 } |
|
1472 |
|
1473 // |
|
1474 // TEST CASE 15 |
|
1475 // |
|
1476 TEST(ReadCerts,errorCasesForSetApplicability) |
|
1477 { |
|
1478 printf("+errorCasesForSetApplicability\n"); |
|
1479 |
|
1480 try |
|
1481 { |
|
1482 //Starting java captain. |
|
1483 TestUtils::StartJavaCaptain(); |
|
1484 |
|
1485 //Stopping javacertstore extension plugin of the java captain. |
|
1486 CommsMsgSender commsMsgSender; |
|
1487 commsMsgSender.SendStopJavaCertStorePlugin(); |
|
1488 sleep(2); |
|
1489 |
|
1490 //Deleting all existing |
|
1491 auto_ptr<CTestData> testData(CTestData::NewL()); |
|
1492 testData->DeleteTestDataL(); |
|
1493 |
|
1494 //# 1 |
|
1495 //Create certificates + metadata. |
|
1496 list<CertMetaData> listOfCerts; |
|
1497 { |
|
1498 CertMetaData tmpObj(STATE_ENABLED,"enabledcert1",true,false,"1","content1"); |
|
1499 listOfCerts.push_back(tmpObj); |
|
1500 } |
|
1501 testData->StoreTestData(listOfCerts); |
|
1502 |
|
1503 auto_ptr<CTestExecutor> testExecutor(new CTestExecutor()); |
|
1504 auto_ptr<CJavaCertStoreTokenType> certStoreTokenType |
|
1505 (static_cast<CJavaCertStoreTokenType*>(CJavaCertStoreTokenType::New2L())); |
|
1506 auto_ptr<CJavaCertStoreToken> certStoreToken |
|
1507 (CJavaCertStoreToken::New(0x1234,*certStoreTokenType.get())); |
|
1508 auto_ptr<CJavaCertStoreImpl> certStoreObj(CJavaCertStoreImpl::NewL(*certStoreToken.get())); |
|
1509 auto_ptr<CCertAttributeFilter> attrFilter(TestUtils::GetFilterObj()); |
|
1510 |
|
1511 { |
|
1512 //# 2 |
|
1513 //CertInfo object does not match to any cert. |
|
1514 CCTCertInfo* certInfo(CCTCertInfo::NewL(KMIDP2TrustRoot,EX509Certificate, |
|
1515 ECACertificate,10,NULL,NULL, |
|
1516 certStoreObj->Token(),2,true)); |
|
1517 RArray<TUid> emptyArray; |
|
1518 certStoreObj->SetApplicability(*certInfo,emptyArray,testExecutor->GetRequestStatus()); |
|
1519 CActiveScheduler::Start(); |
|
1520 CHECK(KErrArgument == testExecutor->GetErrorCode()); |
|
1521 certInfo->Release(); |
|
1522 emptyArray.Close(); |
|
1523 } |
|
1524 |
|
1525 { |
|
1526 //# 3 |
|
1527 //Try to disable cert which cannot be disabled. |
|
1528 RMPointerArray<CCTCertInfo> certInfoArray; |
|
1529 certStoreObj->List(certInfoArray,*attrFilter.get(),testExecutor->GetRequestStatus()); |
|
1530 testExecutor->Activate(); |
|
1531 CActiveScheduler::Start(); |
|
1532 CHECK(KErrNone == testExecutor->GetErrorCode()); |
|
1533 CHECK(1 == certInfoArray.Count()); |
|
1534 |
|
1535 RArray<TUid> emptyArray; |
|
1536 certStoreObj->SetApplicability(*certInfoArray[0],emptyArray,testExecutor->GetRequestStatus()); |
|
1537 testExecutor->Activate(); |
|
1538 CActiveScheduler::Start(); |
|
1539 CHECK(KErrArgument == testExecutor->GetErrorCode()); |
|
1540 certInfoArray.Close(); |
|
1541 emptyArray.Close(); |
|
1542 } |
|
1543 |
|
1544 printf("-errorCasesForSetApplicability\n"); |
|
1545 } |
|
1546 catch (TestFailedException& ex) |
|
1547 { |
|
1548 printf("errorCasesForSetApplicability() ERROR: %s",ex.toString().c_str()); |
|
1549 CHECK(false); |
|
1550 } |
|
1551 catch (...) |
|
1552 { |
|
1553 printf("errorCasesForSetApplicability() Unexpected exception caught"); |
|
1554 CHECK(false); |
|
1555 } |
|
1556 } |
|
1557 |
|
1558 |