1 /* |
|
2 * Copyright (c) 2005-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 * CTestStep derived implementation |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "tAuthSvrStep.h" |
|
21 |
|
22 #include "authserver/authclient.h" |
|
23 #include "authserver/authmgrclient.h" |
|
24 #include "authrepository.h" |
|
25 using namespace AuthServer; |
|
26 |
|
27 CTFirstStart::CTFirstStart() |
|
28 /** |
|
29 * Constructor |
|
30 */ |
|
31 { |
|
32 // Call base class method to set up the human readable name for logging |
|
33 SetTestStepName(KTFirstStart); |
|
34 } |
|
35 |
|
36 TVerdict CTFirstStart::doTestStepPreambleL() |
|
37 /** |
|
38 * @return - TVerdict code |
|
39 * Override of base class virtual |
|
40 */ |
|
41 { |
|
42 CTAuthSvrStepBase::doTestStepPreambleL(); |
|
43 |
|
44 SetTestStepResult(EPass); |
|
45 return TestStepResult(); |
|
46 } |
|
47 |
|
48 TVerdict CTFirstStart::doTestStepL() |
|
49 /** |
|
50 * @return - TVerdict code |
|
51 * Override of base class pure virtual |
|
52 * |
|
53 */ |
|
54 { |
|
55 // remove trained identity 22 for these tests |
|
56 CAuthDb2* db = CAuthDb2::NewLC(iFs); |
|
57 db->RemoveIdentityL(22); |
|
58 CleanupStack::PopAndDestroy(db); |
|
59 |
|
60 //INFO_PRINTF1(_L("In FirstStart Step")); |
|
61 |
|
62 //User::SetJustInTime(ETrue); //a panic will kill just the thread, not the whole emulator. |
|
63 |
|
64 //If any test step leaves or panics, the test step thread exits and no further calls are made. |
|
65 if (TestStepResult() != EPass) |
|
66 { |
|
67 return TestStepResult(); |
|
68 } |
|
69 |
|
70 __UHEAP_MARK; // Check for memory leaks |
|
71 |
|
72 SetTestStepResult(EPass); |
|
73 |
|
74 TDriveUnit sysDrive (RFs::GetSystemDrive()); |
|
75 TDriveName sysDriveName (sysDrive.Name()); |
|
76 TBuf<128> fileName (sysDriveName); |
|
77 fileName.Append(KAuthSvrPolicyFile); |
|
78 CIniData* policyFile=NULL; |
|
79 policyFile=CIniData::NewL(fileName); |
|
80 CleanupStack::PushL(policyFile); |
|
81 |
|
82 fileName.Copy(sysDriveName); |
|
83 fileName.Append(KPluginIniFile); |
|
84 |
|
85 CIniData* pluginFile=NULL; |
|
86 pluginFile=CIniData::NewL(fileName); |
|
87 CleanupStack::PushL(pluginFile); |
|
88 //Set a default plugin using an ini file. Read this value from a file if it is specified |
|
89 //Set this to be the default plugin (update the policy file) if the test case specifies it (in the script's ini file). |
|
90 TInt defaultPluginFromFile; |
|
91 if (GetIntFromConfig(ConfigSection(),_L("defaultPlugin"), defaultPluginFromFile) != EFalse) // the tag 'defaultPlugin' was present |
|
92 { |
|
93 |
|
94 //Write this value to the policy file, Which is picked up by the AuthServer (not implemented yet) |
|
95 //writeToNamedConfig(policyFile, KDefaultPluginTag, defaultPluginFromFile); |
|
96 SetDefaultPluginIdL(defaultPluginFromFile); |
|
97 } |
|
98 |
|
99 //Set whether a plugin supports default data. Read this value from a file if it is specified |
|
100 _LIT(KTrueText,"true"); |
|
101 _LIT(KFalseText,"false"); |
|
102 |
|
103 TBool iSupportsDefaultDataFromFile(ETrue); //Default case - the plugin supports default data |
|
104 |
|
105 TBufC<16> trueBuf1(KTrueText); |
|
106 TBufC<16> falseBuf1(KFalseText); |
|
107 TPtr valueToWrite = trueBuf1.Des(); //Default case - the plugin supports default data |
|
108 |
|
109 |
|
110 if (GetBoolFromConfig(ConfigSection(),_L("iSupportsDefaultData"), iSupportsDefaultDataFromFile) != EFalse) // the tag 'isTrusted' was present |
|
111 { |
|
112 //Set the value that will be picked up by the constructor of the plugin |
|
113 //writeToNamedConfig(pluginIniFile, KPluginIniSection, _L("iSupportsDefaultData"), iSupportsDefaultDataFromFile); |
|
114 if (iSupportsDefaultDataFromFile) |
|
115 { valueToWrite = trueBuf1.Des(); } |
|
116 else |
|
117 { valueToWrite = falseBuf1.Des(); } |
|
118 |
|
119 writeToNamedConfig(pluginFile, KPluginIniSection, _L("iSupportsDefaultData"), valueToWrite); |
|
120 } |
|
121 else |
|
122 { |
|
123 INFO_PRINTF1(_L("The iSupportsDefaultData tag was not specified in the testexecute ini file.")); |
|
124 //Use the default value of false |
|
125 writeToNamedConfig(pluginFile, KPluginIniSection, _L("iSupportsDefaultData"), valueToWrite); |
|
126 } |
|
127 |
|
128 //Carry out the other initialisation that is required. |
|
129 // TODO. |
|
130 |
|
131 |
|
132 //----------------------------------------------------------------------------------------------------- |
|
133 //Connect to the AuthServer |
|
134 AuthServer::RAuthClient authClient1; |
|
135 //TInt connectVal = User::LeaveIfError(authClient1.Connect()); |
|
136 TInt connectVal = authClient1.Connect(); |
|
137 if (KErrNotFound == connectVal) |
|
138 { |
|
139 //Retry after a delay |
|
140 TTimeIntervalMicroSeconds32 timeInterval = 2000; //2 Milliseconds |
|
141 User::After(timeInterval); |
|
142 connectVal = authClient1.Connect(); |
|
143 } |
|
144 if (KErrNone != connectVal) |
|
145 { |
|
146 ERR_PRINTF2(_L("Unable to start a session or other connection error. Err = %d"), connectVal); |
|
147 User::LeaveIfError(connectVal); |
|
148 } |
|
149 CleanupClosePushL(authClient1); |
|
150 |
|
151 |
|
152 //Check that the default identity has been created |
|
153 //Call the Enumerate Identity API |
|
154 //AuthServer::RIdentityIdList idList; |
|
155 AuthServer::RIdentityIdArray idArray; |
|
156 CleanupClosePushL(idArray); |
|
157 //TInt ret = User::LeaveIfError(authClient1.IdentitiesL(idArray)); |
|
158 TInt ret = KErrNone; |
|
159 TRAP(ret, authClient1.IdentitiesL(idArray)); |
|
160 if (KErrNone != ret) |
|
161 { |
|
162 ERR_PRINTF2(_L("IdentitiesL left with errorcode: %d"), ret); |
|
163 SetTestStepResult(EFail); |
|
164 } |
|
165 |
|
166 else |
|
167 { |
|
168 |
|
169 //List the present identities by their strings |
|
170 for (TInt i = 0; i < idArray.Count(); i++) |
|
171 { |
|
172 HBufC* idName = 0; |
|
173 //TRAP(ret, idName = authClient1.IdentityStringL(idArray[i])); |
|
174 idName = authClient1.IdentityStringL(idArray[i]); |
|
175 INFO_PRINTF3(_L("Id %d has the name %S"), i, idName); |
|
176 delete idName; |
|
177 } |
|
178 //Retrieve the expected information from the ini file |
|
179 TInt expNumIdentities; |
|
180 |
|
181 if(GetIntFromConfig(ConfigSection(),_L("NumIdentities"), expNumIdentities) != EFalse) // the tag 'NumIdentities' was present |
|
182 { |
|
183 //Do the compare |
|
184 if ((idArray.Count()) != expNumIdentities) |
|
185 { |
|
186 ERR_PRINTF2(_L("expNumIdentities differs from expected, Number of Identities = %d"), (idArray.Count())); |
|
187 SetTestStepResult(EFail); |
|
188 } |
|
189 } |
|
190 |
|
191 TBool expIsDefaultPlugin = EFalse; |
|
192 if(GetBoolFromConfig(ConfigSection(), _L("isDefaultPlugin"), expIsDefaultPlugin) != EFalse) // the tag 'isDefaultPlugin' was present |
|
193 { |
|
194 if(!expIsDefaultPlugin && (KErrServerTerminated != ret) ) |
|
195 { |
|
196 //The plugin is not a default plugin as defined in the policy file, and thus the server should have been terminated |
|
197 ERR_PRINTF2(_L("connectVal differs from expected, connectVal= %d"), connectVal); |
|
198 SetTestStepResult(EFail); |
|
199 } |
|
200 } |
|
201 |
|
202 } |
|
203 |
|
204 |
|
205 //Maybe check the individual identifier -not predictable though.. |
|
206 CleanupStack::PopAndDestroy(&idArray); |
|
207 CleanupStack::PopAndDestroy(&authClient1); |
|
208 |
|
209 REComSession::FinalClose(); //garbage collect the last previously destroyed implementation and close the REComSession if no longer in use |
|
210 __UHEAP_MARKEND; |
|
211 return TestStepResult(); |
|
212 } |
|
213 |
|
214 //TVerdict CTFirstStart::doTestStepPostambleL() |
|
215 /** |
|
216 * @return - TVerdict code |
|
217 * Override of base class virtual |
|
218 */ |
|
219 /* { |
|
220 INFO_PRINTF1(_L("Test Step Postamble")); |
|
221 return TestStepResult(); |
|
222 } |
|
223 */ |
|