authorisation/userpromptservice/test/tups/src/tupsdbmanagementstep.cpp
changeset 8 35751d3474b7
child 15 da2ae96f639b
equal deleted inserted replaced
2:675a964f4eb5 8:35751d3474b7
       
     1 /*
       
     2 * Copyright (c) 2007-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 "tupsdbmanagementstep.h"  
       
    20 #include "tupsintegdefs.h"
       
    21 #include "upstypes.h"
       
    22 
       
    23 using namespace UserPromptService;
       
    24 
       
    25 _LIT(KOperationCreateView, "CreateView");
       
    26 _LIT(KOperationCancelCloseView, "CancelCloseView");
       
    27 _LIT(KOperationNextMatch, "NextMatch");
       
    28 _LIT(KOperationRemoveDecision, "RemoveDecision");
       
    29 _LIT(KOperationUpdateDecisionAllow, "UpdateDecisionAllow");
       
    30 _LIT(KOperationUpdateDecisionDeny, "UpdateDecisionDeny");
       
    31 _LIT(KOperationCancelUpdate, "CancelUpdate");
       
    32 _LIT(KOperationDeleteDatabase, "DeleteDatabase");
       
    33 _LIT(KOperationDecisionCount, "DecisionCount");
       
    34 
       
    35 
       
    36 CUpsDbRequest* CUpsDbRequest::NewL()
       
    37 	{
       
    38 	CUpsDbRequest* me = new (ELeave) CUpsDbRequest();
       
    39 	CleanupStack::PushL(me);
       
    40 	me->ConstructL();
       
    41 	CleanupStack::Pop(me);
       
    42 	return me;	
       
    43 	}
       
    44 	
       
    45 CUpsDbRequest::~CUpsDbRequest()
       
    46 	{
       
    47 	delete iDecisionFilter;	
       
    48 	}
       
    49 
       
    50 CUpsDbRequest::CUpsDbRequest() 
       
    51 	:iOperation(0), iClientSid(0), iEvaluatorId(0), iServiceId(0), iServerSid(0), iFingerprint(0), 
       
    52 	iClientEntity(0), iDescription(0), iDecisionResult(0), iMajorPolicyVersion(0), iRecordId(0), iEvaluatorInfo(0), iExpectedDecisionCount(0)
       
    53 	{	
       
    54 	} 
       
    55 	
       
    56 void CUpsDbRequest::ConstructL()
       
    57 	{
       
    58 	iDecisionFilter = CDecisionFilter::NewL();	
       
    59 	}
       
    60 	
       
    61 CUPSDbManagementStep::CUPSDbManagementStep()
       
    62 	{
       
    63 	SetTestStepName(KUPSDbManagementStep);
       
    64 	}
       
    65 
       
    66 CUPSDbManagementStep::~CUPSDbManagementStep()
       
    67 	{
       
    68 	iUpsManager.CancelAndCloseView();
       
    69 	iUpsManager.Close();	
       
    70 	iArraySersToRequest.ResetAndDestroy();
       
    71 	INFO_PRINTF2(_L("END CELLS: %d"), User::CountAllocCells());  
       
    72 	__UHEAP_MARKEND;
       
    73 	}
       
    74 	
       
    75 TVerdict CUPSDbManagementStep::doTestStepPreambleL()
       
    76 /**
       
    77  * @return - TVerdict code
       
    78  * Override of base class virtual
       
    79  */
       
    80 	{
       
    81  	__UHEAP_MARK;
       
    82  	
       
    83  	INFO_PRINTF2(_L("START CELLS: %d"), User::CountAllocCells());
       
    84  	
       
    85  	// reads client name and SID
       
    86 	TParse clientFullName;
       
    87 	RThread client;
       
    88 	clientFullName.Set(client.FullName(),NULL, NULL);
       
    89 	iTEFServerName=clientFullName.Name();
       
    90 	iExpectedClientSid = client.SecureId() ;
       
    91 	client.Close();
       
    92  	
       
    93     // Read how many times the test step needs to be repeated.
       
    94     TName fStepRepeat(_L("StepRepeat"));
       
    95     TInt  repeats;
       
    96     
       
    97     if(GetIntFromConfig(ConfigSection(),fStepRepeat,repeats))
       
    98     	{
       
    99     	iStepRepeat=repeats;
       
   100     	}
       
   101 	else
       
   102 		{	
       
   103 		iStepRepeat=1;		
       
   104 		}
       
   105     
       
   106     // Read values for test sequence from INI file. (ARRAY of values)
       
   107 	TInt index=0;
       
   108 	TName fOperation;
       
   109 	fOperation.Format(_L("Operation_%d"), index);
       
   110 	TName fClientSid;
       
   111 	fClientSid.Format(_L("ClientSid_%d"),index);
       
   112 	TName fEvaluatorId;
       
   113 	fEvaluatorId.Format(_L("EvaluatorId_%d"),index);
       
   114 	TName fServiceId;
       
   115 	fServiceId.Format(_L("ServiceId_%d"),index);
       
   116 	TName fServerSid;
       
   117 	fServerSid.Format(_L("ServerSid_%d"),index);
       
   118 	TName fFingerprint;
       
   119 	fFingerprint.Format(_L("Fingerprint_%d"),index);
       
   120 	TName fClientEntity;
       
   121 	fClientEntity.Format(_L("ClientEntity_%d"),index);
       
   122 	TName fDescription;
       
   123 	fDescription.Format(_L("Description_%d"),index);
       
   124 	TName fDecisionResult;
       
   125 	fDecisionResult.Format(_L("DecisionResult_%d"),index);
       
   126 	TName fMajorPolicyVersion;
       
   127 	fMajorPolicyVersion.Format(_L("MajorPolicyVersion_%d"),index);
       
   128 	TName fRecordId;
       
   129 	fRecordId.Format(_L("RecordId_%d"),index);
       
   130 	TName fEvaluatorInfo;
       
   131 	fEvaluatorInfo.Format(_L("EvaluatorInfo_%d"),index);
       
   132 	TName fExpectedDecisionCount;
       
   133 	fExpectedDecisionCount.Format(_L("ExpectedDecisionCount_%d"),index);
       
   134 	
       
   135 	TPtrC 	operation;
       
   136 	TInt	clientSid;
       
   137 	TInt	evaluatorId;
       
   138 	TInt	serviceId;
       
   139 	TInt	serverSid;
       
   140 	TPtrC	fingerprint;
       
   141 	TPtrC	clientEntity;
       
   142 	TPtrC	description;
       
   143 	TPtrC	decisionResult;
       
   144 	TInt	majorPolicyVersion;
       
   145 	TInt 	recordId;
       
   146 	TInt	evaluatorInfo;
       
   147 	TInt 	expectedDecisionCount;
       
   148 	
       
   149 	while (GetStringFromConfig(ConfigSection(),fOperation,operation))
       
   150 		{
       
   151 		
       
   152 		// Create an instance of a new request
       
   153 		CUpsDbRequest* newRequest = CUpsDbRequest::NewL();
       
   154 		CleanupStack::PushL(newRequest);
       
   155 		
       
   156 		// Set the operation to be performed
       
   157 	    newRequest->iOperation = operation;
       
   158 	    
       
   159 	    if(GetHexFromConfig(ConfigSection(),fClientSid,clientSid))
       
   160 		    {
       
   161 		    newRequest->iClientSid = clientSid;
       
   162 		  	newRequest->iDecisionFilter->SetClientSid(TSecureId(clientSid),EEqual);
       
   163 		    }
       
   164 	    
       
   165 		if(GetHexFromConfig(ConfigSection(),fEvaluatorId,evaluatorId))
       
   166 			{
       
   167 			newRequest->iEvaluatorId = evaluatorId;	
       
   168 			newRequest->iDecisionFilter->SetEvaluatorId(TUid::Uid(evaluatorId),EEqual);
       
   169 			}
       
   170 		
       
   171 		if(GetHexFromConfig(ConfigSection(),fServiceId,serviceId))
       
   172 			{
       
   173 			newRequest->iServiceId = serviceId;	
       
   174 			newRequest->iDecisionFilter->SetServiceId(TUid::Uid(serviceId),EEqual);
       
   175 			}
       
   176 	
       
   177 		if(GetHexFromConfig(ConfigSection(),fServerSid,serverSid))
       
   178 			{
       
   179 			newRequest->iServerSid = serverSid;	
       
   180 			newRequest->iDecisionFilter->SetServerSid(TSecureId(serverSid),EEqual);
       
   181 			}
       
   182 			
       
   183 		if(GetStringFromConfig(ConfigSection(),fFingerprint,fingerprint))
       
   184 			{
       
   185 			HBufC8* fingerprintConverter = HBufC8::NewLC(fingerprint.Length());
       
   186 			TPtr8 fingerprintPtr = fingerprintConverter->Des();
       
   187 			fingerprintPtr.Copy(fingerprint); 	
       
   188              
       
   189 	       	newRequest->iFingerprint = fingerprintPtr;
       
   190 	       	
       
   191 	       	HBufC8* binaryFingerprint = StringToBinaryLC(fingerprintPtr);
       
   192 	       	
       
   193 	      	newRequest->iDecisionFilter->SetFingerprintL(*binaryFingerprint,EEqual);	
       
   194 	       	CleanupStack::PopAndDestroy(binaryFingerprint);
       
   195 	       	CleanupStack::PopAndDestroy(fingerprintConverter); 
       
   196 			}
       
   197 
       
   198 		if(GetStringFromConfig(ConfigSection(),fClientEntity,clientEntity))
       
   199 			{
       
   200 			HBufC8* clientEntityConverter = HBufC8::NewLC(clientEntity.Length());
       
   201 			TPtr8 clientEntityPtr = clientEntityConverter->Des();
       
   202 			clientEntityPtr.Copy(clientEntity); 	
       
   203              
       
   204 	       	newRequest->iClientEntity = clientEntityPtr;
       
   205 	       	newRequest->iDecisionFilter->SetClientEntityL(clientEntityPtr,EEqual);		
       
   206 	       	CleanupStack::PopAndDestroy(clientEntityConverter); 
       
   207 			}
       
   208 			
       
   209 		if(GetStringFromConfig(ConfigSection(),fDescription,description))
       
   210 			{
       
   211 		    newRequest->iDescription = description;
       
   212 			}
       
   213 			
       
   214 		if(GetStringFromConfig(ConfigSection(),fDecisionResult,decisionResult))
       
   215 			{
       
   216 			if(decisionResult.CompareF(_L("Yes"))==0 || decisionResult.CompareF(_L("No"))==0 || decisionResult.CompareF(_L(""))==0 )
       
   217 				{
       
   218 				newRequest->iDecisionResult = decisionResult;	
       
   219 				}
       
   220 			else 
       
   221 				{
       
   222 				ERR_PRINTF3(_L("%S: Unexpected Decision Result - %S"),&iTEFServerName, &decisionResult);
       
   223 				}
       
   224 			}
       
   225 
       
   226 		if(GetIntFromConfig(ConfigSection(),fMajorPolicyVersion,majorPolicyVersion)) 
       
   227 			{
       
   228 			newRequest->iMajorPolicyVersion = majorPolicyVersion;
       
   229 			newRequest->iDecisionFilter->SetMajorPolicyVersion(majorPolicyVersion,EEqual);		
       
   230 			}
       
   231 		
       
   232 		if(GetIntFromConfig(ConfigSection(),fRecordId,recordId))
       
   233 			{
       
   234 			newRequest->iRecordId = recordId;
       
   235 			newRequest->iDecisionFilter->SetRecordId(recordId,EEqual);		
       
   236 			}
       
   237 			
       
   238 		if(GetIntFromConfig(ConfigSection(),fEvaluatorInfo,evaluatorInfo))
       
   239 			{
       
   240 			newRequest->iEvaluatorInfo = evaluatorInfo;		
       
   241 			}
       
   242 			
       
   243 		if(GetIntFromConfig(ConfigSection(),fExpectedDecisionCount,expectedDecisionCount))
       
   244 			{
       
   245 			newRequest->iExpectedDecisionCount = expectedDecisionCount;		
       
   246 			}
       
   247 	    
       
   248 	    // Add the new service to be requested to array.
       
   249 	    iArraySersToRequest.AppendL(newRequest);
       
   250 	    
       
   251 	    CleanupStack::Pop(newRequest);
       
   252 	       
       
   253 	    index++;
       
   254 	    fOperation.Format(_L("Operation_%d"), index);
       
   255 	    fClientSid.Format(_L("ClientSid_%d"),index);
       
   256 		fEvaluatorId.Format(_L("EvaluatorId_%d"),index);
       
   257 		fServiceId.Format(_L("ServiceId_%d"),index);
       
   258 		fServerSid.Format(_L("ServerSid_%d"),index);
       
   259 		fFingerprint.Format(_L("Fingerprint_%d"),index);
       
   260 		fClientEntity.Format(_L("ClientEntity_%d"),index);
       
   261 		fDescription.Format(_L("Description_%d"),index);
       
   262 		fDecisionResult.Format(_L("DecisionResult_%d"),index);
       
   263 		fMajorPolicyVersion.Format(_L("MajorPolicyVersion_%d"),index);
       
   264 		fRecordId.Format(_L("RecordId_%d"),index);
       
   265 		fEvaluatorInfo.Format(_L("EvaluatorInfo_%d"),index);
       
   266 		fExpectedDecisionCount.Format(_L("ExpectedDecisionCount_%d"),index);
       
   267 		}
       
   268 	
       
   269 	SetTestStepResult(EPass);
       
   270 	return TestStepResult();
       
   271 	}
       
   272 
       
   273 TVerdict CUPSDbManagementStep::doTestStepL()
       
   274 	{
       
   275 	// Connect to the UPS Manager
       
   276 	User::LeaveIfError(iUpsManager.Connect());
       
   277 	
       
   278 	// loop to request for different test services.
       
   279 	SetTestStepResult(EPass);
       
   280 	TInt numServicesToRequest = iArraySersToRequest.Count();
       
   281 
       
   282 	if(numServicesToRequest > 0) 
       
   283 		{
       
   284 		// repeats the sequence of test services request as many times as specified in iStepRepeat
       
   285 		for(TInt repeatTimes = 0;repeatTimes<iStepRepeat;++repeatTimes)
       
   286 			{
       
   287 			
       
   288 			INFO_PRINTF3(_L("%S: Repeat number: %d"),&iTEFServerName,repeatTimes);
       
   289 			
       
   290 			for(TInt index=0;index < numServicesToRequest; ++index )
       
   291 				{
       
   292 				
       
   293  			    INFO_PRINTF4(_L("%S: Database Request: %d, Command: %S"),&iTEFServerName, index, &iArraySersToRequest[index]->iOperation);	
       
   294  			    
       
   295  			    TRequestStatus requestStatus;	    
       
   296     			
       
   297  			    TPtrC op(iArraySersToRequest[index]->iOperation);
       
   298  			    
       
   299  			    // *** CREATE VIEW ***
       
   300  			    if (!op.CompareF(KOperationCreateView))
       
   301  			    	{
       
   302  					// Create view using the Decision Filter for the Request
       
   303  			    	iUpsManager.CreateView(*iArraySersToRequest[index]->iDecisionFilter,requestStatus);
       
   304  			    	
       
   305  			    	User::WaitForRequest(requestStatus);
       
   306  			    	
       
   307  			    	if(requestStatus != KErrNone)
       
   308 	 			    	{
       
   309 	 			    	SetTestStepResult(EFail);
       
   310 	 			    	ERR_PRINTF3(_L("%S: Create View Failure - %d"),&iTEFServerName,requestStatus.Int());	
       
   311 	 			    	User::Leave(requestStatus.Int());	
       
   312 	 			    	}
       
   313  			    	}
       
   314  			    // *** CANCEL CLOSE VIEW ***
       
   315  			    else if (!op.CompareF(KOperationCancelCloseView))
       
   316  			    	{
       
   317  			    	iUpsManager.CancelAndCloseView();
       
   318  			    	
       
   319  			    	INFO_PRINTF2(_L("%S: UPS DB Management - Current View Cancelled and Closed"),&iTEFServerName);
       
   320  			    	}
       
   321  			    // *** NEXT MATCH ***	
       
   322  			    else if (!op.CompareF(KOperationNextMatch))
       
   323  			    	{
       
   324  			    	CDecisionRecord* record = NULL;
       
   325  			    	
       
   326  			    	// Retrieve the Next Decision according to the Current View
       
   327  			    	record = iUpsManager.NextMatchL();
       
   328  			    	CleanupStack::PushL(record);
       
   329  			    	
       
   330  			    	// If a record is found, check that the record matches any data specified in the INI
       
   331  			    	if(record != NULL)
       
   332 	 			    	{
       
   333 	 			    	if(CheckDecisionRecordL(index,*record) == EFalse)
       
   334 		 			    	{
       
   335 		 			    	iUpsManager.CancelAndCloseView();
       
   336 		 			    	ERR_PRINTF2(_L("%S: Incorrect Results"),&iTEFServerName);
       
   337 							User::Leave(KErrGeneral);	
       
   338 		 			    	}	 			    		
       
   339 	 			    	}
       
   340 	 			    else
       
   341 	 			    	{
       
   342 	 			    	iUpsManager.CancelAndCloseView();
       
   343 	 			    	SetTestStepResult(EFail);
       
   344 		    			ERR_PRINTF2(_L("%S: NextMatchL - No Decision Retrieved"),&iTEFServerName);
       
   345 						User::Leave(KErrEof);	
       
   346 	 			    	}
       
   347 	 			    	
       
   348 	 			    CleanupStack::PopAndDestroy(record);
       
   349  			    	
       
   350  			    	}
       
   351  			    // *** REMOVE DECISION ***
       
   352  			    else if (!op.CompareF(KOperationRemoveDecision))
       
   353  			    	{
       
   354  			    	// Remove decisions from the database based on the contents of the Decision Filter
       
   355  			    	TRAPD(err, iUpsManager.RemoveDecisionsL(*iArraySersToRequest[index]->iDecisionFilter));
       
   356  			    	
       
   357  			    	if(err == KErrNone)
       
   358 	 			    	{
       
   359 	 			    	INFO_PRINTF2(_L("%S: Remove Decision - Decision(s) Successfully Removed"),&iTEFServerName);
       
   360 	 			    	}
       
   361 	 			    else
       
   362 	 			    	{
       
   363 	 			    	SetTestStepResult(EFail);
       
   364 	 			    	ERR_PRINTF3(_L("%S: ** Error ** Remove Decision Failure - %d"),&iTEFServerName,err);
       
   365 	 			    	User::Leave(err);	
       
   366 	 			    	}
       
   367  			    	}
       
   368  			    // *** UPDATE DECISION ALLOW ***
       
   369  			    else if (!op.CompareF(KOperationUpdateDecisionAllow))
       
   370  			    	{
       
   371  			    	iUpsManager.UpdateDecision(iArraySersToRequest[index]->iRecordId, ETrue, requestStatus);
       
   372  			    	
       
   373  			    	User::WaitForRequest(requestStatus);
       
   374  			    	
       
   375  			    	if(requestStatus != KErrNone)
       
   376 	 			    	{
       
   377 	 			    	SetTestStepResult(EFail);
       
   378 	 			    	ERR_PRINTF3(_L("%S: Update Decision 'Allow' Failure - %d"),&iTEFServerName,requestStatus.Int());	
       
   379 	 			    	User::Leave(requestStatus.Int());	
       
   380 	 			    	}
       
   381  			    	}
       
   382  			    // *** UPDATE DECISION DENY ***
       
   383  			    else if (!op.CompareF(KOperationUpdateDecisionDeny))
       
   384  			    	{
       
   385  			    	iUpsManager.UpdateDecision(iArraySersToRequest[index]->iRecordId, EFalse, requestStatus);
       
   386  			    	
       
   387  			    	User::WaitForRequest(requestStatus);
       
   388  			    	
       
   389  			    	if(requestStatus != KErrNone)
       
   390 	 			    	{
       
   391 	 			    	SetTestStepResult(EFail);
       
   392 	 			    	ERR_PRINTF3(_L("%S: Update Decision 'Deny' Failure - %d"),&iTEFServerName,requestStatus.Int());	
       
   393 	 			    	User::Leave(requestStatus.Int());	
       
   394 	 			    	}
       
   395  			    	}
       
   396  			    // *** CANCEL DECISION UPDATE ***
       
   397  			    else if (!op.CompareF(KOperationCancelUpdate))
       
   398  			    	{
       
   399  			    	iUpsManager.CancelUpdateDecision();
       
   400  			    	
       
   401  			    	INFO_PRINTF2(_L("%S: UPS DB Management - Current Decision Update Cancelled"),&iTEFServerName);
       
   402  			    	}
       
   403  			    // *** DELETE DATABASE ***
       
   404  			    else if (!op.CompareF(KOperationDeleteDatabase))
       
   405  			    	{
       
   406  			    	// Delete the contents of the Decision Database
       
   407  			    	TRAPD(err, iUpsManager.DeleteDatabaseL());
       
   408  			    	
       
   409  			    	if(err == KErrNone)
       
   410 	 			    	{
       
   411 	 			    	INFO_PRINTF2(_L("%S: UPS DB Management - Database Deleted"),&iTEFServerName);
       
   412 	 			    	}
       
   413 	 			    else
       
   414 	 			    	{
       
   415 	 			    	SetTestStepResult(EFail);
       
   416 	 			    	ERR_PRINTF3(_L("%S: ** Error ** Database Deletion Failure - %d"),&iTEFServerName,err);
       
   417 	 			    	User::Leave(err);	
       
   418 	 			    	}
       
   419  			    	}
       
   420  			    // *** DECISION COUNT ***
       
   421  			    else if (!op.CompareF(KOperationDecisionCount))
       
   422  			    	{
       
   423  			    	iUpsManager.CancelAndCloseView();
       
   424  			    	
       
   425  			    	// Create a new view using the constructed decision filter for the request
       
   426  			    	iUpsManager.CreateView(*iArraySersToRequest[index]->iDecisionFilter,requestStatus);
       
   427  			    	
       
   428  			    	User::WaitForRequest(requestStatus);
       
   429  			    	
       
   430  			    	if(requestStatus.Int() == KErrNone)
       
   431 	 			    	{
       
   432 	 			    	TInt decisionCount = 0;
       
   433 	 			    	CDecisionRecord* record = NULL;
       
   434 	 			    	
       
   435 	 			    	TInt result = KErrNone;
       
   436 	 			    	
       
   437 	 			    	// Whilst records located using the "NextMatchL" method, increment the record count
       
   438 						while(result == KErrNone)
       
   439 							{
       
   440 							TRAP(result, record = iUpsManager.NextMatchL());
       
   441 							
       
   442 							if(record == NULL)
       
   443 								{
       
   444 								break;
       
   445 								}
       
   446 							else
       
   447 								{
       
   448 								++decisionCount;	
       
   449 								}
       
   450 							
       
   451 							delete record;
       
   452 							record = NULL;
       
   453 							}
       
   454 														
       
   455 						iUpsManager.CancelAndCloseView();
       
   456 							
       
   457 						if(decisionCount != iArraySersToRequest[index]->iExpectedDecisionCount)
       
   458 		    				{
       
   459 		    				SetTestStepResult(EFail);
       
   460 		    				ERR_PRINTF2(_L("%S: Decision Count - Unexpected Number of Database Decisions"),&iTEFServerName);
       
   461 		    				ERR_PRINTF3(_L("%S: Decisions expected: %d"),&iTEFServerName,iArraySersToRequest[index]->iExpectedDecisionCount);
       
   462 		    				ERR_PRINTF3(_L("%S: Decisions in Database: %d"),&iTEFServerName,decisionCount);
       
   463 							User::Leave(KErrNotFound);
       
   464 		    				}
       
   465 		    						    				
       
   466 	 			    	}
       
   467 	 			    else
       
   468 	 			    	{
       
   469 	 			    	SetTestStepResult(EFail);
       
   470 	 			    	ERR_PRINTF3(_L("%S: Decision Count - Create View Failure - %d"),&iTEFServerName,requestStatus.Int());	
       
   471 	 			    	User::Leave(requestStatus.Int());
       
   472 	 			    	}
       
   473  			    	}	
       
   474  			    else
       
   475  			    	{
       
   476  			    	SetTestStepResult(EFail);
       
   477 		     	    ERR_PRINTF2(_L("%S: Invalid operation"),&iTEFServerName);
       
   478 					User::Leave(KErrNotSupported);	 			    	
       
   479  			    	}
       
   480 	    	
       
   481 				}  // End of second loop
       
   482 			}// End of first loop
       
   483 		
       
   484 		} 
       
   485 	else
       
   486 		{
       
   487 		SetTestStepResult(EFail);
       
   488 		ERR_PRINTF2(_L("%S: Problem reading ini file"),&iTEFServerName);
       
   489 		User::Leave(KErrGeneral);	
       
   490 		}  
       
   491 		
       
   492 	return TestStepResult();
       
   493 	}  // End of function
       
   494 
       
   495 
       
   496 TVerdict CUPSDbManagementStep::doTestStepPostambleL()
       
   497 	{
       
   498 	return TestStepResult();
       
   499 	}
       
   500 	
       
   501 	
       
   502 TBool CUPSDbManagementStep::CheckDecisionRecordL(TInt aIndex, const CDecisionRecord& aRecord)
       
   503 /**
       
   504  * Checks the expected record values against those stored within CDecisionRecord retrieved from the database
       
   505  *
       
   506  * @param  - TInt aIndex: Database request index used to access the required instance of CUpsDbRequest held 
       
   507  * 			 within the request array
       
   508  * @param  - const CDecisionRecord& aRecord: Decision Record retrieved from the database
       
   509  * @return - TBool: Boolean to determine the result of the value checks (ETrue = Pass, EFalse = Fail)
       
   510  **/
       
   511 	{
       
   512 	
       
   513 	TBool checkPassed = ETrue;
       
   514 		
       
   515 
       
   516 	if(iArraySersToRequest[aIndex]->iClientSid != aRecord.iClientSid)
       
   517 		{
       
   518 		ERR_PRINTF2(_L("%S: 'Client SID' value mismatch"),&iTEFServerName);
       
   519 		checkPassed = EFalse;	
       
   520 		}
       
   521 
       
   522 	if(iArraySersToRequest[aIndex]->iEvaluatorId != aRecord.iEvaluatorId.iUid)
       
   523 		{
       
   524 		ERR_PRINTF2(_L("%S: 'Evaluator ID' value mismatch"),&iTEFServerName);
       
   525 		checkPassed = EFalse;	
       
   526 		}	
       
   527 
       
   528 	if(iArraySersToRequest[aIndex]->iServiceId != aRecord.iServiceId.iUid)
       
   529 		{
       
   530 		ERR_PRINTF2(_L("%S: 'Service ID' value mismatch"),&iTEFServerName);
       
   531 		checkPassed = EFalse;	
       
   532 		}	
       
   533 
       
   534 	if(iArraySersToRequest[aIndex]->iServerSid != aRecord.iServerSid)
       
   535 		{
       
   536 		ERR_PRINTF2(_L("%S: 'Server SID' value mismatch"),&iTEFServerName);
       
   537 		checkPassed = EFalse;	
       
   538 		}	
       
   539 
       
   540 	HBufC8* recordFingerprint = StringToHexLC(aRecord.iFingerprint);
       
   541 	
       
   542 	if(iArraySersToRequest[aIndex]->iFingerprint != *recordFingerprint)
       
   543 		{
       
   544 		HBufC* expectedFingerprint = HBufC::NewLC(iArraySersToRequest[aIndex]->iFingerprint.Length());
       
   545 		HBufC* receivedFingerprint = HBufC::NewLC(recordFingerprint->Length());
       
   546 		
       
   547 		expectedFingerprint->Des().Copy(iArraySersToRequest[aIndex]->iFingerprint);
       
   548 		receivedFingerprint->Des().Copy(*recordFingerprint);
       
   549 		
       
   550 		ERR_PRINTF2(_L("%S: 'Fingerprint' value mismatch."),&iTEFServerName);
       
   551 		ERR_PRINTF3(_L("%S: Fingerprint expected: %S"),&iTEFServerName,expectedFingerprint);
       
   552     	ERR_PRINTF3(_L("%S: Fingerprint received: %S"),&iTEFServerName,receivedFingerprint);
       
   553 		
       
   554 		CleanupStack::PopAndDestroy(receivedFingerprint);
       
   555 		CleanupStack::PopAndDestroy(expectedFingerprint);
       
   556 		checkPassed = EFalse;	
       
   557 		}
       
   558 		
       
   559 	CleanupStack::PopAndDestroy(recordFingerprint);	
       
   560 
       
   561 	if(iArraySersToRequest[aIndex]->iClientEntity != aRecord.iClientEntity)
       
   562 		{
       
   563 		HBufC* expectedClientEntity = HBufC::NewLC(iArraySersToRequest[aIndex]->iClientEntity.Length());
       
   564 		HBufC* receivedClientEntity = HBufC::NewLC(aRecord.iClientEntity.Length());
       
   565 		
       
   566 		expectedClientEntity->Des().Copy(iArraySersToRequest[aIndex]->iClientEntity);
       
   567 		receivedClientEntity->Des().Copy(aRecord.iClientEntity);
       
   568 		
       
   569 		ERR_PRINTF2(_L("%S: 'Client Entity' value mismatch."),&iTEFServerName);
       
   570 		
       
   571 		CleanupStack::PopAndDestroy(receivedClientEntity);
       
   572 		CleanupStack::PopAndDestroy(expectedClientEntity);
       
   573 		checkPassed = EFalse;
       
   574 		}	
       
   575 
       
   576 	if(iArraySersToRequest[aIndex]->iDescription.CompareF(aRecord.iDescription) != 0)
       
   577 		{
       
   578 		TPtrC retrievedDescription(aRecord.iDescription);
       
   579 		ERR_PRINTF2(_L("%S: 'Description' value mismatch."),&iTEFServerName);
       
   580     	checkPassed = EFalse;
       
   581 		}
       
   582 	
       
   583 	TInt expectedDecisionResult = 0;
       
   584 	
       
   585 	if(iArraySersToRequest[aIndex]->iDecisionResult.CompareF(_L("Yes")) == 0)
       
   586 		{
       
   587 		expectedDecisionResult = 1;	
       
   588 		}
       
   589 	
       
   590 	if(expectedDecisionResult != aRecord.iResult)
       
   591 		{
       
   592 		ERR_PRINTF2(_L("%S: 'Decision Result' value mismatch."),&iTEFServerName);
       
   593 		checkPassed = EFalse;
       
   594 		}
       
   595 
       
   596 	if(iArraySersToRequest[aIndex]->iMajorPolicyVersion != aRecord.iMajorPolicyVersion)
       
   597 		{
       
   598 		ERR_PRINTF2(_L("%S: 'Major Policy Version' value mismatch."),&iTEFServerName);
       
   599 		checkPassed = EFalse;	
       
   600 		}	
       
   601 
       
   602 	if(iArraySersToRequest[aIndex]->iEvaluatorInfo != aRecord.iEvaluatorInfo)
       
   603 		{
       
   604 		ERR_PRINTF2(_L("%S: 'Evaluator Info' value mismatch."),&iTEFServerName);
       
   605 		checkPassed = EFalse;	
       
   606 		}	
       
   607 
       
   608 	if(iArraySersToRequest[aIndex]->iRecordId != aRecord.iRecordId)
       
   609 		{
       
   610 		ERR_PRINTF2(_L("%S: 'Record ID' value mismatch."),&iTEFServerName);
       
   611 		checkPassed = EFalse;	
       
   612 		}	
       
   613 	
       
   614 	return checkPassed;
       
   615 	}
       
   616 	
       
   617 
       
   618 	
       
   619 HBufC8* CUPSDbManagementStep::StringToHexLC(const TDes8 &aString)
       
   620 /**
       
   621  * Function to convert the contents of a TDes8 into a Hexadecimal format
       
   622  *
       
   623  * @param  - cosnt TDes8 aString: String to convert into Hexadecimal
       
   624  * @return - HBufC8*: Converted Hexadecial string representation
       
   625  **/
       
   626 	{
       
   627 	HBufC8* parsedString = HBufC8::NewLC(aString.Length()*2);
       
   628 	TBuf8<2> pair;
       
   629 	_LIT8(KFormatHex,"%02x"); 
       
   630 		
       
   631 	TPtr8 ptr(parsedString->Des());
       
   632    	for(TInt i = 0; i<aString.Length() ; i++)
       
   633     	{
       
   634 		TInt num  = (aString)[i];
       
   635     	pair.Format(KFormatHex,num);
       
   636     	ptr.Append(pair);
       
   637     	}
       
   638 	    
       
   639 	return parsedString;
       
   640 	}
       
   641 	
       
   642 	
       
   643 HBufC8* CUPSDbManagementStep::StringToBinaryLC(const TDes8 &aString)
       
   644 /**
       
   645  * Function to convert the contents of a TDes8 into a Binary format
       
   646  *
       
   647  * @param  - cosnt TDes8 aString: String to convert into Hexadecimal
       
   648  * @return - HBufC8*: Converted Binary string representation
       
   649  **/
       
   650 	{
       
   651 	HBufC8* parsedString = HBufC8::NewLC(aString.Length()/2);
       
   652 	TBuf8<1> binChar;
       
   653 	_LIT8(KFormatBinary,"%c"); 
       
   654 		
       
   655 	TPtr8 ptr(parsedString->Des());
       
   656    	for(TInt i = 0; i<aString.Length()/2 ; i++)
       
   657     	{
       
   658     	TPtrC8 tempPtr(aString.Mid(i*2,2));
       
   659     	TLex8 lex(tempPtr);
       
   660     	TUint val=0;
       
   661     	lex.Val(val, EHex);
       
   662     	binChar.Format(KFormatBinary,val);
       
   663     	ptr.Append(binChar);
       
   664     	}
       
   665 	    
       
   666 	return parsedString;
       
   667 	}