24
|
1 |
// Copyright (c) 2005-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 |
//
|
|
15 |
|
|
16 |
#include "Te_SimPhBkPhoneSecurityTest.h"
|
|
17 |
|
|
18 |
CSimPhBkPhoneSecurityTest::CSimPhBkPhoneSecurityTest()
|
|
19 |
{
|
|
20 |
SetTestStepName(_L("PhoneSecurityTest"));
|
|
21 |
}
|
|
22 |
|
|
23 |
TVerdict CSimPhBkPhoneSecurityTest::doTestStepL()
|
|
24 |
{
|
|
25 |
INFO_PRINTF1(_L("BeginPhBkPhoneSecurityTest"));
|
|
26 |
|
|
27 |
CreateConfigFileL(_L("c:\\config3.txt"));
|
|
28 |
SetTestNumberL(0);
|
|
29 |
|
|
30 |
TInt ret = iPhone.Open(iTelServer,KPhoneName);
|
|
31 |
INFO_PRINTF2(_L("Result: %d"),ret);
|
|
32 |
TESTL(ret == KErrNone);
|
|
33 |
INFO_PRINTF1(_L("Opened phone object"));
|
|
34 |
TRequestStatus aReqStatus;
|
|
35 |
TRequestStatus stat0;
|
|
36 |
RMobilePhone::TMobilePhoneLockInfoV1 asyncLockInfo;
|
|
37 |
RMobilePhone::TMobilePhoneLockInfoV1Pckg asyncLockInfoPckg(asyncLockInfo);
|
|
38 |
|
|
39 |
TUint32 secCaps;
|
|
40 |
TUint32 expectedSecCaps = RMobilePhone::KCapsLockPhone | \
|
|
41 |
RMobilePhone::KCapsLockICC | \
|
|
42 |
RMobilePhone::KCapsAccessPin1 | \
|
|
43 |
RMobilePhone::KCapsAccessPin2 | \
|
|
44 |
RMobilePhone::KCapsAccessPhonePassword | \
|
|
45 |
RMobilePhone::KCapsAccessSPC | \
|
|
46 |
RMobilePhone::KCapsAccessHiddenKey | \
|
|
47 |
RMobilePhone::KCapsAccessUSIMAppPin | \
|
|
48 |
RMobilePhone::KCapsAccessUSIMAppSecondPin | \
|
|
49 |
RMobilePhone::KCapsAccessUniversalPin;
|
|
50 |
INFO_PRINTF1(_L("GetSecurityCaps test"));
|
|
51 |
ret=iPhone.GetSecurityCaps(secCaps);
|
|
52 |
CHECKPOINTL(ret, KErrNone, CHP_APPS_CASE("H.1"));
|
|
53 |
TESTL(secCaps == expectedSecCaps);
|
|
54 |
|
|
55 |
RMobilePhone::TMobilePhoneLock whichLock = RMobilePhone::ELockICC;
|
|
56 |
INFO_PRINTF1(_L("GetLockInfo test"));
|
|
57 |
iPhone.GetLockInfo(aReqStatus,whichLock,asyncLockInfoPckg);
|
|
58 |
User::WaitForRequest(aReqStatus);
|
|
59 |
CHECKPOINTL(aReqStatus, KErrNone, CHP_APPS_CASE("H.3"));
|
|
60 |
TESTL(asyncLockInfo.iStatus == RMobilePhone::EStatusUnlocked);
|
|
61 |
TESTL(asyncLockInfo.iSetting == RMobilePhone::ELockSetDisabled);
|
|
62 |
|
|
63 |
INFO_PRINTF1(_L("NotifyLockInfoChange test (triggered)"));
|
|
64 |
iPhone.NotifyLockInfoChange(aReqStatus, whichLock,asyncLockInfoPckg);
|
|
65 |
iPhone.SetLockSetting(stat0,whichLock,RMobilePhone::ELockSetEnabled);
|
|
66 |
User::WaitForRequest(stat0);
|
|
67 |
User::WaitForRequest(aReqStatus);
|
|
68 |
TESTL(asyncLockInfo.iStatus == RMobilePhone::EStatusUnlocked);
|
|
69 |
TESTL(asyncLockInfo.iSetting == RMobilePhone::ELockSetEnabled);
|
|
70 |
CHECKPOINT_EXL(stat0==KErrNone, CHP_APPS_CASE("H.6"));
|
|
71 |
CHECKPOINTL(aReqStatus, KErrNone, CHP_APPS_CASE("H.5"));
|
|
72 |
|
|
73 |
INFO_PRINTF1(_L("ChangeSecurityCode test"));
|
|
74 |
RMobilePhone::TMobilePhonePasswordChangeV1 passwordChange;
|
|
75 |
RMobilePhone::TMobilePhonePasswordChangeV1 wrongPasswordChange;
|
|
76 |
passwordChange.iOldPassword = _L("1111");
|
|
77 |
passwordChange.iNewPassword = _L("2222");
|
|
78 |
wrongPasswordChange.iOldPassword = _L("1111111");
|
|
79 |
wrongPasswordChange.iNewPassword = _L("2222");
|
|
80 |
|
|
81 |
RMobilePhone::TMobilePhoneSecurityCode whichCode = RMobilePhone::ESecurityCodePin1;
|
|
82 |
|
|
83 |
iPhone.ChangeSecurityCode(aReqStatus,whichCode,wrongPasswordChange);
|
|
84 |
User::WaitForRequest(aReqStatus);
|
|
85 |
CHECKPOINT_EXL(aReqStatus==KErrArgument, CHP_APPS_CASE("H.8"));
|
|
86 |
|
|
87 |
iPhone.ChangeSecurityCode(aReqStatus,whichCode,passwordChange);
|
|
88 |
User::WaitForRequest(aReqStatus);
|
|
89 |
CHECKPOINT_EXL(aReqStatus==KErrNone, CHP_APPS_CASE("H.9"));
|
|
90 |
|
|
91 |
RMobilePhone::TMobilePassword code = _L("2222");
|
|
92 |
RMobilePhone::TMobilePassword unblockCode = _L("1111");
|
|
93 |
RMobilePhone::TMobilePhoneSecurityEvent securityEvent;
|
|
94 |
|
|
95 |
iPhone.NotifySecurityEvent(stat0,securityEvent);
|
|
96 |
iPhone.VerifySecurityCode(aReqStatus,whichCode,code,unblockCode);
|
|
97 |
User::WaitForRequest(stat0);
|
|
98 |
User::WaitForRequest(aReqStatus);
|
|
99 |
CHECKPOINTL(aReqStatus, KErrNone, CHP_APPS_CASE("H.11"));
|
|
100 |
CHECKPOINTL(stat0, KErrNone, CHP_APPS_CASE("H.10"));
|
|
101 |
|
|
102 |
TESTL(securityEvent == RMobilePhone::EPin1Verified);
|
|
103 |
ret=iPhone.AbortSecurityCode(whichCode);
|
|
104 |
CHECKPOINTL(ret, KErrNone, CHP_APPS_CASE("H.13"));
|
|
105 |
|
|
106 |
// reset initial security code
|
|
107 |
passwordChange.iOldPassword = _L("2222");
|
|
108 |
passwordChange.iNewPassword = _L("1111");
|
|
109 |
iPhone.ChangeSecurityCode(aReqStatus,RMobilePhone::ESecurityCodePin1,passwordChange);
|
|
110 |
User::WaitForRequest(aReqStatus);
|
|
111 |
|
|
112 |
|
|
113 |
INFO_PRINTF1(_L("GetSecurityCodeInfo test"));
|
|
114 |
const TInt testSecurityCodeNr = 4;
|
|
115 |
RMobilePhone::TMobilePhoneSecurityCode testSecurityCode[testSecurityCodeNr]=
|
|
116 |
{
|
|
117 |
RMobilePhone::ESecurityCodePin1,
|
|
118 |
RMobilePhone::ESecurityCodePin2,
|
|
119 |
RMobilePhone::ESecurityCodePuk1,
|
|
120 |
RMobilePhone::ESecurityCodePuk2
|
|
121 |
};
|
|
122 |
|
|
123 |
RMobilePhone::TMobilePhoneSecurityCodeInfoV5 securityCodeInfo;
|
|
124 |
RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg securityCodeInfoPckg(securityCodeInfo);
|
|
125 |
|
|
126 |
RMobilePhone::TMobilePhoneSecurityCode notifySecurityCode;
|
|
127 |
RMobilePhone::TMobilePhoneSecurityCodeInfoV5 notifySecurityCodeInfo;
|
|
128 |
RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg notifySecurityCodeInfoPckg(notifySecurityCodeInfo);
|
|
129 |
RMobilePhone::TMobilePassword wrongCode = _L("1234");
|
|
130 |
RMobilePhone::TMobilePassword correctCode = _L("1111");
|
|
131 |
|
|
132 |
// check security code supporting GetSecurityCodeInfo
|
|
133 |
for (TInt testSecurityCodeCnt=0; testSecurityCodeCnt<testSecurityCodeNr; testSecurityCodeCnt++)
|
|
134 |
{
|
|
135 |
whichCode = testSecurityCode[testSecurityCodeCnt];
|
|
136 |
notifySecurityCodeInfo.iRemainingEntryAttempts = 0;
|
|
137 |
iPhone.GetSecurityCodeInfo(aReqStatus,whichCode,securityCodeInfoPckg);
|
|
138 |
User::WaitForRequest(aReqStatus);
|
|
139 |
CHECKPOINT_EXL(aReqStatus==KErrNone, CHP_APPS_CASE("H.14"));
|
|
140 |
TESTL(securityCodeInfo.iRemainingEntryAttempts == 3);
|
|
141 |
}
|
|
142 |
|
|
143 |
// check security code NOT supporting GetSecurityCodeInfo
|
|
144 |
whichCode = RMobilePhone::ESecurityCodePhonePassword;
|
|
145 |
iPhone.GetSecurityCodeInfo(aReqStatus,whichCode,securityCodeInfoPckg);
|
|
146 |
User::WaitForRequest(aReqStatus);
|
|
147 |
CHECKPOINT_EXL(aReqStatus==KErrNotFound, CHP_APPS_CASE("H.14"));
|
|
148 |
|
|
149 |
|
|
150 |
INFO_PRINTF1(_L("NotifySecurityCodeInfoChange test"));
|
|
151 |
// check security code supporting NotifySecurityCodeInfoChange only
|
|
152 |
for (TInt testSecurityCodeCnt=0; testSecurityCodeCnt<testSecurityCodeNr; testSecurityCodeCnt++)
|
|
153 |
{
|
|
154 |
whichCode = testSecurityCode[testSecurityCodeCnt];
|
|
155 |
notifySecurityCodeInfo.iRemainingEntryAttempts = 0;
|
|
156 |
iPhone.NotifySecurityCodeInfoChange(stat0,notifySecurityCode,notifySecurityCodeInfoPckg);
|
|
157 |
iPhone.VerifySecurityCode(aReqStatus,whichCode,wrongCode,wrongCode);
|
|
158 |
User::WaitForRequest(aReqStatus);
|
|
159 |
User::WaitForRequest(stat0);
|
|
160 |
CHECKPOINTL(aReqStatus, KErrArgument, CHP_APPS_CASE("H.15"));
|
|
161 |
TESTL(notifySecurityCode == whichCode);
|
|
162 |
TESTL(notifySecurityCodeInfo.iRemainingEntryAttempts == 2);
|
|
163 |
|
|
164 |
notifySecurityCodeInfo.iRemainingEntryAttempts = 0;
|
|
165 |
iPhone.NotifySecurityCodeInfoChange(stat0,notifySecurityCode,notifySecurityCodeInfoPckg);
|
|
166 |
iPhone.VerifySecurityCode(aReqStatus,whichCode,correctCode,correctCode);
|
|
167 |
User::WaitForRequest(aReqStatus);
|
|
168 |
User::WaitForRequest(stat0);
|
|
169 |
CHECKPOINTL(aReqStatus, KErrNone, CHP_APPS_CASE("H.15"));
|
|
170 |
TESTL(notifySecurityCode == whichCode);
|
|
171 |
TESTL(notifySecurityCodeInfo.iRemainingEntryAttempts == 3);
|
|
172 |
}
|
|
173 |
|
|
174 |
INFO_PRINTF1(_L("Check that security code get blocked"));
|
|
175 |
// block all codes
|
|
176 |
for (TInt testSecurityCodeCnt=0; testSecurityCodeCnt<testSecurityCodeNr; testSecurityCodeCnt++)
|
|
177 |
{
|
|
178 |
whichCode = testSecurityCode[testSecurityCodeCnt];
|
|
179 |
do
|
|
180 |
{
|
|
181 |
iPhone.VerifySecurityCode(aReqStatus,whichCode,wrongCode,wrongCode);
|
|
182 |
User::WaitForRequest(aReqStatus);
|
|
183 |
iPhone.GetSecurityCodeInfo(aReqStatus,whichCode,securityCodeInfoPckg);
|
|
184 |
User::WaitForRequest(aReqStatus);
|
|
185 |
}
|
|
186 |
while (securityCodeInfo.iRemainingEntryAttempts > 0);
|
|
187 |
}
|
|
188 |
// check the corresponding lock is blocked
|
|
189 |
// PIN1 os for ELockICC
|
|
190 |
iPhone.GetLockInfo(aReqStatus,RMobilePhone::ELockICC,asyncLockInfoPckg);
|
|
191 |
User::WaitForRequest(aReqStatus);
|
|
192 |
CHECKPOINTL(aReqStatus, KErrNone, CHP_APPS_CASE("H.16"));
|
|
193 |
TESTL(asyncLockInfo.iStatus == RMobilePhone::EStatusBlocked);
|
|
194 |
|
|
195 |
// PIN2 os for ELockPin2
|
|
196 |
iPhone.GetLockInfo(aReqStatus,RMobilePhone::ELockPin2,asyncLockInfoPckg);
|
|
197 |
User::WaitForRequest(aReqStatus);
|
|
198 |
CHECKPOINTL(aReqStatus, KErrNone, CHP_APPS_CASE("H.16"));
|
|
199 |
TESTL(asyncLockInfo.iStatus == RMobilePhone::EStatusBlocked);
|
|
200 |
|
|
201 |
// there is no coresponding lock for PUK1 and PUK2
|
|
202 |
|
|
203 |
iPhone.Close();
|
|
204 |
ASSERT(RThread().RequestCount()==0);
|
|
205 |
|
|
206 |
return TestStepResult();
|
|
207 |
}
|
|
208 |
|