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