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