securityanddataprivacytools/securitytools/certapp/test/tcertapp/goodconfigwriter.cpp
changeset 8 35751d3474b7
parent 0 2c201484c85f
equal deleted inserted replaced
2:675a964f4eb5 8:35751d3474b7
    17 
    17 
    18 
    18 
    19 #include "goodconfigwriter.h"
    19 #include "goodconfigwriter.h"
    20 #include <iostream>
    20 #include <iostream>
    21 #include <sstream>
    21 #include <sstream>
       
    22 #include <stdio.h>
    22 #include "tcertapp_good.h"
    23 #include "tcertapp_good.h"
    23 
    24 
    24 // Array for the StatCA- holds all relevant details
    25 // Array for the StatCA- holds all relevant details
    25 const char *swicertemu_array[]=
    26 const char *swicertemu_array[]=
    26 	{
    27 	{
   256 	iFile << "\t\tSystemUpgrade " << aGoodSystemUpgrade << std::endl;
   257 	iFile << "\t\tSystemUpgrade " << aGoodSystemUpgrade << std::endl;
   257 	iFile << "\tEndEntry" << std::endl;
   258 	iFile << "\tEndEntry" << std::endl;
   258 }
   259 }
   259 
   260 
   260 
   261 
       
   262 //Script and INI file generator
       
   263 ScriptAndIniGeneration::ScriptAndIniGeneration(const std::stringstream &aFileName)
       
   264 	: GoodConfigWriter(aFileName)
       
   265 {
       
   266 	int last_dot = aFileName.str().rfind('.');
       
   267 	if(last_dot>=0)
       
   268 	{
       
   269 		iIniFileName = aFileName.str().substr(0,last_dot);
       
   270 		iIniFileName.append(".ini");
       
   271 		iIniFile.open(iIniFileName.c_str(), std::ios_base::trunc | std::ios_base::out);
       
   272 		if(iIniFile.fail())
       
   273 		{
       
   274 			std::cout << "Failed to open '" << iIniFileName.c_str()<< "' for output!" << std::endl;
       
   275 			exit(-1);
       
   276 		}
       
   277 	}	
       
   278 }
       
   279 
       
   280 ScriptAndIniGeneration::~ScriptAndIniGeneration()
       
   281 {
       
   282 	iIniFile.close();
       
   283 }
       
   284 
       
   285 void ScriptAndIniGeneration::WriteTestCaseToScript(const std::stringstream &aTestCaseType,int &aTestIndex,const char *aTestActionName,const char *aTestActionType,bool aHasActionBody)
       
   286 {
       
   287 	// set test case ID string
       
   288 	char testCaseIndexBuffer[6];
       
   289 	sprintf(testCaseIndexBuffer, "-%04d", aTestIndex);
       
   290 
       
   291 	iFile << "START_TESTCASE                " << aTestCaseType.str() << testCaseIndexBuffer << std::endl;
       
   292 	iFile << "//! @SYMTestCaseID            " << aTestCaseType.str() << testCaseIndexBuffer << std::endl;
       
   293 	iFile << "//! @SYMTestCaseDesc          " << aTestActionName << std::endl;
       
   294 	iFile << "RUN_TEST_STEP                 -1\tCTestHandler\t" << aTestActionType;
       
   295 	if(aHasActionBody)
       
   296 	{
       
   297 		iFile << "\t" << iIniFileName << "\t" << aTestCaseType.str() << testCaseIndexBuffer << "-001";
       
   298 		iIniFile << "[" << aTestCaseType.str() << testCaseIndexBuffer << "-001" << "]" << std::endl;
       
   299 	}
       
   300 	iFile << std::endl;
       
   301 	iFile << "END_TESTCASE                  " << aTestCaseType.str() << testCaseIndexBuffer << std::endl;
       
   302 	iFile << std::endl;
       
   303 }
       
   304 
       
   305 
   261 FileStoreScriptGeneration::FileStoreScriptGeneration(const std::stringstream &aFileName)
   306 FileStoreScriptGeneration::FileStoreScriptGeneration(const std::stringstream &aFileName)
   262 	: GoodConfigWriter(aFileName), iCount(1)
   307 	: ScriptAndIniGeneration(aFileName)
   263 {
   308 {
   264 	
   309 	
   265 }
   310 }
   266 
   311 
   267 FileStoreScriptGeneration::~FileStoreScriptGeneration()
   312 FileStoreScriptGeneration::~FileStoreScriptGeneration()
   268 {
   313 {
   269 }
   314 }
   270 
   315 
   271 void FileStoreScriptGeneration:: WriteInitialiseCert(const char *aMode)
   316 void FileStoreScriptGeneration:: WriteInitialiseCert(const char *aMode, const std::stringstream &aTestCaseType, int &aTestIndex)
   272 {
   317 {
   273 	iFile << "# TEST" << iCount++ << std::endl;
   318 	const char *testcasename = "Initializing a CUnifiedCertStore";
   274 	iFile <<"<action>"<<std::endl;
   319 	const char *testcasetype = "init";
   275 	iFile << "\t<actionname>" << "Initializing a CUnifiedCertStore" <<"</actionname>"<< std::endl;
   320 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   276 	iFile << "\t<actiontype>" << "init" <<"</actiontype>"<< std::endl;
   321 	iIniFile << "<actionbody>" << std::endl;
   277 	iFile << "\t<actionbody>" << std::endl;
   322 	iIniFile << "\t<mode>" << aMode << "</mode>" << std::endl;
   278 	iFile << "\t\t<mode>" <<aMode <<"</mode>"<< std::endl;
   323 	iIniFile << "</actionbody>" << std::endl;
   279 	iFile << "\t</actionbody>" << std::endl;
   324 	iIniFile << std::endl;
   280 	iFile << "\t<actionresult>" << std::endl;
   325 }
   281 	iFile << "\t\t<return>" << "KErrNone" << "</return>" << std::endl;
   326 
   282 	iFile << "\t</actionresult>" << std::endl;
   327 
   283 	iFile <<"</action>"<<std::endl;
   328 
   284 	iFile << std::endl;
   329 void  FileStoreScriptGeneration::WriteListcert(const char *aGoodOwnerType, const std::stringstream &aTestCaseType, int &aTestIndex)
   285 }
   330 {
   286 
   331 	const char *testcasename = "Get the list of certificates";
   287 
   332 	const char *testcasetype = "listcert";
   288 
   333 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   289 void  FileStoreScriptGeneration::WriteListcert(const char *aGoodOwnerType)
   334 	iIniFile << "<actionbody>" << std::endl;
   290 {
   335 	iIniFile << "\t<filter>" << std::endl;
   291 	iFile << "# TEST" << iCount++ << std::endl;
   336 	iIniFile << "\t\t<ownertype>" << aGoodOwnerType << "</ownertype>" << std::endl;
   292 	iFile <<"<action>"<<std::endl;
   337 	iIniFile << "\t</filter>" << std::endl;
   293 	iFile << "\t<actionname>" << "Get the list of certificates" <<"</actionname>"<< std::endl;
   338 	iIniFile << "</actionbody>" << std::endl;
   294 	iFile << "\t<actiontype>" << "listcert" <<"</actiontype>"<< std::endl;
   339 	iIniFile << "<actionresult>" << std::endl;
   295 	iFile << "\t<actionbody>" << std::endl;
       
   296 	iFile << "\t\t<filter>" << std::endl;
       
   297 	iFile << "\t\t\t<ownertype>" << aGoodOwnerType	<< "</ownertype>" << std::endl;
       
   298 	iFile << "\t\t<filter>" << std::endl;
       
   299 	iFile << "\t</actionbody>" << std::endl;
       
   300 	iFile << "\t<actionresult>" << std::endl;
       
   301 	iFile << "\t\t<return>" <<"KErrNone"<< "</return>" << std::endl;
       
   302 	for(int z =0; z<6; z++)
   340 	for(int z =0; z<6; z++)
   303 		{
   341 		{
   304 		iFile << "\t\t<CCTCertInfo><label>" <<goodEmuCert_array[z] << "</label></CCTCertInfo>" <<std::endl;
   342 		iIniFile << "\t<CCTCertInfo><label>" << goodEmuCert_array[z] << "</label></CCTCertInfo>" << std::endl;
   305 		}
   343 		}
   306 	iFile << "\t</actionresult>" << std::endl;
   344 	iIniFile << "</actionresult>" << std::endl;
   307 	iFile <<"</action>"<<std::endl;
   345 	iIniFile << std::endl;
   308 	iFile <<std::endl;
   346 }
   309 }
   347 
   310 
   348 void  FileStoreScriptGeneration::WriteGetCertificateDetails(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex)
   311 void  FileStoreScriptGeneration::WriteGetCertificateDetails(const char *label)
   349 {
   312 {
   350 	const char *testcasename = "Get certificate details";
   313 	iFile << "# TEST" << iCount++ << std::endl;
   351 	const char *testcasetype = "listcert";
   314 	iFile <<"<action>"<<std::endl;
   352 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   315 	iFile << "\t<actionname>" << "Get the list of certificates" <<"</actionname>"<< std::endl;
       
   316 	iFile << "\t<actiontype>" << "listcert" <<"</actiontype>"<< std::endl;
       
   317 	iFile << "\t<actionbody>" << std::endl;
       
   318 	iFile << "\t\t<filter>" << std::endl;
       
   319 	iFile << "\t\t\t<label>" << label <<"</label>" <<std::endl;
       
   320 	WriteDetailsToArray(cert_array);
       
   321 	iFile << "\t\t<CCTCertInfo><label>" << label << "</label></CCTCertInfo>" <<std::endl;
       
   322 	iFile << "\t</actionresult>" << std::endl;
       
   323 	iFile <<"</action>"<<std::endl;
       
   324 	iFile <<std::endl;
       
   325 
       
   326 }
       
   327 
       
   328 
       
   329 void FileStoreScriptGeneration::WriteDetailsToArray(const char *array[])
       
   330 	{
       
   331 	int i = 0;
   353 	int i = 0;
   332 	iFile << "\t\t\t<format>" << array[i++]	<< "</format>" << std::endl;
   354 	iIniFile << "<actionbody>" << std::endl;
   333 	iFile << "\t\t\t<certowner>" << array[i++] << "</certowner>" << std::endl;
   355 	iIniFile << "\t<filter>" << std::endl;
   334 	iFile << "\t\t\t<subjectkeyid>" << array[i++]<< "</subjectkeyid>" << std::endl;
   356 	iIniFile << "\t\t<label>" << label << "</label>" << std::endl;
   335 	iFile << "\t\t\t<issuerkeyid>" <<array[i++]<< "</issuerkeyid>" << std::endl;
   357 	iIniFile << "\t\t<format>" << cert_array[i++]<< "</format>" << std::endl;
   336 	iFile << "\t\t\t<deletable>" << array[i++] << "</deletable>" << std::endl;
   358 	iIniFile << "\t\t<certowner>" << cert_array[i++] << "</certowner>" << std::endl;
   337 	iFile << "\t\t</filter>" << std::endl;
   359 	iIniFile << "\t\t<subjectkeyid>" << cert_array[i++] << "</subjectkeyid>" << std::endl;
   338 	iFile << "\t</actionbody>" << std::endl;
   360 	iIniFile << "\t\t<issuerkeyid>" <<cert_array[i++] << "</issuerkeyid>" << std::endl;
   339 	iFile << "\t<actionresult>" << std::endl;
   361 	iIniFile << "\t\t<deletable>" << cert_array[i++] << "</deletable>" << std::endl;
   340 	iFile << "\t\t<return>" <<"KErrNone"<< "</return>" << std::endl;
   362 	iIniFile << "\t</filter>" << std::endl;
   341 	}
   363 	iIniFile << "</actionbody>" << std::endl;
   342 
   364 	iIniFile << "<actionresult>" << std::endl;
   343 
   365 	iIniFile << "\t<CCTCertInfo><label>" << label << "</label></CCTCertInfo>" << std::endl;
   344 void  FileStoreScriptGeneration::WriteGetTrust(const char *label, const char *trust)
   366 	iIniFile << "</actionresult>" << std::endl;
   345 {
   367 	iIniFile << std::endl;
   346 	iFile << "# TEST" << iCount++ << std::endl;
   368 }
   347 	iFile <<"<action>"<<std::endl;
   369 
   348 	iFile << "\t<actionname>" << "Get Trust certificate" <<"</actionname>"<< std::endl;
   370 
   349 	iFile << "\t<actiontype>" << "gettrusters" <<"</actiontype>"<< std::endl;
   371 void  FileStoreScriptGeneration::WriteGetTrust(const char *label, const char *trust, const std::stringstream &aTestCaseType, int &aTestIndex)
   350 	iFile << "\t<actionbody>" << std::endl;
   372 {
   351 	iFile << "\t\t<label>" << label<< "</label>" << std::endl;
   373 	const char *testcasename = "Get Trust certificate";
   352 	iFile << "\t</actionbody>" << std::endl;
   374 	const char *testcasetype = "gettrusters";
   353 	iFile << "\t<actionresult>" << std::endl;
   375 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   354 	iFile << "\t\t<return>" <<"KErrNone"<< "</return>" << std::endl;
   376 	iIniFile << "<actionbody>" << std::endl;
   355 	iFile << "\t\t\t<trust>" << trust << "</trust>" <<std::endl;
   377 	iIniFile << "\t<label>" << label << "</label>" << std::endl;
   356 	iFile << "\t</actionresult>" << std::endl;
   378 	iIniFile << "</actionbody>" << std::endl;
   357 	iFile <<"</action>"<<std::endl;
   379 	iIniFile << "<actionresult>" << std::endl;
   358 	iFile <<std::endl;
   380 	iIniFile << "\t<trust>" << trust << "</trust>" << std::endl;
   359 }
   381 	iIniFile << "</actionresult>" << std::endl;
   360 
   382 	iIniFile << std::endl;
   361 
   383 }
   362 void  FileStoreScriptGeneration::WriteGetApplications(const char *label)
   384 
   363 {
   385 
   364 	iFile << "# TEST" << iCount++ << std::endl;
   386 void  FileStoreScriptGeneration::WriteGetApplications(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex)
   365 	iFile <<"<action>"<<std::endl;
   387 {
   366 	iFile << "\t<actionname>" << "Get applications" <<"</actionname>"<< std::endl;
   388 	const char *testcasename = "Get applications";
   367 	iFile << "\t<actiontype>" << "getapplications" <<"</actiontype>"<< std::endl;
   389 	const char *testcasetype = "getapplications";
   368 	iFile << "\t<actionbody>" << std::endl;
   390 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   369 	iFile << "\t\t\t<label>" << label << "</label>" << std::endl;
   391 	iIniFile << "<actionbody>" << std::endl;
   370 	iFile << "\t</actionbody>" << std::endl;
   392 	iIniFile << "\t<label>" << label << "</label>" << std::endl;
   371 	iFile << "\t<actionresult>" << std::endl;
   393 	iIniFile << "</actionbody>" << std::endl;
   372 	iFile << "\t\t<return>" <<"KErrNone"<< "</return>" << std::endl;
   394 	iIniFile << "<actionresult>" << std::endl;
   373 	iFile << "\t\t\t<uid>";
   395 	iIniFile << "\t<uid>";
   374 
       
   375 	for(int j = 0; j<2; j++)
   396 	for(int j = 0; j<2; j++)
   376 		{
   397 		{
   377 		iFile << emu_cacertsUid[j]<<" ";
   398 		iIniFile << emu_cacertsUid[j] << " ";
   378 		}
   399 		}
   379 	iFile <<"</uid>"<<std::endl;
   400 	iIniFile << "</uid>" << std::endl;
   380 	iFile << "\t</actionresult>" << std::endl;
   401 	iIniFile << "</actionresult>" << std::endl;
   381 	iFile <<"</action>"<<std::endl;
   402 	iIniFile << std::endl;
   382 	iFile <<std::endl;
   403 }
   383 }
   404 
   384 
   405 
   385 
   406 void  FileStoreScriptGeneration::WriteRetrieveCerts(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex)
   386 void  FileStoreScriptGeneration::WriteRetrieveCerts(const char *label)
   407 {
   387 {
   408 	const char *testcasename = "Retrieve Certificate";
   388 	iFile << "# TEST" << iCount++ << std::endl;
   409 	const char *testcasetype = "retrieve";
   389 	iFile <<"<action>"<<std::endl;
   410 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   390 	iFile << "\t<actionname>" << "Retrieve Certificate" <<"</actionname>"<< std::endl;
   411 	iIniFile << "<actionbody>" << std::endl;
   391 	iFile << "\t<actiontype>" << "retrieve" <<"</actiontype>"<< std::endl;
   412 	iIniFile << "\t<label>" << label << "</label>" << std::endl;
   392 	iFile << "\t<actionbody>" << std::endl;
   413 	iIniFile << "</actionbody>" << std::endl;
   393 	iFile << "\t\t\t<label>" << label<< "</label>" << std::endl;
   414 	iIniFile << std::endl;
   394 	iFile << "\t</actionbody>" << std::endl;
       
   395 	iFile << "\t<actionresult>" << std::endl;
       
   396 	iFile << "\t\t<return>" <<"KErrNone"<< "</return>" << std::endl;
       
   397 	iFile << "\t</actionresult>" << std::endl;
       
   398 	iFile <<"</action>"<<std::endl;
       
   399 	iFile <<std::endl;
       
   400 }
   415 }
   401 
   416 
   402 
   417 
   403 
   418 
   404 //Swi store script generator for emulator tests
   419 //Swi store script generator for emulator tests
   405 SWIStoreScriptGeneration::SWIStoreScriptGeneration(const std::stringstream &aFileName)
   420 SWIStoreScriptGeneration::SWIStoreScriptGeneration(const std::stringstream &aFileName)
   406 	: GoodConfigWriter(aFileName), iCount(1)
   421 	: ScriptAndIniGeneration(aFileName)
   407 {
   422 {
   408 	
   423 	
   409 }
   424 }
   410 
   425 
   411 SWIStoreScriptGeneration::~SWIStoreScriptGeneration()
   426 SWIStoreScriptGeneration::~SWIStoreScriptGeneration()
   412 {
   427 {
   413 }
   428 }
   414 
   429 
   415 void SWIStoreScriptGeneration:: WriteInitialiseCert()
   430 void SWIStoreScriptGeneration:: WriteInitialiseCert(const std::stringstream &aTestCaseType, int &aTestIndex)
   416 {
   431 {
   417 	iFile << "# TEST" << iCount++ << std::endl;
   432 	const char *testcasename = "Initialise a SWICertStore";
   418 	iFile <<"<action>"<<std::endl;
   433 	const char *testcasetype = "initswicertstore";
   419 	iFile << "\t<actionname>" << "Initialise a SWICertStore" <<"</actionname>"<< std::endl;
   434 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype, false);
   420 	iFile << "\t<actiontype>" << "initswicertstore" <<"</actiontype>"<< std::endl;
   435 }
   421 	iFile << "\t<actionbody>" << std::endl;
   436 
   422 	iFile << "\t</actionbody>" << std::endl;
   437 
   423 	iFile << "\t<actionresult>" << std::endl;
   438 void  SWIStoreScriptGeneration::WriteListcert(const char *aGoodOwnerType, const std::stringstream &aTestCaseType, int &aTestIndex)
   424 	iFile << "\t\t<return>" << "KErrNone" << "</return>" << std::endl;
   439 {
   425 	iFile << "\t</actionresult>" << std::endl;
   440 	const char *testcasename = "Get the list of certificates";
   426 	iFile <<"</action>"<<std::endl;
   441 	const char *testcasetype = "listcert";
   427 	iFile << std::endl;
   442 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   428 }
   443 	iIniFile << "<actionbody>" << std::endl;
   429 
   444 	iIniFile << "\t<filter>" << std::endl;
   430 
   445 	iIniFile << "\t\t<ownertype>" << aGoodOwnerType << "</ownertype>" << std::endl;
   431 void  SWIStoreScriptGeneration::WriteListcert(const char *aGoodOwnerType)
   446 	iIniFile << "\t</filter>" << std::endl;
   432 {
   447 	iIniFile << "</actionbody>" << std::endl;
   433 	iFile << "# TEST" << iCount++ << std::endl;
   448 	iIniFile << "<actionresult>" << std::endl;
   434 	iFile <<"<action>"<<std::endl;
       
   435 	iFile << "\t<actionname>" << "Get the list of certificates" <<"</actionname>"<< std::endl;
       
   436 	iFile << "\t<actiontype>" << "listcert" <<"</actiontype>"<< std::endl;
       
   437 	iFile << "\t<actionbody>" << std::endl;
       
   438 	iFile << "\t\t<filter>" << std::endl;
       
   439 	iFile << "\t\t\t<ownertype>" << aGoodOwnerType	<< "</ownertype>" << std::endl;
       
   440 	iFile << "\t\t<filter>" << std::endl;
       
   441 	iFile << "\t</actionbody>" << std::endl;
       
   442 	iFile << "\t<actionresult>" << std::endl;
       
   443 	iFile << "\t\t<return>" <<"KErrNone"<< "</return>" << std::endl;
       
   444 	for(int i =0; i<6; i++)
   449 	for(int i =0; i<6; i++)
   445 		{
   450 		{
   446 		iFile << "\t\t<CCTCertInfo><label>" << goodSwiCert_array[i] << "</label><readonly>True</readonly></CCTCertInfo>" <<std::endl;
   451 		iIniFile << "\t<CCTCertInfo><label>" << goodSwiCert_array[i] << "</label><readonly>True</readonly></CCTCertInfo>" << std::endl;
   447 		}
   452 		}
   448 	iFile << "\t</actionresult>" << std::endl;
   453 	iIniFile << "</actionresult>" << std::endl;
   449 	iFile <<"</action>"<<std::endl;
   454 	iIniFile << std::endl;
   450 	iFile <<std::endl;
   455 }
   451 }
   456 
   452 
   457 void  SWIStoreScriptGeneration::WriteGetSystemUpgrade(const char *label, const char *aSystemUpgrade, const std::stringstream &aTestCaseType, int &aTestIndex)
   453 void SWIStoreScriptGeneration::WriteDetailsToArray(const char *array[])
   458 {
   454 	{
   459 	const char *testcasename = "Get the systemupgrade flag";
   455 	int i = 0;
   460 	const char *testcasetype = "getsystemupgrade";
   456 	iFile << "\t\t\t<format>" << array[i++]	<< "</format>" << std::endl;
   461 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   457 	iFile << "\t\t\t<subjectkeyid>" << array[i++]<< "</subjectkeyid>" << std::endl;
   462 	iIniFile << "<actionbody>" << std::endl;
   458 	iFile << "\t\t</filter>" << std::endl;
   463 	iIniFile << "\t<label>" << label << "</label>" << std::endl;
   459 	iFile << "\t</actionbody>" << std::endl;
   464 	iIniFile << "</actionbody>" << std::endl;
   460 	iFile << "\t<actionresult>" << std::endl;
   465 	iIniFile << "<actionresult>" << std::endl;
   461 	iFile << "\t\t<return>" <<"KErrNone"<< "</return>" << std::endl;
   466 	iIniFile << "\t<systemupgrade>" << aSystemUpgrade << "</systemupgrade>" << std::endl;
   462 	}
   467 	iIniFile << "</actionresult>" << std::endl;
   463 
   468 	iIniFile << std::endl;
   464 void  SWIStoreScriptGeneration::WriteGetSystemUpgrade(const char *label, const char *aSystemUpgrade)
   469 }
   465 {
   470 
   466 	iFile << "# TEST" << iCount++ << std::endl;
   471 
   467 	iFile <<"<action>"<<std::endl;
   472 void  SWIStoreScriptGeneration::WriteRetrieveCerts(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex)
   468 	iFile << "\t<actionname>" << "Get the systemupgrade flag" <<"</actionname>"<< std::endl;
   473 {
   469 	iFile << "\t<actiontype>" << "getsystemupgrade" <<"</actiontype>"<< std::endl;
   474 	const char *testcasename = "Retrieve Certificate";
   470 	iFile << "\t<actionbody>" << std::endl;
   475 	const char *testcasetype = "retrieve";
   471 	iFile << "\t\t<label>" << label<< "</label>" << std::endl;
   476 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   472 	iFile << "\t</actionbody>" << std::endl;
   477 	iIniFile << "<actionbody>" << std::endl;
   473 	iFile << "\t<actionresult>" << std::endl;
   478 	iIniFile << "\t<label>" << label << "</label>" << std::endl;
   474 	iFile << "\t\t<return>" <<"KErrNone"<< "</return>" << std::endl;
   479 	iIniFile << "</actionbody>" << std::endl;
   475 	iFile << "\t\t<systemupgrade>" << aSystemUpgrade <<"</systemupgrade>" << std::endl;
   480 	iIniFile << std::endl;
   476 	iFile << "\t</actionresult>" << std::endl;
   481 }
   477 	iFile <<"</action>"<<std::endl;
   482 
   478 	iFile <<std::endl;
   483 
   479 }
   484 
   480 
   485 void  SWIStoreScriptGeneration::WriteGetApplications(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex)
   481 
   486 {
   482 void  SWIStoreScriptGeneration::WriteRetrieveCerts(const char *label)
   487 	const char *testcasename = "Get applications";
   483 {
   488 	const char *testcasetype = "getapplications";
   484 	iFile << "# TEST" << iCount++ << std::endl;
   489 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   485 	iFile <<"<action>"<<std::endl;
   490 	iIniFile << "<actionbody>" << std::endl;
   486 	iFile << "\t<actionname>" << "Retrieve Certificate" <<"</actionname>"<< std::endl;
   491 	iIniFile << "\t<label>" << label << "</label>" << std::endl;
   487 	iFile << "\t<actiontype>" << "retrieve" <<"</actiontype>"<< std::endl;
   492 	iIniFile << "</actionbody>" << std::endl;
   488 	iFile << "\t<actionbody>" << std::endl;
   493 	iIniFile << "<actionresult>" << std::endl;
   489 	iFile << "\t\t<label>" << label<< "</label>" << std::endl;
   494 	iIniFile << "\t<uid>";
   490 	iFile << "\t</actionbody>" << std::endl;
       
   491 	iFile << "\t<actionresult>" << std::endl;
       
   492 	iFile << "\t\t<return>" <<"KErrNone"<< "</return>" << std::endl;
       
   493 	iFile << "\t</actionresult>" << std::endl;
       
   494 	iFile <<"</action>"<<std::endl;
       
   495 	iFile <<std::endl;
       
   496 }
       
   497 
       
   498 
       
   499 
       
   500 void  SWIStoreScriptGeneration::WriteGetApplications(const char *label)
       
   501 {
       
   502 	iFile << "# TEST" << iCount++ << std::endl;
       
   503 	iFile <<"<action>"<<std::endl;
       
   504 	iFile << "\t<actionname>" << "Get applications" <<"</actionname>"<< std::endl;
       
   505 	iFile << "\t<actiontype>" << "getapplications" <<"</actiontype>"<< std::endl;
       
   506 	iFile << "\t<actionbody>" << std::endl;
       
   507 	iFile << "\t\t<label>" << label << "</label>" << std::endl;
       
   508 	iFile << "\t</actionbody>" << std::endl;
       
   509 	iFile << "\t<actionresult>" << std::endl;
       
   510 	iFile << "\t\t<return>" <<"KErrNone"<< "</return>" << std::endl;
       
   511 	
       
   512 	iFile << "\t\t\t<uid>";
       
   513 	for(int j = 0; j<2; j++)
   495 	for(int j = 0; j<2; j++)
   514 		{
   496 		{
   515 		iFile << emu_cacertsUid[j] << " ";
   497 		iIniFile << emu_cacertsUid[j] << " ";
   516 		}
   498 		}
   517 	iFile <<"</uid>"<<std::endl;
   499 	iIniFile << "</uid>" << std::endl;
   518 	iFile << "\t</actionresult>" << std::endl;
   500 	iIniFile << "</actionresult>" << std::endl;
   519 	iFile <<"</action>"<<std::endl;
   501 	iIniFile << std::endl;
   520 	iFile <<std::endl;
   502 }
   521 }
   503 
   522 
   504 
   523 
   505 void  SWIStoreScriptGeneration::WriteGetTrust(const char *label, const char *trust, const std::stringstream &aTestCaseType, int &aTestIndex)
   524 void  SWIStoreScriptGeneration::WriteGetTrust(const char *label, const char *trust)
   506 {
   525 {
   507 	const char *testcasename = "Get Trust certificate";
   526 	iFile << "# TEST" << iCount++ << std::endl;
   508 	const char *testcasetype = "gettrusters";
   527 	iFile <<"<action>"<<std::endl;
   509 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   528 	iFile << "\t<actionname>" << "Get Trust certificate" <<"</actionname>"<< std::endl;
   510 	iIniFile << "<actionbody>" << std::endl;
   529 	iFile << "\t<actiontype>" << "gettrusters" <<"</actiontype>"<< std::endl;
   511 	iIniFile << "\t<label>" << label << "</label>" << std::endl;
   530 	iFile << "\t<actionbody>" << std::endl;
   512 	iIniFile << "</actionbody>" << std::endl;
   531 	iFile << "\t\t<label>" << label<< "</label>" << std::endl;
   513 	iIniFile << "<actionresult>" << std::endl;
   532 	iFile << "\t</actionbody>" << std::endl;
   514 	iIniFile << "\t<trust>" << trust << "</trust>" << std::endl;
   533 	iFile << "\t<actionresult>" << std::endl;
   515 	iIniFile << "</actionresult>" << std::endl;
   534 	iFile << "\t\t<return>" <<"KErrNone"<< "</return>" << std::endl;
   516 	iIniFile << std::endl;
   535 	iFile << "\t\t\t<trust>" << trust << "</trust>" <<std::endl;
   517 }
   536 	iFile << "\t</actionresult>" << std::endl;
   518 
   537 	iFile <<"</action>"<<std::endl;
   519 
   538 	iFile <<std::endl;
   520 
   539 }
   521 void  SWIStoreScriptGeneration::WriteGetCapabilities(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex)
   540 
   522 {
   541 
   523 	const char *testcasename = "Get the capabilities";
   542 
   524 	const char *testcasetype = "getcapabilities";
   543 void  SWIStoreScriptGeneration::WriteGetCapabilities(const char *label)
   525 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   544 {
   526 	iIniFile << "<actionbody>" << std::endl;
   545 	iFile << "# TEST" << iCount++ << std::endl;
   527 	iIniFile << "\t<label>" << label << "</label>" << std::endl;
   546 	iFile <<"<action>"<<std::endl;
   528 	iIniFile << "</actionbody>" << std::endl;
   547 	iFile << "\t<actionname>" << "Get the capabilities" <<"</actionname>"<< std::endl;
   529 	iIniFile << "<actionresult>" << std::endl;
   548 	iFile << "\t<actiontype>" << "getcapabilities" <<"</actiontype>"<< std::endl;
       
   549 	iFile << "\t<actionbody>" << std::endl;
       
   550 	iFile << "\t\t<label>" << label<< "</label>" << std::endl;
       
   551 	iFile << "\t</actionbody>" << std::endl;
       
   552 	iFile << "\t<actionresult>" << std::endl;
       
   553 	iFile << "\t\t<return>" <<"KErrNone"<< "</return>" << std::endl;
       
   554 
       
   555 	for(int i=0; i<20; i++)
   530 	for(int i=0; i<20; i++)
   556 		{
   531 		{
   557 		iFile << "\t\t<capability>" << goodCapabilitySets[i] <<"</capability>" << std::endl;
   532 		iIniFile << "\t<capability>" << goodCapabilitySets[i] << "</capability>" << std::endl;
   558 		}
   533 		}
   559 	iFile << "\t</actionresult>" << std::endl;
   534 	iIniFile << "</actionresult>" << std::endl;
   560 	iFile <<"</action>"<<std::endl;
   535 	iIniFile << std::endl;
   561 	iFile <<std::endl;
   536 }
   562 }
   537 
   563 
   538 
   564 
   539 void  SWIStoreScriptGeneration::WriteGetMandatoryFlag(const char *label, const char *aMandatory, const std::stringstream &aTestCaseType, int &aTestIndex)
   565 void  SWIStoreScriptGeneration::WriteGetMandatoryFlag(const char *label, const char *aMandatory)
   540 {
   566 {
   541 	const char *testcasename = "Get the mandatory flag";
   567 	iFile << "# TEST" << iCount++ << std::endl;
   542 	const char *testcasetype = "getmandatory";
   568 	iFile <<"<action>"<<std::endl;
   543 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   569 	iFile << "\t<actionname>" << "Get the mandatory flag" <<"</actionname>"<< std::endl;
   544 	iIniFile << "<actionbody>" << std::endl;
   570 	iFile << "\t<actiontype>" << "getmandatory" <<"</actiontype>"<< std::endl;
   545 	iIniFile << "\t<label>" << label << "</label>" << std::endl;
   571 	iFile << "\t<actionbody>" << std::endl;
   546 	iIniFile << "</actionbody>" << std::endl;
   572 	iFile << "\t\t<label>" << label<< "</label>" << std::endl;
   547 	iIniFile << "<actionresult>" << std::endl;
   573 	iFile << "\t</actionbody>" << std::endl;
   548 	iIniFile << "\t<mandatory>" << aMandatory << "</mandatory>" << std::endl;
   574 	iFile << "\t<actionresult>" << std::endl;
   549 	iIniFile << "</actionresult>" << std::endl;
   575 	iFile << "\t\t<return>" <<"KErrNone"<< "</return>" << std::endl;
   550 	iIniFile << std::endl;
   576 	iFile << "\t\t<mandatory>" << aMandatory <<"</mandatory>" << std::endl;
       
   577 	iFile << "\t</actionresult>" << std::endl;
       
   578 	iFile <<"</action>"<<std::endl;
       
   579 	iFile <<std::endl;
       
   580 }
   551 }
   581 
   552 
   582 
   553 
   583 //Cert client script generator
   554 //Cert client script generator
   584 CertClientsStoreScriptGeneration::CertClientsStoreScriptGeneration(const std::stringstream &aFileName)
   555 CertClientsStoreScriptGeneration::CertClientsStoreScriptGeneration(const std::stringstream &aFileName)
   585 	: GoodConfigWriter(aFileName), iCount(1)
   556 	: ScriptAndIniGeneration(aFileName)
   586 {
   557 {
   587 }
   558 }
   588 
   559 
   589 CertClientsStoreScriptGeneration::~CertClientsStoreScriptGeneration()
   560 CertClientsStoreScriptGeneration::~CertClientsStoreScriptGeneration()
   590 {
   561 {
   591 }
   562 }
   592 
   563 
   593 void CertClientsStoreScriptGeneration::WriteInitialiseCertClient()
   564 void CertClientsStoreScriptGeneration::WriteInitialiseCertClient(const std::stringstream &aTestCaseType, int &aTestIndex)
   594 {
   565 {
   595 	iFile << "# TEST" << iCount++ << std::endl;
   566 	const char *testcasename = "Initialise a CertClientStore";
   596 	iFile <<"<action>"<<std::endl;
   567 	const char *testcasetype = "InitManager";
   597 	iFile << "\t<actionname>" << "Initialise a CertClientStore" <<"</actionname>"<< std::endl;
   568 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype, false);
   598 	iFile << "\t<actiontype>" << "InitManager" <<"</actiontype>"<< std::endl;
   569 }
   599 	iFile << "\t<actionbody>" << std::endl;
   570 
   600 	iFile << "\t</actionbody>" << std::endl;
   571 void CertClientsStoreScriptGeneration::WriteGetCount(const int aApp_uidIndex, const std::stringstream &aTestCaseType, int &aTestIndex)
   601 	iFile << "\t<actionresult>" << std::endl;
   572 {
   602 	iFile << "\t\t<return>" << "KErrNone" << "</return>" << std::endl;
   573 	const char *testcasename = "Get Count of Applications";
   603 	iFile << "\t</actionresult>" << std::endl;
   574 	const char *testcasetype = "AppCount";
   604 	iFile <<"</action>"<<std::endl;
   575 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   605 	iFile << std::endl;
   576 	iIniFile << "<actionbody>" << std::endl;
   606 }
   577 	iIniFile << "\t<count>" << aApp_uidIndex << "</count>" << std::endl;
   607 
   578 	iIniFile << "</actionbody>" << std::endl;
   608 void CertClientsStoreScriptGeneration::WriteGetCount(const int aApp_uidIndex)
   579 	iIniFile << std::endl;
   609 {
   580 }
   610 	iFile << "# TEST" << iCount++ << std::endl;
   581 
   611 	iFile <<"<action>"<<std::endl;
   582 
   612 	iFile << "\t<actionname>" << "Get Count of Applications" <<"</actionname>"<< std::endl;
   583 void CertClientsStoreScriptGeneration::WriteGetApplicationsList(const std::stringstream &aTestCaseType, int &aTestIndex)
   613 	iFile << "\t<actiontype>" << "AppCount" <<"</actiontype>"<< std::endl;
   584 {
   614 	iFile << "\t<actionbody>" << std::endl;
   585 	const char *testcasename = "Getting the application list";
   615 	iFile << "\t\t<count>" << aApp_uidIndex << "</count>" << std::endl;
   586 	const char *testcasetype = "GetApplications";
   616 	iFile << "\t</actionbody>" << std::endl;
   587 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   617 	iFile << "\t<actionresult>" << std::endl;
   588 	iIniFile << "<actionbody>" << std::endl;
   618 	iFile << "\t\t<return>" <<"KErrNone"<< "</return>" << std::endl;
       
   619 	iFile << "\t</actionresult>" << std::endl;
       
   620 	iFile <<"</action>"<<std::endl;
       
   621 	iFile <<std::endl;
       
   622 }
       
   623 
       
   624 
       
   625 void CertClientsStoreScriptGeneration::WriteGetApplicationsList()
       
   626 {
       
   627 	iFile << "# TEST" << iCount++ << std::endl;
       
   628 	iFile <<"<action>"<<std::endl;
       
   629 	iFile << "\t<actionname>" << "Getting the application list" <<"</actionname>"<< std::endl;
       
   630 	iFile << "\t<actiontype>" << "GetApplications" <<"</actiontype>"<< std::endl;
       
   631 	iFile << "\t<actionbody>" << std::endl;
       
   632 	for(int i = 0 ; i<4 ; i++)
   589 	for(int i = 0 ; i<4 ; i++)
   633 		{
   590 		{
   634 		iFile << "\t\t<uid>" << gooddecimalUid_array[i] << "</uid>"<<"<appname>" << goodcertclient_array[i] << "</appname>" << std::endl;
   591 		iIniFile << "\t<uid>" << gooddecimalUid_array[i] << "</uid>"<<"<appname>" << goodcertclient_array[i] << "</appname>" << std::endl;
   635 		}
   592 		}
   636 	iFile << "\t</actionbody>" << std::endl;
   593 	iIniFile << "</actionbody>" << std::endl;
   637 	iFile << "\t<actionresult>" << std::endl;
   594 	iIniFile << std::endl;
   638 	iFile << "\t\t<return>" <<"KErrNone"<< "</return>" << std::endl;
   595 }
   639 	iFile << "\t</actionresult>" << std::endl;
   596 
   640 	iFile <<"</action>"<<std::endl;
   597 
   641 	iFile <<std::endl;
   598 void CertClientsStoreScriptGeneration::WriteGetAppWithUid(const char *goodlabel,const char *uid,const std::stringstream &aTestCaseType,int &aTestIndex)
   642 }
   599 {
   643 
   600 	const char *testcasename = "Get application with given id";
   644 
   601 	const char *testcasetype = "GetApp";
   645 void CertClientsStoreScriptGeneration::WriteGetAppWithUid(const char *goodlabel,const char *uid)
   602 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   646 {
   603 	iIniFile << "<actionbody>" << std::endl;
   647 	iFile << "# TEST" << iCount++ << std::endl;
   604 	iIniFile << "\t<uid>" << uid << "</uid>" << std::endl;
   648 	iFile <<"<action>"<<std::endl;
   605 	iIniFile << "\t<appname>" << goodlabel << "</appname>" << std::endl;
   649 	iFile << "\t<actionname>" << "Get application with given id" <<"</actionname>"<< std::endl;
   606 	iIniFile << "</actionbody>" << std::endl;
   650 	iFile << "\t<actiontype>" << "GetApp" <<"</actiontype>"<< std::endl;
   607 	iIniFile << std::endl;
   651 	iFile << "\t<actionbody>" << std::endl;
   608 }
   652 	iFile << "\t\t<uid>" << uid << "</uid>"<< std::endl;
   609 
   653 	iFile << "\t\t<appname>" << goodlabel << "</appname>" << std::endl;
   610 
   654 	iFile << "\t</actionbody>" << std::endl;
   611 void CertClientsStoreScriptGeneration::WriteDestroyManager(const std::stringstream &aTestCaseType, int &aTestIndex)
   655 	iFile << "\t<actionresult>" << std::endl;
   612 {
   656 	iFile << "\t\t<return>" <<"KErrNone"<< "</return>" << std::endl;
   613 	const char *testcasename = "Destroy the manager";
   657 	iFile << "\t</actionresult>" << std::endl;
   614 	const char *testcasetype = "DestroyManager";
   658 	iFile <<"</action>"<<std::endl;
   615 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype, false);
   659 	iFile <<std::endl;
       
   660 }
       
   661 
       
   662 
       
   663 void CertClientsStoreScriptGeneration::WriteDestroyManager()
       
   664 {
       
   665 	iFile << "# TEST" << iCount++ << std::endl;
       
   666 	iFile <<"<action>"<<std::endl;
       
   667 	iFile << "\t<actionname>" << "Destroy the manager" <<"</actionname>"<< std::endl;
       
   668 	iFile << "\t<actiontype>" << "DestroyManager" <<"</actiontype>"<< std::endl;
       
   669 	iFile << "\t<actionbody>" << std::endl;
       
   670 	iFile << "\t</actionbody>" << std::endl;
       
   671 	iFile << "\t<actionresult>" << std::endl;
       
   672 	iFile << "\t\t<return>" << "KErrNone" << "</return>" << std::endl;
       
   673 	iFile << "\t</actionresult>" << std::endl;
       
   674 	iFile <<"</action>"<<std::endl;
       
   675 	iFile << std::endl;
       
   676 }
   616 }
   677 
   617 
   678 
   618 
   679 /**
   619 /**
   680 Class definition for creating cacerts
   620 Class definition for creating cacerts
   689 {
   629 {
   690 	iFile << "EndCertStoreEntries" << std::endl;
   630 	iFile << "EndCertStoreEntries" << std::endl;
   691 }
   631 }
   692 
   632 
   693 // End of file
   633 // End of file
       
   634