sl@0
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <e32test.h>
|
sl@0
|
17 |
#include <bautils.h>
|
sl@0
|
18 |
#include <sqldb.h>
|
sl@0
|
19 |
|
sl@0
|
20 |
#define __SQLSRV_STRINGS__
|
sl@0
|
21 |
#include "SqlSrvStrings.h"
|
sl@0
|
22 |
|
sl@0
|
23 |
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
24 |
|
sl@0
|
25 |
RFs TheFs;
|
sl@0
|
26 |
RSqlDatabase TheDb;
|
sl@0
|
27 |
TParse TheFileNameParse;
|
sl@0
|
28 |
RTest TheTest(_L("t_sqlauthorizer test"));
|
sl@0
|
29 |
|
sl@0
|
30 |
const TSecurityPolicy KPolicy1(ECapabilityReadUserData, ECapabilityNetworkControl, ECapabilityWriteUserData);
|
sl@0
|
31 |
const TSecurityPolicy KPolicy2(ECapabilityReadUserData);
|
sl@0
|
32 |
|
sl@0
|
33 |
_LIT8(KPragma , "PRAGMA %S.%S\x0");
|
sl@0
|
34 |
_LIT8(KPragmaWithParam, "PRAGMA %S.%S%S\x0");
|
sl@0
|
35 |
|
sl@0
|
36 |
_LIT(KPublicDir, "C:\\test\\");
|
sl@0
|
37 |
_LIT(KPrivateDir, "C:\\private\\21212129\\");
|
sl@0
|
38 |
|
sl@0
|
39 |
_LIT(KPublicDbName, "C:\\test\\t_sqlauthorizer.db");
|
sl@0
|
40 |
_LIT(KSecureDbName, "C:[21212129]t_sqlauthorizer.db");
|
sl@0
|
41 |
_LIT(KPrivateDbName, "C:\\private\\21212129\\t_sqlauthorizer.db");
|
sl@0
|
42 |
_LIT(KAttachDb, "AttachedDB");
|
sl@0
|
43 |
|
sl@0
|
44 |
_LIT(KCreateTable1, "CREATE TABLE A(Id INTEGER,Name TEXT)");
|
sl@0
|
45 |
_LIT(KCreateTable2, "CREATE TABLE B(Id INTEGER,Address TEXT, Num INTEGER, FOREIGN KEY (Address) REFERENCES A(id))");
|
sl@0
|
46 |
_LIT(KCreateIndex, "CREATE INDEX Index1 ON B (Num)");
|
sl@0
|
47 |
_LIT(KInsertTable, "INSERT INTO A VALUES(1, 'AAA')");
|
sl@0
|
48 |
|
sl@0
|
49 |
TBuf8<KMaxFileName + 64> TheSql;
|
sl@0
|
50 |
const TInt KNumPragma = 34;
|
sl@0
|
51 |
|
sl@0
|
52 |
//////////////////////////////////////////// Input List ///////////////////////////////////////////////
|
sl@0
|
53 |
struct TInputList
|
sl@0
|
54 |
{
|
sl@0
|
55 |
const TPtrC8 iPragmaName;
|
sl@0
|
56 |
const TPtrC8 iReadParam;
|
sl@0
|
57 |
const TPtrC8 iWriteParam;
|
sl@0
|
58 |
};
|
sl@0
|
59 |
|
sl@0
|
60 |
const TInputList KInputList [KNumPragma] =
|
sl@0
|
61 |
{
|
sl@0
|
62 |
////////////////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
63 |
// Pragma Name |Read Parameter |Write Parameter |Pragma Command
|
sl@0
|
64 |
////////////////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
65 |
{KAutoVacuum(), KNullDesC8(), _L8(" = 0")}, //auto_vacuum
|
sl@0
|
66 |
{KCacheSize(), KNullDesC8(), _L8(" = 32")}, //cache_size
|
sl@0
|
67 |
{KCaseSensitiveLike(), KNullDesC8(), _L8(" = 0")}, //case_sensitive_like
|
sl@0
|
68 |
{KCountChanges(), KNullDesC8(), _L8(" = 1")}, //count_changes
|
sl@0
|
69 |
{KDefaultCacheSize(), KNullDesC8(), _L8(" = 32")}, //DefaultAccess_cache_size
|
sl@0
|
70 |
{KEmptyResultCallbacks(), KNullDesC8(), _L8(" = 0")}, //empty_result_callbacks
|
sl@0
|
71 |
{KEncoding(), KNullDesC8(), _L8(" = \"UTF-8\"")}, //encoding
|
sl@0
|
72 |
{KFullColumnNames(), KNullDesC8(), _L8(" = 0")}, //full_column_names
|
sl@0
|
73 |
{KFullfsync(), KNullDesC8(), _L8(" = 1")}, //fullfsync
|
sl@0
|
74 |
{KIncrementalVacuum(), KNullDesC8(), _L8(" = 0")}, //incremental_vacuum
|
sl@0
|
75 |
{KJournalMode(), KNullDesC8(), _L8(" = DELETE")}, //journal_mode
|
sl@0
|
76 |
{KJournalSizeLimit(), KNullDesC8(), _L8(" = 1000000")}, //journal_size_limit
|
sl@0
|
77 |
{KLegacyFileFormat(), KNullDesC8(), _L8(" = ON")}, //legacy_file_format
|
sl@0
|
78 |
{KLockingMode(), KNullDesC8(), _L8(" = Normal")}, //locking_mode
|
sl@0
|
79 |
{KPageSize(), KNullDesC8(), _L8(" = 2048")}, //page_size
|
sl@0
|
80 |
{KMaxPageCount(), KNullDesC8(), _L8(" = 32")}, //max_page_count
|
sl@0
|
81 |
{KReadUncommitted(), KNullDesC8(), _L8(" = 1")}, //read_uncommitted
|
sl@0
|
82 |
{KShortColumnNames(), KNullDesC8(), _L8(" = 0")}, //short_column_names
|
sl@0
|
83 |
{KSynchronousFlag(), KNullDesC8(), _L8(" = NORMAL")}, //synchronous
|
sl@0
|
84 |
{KTempStore(), KNullDesC8(), _L8(" = MEMORY")}, //temp_store
|
sl@0
|
85 |
{KTempStoreDirectory(), KNullDesC8(), _L8(" = TEMP")}, //temp_store_directory
|
sl@0
|
86 |
{KDatabaseList(), KNullDesC8(), KNullDesC8()}, //database_list
|
sl@0
|
87 |
{KForeignKeyList(), _L8("(B)"), KNullDesC8()}, //foreign_key_list
|
sl@0
|
88 |
{KFreelistCount(), KNullDesC8(), KNullDesC8()}, //freelist_count
|
sl@0
|
89 |
{KIndexInfo(), _L8("(Index1)"), KNullDesC8()}, //index_info
|
sl@0
|
90 |
{KIndexIist(), _L8("(B)"), KNullDesC8()}, //index_list
|
sl@0
|
91 |
{KPageCount(), KNullDesC8(), KNullDesC8()}, //page_count
|
sl@0
|
92 |
{KTableInfo(), _L8("(B)"), KNullDesC8()}, //table_info
|
sl@0
|
93 |
{KSchemaVersion(), KNullDesC8(), _L8(" = 10")}, //schema_version
|
sl@0
|
94 |
{KUserVersion(), KNullDesC8(), _L8(" = 10")}, //user_version
|
sl@0
|
95 |
{KIntegrityCheck(), KNullDesC8(), _L8(" = 1")}, //integrity_check
|
sl@0
|
96 |
{KParserTrace(), KNullDesC8(), _L8(" = ON")}, //parser_trace
|
sl@0
|
97 |
{KVdbeTrace(), KNullDesC8(), _L8(" = ON")}, //vdbe_trace
|
sl@0
|
98 |
{KdbeListing(), KNullDesC8(), _L8(" = ON")}, //vdbe_listing
|
sl@0
|
99 |
};
|
sl@0
|
100 |
|
sl@0
|
101 |
//////////////////////////////////////////////// Expected results ///////////////////////////////////////////////////////////
|
sl@0
|
102 |
|
sl@0
|
103 |
enum TAccessType
|
sl@0
|
104 |
{
|
sl@0
|
105 |
EReadParam,
|
sl@0
|
106 |
EWriteParam,
|
sl@0
|
107 |
};
|
sl@0
|
108 |
|
sl@0
|
109 |
enum TDatabaseType
|
sl@0
|
110 |
{
|
sl@0
|
111 |
ENonSecure,
|
sl@0
|
112 |
ESecure,
|
sl@0
|
113 |
};
|
sl@0
|
114 |
|
sl@0
|
115 |
enum TAccessResult
|
sl@0
|
116 |
{
|
sl@0
|
117 |
EOk = KErrNone,
|
sl@0
|
118 |
EIgnore,
|
sl@0
|
119 |
EDeny,
|
sl@0
|
120 |
ENoCheck
|
sl@0
|
121 |
};
|
sl@0
|
122 |
|
sl@0
|
123 |
|
sl@0
|
124 |
// Table listing the expected for each pragma command for the following access conditions:-
|
sl@0
|
125 |
// 1) Pragma Read with non-secure database
|
sl@0
|
126 |
// 2) Pragma Write with non-secure database
|
sl@0
|
127 |
// 3) Pragma Read with secure database
|
sl@0
|
128 |
// 4) Pragma Write with secure database
|
sl@0
|
129 |
const TInt KResultsTable[KNumPragma][4] =
|
sl@0
|
130 |
{
|
sl@0
|
131 |
////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
132 |
// NON_SECURE | SECURE |
|
sl@0
|
133 |
//W/out Pram |With Param|W/out Pram |With Param |Pragma Command
|
sl@0
|
134 |
///////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
135 |
{EOk, EIgnore, EDeny, EDeny }, //auto_vacuum
|
sl@0
|
136 |
{EOk, EIgnore, EDeny, EDeny }, //cache_size
|
sl@0
|
137 |
{EOk, ENoCheck, EDeny, EDeny }, //case_sensitive_like
|
sl@0
|
138 |
{EOk, EOk, EDeny, EDeny }, //count_changes
|
sl@0
|
139 |
{EOk, EIgnore, EDeny, EDeny }, //cache_size
|
sl@0
|
140 |
{EOk, EIgnore, EDeny, EDeny }, //empty_result_callbacks
|
sl@0
|
141 |
{EOk, EIgnore, EDeny, EDeny }, //encoding
|
sl@0
|
142 |
{EOk, EOk, EDeny, EDeny }, //full_column_names
|
sl@0
|
143 |
{EOk, EIgnore, EDeny, EDeny }, //fullfsync
|
sl@0
|
144 |
{EIgnore, EIgnore, EDeny, EDeny }, //incremental_vacuum
|
sl@0
|
145 |
{EIgnore, EIgnore, EDeny, EDeny }, //journal_mode
|
sl@0
|
146 |
{EIgnore, EIgnore, EDeny, EDeny }, //journal_size_limit
|
sl@0
|
147 |
{EOk, EIgnore, EDeny, EDeny }, //legacy_file_format
|
sl@0
|
148 |
{EOk, EIgnore, EDeny, EDeny }, //locking_mode
|
sl@0
|
149 |
{EOk, EIgnore, EDeny, EDeny }, //page_size
|
sl@0
|
150 |
{EIgnore, EIgnore, EDeny, EDeny }, //max_page_count
|
sl@0
|
151 |
{EOk, EIgnore, EDeny, EDeny }, //read_uncommitted
|
sl@0
|
152 |
{EOk, EOk, EDeny, EDeny }, //short_column_names
|
sl@0
|
153 |
{EOk, EIgnore, EDeny, EDeny }, //synchronous
|
sl@0
|
154 |
{EOk, EIgnore, EDeny, EDeny }, //temp_store
|
sl@0
|
155 |
{EOk, ENoCheck, EDeny, EDeny }, //temp_store_directory
|
sl@0
|
156 |
{EOk, EOk, EDeny, EDeny }, //database_list
|
sl@0
|
157 |
{ENoCheck, EOk, EDeny, EDeny }, //foreign_key_list
|
sl@0
|
158 |
{EOk, EIgnore, EDeny, EDeny }, //freelist_count
|
sl@0
|
159 |
{ENoCheck, EOk, EDeny, EDeny }, //index_info
|
sl@0
|
160 |
{ENoCheck, EOk, EDeny, EDeny }, //index_list
|
sl@0
|
161 |
{EOk, EIgnore, EDeny, EDeny }, //page_count
|
sl@0
|
162 |
{ENoCheck, EOk, EDeny, EDeny }, //table_info
|
sl@0
|
163 |
{EOk, EIgnore, EDeny, EDeny }, //schema_version
|
sl@0
|
164 |
{EOk, EIgnore, EDeny, EDeny }, //user_version
|
sl@0
|
165 |
{EOk, EIgnore, EDeny, EDeny }, //integrity_check
|
sl@0
|
166 |
{EOk, EIgnore, EDeny, EDeny }, //parser_trace
|
sl@0
|
167 |
{EOk, EIgnore, EDeny, EDeny }, //vdbe_trace
|
sl@0
|
168 |
{EOk, EIgnore, EDeny, EDeny }, //vdbe_trace
|
sl@0
|
169 |
};
|
sl@0
|
170 |
|
sl@0
|
171 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
172 |
//Deletes all created test files.
|
sl@0
|
173 |
void DeleteTestFiles()
|
sl@0
|
174 |
{
|
sl@0
|
175 |
(void)RSqlDatabase::Delete(KPrivateDbName);
|
sl@0
|
176 |
(void)RSqlDatabase::Delete(KSecureDbName);
|
sl@0
|
177 |
(void)RSqlDatabase::Delete(KPublicDbName);
|
sl@0
|
178 |
}
|
sl@0
|
179 |
|
sl@0
|
180 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
181 |
//Test macros and functions
|
sl@0
|
182 |
void Check1(TInt aValue, TInt aLine)
|
sl@0
|
183 |
{
|
sl@0
|
184 |
if(!aValue)
|
sl@0
|
185 |
{
|
sl@0
|
186 |
DeleteTestFiles();
|
sl@0
|
187 |
RDebug::Print(_L("*** Line %d\r\n"), aLine);
|
sl@0
|
188 |
TheTest(EFalse, aLine);
|
sl@0
|
189 |
}
|
sl@0
|
190 |
}
|
sl@0
|
191 |
void Check2(TInt aValue, TInt aExpected, TInt aLine)
|
sl@0
|
192 |
{
|
sl@0
|
193 |
if(aValue != aExpected)
|
sl@0
|
194 |
{
|
sl@0
|
195 |
DeleteTestFiles();
|
sl@0
|
196 |
RDebug::Print(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue);
|
sl@0
|
197 |
TheTest(EFalse, aLine);
|
sl@0
|
198 |
}
|
sl@0
|
199 |
}
|
sl@0
|
200 |
#define TEST(arg) ::Check1((arg), __LINE__)
|
sl@0
|
201 |
#define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
|
sl@0
|
202 |
|
sl@0
|
203 |
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
204 |
//Creates file session instance and the test directory
|
sl@0
|
205 |
void CreateTestEnv()
|
sl@0
|
206 |
{
|
sl@0
|
207 |
TInt err = TheFs.Connect();
|
sl@0
|
208 |
TEST2(err, KErrNone);
|
sl@0
|
209 |
|
sl@0
|
210 |
err = TheFs.MkDir(KPublicDir);
|
sl@0
|
211 |
TEST(err == KErrNone || err == KErrAlreadyExists);
|
sl@0
|
212 |
|
sl@0
|
213 |
err = TheFs.MkDir(KPrivateDir);
|
sl@0
|
214 |
TEST(err == KErrNone || err == KErrAlreadyExists);
|
sl@0
|
215 |
}
|
sl@0
|
216 |
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
217 |
//Create and setup all the database test files
|
sl@0
|
218 |
|
sl@0
|
219 |
//Perform common setup steps for all databases
|
sl@0
|
220 |
void SetupTestDb()
|
sl@0
|
221 |
{
|
sl@0
|
222 |
TInt err = TheDb.Exec(KCreateTable1);
|
sl@0
|
223 |
TEST(err >= KErrNone);
|
sl@0
|
224 |
|
sl@0
|
225 |
err = TheDb.Exec(KCreateTable2);
|
sl@0
|
226 |
TEST(err >= KErrNone);
|
sl@0
|
227 |
|
sl@0
|
228 |
err = TheDb.Exec(KCreateIndex);
|
sl@0
|
229 |
TEST(err >= KErrNone);
|
sl@0
|
230 |
|
sl@0
|
231 |
err = TheDb.Exec(KInsertTable);
|
sl@0
|
232 |
TEST(err >= KErrNone);
|
sl@0
|
233 |
}
|
sl@0
|
234 |
|
sl@0
|
235 |
void CreateTestDBs()
|
sl@0
|
236 |
{
|
sl@0
|
237 |
RSqlSecurityPolicy policy; //required for secure database
|
sl@0
|
238 |
|
sl@0
|
239 |
//Create Private Database
|
sl@0
|
240 |
TInt err = TheDb.Create(KPublicDbName);
|
sl@0
|
241 |
TEST2(err, KErrNone);
|
sl@0
|
242 |
|
sl@0
|
243 |
SetupTestDb();
|
sl@0
|
244 |
|
sl@0
|
245 |
TheDb.Close();
|
sl@0
|
246 |
|
sl@0
|
247 |
//Create Public Database
|
sl@0
|
248 |
err = TheDb.Create(KPrivateDbName);
|
sl@0
|
249 |
TEST2 (err, KErrNone);
|
sl@0
|
250 |
|
sl@0
|
251 |
SetupTestDb();
|
sl@0
|
252 |
|
sl@0
|
253 |
TheDb.Close();
|
sl@0
|
254 |
|
sl@0
|
255 |
//Create Secure Database
|
sl@0
|
256 |
err = policy.Create(TSecurityPolicy(TSecurityPolicy::EAlwaysPass));
|
sl@0
|
257 |
TEST2 (err, KErrNone);
|
sl@0
|
258 |
err = policy.SetDbPolicy(RSqlSecurityPolicy::EReadPolicy, KPolicy1);
|
sl@0
|
259 |
TEST2 (err, KErrNone);
|
sl@0
|
260 |
err = policy.SetDbPolicy(RSqlSecurityPolicy::EWritePolicy, KPolicy2);
|
sl@0
|
261 |
TEST2 (err, KErrNone);
|
sl@0
|
262 |
err = TheDb.Create(KSecureDbName,policy);
|
sl@0
|
263 |
TEST2 (err, KErrNone);
|
sl@0
|
264 |
|
sl@0
|
265 |
SetupTestDb();
|
sl@0
|
266 |
|
sl@0
|
267 |
policy.Close();
|
sl@0
|
268 |
TheDb.Close();
|
sl@0
|
269 |
}
|
sl@0
|
270 |
|
sl@0
|
271 |
void PragmaTests(const TAccessType aAccessType, TDatabaseType aDbType, TBool aAttached)
|
sl@0
|
272 |
{
|
sl@0
|
273 |
TBuf8<10> databaseName;
|
sl@0
|
274 |
TPtrC8 param;
|
sl@0
|
275 |
TInt index = 0;
|
sl@0
|
276 |
//Depending if we are
|
sl@0
|
277 |
aAttached ? databaseName.Copy(_L8("AttachedDB")) : databaseName.Copy(_L8("main"));
|
sl@0
|
278 |
|
sl@0
|
279 |
if(aDbType == ENonSecure)
|
sl@0
|
280 |
{
|
sl@0
|
281 |
index = (aAccessType == EReadParam) ? 0 : 1;
|
sl@0
|
282 |
}
|
sl@0
|
283 |
else
|
sl@0
|
284 |
{
|
sl@0
|
285 |
index = (aAccessType == EReadParam) ? 2 : 3;
|
sl@0
|
286 |
}
|
sl@0
|
287 |
|
sl@0
|
288 |
for(TInt i=0;i<KNumPragma;i++)
|
sl@0
|
289 |
{
|
sl@0
|
290 |
//////////////////////////////////// Formatting the pragma string ////////////////////////////////////////
|
sl@0
|
291 |
//Check to see if a parameter value is needed for input
|
sl@0
|
292 |
|
sl@0
|
293 |
(aAccessType == EReadParam) ? param.Set(KInputList[i].iReadParam) : param.Set(KInputList[i].iWriteParam);
|
sl@0
|
294 |
if (param != KNullDesC8)
|
sl@0
|
295 |
{
|
sl@0
|
296 |
//Formatting Pragma Strings with Parameters
|
sl@0
|
297 |
TheSql.Format(KPragmaWithParam, &databaseName, &KInputList[i].iPragmaName, ¶m);
|
sl@0
|
298 |
}
|
sl@0
|
299 |
else
|
sl@0
|
300 |
{
|
sl@0
|
301 |
//Formatting Pragma Strings without Parameters
|
sl@0
|
302 |
TheSql.Format(KPragma, &databaseName, &KInputList[i].iPragmaName);
|
sl@0
|
303 |
}
|
sl@0
|
304 |
|
sl@0
|
305 |
//////////////////// Executing the pragma and checking the results against the "ResultsTable" ////////////
|
sl@0
|
306 |
|
sl@0
|
307 |
RSqlStatement stmt;
|
sl@0
|
308 |
TInt err = stmt.Prepare(TheDb, TheSql);
|
sl@0
|
309 |
RDebug::Printf("Testing the following pragma command - %s",TheSql.Ptr());
|
sl@0
|
310 |
switch (KResultsTable[i][index])
|
sl@0
|
311 |
{
|
sl@0
|
312 |
case EOk:
|
sl@0
|
313 |
case EIgnore:
|
sl@0
|
314 |
TEST2(err, KErrNone);
|
sl@0
|
315 |
break;
|
sl@0
|
316 |
case EDeny:
|
sl@0
|
317 |
TEST2(err, KErrPermissionDenied);
|
sl@0
|
318 |
break;
|
sl@0
|
319 |
case ENoCheck:
|
sl@0
|
320 |
break;
|
sl@0
|
321 |
default:
|
sl@0
|
322 |
TEST(KErrNone);
|
sl@0
|
323 |
}
|
sl@0
|
324 |
stmt.Close();
|
sl@0
|
325 |
}
|
sl@0
|
326 |
}
|
sl@0
|
327 |
|
sl@0
|
328 |
//This function will perform the following to test authorizer:-
|
sl@0
|
329 |
// 1) Setup the connection - either using a single or attached database
|
sl@0
|
330 |
// 2) Test the authorizer using pragma 'writes'
|
sl@0
|
331 |
// 3) Test the authorizer using pragma 'reads'
|
sl@0
|
332 |
void PerformPragmaTest(const TDesC16& aDatabaseName, TDatabaseType aDbType, TBool aAttached)
|
sl@0
|
333 |
{
|
sl@0
|
334 |
TInt err = 0;
|
sl@0
|
335 |
|
sl@0
|
336 |
if(aAttached)
|
sl@0
|
337 |
{
|
sl@0
|
338 |
if (aDatabaseName.Compare(KSecureDbName) == 0)
|
sl@0
|
339 |
{
|
sl@0
|
340 |
TheDb.Open(KPublicDbName);
|
sl@0
|
341 |
TEST2(err, KErrNone);
|
sl@0
|
342 |
}
|
sl@0
|
343 |
else
|
sl@0
|
344 |
{
|
sl@0
|
345 |
TheDb.Open(KSecureDbName);
|
sl@0
|
346 |
TEST2(err, KErrNone);
|
sl@0
|
347 |
}
|
sl@0
|
348 |
|
sl@0
|
349 |
err = TheDb.Attach(aDatabaseName,KAttachDb);
|
sl@0
|
350 |
TEST2(err, KErrNone);
|
sl@0
|
351 |
}
|
sl@0
|
352 |
else
|
sl@0
|
353 |
{
|
sl@0
|
354 |
err = TheDb.Open(aDatabaseName);
|
sl@0
|
355 |
TEST2(err, KErrNone);
|
sl@0
|
356 |
}
|
sl@0
|
357 |
|
sl@0
|
358 |
//Testing Pragma Reads
|
sl@0
|
359 |
PragmaTests(EReadParam, aDbType, aAttached);
|
sl@0
|
360 |
|
sl@0
|
361 |
//Testing Pragma Writes
|
sl@0
|
362 |
PragmaTests(EWriteParam, aDbType, aAttached);
|
sl@0
|
363 |
|
sl@0
|
364 |
TheDb.Close();
|
sl@0
|
365 |
}
|
sl@0
|
366 |
|
sl@0
|
367 |
/**
|
sl@0
|
368 |
@SYMTestCaseID PDS-SQL-UT-4122
|
sl@0
|
369 |
@SYMTestCaseDesc Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
|
sl@0
|
370 |
Execute all SQL pragmas to test the permissions returned from the CSqlSrvDatabase::AuthorizeCallback
|
sl@0
|
371 |
function is correct.
|
sl@0
|
372 |
The test attempts to execute pragmas for the following cases:-
|
sl@0
|
373 |
1) Without paramter (also known as 'Read' access)
|
sl@0
|
374 |
2) With parameter (also known as 'Write' access)
|
sl@0
|
375 |
The database tested in this case is a public database.
|
sl@0
|
376 |
@SYMTestPriority High
|
sl@0
|
377 |
@SYMTestActions Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
|
sl@0
|
378 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
379 |
@SYMDEF DEF129581
|
sl@0
|
380 |
*/
|
sl@0
|
381 |
void PublicDbPragmaTest()
|
sl@0
|
382 |
{
|
sl@0
|
383 |
PerformPragmaTest(KPublicDbName(), ENonSecure, EFalse);
|
sl@0
|
384 |
}
|
sl@0
|
385 |
|
sl@0
|
386 |
/**
|
sl@0
|
387 |
@SYMTestCaseID PDS-SQL-UT-4123
|
sl@0
|
388 |
@SYMTestCaseDesc Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
|
sl@0
|
389 |
Execute all SQL pragmas to test the permissions returned from the CSqlSrvDatabase::AuthorizeCallback
|
sl@0
|
390 |
function is correct.
|
sl@0
|
391 |
The test attempts to execute pragmas for the following cases:-
|
sl@0
|
392 |
1) Without paramter (also known as 'Read' access)
|
sl@0
|
393 |
2) With parameter (also known as 'Write' access)
|
sl@0
|
394 |
The database tested in this case is a private database.
|
sl@0
|
395 |
@SYMTestPriority High
|
sl@0
|
396 |
@SYMTestActions Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
|
sl@0
|
397 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
398 |
@SYMDEF DEF129581
|
sl@0
|
399 |
*/
|
sl@0
|
400 |
void PrivateDbPragmaTest()
|
sl@0
|
401 |
{
|
sl@0
|
402 |
PerformPragmaTest(KPrivateDbName(), ENonSecure, EFalse);
|
sl@0
|
403 |
}
|
sl@0
|
404 |
|
sl@0
|
405 |
/**
|
sl@0
|
406 |
@SYMTestCaseID PDS-SQL-UT-4124
|
sl@0
|
407 |
@SYMTestCaseDesc Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
|
sl@0
|
408 |
Execute all SQL pragmas to test the permissions returned from the CSqlSrvDatabase::AuthorizeCallback
|
sl@0
|
409 |
function is correct.
|
sl@0
|
410 |
The test attempts to execute pragmas for the following cases:-
|
sl@0
|
411 |
1) Without paramter (also known as 'Read' access)
|
sl@0
|
412 |
2) With parameter (also known as 'Write' access)
|
sl@0
|
413 |
The database tested in this case is a secure database.
|
sl@0
|
414 |
@SYMTestPriority High
|
sl@0
|
415 |
@SYMTestActions Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
|
sl@0
|
416 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
417 |
@SYMDEF DEF129581
|
sl@0
|
418 |
*/
|
sl@0
|
419 |
void SecureDbPragmaTest()
|
sl@0
|
420 |
{
|
sl@0
|
421 |
PerformPragmaTest(KSecureDbName(), ESecure, EFalse);
|
sl@0
|
422 |
}
|
sl@0
|
423 |
|
sl@0
|
424 |
/**
|
sl@0
|
425 |
@SYMTestCaseID PDS-SQL-UT-4125
|
sl@0
|
426 |
@SYMTestCaseDesc Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
|
sl@0
|
427 |
Execute all SQL pragmas to test the permissions returned from the CSqlSrvDatabase::AuthorizeCallback
|
sl@0
|
428 |
function is correct.
|
sl@0
|
429 |
The test attempts to execute pragmas for the following cases:-
|
sl@0
|
430 |
1) Without paramter (also known as 'Read' access)
|
sl@0
|
431 |
2) With parameter (also known as 'Write' access)
|
sl@0
|
432 |
The database tested in this case is a public attached database.
|
sl@0
|
433 |
@SYMTestPriority High
|
sl@0
|
434 |
@SYMTestActions Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
|
sl@0
|
435 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
436 |
@SYMDEF DEF129581
|
sl@0
|
437 |
*/
|
sl@0
|
438 |
void PublicAttDbPragmaTest()
|
sl@0
|
439 |
{
|
sl@0
|
440 |
PerformPragmaTest(KPublicDbName(), ENonSecure, ETrue);
|
sl@0
|
441 |
}
|
sl@0
|
442 |
|
sl@0
|
443 |
/**
|
sl@0
|
444 |
@SYMTestCaseID PDS-SQL-UT-4126
|
sl@0
|
445 |
@SYMTestCaseDesc Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
|
sl@0
|
446 |
Execute all SQL pragmas to test the permissions returned from the CSqlSrvDatabase::AuthorizeCallback
|
sl@0
|
447 |
function is correct.
|
sl@0
|
448 |
The test attempts to execute pragmas for the following cases:-
|
sl@0
|
449 |
1) Without paramter (also known as 'Read' access)
|
sl@0
|
450 |
2) With parameter (also known as 'Write' access)
|
sl@0
|
451 |
The database tested in this case is a private attached database.
|
sl@0
|
452 |
@SYMTestPriority High
|
sl@0
|
453 |
@SYMTestActions Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
|
sl@0
|
454 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
455 |
@SYMDEF DEF129581
|
sl@0
|
456 |
*/
|
sl@0
|
457 |
void PrivateAttDbPragmaTest()
|
sl@0
|
458 |
{
|
sl@0
|
459 |
PerformPragmaTest(KPrivateDbName(), ENonSecure, ETrue);
|
sl@0
|
460 |
}
|
sl@0
|
461 |
|
sl@0
|
462 |
/**
|
sl@0
|
463 |
@SYMTestCaseID PDS-SQL-UT-4127
|
sl@0
|
464 |
@SYMTestCaseDesc Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
|
sl@0
|
465 |
Execute all SQL pragmas to test the permissions returned from the CSqlSrvDatabase::AuthorizeCallback
|
sl@0
|
466 |
function is correct.
|
sl@0
|
467 |
The test attempts to execute pragmas for the following cases:-
|
sl@0
|
468 |
1) Without paramter (also known as 'Read' access)
|
sl@0
|
469 |
2) With parameter (also known as 'Write' access)
|
sl@0
|
470 |
The database tested in this case is a secure attached database.
|
sl@0
|
471 |
@SYMTestPriority High
|
sl@0
|
472 |
@SYMTestActions Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
|
sl@0
|
473 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
474 |
@SYMDEF DEF129581
|
sl@0
|
475 |
*/
|
sl@0
|
476 |
void SecureAttDbPragmaTest()
|
sl@0
|
477 |
{
|
sl@0
|
478 |
PerformPragmaTest(KSecureDbName(), ESecure, ETrue);
|
sl@0
|
479 |
}
|
sl@0
|
480 |
|
sl@0
|
481 |
void DoTests()
|
sl@0
|
482 |
{
|
sl@0
|
483 |
TheTest.Start(_L("@SYMTestCaseID:PDS-SQL-UT-4122 Pragma Testing with public databases"));
|
sl@0
|
484 |
PublicDbPragmaTest();
|
sl@0
|
485 |
|
sl@0
|
486 |
TheTest.Next(_L("@SYMTestCaseID:PDS-SQL-UT-4123 Pragma Testing with private databases"));
|
sl@0
|
487 |
PrivateDbPragmaTest();
|
sl@0
|
488 |
|
sl@0
|
489 |
TheTest.Next(_L("@SYMTestCaseID:PDS-SQL-UT-4124 Pragma Testing with secure databases"));
|
sl@0
|
490 |
SecureDbPragmaTest();
|
sl@0
|
491 |
|
sl@0
|
492 |
TheTest.Next(_L("@SYMTestCaseID:PDS-SQL-UT-4125 Pragma Testing with attached public databases"));
|
sl@0
|
493 |
PublicAttDbPragmaTest();
|
sl@0
|
494 |
|
sl@0
|
495 |
TheTest.Next(_L("@SYMTestCaseID:PDS-SQL-UT-4126 Pragma Testing with attached private databases"));
|
sl@0
|
496 |
PrivateAttDbPragmaTest();
|
sl@0
|
497 |
|
sl@0
|
498 |
TheTest.Next(_L("@SYMTestCaseID:PDS-SQL-UT-4127 Pragma Testing with attached secure databases"));
|
sl@0
|
499 |
SecureAttDbPragmaTest();
|
sl@0
|
500 |
}
|
sl@0
|
501 |
|
sl@0
|
502 |
TInt E32Main()
|
sl@0
|
503 |
{
|
sl@0
|
504 |
TheTest.Title();
|
sl@0
|
505 |
|
sl@0
|
506 |
CTrapCleanup* tc = CTrapCleanup::New();
|
sl@0
|
507 |
TheTest(tc != NULL);
|
sl@0
|
508 |
|
sl@0
|
509 |
__UHEAP_MARK;
|
sl@0
|
510 |
|
sl@0
|
511 |
CreateTestEnv();
|
sl@0
|
512 |
DeleteTestFiles();
|
sl@0
|
513 |
CreateTestDBs();
|
sl@0
|
514 |
DoTests();
|
sl@0
|
515 |
DeleteTestFiles();
|
sl@0
|
516 |
TheFs.Close();
|
sl@0
|
517 |
|
sl@0
|
518 |
__UHEAP_MARKEND;
|
sl@0
|
519 |
|
sl@0
|
520 |
TheTest.End();
|
sl@0
|
521 |
TheTest.Close();
|
sl@0
|
522 |
|
sl@0
|
523 |
delete tc;
|
sl@0
|
524 |
|
sl@0
|
525 |
User::Heap().Check();
|
sl@0
|
526 |
return KErrNone;
|
sl@0
|
527 |
}
|