os/security/cryptoservices/certificateandkeymgmt/tcertstore/t_certstoretests.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2004-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 the License "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 
    19 #include <e32std.h>
    20 #include <fbs.h>
    21 #include "t_testhandler.h"
    22 #include "t_certstoreactionsclient.h"
    23 #include "t_certstoreactionslistcertificates.h"
    24 #include "t_unifiedcertstorewritablecertstorecount.h"
    25 #include "t_unifiedcertstorereadonlycertstorecount.h"
    26 #include "t_unifiedcertstorecertstorecount.h"
    27 #include "t_certstoredefs.h"
    28 #include "t_certstoreactions.h"
    29 #include "t_certstoreactionsfilecertstore.h"
    30 #include "t_unifiedcertstoreadd.h"
    31 #include "t_unifiedcertstoreremove.h"
    32 #include "T_unifiedcertstoreapplications.h"
    33 #include "t_unifiedcertstoreactiongetcert.h"
    34 #include "t_ccttokentypeinfoattributes.h"
    35 #include "t_certstoreactionshandle.h"
    36 #include "t_retrieve.h"
    37 #include "t_concurrentcertstore.h"
    38 #include "t_certstoretests.h"
    39 #include "t_testcertfordeletable.h"
    40 #include "t_filetokens.h"
    41 #include <ecom/ecom.h>
    42 
    43 #include "tscriptandhardcoded.h"
    44 #include "t_swicertstoreactions.h"
    45 
    46 START_SCRIPT_LIST
    47 SCRIPT_ITEM(CCreateFileCertStore, KCreateFileCertStore),
    48 SCRIPT_ITEM(CImportKey, KImportKey),
    49 SCRIPT_ITEM(CAddCertificate, KAddCert),
    50 SCRIPT_ITEM(CInitialiseCertStore, KInitStore),
    51 SCRIPT_ITEM(COnlyCreateCertStore, KOnlyCreateStore),
    52 SCRIPT_ITEM(CDeleteCertStore, KDeleteStore),
    53 SCRIPT_ITEM(CDeleteCertificate, KDeleteCert),
    54 SCRIPT_ITEM(CDeleteRetrieveCACertificate, KDeleteRetrieveCACert),
    55 SCRIPT_ITEM(CDeleteRetrieveUserCertificate, KDeleteRetrieveUserCert),
    56 SCRIPT_ITEM(CListCertificates, KListCert),
    57 SCRIPT_ITEM(CRetrieveCertificate, KRetrieveCert),
    58 SCRIPT_ITEM(CUnifiedCertStoreApplications, KGetApplications),
    59 SCRIPT_ITEM(CSetApplications, KSetApplications),
    60 SCRIPT_ITEM(CSetTrusters, KSetTruster),
    61 SCRIPT_ITEM(CGetTrusters, KGetTrusters),
    62 SCRIPT_ITEM(CInitCertificateAppInfoManager, KInitAppManager),
    63 SCRIPT_ITEM(CDeleteCertificateAppInfoManager, KDeleteAppManager),
    64 SCRIPT_ITEM(CAddClient, KAddClient),
    65 SCRIPT_ITEM(CGetClients, KGetClients),
    66 SCRIPT_ITEM(CRemoveClient, KRemoveClient),
    67 SCRIPT_ITEM(CUnifiedCertStoreWritableCertStoreCount, KCUnifiedCertStoreWritableCertStoreCount),
    68 SCRIPT_ITEM(CUnifiedCertStoreReadOnlyCertStoreCount, KCUnifiedCertStoreReadOnlyCertStoreCount),
    69 SCRIPT_ITEM(CUnifiedCertStoreCertStoreCount, KCUnifiedCertStoreCertStoreCount),
    70 SCRIPT_ITEM(CUnifiedCertStoreGetCert, KCUnifiedCertStoreGetCert),
    71 SCRIPT_ITEM(CInitSWICertStoreAction, KInitSWICertStore),
    72 SCRIPT_ITEM(CGetCapabilitiesAction, KGetCapabilities),
    73 SCRIPT_ITEM(CGetMandatoryAction, KGetMandatory),
    74 SCRIPT_ITEM(CGetSystemUpgradeAction, KGetSystemUpgrade),
    75 SCRIPT_ITEM(CGetDeletionAction, KGetDeletable),
    76 SCRIPT_ITEM(CCTTokenTypeInfoAttributes, KCCTTokenTypeInfoAttributes),
    77 SCRIPT_ITEM(CCertStoreHandle, KCCTCertInfoHandle),
    78 SCRIPT_ITEM(CTestConcurrentCertStore, KTestConcurrentCertStore),
    79 SCRIPT_ITEM(CTestCertForDeletable, KCTestCertForDeletable),
    80 SCRIPT_ITEM(CServerOOMTestStart, KServerOOMTestStart),
    81 SCRIPT_ITEM(CServerOOMTestStop, KServerOOMTestStop),
    82 SCRIPT_ITEM(CMultipleReadersAction, KMultipleReaders),
    83 SCRIPT_ITEM(CCheckServerHeapError, KCheckServerHeapError)
    84 END_SCRIPT_LIST
    85 
    86 void DeleteKeyStoreL()
    87 	{
    88 	RFs fs;
    89 	User::LeaveIfError(fs.Connect());
    90 	CleanupClosePushL(fs);
    91 	
    92 	TDriveUnit sysDrive (RFs::GetSystemDrive());
    93 	TBuf<64> datFile (sysDrive.Name());
    94 	datFile.Append(_L("\\system\\data\\keys.dat"));
    95 	User::LeaveIfError(fs.Delete(datFile));
    96 	CleanupStack::PopAndDestroy(&fs);
    97 	}
    98 
    99 void DoTests()
   100 	{
   101 	// Need to delete the keystore first
   102 	TRAP_IGNORE(DeleteKeyStoreL());
   103 	
   104 	TDriveUnit sysDrive (RFs::GetSystemDrive());
   105 	TBuf<64> scriptFile (sysDrive.Name());
   106 	scriptFile.Append(_L("\\tcertstore\\scripts\\unifiedcertstore1-conf1.txt"));
   107 	
   108 	TBuf<24> logFile (sysDrive.Name());
   109 	logFile.Append(_L("\\tcertstore.log"));
   110 	CScriptSetup::CreateAndRunTestsL(theTestTypes, scriptFile, logFile);
   111 	}
   112 
   113 void DoTests(const TDesC& aScriptFile, const TDesC& aLogFile, TBool isConcurrent)
   114 	{
   115 	TRAP_IGNORE(DeleteKeyStoreL());
   116 	CNullConsole console;
   117 	CConsoleBase* consolePtr = (isConcurrent) ? &console : NULL;
   118 	CScriptSetup::CreateAndRunTestsL(theTestTypes, aScriptFile, aLogFile, EFalse, consolePtr);
   119 	}