24
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// Tests ETelMM's API for Smart Card Application EAP support. This uses
|
|
15 |
// the dummy TSY (dmmtsy.tsy) to run basic tests on the
|
|
16 |
// RMobileSmartCardEap.
|
|
17 |
//
|
|
18 |
//
|
|
19 |
|
|
20 |
/**
|
|
21 |
@file
|
|
22 |
@internalComponent
|
|
23 |
*/
|
|
24 |
|
|
25 |
|
|
26 |
#include <e32test.h>
|
|
27 |
|
|
28 |
#include "TE_EtelMMTestStepBase.h"
|
|
29 |
#include "TE_mmsmartcardeap.h"
|
|
30 |
#include "testdef.h"
|
|
31 |
|
|
32 |
/**
|
|
33 |
Each test step initialises it's own name
|
|
34 |
*/
|
|
35 |
CTestSmartCardEap::CTestSmartCardEap()
|
|
36 |
{
|
|
37 |
// store the name of this test case
|
|
38 |
// this is the name that is used by the script file
|
|
39 |
SetTestStepName(_L("TestMMSmartCardBasedEap"));
|
|
40 |
}
|
|
41 |
|
|
42 |
enum TVerdict CTestSmartCardEap::doTestStepL()
|
|
43 |
{
|
|
44 |
INFO_PRINTF1(_L("Test SmartCard Application based EAP Functionality"));
|
|
45 |
|
|
46 |
RMobilePhone mmPhone;
|
|
47 |
TInt ret = mmPhone.Open(iTelServer, DMMTSY_PHONE_NAME);
|
|
48 |
TEST(ret == KErrNone);
|
|
49 |
|
|
50 |
// Vars to be used throughout test
|
|
51 |
TRequestStatus reqStatus = KErrNone;
|
|
52 |
RMobilePhone::TAID myAID;
|
|
53 |
RMobileSmartCardEap::TEapType myEapType;
|
|
54 |
RMobileSmartCardEap mmScEap, mmScEap2, mmScEap3;
|
|
55 |
|
|
56 |
// Test opening RMobileSmartCardEap sub-session to bad eap method/AID
|
|
57 |
_LIT8(badAID, "\xFF\xEE\xDD");
|
|
58 |
_LIT8(badMethod, "BadEap");
|
|
59 |
|
|
60 |
myAID = badAID();
|
|
61 |
myEapType = badMethod();
|
|
62 |
|
|
63 |
// Open a handle and don't initialise; to be used in TestScEapL() for a little more coverage
|
|
64 |
ret = mmScEap3.Open(mmPhone, myAID, myEapType);
|
|
65 |
TEST(ret == KErrNone);
|
|
66 |
TEST(!mmScEap3.IsEapMethodOwner());
|
|
67 |
|
|
68 |
// Open with immediate close should have no problems
|
|
69 |
ret = mmScEap.Open(mmPhone, myAID, myEapType);
|
|
70 |
TEST(ret == KErrNone);
|
|
71 |
TEST(!mmScEap.IsEapMethodOwner());
|
|
72 |
mmScEap.Close();
|
|
73 |
|
|
74 |
ret = mmScEap.Open(mmPhone, myAID, myEapType);
|
|
75 |
TEST(ret == KErrNone);
|
|
76 |
TEST(!mmScEap.IsEapMethodOwner());
|
|
77 |
mmScEap.InitialiseEapMethod(reqStatus);
|
|
78 |
User::WaitForRequest(reqStatus);
|
|
79 |
TEST(reqStatus == KErrNotFound);
|
|
80 |
// Although the sub-session does not technically work, the owner is still this instance!
|
|
81 |
TEST(mmScEap.IsEapMethodOwner());
|
|
82 |
mmScEap.Close();
|
|
83 |
|
|
84 |
// Successful opening of RMobileSmartCardEap sub-session
|
|
85 |
TPtrC8 hardCodedEapMethod(DMMTSY_PHONE_EAP_METHOD);
|
|
86 |
myAID = DMMTSY_PHONE_EAPAPP_AID();
|
|
87 |
myEapType = hardCodedEapMethod;
|
|
88 |
ret = mmScEap2.Open(mmPhone, myAID, myEapType);
|
|
89 |
TEST(ret == KErrNone);
|
|
90 |
mmScEap2.InitialiseEapMethod(reqStatus);
|
|
91 |
User::WaitForRequest(reqStatus);
|
|
92 |
TEST(reqStatus == KErrNone);
|
|
93 |
TEST(mmScEap2.IsEapMethodOwner());
|
|
94 |
// Test re-initialising a sub-session that owns the EAP method lock
|
|
95 |
mmScEap2.InitialiseEapMethod(reqStatus);
|
|
96 |
User::WaitForRequest(reqStatus);
|
|
97 |
TEST(reqStatus == KErrNone);
|
|
98 |
TEST(mmScEap2.IsEapMethodOwner());
|
|
99 |
|
|
100 |
// Test failure to init RMobileSmartCardEap sub-session to <AID,method> already in use
|
|
101 |
ret = mmScEap.Open(mmPhone, myAID, myEapType);
|
|
102 |
TEST(ret == KErrNone);
|
|
103 |
mmScEap.InitialiseEapMethod(reqStatus);
|
|
104 |
User::WaitForRequest(reqStatus);
|
|
105 |
TEST(reqStatus == KErrInUse);
|
|
106 |
TEST(!mmScEap.IsEapMethodOwner());
|
|
107 |
|
|
108 |
// Test the two active RMobileSmartCardEap sub-sessions' functionality (owner will be the only one to pass everything)
|
|
109 |
TestScEapL(reqStatus, mmScEap2, mmScEap, mmScEap3); // status, owner, non-owner, uninitialised handle
|
|
110 |
|
|
111 |
// Release and re-init the valid sub-session on mmScEap (at the same time, run a notification and some gets)
|
|
112 |
RMobileSmartCardEap::TEapMethodAccessStatus accessStatus(RMobileSmartCardEap::EEapMethodAvailable);
|
|
113 |
RMobileSmartCardEap::TEapMethodAccessStatus accessStatus2(RMobileSmartCardEap::EEapMethodAvailable);
|
|
114 |
RMobileSmartCardEap::TEapMethodAccessStatus accessStatusNotify(RMobileSmartCardEap::EEapMethodAvailable);
|
|
115 |
|
|
116 |
mmScEap.NotifyEapMethodAccessStatusChange(reqStatus, accessStatusNotify);
|
|
117 |
ret = mmScEap.GetEapMethodAccessStatus(accessStatus);
|
|
118 |
TEST(ret == KErrNone);
|
|
119 |
TEST(accessStatus == RMobileSmartCardEap::EEapMethodInUseApplicationActive);
|
|
120 |
|
|
121 |
ret = mmScEap2.GetEapMethodAccessStatus(accessStatus2);
|
|
122 |
TEST(ret == KErrNone);
|
|
123 |
TEST(accessStatus2 == RMobileSmartCardEap::EEapMethodInUseApplicationActive);
|
|
124 |
|
|
125 |
ret = mmScEap2.ReleaseEapMethod();
|
|
126 |
TEST(ret == KErrNone);
|
|
127 |
TEST(!mmScEap2.IsEapMethodOwner());
|
|
128 |
|
|
129 |
User::WaitForRequest(reqStatus);
|
|
130 |
TEST(reqStatus == KErrNone);
|
|
131 |
TEST(accessStatusNotify == RMobileSmartCardEap::EEapMethodUnableToInitialise);
|
|
132 |
|
|
133 |
// 2 secs wait because dummy tsy will take this long to make EAP method available again
|
|
134 |
User::After(2000000);
|
|
135 |
|
|
136 |
ret = mmScEap.GetEapMethodAccessStatus(accessStatus);
|
|
137 |
TEST(ret == KErrNone);
|
|
138 |
TEST(accessStatus == RMobileSmartCardEap::EEapMethodAvailable);
|
|
139 |
|
|
140 |
ret = mmScEap2.GetEapMethodAccessStatus(accessStatus2);
|
|
141 |
TEST(ret == KErrNone);
|
|
142 |
TEST(accessStatus2 == RMobileSmartCardEap::EEapMethodAvailable);
|
|
143 |
|
|
144 |
mmScEap.InitialiseEapMethod(reqStatus);
|
|
145 |
User::WaitForRequest(reqStatus);
|
|
146 |
TEST(reqStatus == KErrNone);
|
|
147 |
TEST(mmScEap.IsEapMethodOwner());
|
|
148 |
|
|
149 |
// Continue testing functionality with sub-sessions reversed
|
|
150 |
// TODO - somefunc (reqStatus, mmScEap2, mmScEap) // status, owner, non-owner (possibly need a second thread to test non-owner)
|
|
151 |
TestScEapL(reqStatus, mmScEap, mmScEap2, mmScEap3);
|
|
152 |
|
|
153 |
// Close all sub-sessions and end test
|
|
154 |
mmScEap.Close();
|
|
155 |
mmScEap2.Close();
|
|
156 |
mmScEap3.Close();
|
|
157 |
mmPhone.Close();
|
|
158 |
return TestStepResult();
|
|
159 |
}
|
|
160 |
|
|
161 |
/**
|
|
162 |
Tests the EAP-capable application's functionality for two instances of
|
|
163 |
RMobileSmartCardEap; one which owns a lock on the <EAPType,AID>, which
|
|
164 |
should pass all requests; and another which does not own the lock and
|
|
165 |
should fail (KErrInUse) all requests.
|
|
166 |
|
|
167 |
@param aOwnerScEap An RMobileSmartCardEap that has successfully called
|
|
168 |
the InitialiseEapMethod request.
|
|
169 |
|
|
170 |
@param aNonownerScEap An RMobileSmartCardEap that has opened the sub-
|
|
171 |
session but failed to InitialiseEapMethod because
|
|
172 |
aOwnerScEap initialised first.
|
|
173 |
*/
|
|
174 |
void CTestSmartCardEap::TestScEapL(TRequestStatus& aReqStatus, RMobileSmartCardEap& aOwnerScEap,
|
|
175 |
RMobileSmartCardEap& aNonownerScEap, RMobileSmartCardEap& aUnInitScEap)
|
|
176 |
{
|
|
177 |
// local variables used throughout the phone tests
|
|
178 |
TInt iTestCount = 0;
|
|
179 |
|
|
180 |
// Test GetUserIdentity
|
|
181 |
RMobileSmartCardEap::TEapUserIdentityV6 userId;
|
|
182 |
RMobileSmartCardEap::TEapUserIdentityV6Pckg userIdPckg(userId);
|
|
183 |
RMobileSmartCardEap::TEapUserIdType eapIdType = DMMTSY_PHONE1_EAP_IDTYPE;
|
|
184 |
|
|
185 |
// call
|
|
186 |
INFO_PRINTF2(_L("Test %d - RMobileSmartCardEap::GetEapSimUserIdentity async."), iTestCount++);
|
|
187 |
|
|
188 |
aOwnerScEap.GetUserIdentity(aReqStatus, eapIdType, userIdPckg);
|
|
189 |
User::WaitForRequest(aReqStatus);
|
|
190 |
TEST(aReqStatus == KErrNone);
|
|
191 |
TEST(userId.iEapId == DMMTSY_PHONE1_EAP_UID);
|
|
192 |
|
|
193 |
// call and cancel
|
|
194 |
eapIdType = DMMTSY_PHONE2_EAP_IDTYPE;
|
|
195 |
INFO_PRINTF2(_L("Test %d - RMobileSmartCardEap::GetEapSimUserIdentity async & cancel."), iTestCount++);
|
|
196 |
|
|
197 |
aOwnerScEap.GetUserIdentity(aReqStatus, eapIdType, userIdPckg);
|
|
198 |
aOwnerScEap.CancelAsyncRequest(EMobileSmartCardEapGetUserIdentity);
|
|
199 |
User::WaitForRequest(aReqStatus);
|
|
200 |
TEST(aReqStatus == KErrCancel);
|
|
201 |
|
|
202 |
// non-owner GetUserIdentity
|
|
203 |
aNonownerScEap.GetUserIdentity(aReqStatus, eapIdType, userIdPckg);
|
|
204 |
User::WaitForRequest(aReqStatus);
|
|
205 |
TEST(aReqStatus == KErrInUse);
|
|
206 |
|
|
207 |
// uninitialised GetUserIdentity
|
|
208 |
aUnInitScEap.GetUserIdentity(aReqStatus, eapIdType, userIdPckg);
|
|
209 |
User::WaitForRequest(aReqStatus);
|
|
210 |
TEST(aReqStatus == KErrBadHandle);
|
|
211 |
|
|
212 |
// Test GetAuthenticationStatus
|
|
213 |
RMobileSmartCardEap::TEapAuthStatus authStatus;
|
|
214 |
|
|
215 |
// call
|
|
216 |
INFO_PRINTF2(_L("Test %d - RMobileSmartCardEap::GetAuthenticationStatus async."), iTestCount++);
|
|
217 |
|
|
218 |
aOwnerScEap.GetAuthenticationStatus(aReqStatus, authStatus);
|
|
219 |
User::WaitForRequest(aReqStatus);
|
|
220 |
TEST(aReqStatus == KErrNone);
|
|
221 |
TEST(authStatus == DMMTSY_PHONE_EAPAUTHSTATUS);
|
|
222 |
|
|
223 |
// call and cancel
|
|
224 |
INFO_PRINTF2(_L("Test %d - RMobileSmartCardEap::GetAuthenticationStatus async & cancel."), iTestCount++);
|
|
225 |
|
|
226 |
aOwnerScEap.GetAuthenticationStatus(aReqStatus, authStatus);
|
|
227 |
aOwnerScEap.CancelAsyncRequest(EMobileSmartCardEapGetAuthenticationStatus);
|
|
228 |
User::WaitForRequest(aReqStatus);
|
|
229 |
TEST(aReqStatus == KErrCancel);
|
|
230 |
|
|
231 |
// non-owner GetAuthenticationStatus
|
|
232 |
aNonownerScEap.GetAuthenticationStatus(aReqStatus, authStatus);
|
|
233 |
User::WaitForRequest(aReqStatus);
|
|
234 |
TEST(aReqStatus == KErrInUse);
|
|
235 |
|
|
236 |
// uninitialised GetAuthenticationStatus
|
|
237 |
aUnInitScEap.GetAuthenticationStatus(aReqStatus, authStatus);
|
|
238 |
User::WaitForRequest(aReqStatus);
|
|
239 |
TEST(aReqStatus == KErrBadHandle);
|
|
240 |
|
|
241 |
// Test GetEapKey
|
|
242 |
RMobileSmartCardEap::TEapKeyV6 eapKey;
|
|
243 |
RMobileSmartCardEap::TEapKeyV6Pckg eapKeyPckg(eapKey);
|
|
244 |
|
|
245 |
RMobileSmartCardEap::TEapKeyTag eapKeyTag = DMMTSY_PHONE1_EAPKEYTAG;
|
|
246 |
|
|
247 |
// call
|
|
248 |
INFO_PRINTF2(_L("Test %d - RMobileSmartCardEap::GetEapKey async."), iTestCount++);
|
|
249 |
|
|
250 |
aOwnerScEap.GetEapKey(aReqStatus, eapKeyTag, eapKeyPckg);
|
|
251 |
User::WaitForRequest(aReqStatus);
|
|
252 |
TEST(aReqStatus == KErrNone);
|
|
253 |
TEST(eapKey.iEapKey == DMMTSY_PHONE1_EAPKEY);
|
|
254 |
|
|
255 |
// call and cancel
|
|
256 |
INFO_PRINTF2(_L("Test %d - RMobileSmartCardEap::GetEapKey async & cancel."), iTestCount++);
|
|
257 |
|
|
258 |
eapKeyTag = DMMTSY_PHONE2_EAPKEYTAG;
|
|
259 |
|
|
260 |
aOwnerScEap.GetEapKey(aReqStatus, eapKeyTag, eapKeyPckg);
|
|
261 |
aOwnerScEap.CancelAsyncRequest(EMobileSmartCardEapGetEapKey);
|
|
262 |
User::WaitForRequest(aReqStatus);
|
|
263 |
TEST(aReqStatus == KErrCancel);
|
|
264 |
|
|
265 |
// non-owner GetEapKey
|
|
266 |
aNonownerScEap.GetEapKey(aReqStatus, eapKeyTag, eapKeyPckg);
|
|
267 |
User::WaitForRequest(aReqStatus);
|
|
268 |
TEST(aReqStatus == KErrInUse);
|
|
269 |
|
|
270 |
// uninitialised GetEapKey
|
|
271 |
aUnInitScEap.GetEapKey(aReqStatus, eapKeyTag, eapKeyPckg);
|
|
272 |
User::WaitForRequest(aReqStatus);
|
|
273 |
TEST(aReqStatus == KErrBadHandle);
|
|
274 |
|
|
275 |
// Test CAsyncSmartCardEapAuthentication
|
|
276 |
INFO_PRINTF2(_L("Test %d - CAsyncSmartCardEapAuthentication async."), iTestCount++);
|
|
277 |
TPtrC8 reqPacketPtr(DMMTSY_PHONE1_EAPPACKET);
|
|
278 |
CTestEapAuthenticateData* eapAuth = CTestEapAuthenticateData::NewLC(aOwnerScEap, static_cast<TDesC8&>(reqPacketPtr));
|
|
279 |
eapAuth->Start();
|
|
280 |
CActiveScheduler::Start();
|
|
281 |
TInt err = eapAuth->ValidateEapResponse();
|
|
282 |
TEST(err == KErrNone);
|
|
283 |
CleanupStack::PopAndDestroy(eapAuth);
|
|
284 |
|
|
285 |
// Test CAsyncSmartCardEapAuthentication with bigger mem allocation
|
|
286 |
reqPacketPtr.Set(DMMTSY_PHONE1_EAPPACKET2);
|
|
287 |
eapAuth = CTestEapAuthenticateData::NewLC(aOwnerScEap, static_cast<TDesC8&>(reqPacketPtr));
|
|
288 |
eapAuth->Start();
|
|
289 |
CActiveScheduler::Start();
|
|
290 |
err = eapAuth->ValidateEapResponse();
|
|
291 |
TEST(err == KErrNone);
|
|
292 |
CleanupStack::PopAndDestroy(eapAuth);
|
|
293 |
|
|
294 |
// non-owner CAsyncSmartCardEapAuthentication
|
|
295 |
CTestEapAuthenticateData* eapAuthFail = CTestEapAuthenticateData::NewLC(aNonownerScEap, static_cast<TDesC8&>(reqPacketPtr));
|
|
296 |
eapAuthFail->Start();
|
|
297 |
CActiveScheduler::Start();
|
|
298 |
err = eapAuthFail->ValidateEapResponse();
|
|
299 |
TEST(err == KErrInUse);
|
|
300 |
CleanupStack::PopAndDestroy(eapAuthFail);
|
|
301 |
|
|
302 |
// uninitialised CAsyncSmartCardEapAuthentication
|
|
303 |
CTestEapAuthenticateData* eapAuthFail2 = CTestEapAuthenticateData::NewLC(aUnInitScEap, static_cast<TDesC8&>(reqPacketPtr));
|
|
304 |
eapAuthFail2->Start();
|
|
305 |
CActiveScheduler::Start();
|
|
306 |
err = eapAuthFail2->ValidateEapResponse();
|
|
307 |
TEST(err == KErrBadHandle);
|
|
308 |
CleanupStack::PopAndDestroy(eapAuthFail2);
|
|
309 |
|
|
310 |
// non-owner ReleaseEapMethod
|
|
311 |
TInt ret = aNonownerScEap.ReleaseEapMethod();
|
|
312 |
TEST(ret == KErrInUse);
|
|
313 |
|
|
314 |
// uninitialised ReleaseEapMethod();
|
|
315 |
ret = aUnInitScEap.ReleaseEapMethod();
|
|
316 |
TEST(ret == KErrBadHandle);
|
|
317 |
}
|
|
318 |
|
|
319 |
CTestEapAuthenticateData* CTestEapAuthenticateData::NewLC(RMobileSmartCardEap& aPhone, TDesC8& aDes)
|
|
320 |
{
|
|
321 |
CTestEapAuthenticateData* self = new(ELeave) CTestEapAuthenticateData(aPhone, aDes);
|
|
322 |
CleanupStack::PushL(self);
|
|
323 |
self->ConstructL(aDes);
|
|
324 |
return self;
|
|
325 |
}
|
|
326 |
|
|
327 |
CTestEapAuthenticateData::CTestEapAuthenticateData(RMobileSmartCardEap& aPhone, TDesC8& aDes)
|
|
328 |
: CActive(EPriorityStandard), iPhone(aPhone), iDes(aDes), iAuthResp(NULL)
|
|
329 |
{
|
|
330 |
}
|
|
331 |
|
|
332 |
CTestEapAuthenticateData::~CTestEapAuthenticateData()
|
|
333 |
{
|
|
334 |
delete iTwoPhaseRetrieve;
|
|
335 |
}
|
|
336 |
|
|
337 |
void CTestEapAuthenticateData::ConstructL(TDesC8& aDes)
|
|
338 |
{
|
|
339 |
CActiveScheduler::Add(this);
|
|
340 |
iTwoPhaseRetrieve = CAsyncSmartCardEapAuthentication::NewL(iPhone, aDes);
|
|
341 |
}
|
|
342 |
|
|
343 |
void CTestEapAuthenticateData::Start()
|
|
344 |
{
|
|
345 |
iTwoPhaseRetrieve->Start(iStatus);
|
|
346 |
SetActive();
|
|
347 |
}
|
|
348 |
|
|
349 |
void CTestEapAuthenticateData::RunL()
|
|
350 |
{
|
|
351 |
if (iStatus == KErrNone)
|
|
352 |
{
|
|
353 |
iAuthResp = &(iTwoPhaseRetrieve->RetrieveEapResponse());
|
|
354 |
}
|
|
355 |
|
|
356 |
CActiveScheduler::Stop();
|
|
357 |
}
|
|
358 |
|
|
359 |
TInt CTestEapAuthenticateData::ValidateEapResponse()
|
|
360 |
{
|
|
361 |
TInt ret = KErrNone;
|
|
362 |
|
|
363 |
// iStatus will be an error if the request data is invalid.
|
|
364 |
if (iStatus != KErrNone)
|
|
365 |
{
|
|
366 |
ret = iStatus.Int();
|
|
367 |
}
|
|
368 |
else if (iDes == DMMTSY_PHONE1_EAPPACKET &&
|
|
369 |
(*iAuthResp).Compare(DMMTSY_PHONE2_EAPPACKET) != 0)
|
|
370 |
{
|
|
371 |
ret = KErrArgument;
|
|
372 |
}
|
|
373 |
else if (iDes == DMMTSY_PHONE1_EAPPACKET2 &&
|
|
374 |
(*iAuthResp).Compare(DMMTSY_PHONE2_EAPPACKET2) != 0)
|
|
375 |
{
|
|
376 |
ret = KErrArgument;
|
|
377 |
}
|
|
378 |
|
|
379 |
return ret;
|
|
380 |
}
|
|
381 |
|
|
382 |
void CTestEapAuthenticateData::DoCancel()
|
|
383 |
{
|
|
384 |
iTwoPhaseRetrieve->Cancel();
|
|
385 |
CActiveScheduler::Stop();
|
|
386 |
}
|
|
387 |
|
|
388 |
// Now test for bad clients who open but never close the phone //
|
|
389 |
|
|
390 |
/**
|
|
391 |
Each test step initialises its own name.
|
|
392 |
*/
|
|
393 |
CTestInitEapWithoutClosing::CTestInitEapWithoutClosing()
|
|
394 |
{
|
|
395 |
SetTestStepName(_L("TestMMSmartCardBasedEapBadClient"));
|
|
396 |
}
|
|
397 |
|
|
398 |
/**
|
|
399 |
Thread entry point, which initialises an RMobileSmartCardEap sub-
|
|
400 |
session, but dies without closing the handle.
|
|
401 |
*/
|
|
402 |
TInt InitialiseAndDie(TAny* /*aArg*/)
|
|
403 |
{
|
|
404 |
// New cleanup-trap for this thread
|
|
405 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
|
406 |
|
|
407 |
RTelServer telServer;
|
|
408 |
TInt ret = telServer.Connect();
|
|
409 |
|
|
410 |
ret = telServer.LoadPhoneModule(DMMTSY_MODULE_NAME);
|
|
411 |
|
|
412 |
RMobilePhone mmPhone;
|
|
413 |
ret = mmPhone.Open(telServer, DMMTSY_PHONE_NAME);
|
|
414 |
|
|
415 |
RMobileSmartCardEap mmEap;
|
|
416 |
RMobilePhone::TAID myAID;
|
|
417 |
RMobileSmartCardEap::TEapType myEapType;
|
|
418 |
TRequestStatus reqStatus;
|
|
419 |
|
|
420 |
TPtrC8 hardCodedEapMethod(DMMTSY_PHONE_EAP_METHOD);
|
|
421 |
myAID = DMMTSY_PHONE_EAPAPP_AID();
|
|
422 |
myEapType = hardCodedEapMethod;
|
|
423 |
ret = mmEap.Open(mmPhone, myAID, myEapType);
|
|
424 |
mmEap.InitialiseEapMethod(reqStatus);
|
|
425 |
User::WaitForRequest(reqStatus);
|
|
426 |
|
|
427 |
TInt kill;
|
|
428 |
// Return a different panic code depending on previous actions.
|
|
429 |
// 666 is success!
|
|
430 |
if (ret != KErrNone || reqStatus != KErrNone)
|
|
431 |
{
|
|
432 |
kill = 999;
|
|
433 |
}
|
|
434 |
else
|
|
435 |
{
|
|
436 |
kill = 666;
|
|
437 |
}
|
|
438 |
|
|
439 |
_LIT(paniced, "paniced");
|
|
440 |
TPtrC panicedPtr(paniced);
|
|
441 |
User::Panic(panicedPtr, kill);
|
|
442 |
|
|
443 |
// Cannot reach this point! Thread has died.
|
|
444 |
mmPhone.Close();
|
|
445 |
telServer.Close();
|
|
446 |
|
|
447 |
delete cleanup;
|
|
448 |
|
|
449 |
return KErrNone;
|
|
450 |
}
|
|
451 |
|
|
452 |
const TUint KDefaultHeapSize = 0x4000;
|
|
453 |
|
|
454 |
/**
|
|
455 |
Test RMobileSmartCardEap initialisation after another client dies.
|
|
456 |
|
|
457 |
@see InitialiseAndDie
|
|
458 |
*/
|
|
459 |
enum TVerdict CTestInitEapWithoutClosing::doTestStepL()
|
|
460 |
{
|
|
461 |
INFO_PRINTF1(_L("Test Bad Client with SmartCard Application based EAP Functionality"));
|
|
462 |
|
|
463 |
RMobilePhone mmPhone;
|
|
464 |
TInt ret = mmPhone.Open(iTelServer, DMMTSY_PHONE_NAME);
|
|
465 |
TESTL(ret == KErrNone);
|
|
466 |
|
|
467 |
// switches off "just-in-time" thread break-points
|
|
468 |
// Not needed as TestExecute disables JIT.
|
|
469 |
// User::SetJustInTime(EFalse);
|
|
470 |
|
|
471 |
RThread badThread;
|
|
472 |
_LIT(badThreadName, "BadThread");
|
|
473 |
ret = badThread.Create(badThreadName, InitialiseAndDie, KDefaultStackSize,
|
|
474 |
KDefaultHeapSize, KDefaultHeapSize, NULL);
|
|
475 |
TEST(ret == KErrNone);
|
|
476 |
|
|
477 |
TRequestStatus tStatus;
|
|
478 |
badThread.Logon(tStatus);
|
|
479 |
badThread.Resume();
|
|
480 |
User::WaitForRequest(tStatus);
|
|
481 |
|
|
482 |
TInt exitReason = badThread.ExitReason();
|
|
483 |
TEST(exitReason == 666);
|
|
484 |
TEST(badThread.ExitType() == EExitPanic);
|
|
485 |
badThread.Close();
|
|
486 |
|
|
487 |
// bring back "just-in-time" break-points
|
|
488 |
// Not needed as TestExecute disables JIT.
|
|
489 |
// User::SetJustInTime(ETrue);
|
|
490 |
|
|
491 |
RMobileSmartCardEap mmEap;
|
|
492 |
RMobilePhone::TAID myAID;
|
|
493 |
RMobileSmartCardEap::TEapType myEapType;
|
|
494 |
TRequestStatus reqStatus;
|
|
495 |
|
|
496 |
TPtrC8 hardCodedEapMethod(DMMTSY_PHONE_EAP_METHOD);
|
|
497 |
myAID = DMMTSY_PHONE_EAPAPP_AID();
|
|
498 |
myEapType = hardCodedEapMethod;
|
|
499 |
ret = mmEap.Open(mmPhone, myAID, myEapType);
|
|
500 |
TEST(ret == KErrNone);
|
|
501 |
|
|
502 |
RMobileSmartCardEap::TEapMethodAccessStatus accessStatus(RMobileSmartCardEap::EEapMethodAvailable);
|
|
503 |
ret = mmEap.GetEapMethodAccessStatus(accessStatus);
|
|
504 |
TEST(ret == KErrNone);
|
|
505 |
TEST(accessStatus == RMobileSmartCardEap::EEapMethodAvailable);
|
|
506 |
|
|
507 |
mmEap.InitialiseEapMethod(reqStatus);
|
|
508 |
User::WaitForRequest(reqStatus);
|
|
509 |
TEST(reqStatus == KErrNone);
|
|
510 |
TEST(mmEap.IsEapMethodOwner());
|
|
511 |
|
|
512 |
mmEap.Close();
|
|
513 |
mmPhone.Close();
|
|
514 |
|
|
515 |
return TestStepResult();
|
|
516 |
}
|