sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: //
sl@0: 
sl@0: #include <e32test.h>
sl@0: #include <bautils.h>
sl@0: #include <sqldb.h>
sl@0: 
sl@0: #define __SQLSRV_STRINGS__
sl@0: #include "SqlSrvStrings.h"
sl@0: 
sl@0: ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0: 
sl@0: RFs TheFs;
sl@0: RSqlDatabase TheDb;
sl@0: TParse TheFileNameParse;
sl@0: RTest TheTest(_L("t_sqlauthorizer test"));
sl@0: 
sl@0: const TSecurityPolicy KPolicy1(ECapabilityReadUserData, ECapabilityNetworkControl,  ECapabilityWriteUserData);
sl@0: const TSecurityPolicy KPolicy2(ECapabilityReadUserData);
sl@0: 
sl@0: _LIT8(KPragma , 		"PRAGMA %S.%S\x0");
sl@0: _LIT8(KPragmaWithParam, "PRAGMA %S.%S%S\x0");
sl@0: 
sl@0: _LIT(KPublicDir,  "C:\\test\\");
sl@0: _LIT(KPrivateDir, "C:\\private\\21212129\\");
sl@0: 
sl@0: _LIT(KPublicDbName,	 "C:\\test\\t_sqlauthorizer.db");
sl@0: _LIT(KSecureDbName,  "C:[21212129]t_sqlauthorizer.db");
sl@0: _LIT(KPrivateDbName, "C:\\private\\21212129\\t_sqlauthorizer.db");
sl@0: _LIT(KAttachDb, "AttachedDB");
sl@0: 
sl@0: _LIT(KCreateTable1, "CREATE TABLE A(Id INTEGER,Name TEXT)");
sl@0: _LIT(KCreateTable2, "CREATE TABLE B(Id INTEGER,Address TEXT, Num INTEGER, FOREIGN KEY (Address) REFERENCES A(id))");
sl@0: _LIT(KCreateIndex, 	"CREATE INDEX Index1 ON B (Num)");
sl@0: _LIT(KInsertTable, 	"INSERT INTO A VALUES(1, 'AAA')");
sl@0: 
sl@0: TBuf8<KMaxFileName + 64> TheSql;
sl@0: const TInt KNumPragma = 34;
sl@0: 
sl@0: //////////////////////////////////////////// Input List  ///////////////////////////////////////////////
sl@0: struct TInputList
sl@0: 	{
sl@0: 	const TPtrC8 iPragmaName;
sl@0: 	const TPtrC8 iReadParam;
sl@0: 	const TPtrC8 iWriteParam;
sl@0: 	};
sl@0: 
sl@0: const TInputList KInputList [KNumPragma] = 
sl@0: 	{
sl@0: 	////////////////////////////////////////////////////////////////////////////////////////////////
sl@0: 	//	Pragma Name	  	  		 |Read Parameter   |Write Parameter			|Pragma Command    
sl@0: 	////////////////////////////////////////////////////////////////////////////////////////////////
sl@0: 		{KAutoVacuum(), 		  KNullDesC8(), 	_L8(" = 0")}, 			//auto_vacuum
sl@0: 		{KCacheSize(),			  KNullDesC8(), 	_L8(" = 32")},			//cache_size
sl@0: 		{KCaseSensitiveLike(), 	  KNullDesC8(), 	_L8(" = 0")},			//case_sensitive_like
sl@0: 		{KCountChanges(), 	   	  KNullDesC8(), 	_L8(" = 1")},			//count_changes
sl@0: 		{KDefaultCacheSize(), 	  KNullDesC8(), 	_L8(" = 32")},			//DefaultAccess_cache_size	
sl@0: 		{KEmptyResultCallbacks(), KNullDesC8(), 	_L8(" = 0")},			//empty_result_callbacks
sl@0: 		{KEncoding(), 			  KNullDesC8(), 	_L8(" = \"UTF-8\"")},	//encoding
sl@0: 		{KFullColumnNames(), 	  KNullDesC8(), 	_L8(" = 0")},			//full_column_names
sl@0: 		{KFullfsync(), 			  KNullDesC8(), 	_L8(" = 1")},			//fullfsync
sl@0: 		{KIncrementalVacuum(), 	  KNullDesC8(), 	_L8(" = 0")},			//incremental_vacuum
sl@0: 		{KJournalMode(), 		  KNullDesC8(), 	_L8(" = DELETE")},		//journal_mode
sl@0: 		{KJournalSizeLimit(),	  KNullDesC8(), 	_L8(" = 1000000")},		//journal_size_limit
sl@0: 		{KLegacyFileFormat(), 	  KNullDesC8(), 	_L8(" = ON")},			//legacy_file_format
sl@0: 		{KLockingMode(), 		  KNullDesC8(), 	_L8(" = Normal")},		//locking_mode
sl@0: 		{KPageSize(), 			  KNullDesC8(), 	_L8(" = 2048")},		//page_size		
sl@0: 		{KMaxPageCount(), 		  KNullDesC8(), 	_L8(" = 32")},			//max_page_count
sl@0: 		{KReadUncommitted(), 	  KNullDesC8(), 	_L8(" = 1")},			//read_uncommitted
sl@0: 		{KShortColumnNames(), 	  KNullDesC8(), 	_L8(" = 0")},			//short_column_names
sl@0: 		{KSynchronousFlag(), 	  KNullDesC8(), 	_L8(" = NORMAL")}, 		//synchronous
sl@0: 		{KTempStore(), 			  KNullDesC8(), 	_L8(" = MEMORY")},		//temp_store	
sl@0: 		{KTempStoreDirectory(),   KNullDesC8(), 	_L8(" = TEMP")}, 		//temp_store_directory
sl@0: 		{KDatabaseList(), 		  KNullDesC8(), 	KNullDesC8()},			//database_list
sl@0: 		{KForeignKeyList(), 	  _L8("(B)"), 		KNullDesC8()},			//foreign_key_list
sl@0: 		{KFreelistCount(), 		  KNullDesC8(), 	KNullDesC8()},			//freelist_count
sl@0: 		{KIndexInfo(), 			  _L8("(Index1)"), 	KNullDesC8()},			//index_info		
sl@0: 		{KIndexIist(), 			  _L8("(B)"), 		KNullDesC8()},			//index_list
sl@0: 		{KPageCount(), 			  KNullDesC8(), 	KNullDesC8()},			//page_count
sl@0: 		{KTableInfo(), 			  _L8("(B)"), 		KNullDesC8()},			//table_info
sl@0: 		{KSchemaVersion(), 		  KNullDesC8(), 	_L8(" = 10")},			//schema_version
sl@0: 		{KUserVersion(), 		  KNullDesC8(), 	_L8(" = 10")},			//user_version	
sl@0: 		{KIntegrityCheck(), 	  KNullDesC8(), 	_L8(" = 1")},			//integrity_check
sl@0: 		{KParserTrace(), 		  KNullDesC8(), 	_L8(" = ON")},			//parser_trace
sl@0: 		{KVdbeTrace(), 			  KNullDesC8(), 	_L8(" = ON")},			//vdbe_trace
sl@0: 		{KdbeListing(), 		  KNullDesC8(), 	_L8(" = ON")},			//vdbe_listing
sl@0: 	};
sl@0: 
sl@0: //////////////////////////////////////////////// Expected results ///////////////////////////////////////////////////////////
sl@0: 
sl@0: enum TAccessType
sl@0: 	{
sl@0: 	EReadParam,
sl@0: 	EWriteParam,
sl@0: 	};
sl@0: 
sl@0: enum TDatabaseType
sl@0: 	{
sl@0: 	ENonSecure,
sl@0: 	ESecure,
sl@0: 	};
sl@0: 
sl@0: enum TAccessResult
sl@0: 	{
sl@0: 	EOk = KErrNone,
sl@0: 	EIgnore,
sl@0: 	EDeny,
sl@0: 	ENoCheck
sl@0: 	};
sl@0: 
sl@0: 
sl@0: // Table listing the expected for each pragma command for the following access conditions:-
sl@0: // 1) Pragma Read with non-secure database
sl@0: // 2) Pragma Write with non-secure database
sl@0: // 3) Pragma Read with secure database
sl@0: // 4) Pragma Write with secure database
sl@0: const TInt KResultsTable[KNumPragma][4] = 
sl@0: 	{
sl@0: 		////////////////////////////////////////////////////////////////////////////////////
sl@0: 		//		NON_SECURE	  	|			SECURE		|
sl@0: 		//W/out Pram |With Param|W/out Pram |With Param |Pragma Command 
sl@0: 		///////////////////////////////////////////////////////////////////////////////////
sl@0: 		{EOk,		EIgnore,	EDeny, 		EDeny }, 	//auto_vacuum
sl@0: 		{EOk,		EIgnore,	EDeny,		EDeny }, 	//cache_size
sl@0: 		{EOk,		ENoCheck,	EDeny,		EDeny },	//case_sensitive_like  
sl@0: 		{EOk,		EOk,		EDeny,		EDeny }, 	//count_changes
sl@0: 		{EOk,		EIgnore,	EDeny,		EDeny }, 	//cache_size
sl@0: 		{EOk,		EIgnore,	EDeny,		EDeny }, 	//empty_result_callbacks
sl@0: 		{EOk,		EIgnore,	EDeny,		EDeny },  	//encoding
sl@0: 		{EOk,		EOk,		EDeny,		EDeny },	//full_column_names
sl@0: 		{EOk,		EIgnore,	EDeny,		EDeny },	//fullfsync
sl@0: 		{EIgnore,	EIgnore,	EDeny,		EDeny },	//incremental_vacuum
sl@0: 		{EIgnore,	EIgnore,	EDeny,		EDeny },	//journal_mode
sl@0: 		{EIgnore,	EIgnore,	EDeny,		EDeny }, 	//journal_size_limit
sl@0: 		{EOk,		EIgnore,	EDeny,		EDeny }, 	//legacy_file_format
sl@0: 		{EOk,		EIgnore,	EDeny,		EDeny },	//locking_mode
sl@0: 		{EOk,		EIgnore,	EDeny,		EDeny },	//page_size
sl@0: 		{EIgnore,	EIgnore,	EDeny,		EDeny },	//max_page_count
sl@0: 		{EOk,		EIgnore,	EDeny,		EDeny },	//read_uncommitted
sl@0: 		{EOk,		EOk,		EDeny,		EDeny },	//short_column_names
sl@0: 		{EOk,		EIgnore,	EDeny,		EDeny },	//synchronous
sl@0: 		{EOk,		EIgnore,	EDeny,		EDeny },	//temp_store
sl@0: 		{EOk,		ENoCheck,	EDeny,		EDeny },	//temp_store_directory
sl@0: 		{EOk,		EOk,		EDeny,		EDeny },	//database_list
sl@0: 		{ENoCheck,	EOk,		EDeny,		EDeny },	//foreign_key_list
sl@0: 		{EOk,		EIgnore,	EDeny,		EDeny },	//freelist_count
sl@0: 		{ENoCheck,	EOk,		EDeny,		EDeny },	//index_info
sl@0: 		{ENoCheck,	EOk,		EDeny,		EDeny },	//index_list
sl@0: 		{EOk,		EIgnore,	EDeny,		EDeny },	//page_count
sl@0: 		{ENoCheck,	EOk,		EDeny,		EDeny },	//table_info
sl@0: 		{EOk,		EIgnore,	EDeny,		EDeny },	//schema_version
sl@0: 		{EOk,		EIgnore,	EDeny,		EDeny },	//user_version
sl@0: 		{EOk,		EIgnore,	EDeny,		EDeny },	//integrity_check
sl@0: 		{EOk,		EIgnore,	EDeny,		EDeny },	//parser_trace
sl@0: 		{EOk,		EIgnore,	EDeny,		EDeny },	//vdbe_trace
sl@0: 		{EOk,		EIgnore,	EDeny,		EDeny },	//vdbe_trace
sl@0: 	};
sl@0: 
sl@0: ///////////////////////////////////////////////////////////////////////////////////////
sl@0: //Deletes all created test files.
sl@0: void DeleteTestFiles()
sl@0: 	{	
sl@0: 	(void)RSqlDatabase::Delete(KPrivateDbName);
sl@0: 	(void)RSqlDatabase::Delete(KSecureDbName);
sl@0: 	(void)RSqlDatabase::Delete(KPublicDbName);
sl@0: 	}
sl@0: 
sl@0: ///////////////////////////////////////////////////////////////////////////////////////
sl@0: //Test macros and functions
sl@0: void Check1(TInt aValue, TInt aLine)
sl@0: 	{
sl@0: 	if(!aValue)
sl@0: 		{
sl@0: 		DeleteTestFiles();
sl@0: 		RDebug::Print(_L("*** Line %d\r\n"), aLine);
sl@0: 		TheTest(EFalse, aLine);
sl@0: 		}
sl@0: 	}
sl@0: void Check2(TInt aValue, TInt aExpected, TInt aLine)
sl@0: 	{
sl@0: 	if(aValue != aExpected)
sl@0: 		{
sl@0: 		DeleteTestFiles();
sl@0: 		RDebug::Print(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue);
sl@0: 		TheTest(EFalse, aLine);
sl@0: 		}
sl@0: 	}
sl@0: #define TEST(arg) ::Check1((arg), __LINE__)
sl@0: #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
sl@0: 
sl@0: ///////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0: //Creates file session instance and the test directory
sl@0: void CreateTestEnv()
sl@0:     {
sl@0: 	TInt err = TheFs.Connect();
sl@0: 	TEST2(err, KErrNone);
sl@0: 
sl@0: 	err = TheFs.MkDir(KPublicDir);
sl@0: 	TEST(err == KErrNone || err == KErrAlreadyExists);
sl@0: 	
sl@0: 	err = TheFs.MkDir(KPrivateDir);
sl@0: 	TEST(err == KErrNone || err == KErrAlreadyExists);
sl@0: 	}
sl@0: ///////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0: //Create and setup all the database test files
sl@0: 
sl@0: //Perform common setup steps for all databases
sl@0: void SetupTestDb()
sl@0: 	{
sl@0: 	TInt err = TheDb.Exec(KCreateTable1);
sl@0: 	TEST(err >= KErrNone);
sl@0: 
sl@0: 	err = TheDb.Exec(KCreateTable2);
sl@0: 	TEST(err >= KErrNone);
sl@0: 
sl@0: 	err = TheDb.Exec(KCreateIndex);
sl@0: 	TEST(err >= KErrNone);
sl@0: 
sl@0: 	err = TheDb.Exec(KInsertTable);
sl@0: 	TEST(err >= KErrNone);	
sl@0: 	}
sl@0: 
sl@0: void CreateTestDBs()
sl@0: 	{
sl@0: 	RSqlSecurityPolicy policy; //required for secure database
sl@0: 	
sl@0: 	//Create Private Database
sl@0: 	TInt err = TheDb.Create(KPublicDbName);
sl@0: 	TEST2(err, KErrNone);
sl@0: 	
sl@0: 	SetupTestDb();
sl@0: 	
sl@0: 	TheDb.Close();
sl@0: 
sl@0: 	//Create Public Database
sl@0: 	err = TheDb.Create(KPrivateDbName);
sl@0: 	TEST2 (err, KErrNone);
sl@0: 	
sl@0: 	SetupTestDb();
sl@0: 	
sl@0: 	TheDb.Close();
sl@0: 	
sl@0: 	//Create Secure Database
sl@0: 	err = policy.Create(TSecurityPolicy(TSecurityPolicy::EAlwaysPass));
sl@0: 	TEST2 (err, KErrNone);
sl@0: 	err = policy.SetDbPolicy(RSqlSecurityPolicy::EReadPolicy, KPolicy1);
sl@0: 	TEST2 (err, KErrNone);
sl@0: 	err = policy.SetDbPolicy(RSqlSecurityPolicy::EWritePolicy, KPolicy2);
sl@0: 	TEST2 (err, KErrNone);
sl@0: 	err = TheDb.Create(KSecureDbName,policy);
sl@0: 	TEST2 (err, KErrNone);
sl@0: 	
sl@0: 	SetupTestDb();
sl@0: 	
sl@0: 	policy.Close();
sl@0: 	TheDb.Close();	
sl@0: 	}
sl@0: 
sl@0: void PragmaTests(const TAccessType aAccessType, TDatabaseType aDbType, TBool aAttached)
sl@0: 	{
sl@0: 	TBuf8<10> databaseName;
sl@0: 	TPtrC8 param;
sl@0: 	TInt index = 0;
sl@0: 	//Depending if we are 
sl@0: 	aAttached ? databaseName.Copy(_L8("AttachedDB")) : databaseName.Copy(_L8("main"));
sl@0: 	
sl@0: 	if(aDbType == ENonSecure)
sl@0: 		{
sl@0: 		index = (aAccessType == EReadParam) ? 0 : 1;
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		index = (aAccessType == EReadParam) ? 2 : 3;
sl@0: 		}
sl@0: 	
sl@0: 	for(TInt i=0;i<KNumPragma;i++)
sl@0: 		{
sl@0: //////////////////////////////////// Formatting the pragma string ////////////////////////////////////////
sl@0: //Check to see if a parameter value is needed for input
sl@0: 		
sl@0: 		(aAccessType == EReadParam) ? param.Set(KInputList[i].iReadParam) : param.Set(KInputList[i].iWriteParam);
sl@0: 		if (param != KNullDesC8)
sl@0: 			{
sl@0: 			//Formatting Pragma Strings with Parameters
sl@0: 			TheSql.Format(KPragmaWithParam, &databaseName, &KInputList[i].iPragmaName, &param);
sl@0: 			}
sl@0: 		else
sl@0: 			{
sl@0: 			//Formatting Pragma Strings without Parameters
sl@0: 			TheSql.Format(KPragma, &databaseName, &KInputList[i].iPragmaName);
sl@0: 			}
sl@0: 
sl@0: //////////////////// Executing the pragma and checking the results against the "ResultsTable" ////////////
sl@0: 					
sl@0: 			RSqlStatement stmt;
sl@0: 			TInt err = stmt.Prepare(TheDb, TheSql);
sl@0: 			RDebug::Printf("Testing the following pragma command - %s",TheSql.Ptr());
sl@0: 			switch (KResultsTable[i][index])
sl@0: 				{
sl@0: 				case EOk:
sl@0: 				case EIgnore:
sl@0: 					TEST2(err, KErrNone);
sl@0: 					break;
sl@0: 				case EDeny:
sl@0: 					TEST2(err, KErrPermissionDenied);
sl@0: 					break;
sl@0: 				case ENoCheck:
sl@0: 					break;
sl@0: 				default:
sl@0: 					TEST(KErrNone);
sl@0: 				}
sl@0: 			stmt.Close();
sl@0: 		}
sl@0: 	}
sl@0: 
sl@0: //This function will perform the following to test authorizer:-
sl@0: // 1) Setup the connection - either using a single or attached database
sl@0: // 2) Test the authorizer using pragma 'writes'
sl@0: // 3) Test the authorizer using pragma 'reads'  
sl@0: void PerformPragmaTest(const TDesC16& aDatabaseName, TDatabaseType aDbType, TBool aAttached)
sl@0: 	{
sl@0: 	TInt err = 0;
sl@0: 	
sl@0: 	if(aAttached)
sl@0: 		{
sl@0: 		if (aDatabaseName.Compare(KSecureDbName) == 0)
sl@0: 			{
sl@0: 			TheDb.Open(KPublicDbName);
sl@0: 			TEST2(err, KErrNone);
sl@0: 			}
sl@0: 		else
sl@0: 			{
sl@0: 			TheDb.Open(KSecureDbName);
sl@0: 			TEST2(err, KErrNone);
sl@0: 			}
sl@0: 		
sl@0: 		err = TheDb.Attach(aDatabaseName,KAttachDb);
sl@0: 		TEST2(err, KErrNone);
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		err = TheDb.Open(aDatabaseName);
sl@0: 		TEST2(err, KErrNone);
sl@0: 		}
sl@0: 	
sl@0: 	//Testing Pragma Reads
sl@0: 	PragmaTests(EReadParam, aDbType, aAttached);
sl@0: 
sl@0: 	//Testing Pragma Writes
sl@0: 	PragmaTests(EWriteParam, aDbType, aAttached);
sl@0: 	
sl@0: 	TheDb.Close();
sl@0: 	}
sl@0: 
sl@0: /**
sl@0: @SYMTestCaseID			PDS-SQL-UT-4122
sl@0: @SYMTestCaseDesc		Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
sl@0: 						Execute all SQL pragmas to test the permissions returned from the CSqlSrvDatabase::AuthorizeCallback
sl@0: 						function is correct.
sl@0: 						The test attempts to execute pragmas for the following cases:-
sl@0: 						1) Without paramter (also known as 'Read' access)
sl@0: 						2) With parameter (also known as 'Write' access)
sl@0: 						The database tested in this case is a public database. 
sl@0: @SYMTestPriority		High
sl@0: @SYMTestActions			Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
sl@0: @SYMTestExpectedResults Test must not fail
sl@0: @SYMDEF					DEF129581
sl@0: */
sl@0: void PublicDbPragmaTest()
sl@0: 	{
sl@0: 	PerformPragmaTest(KPublicDbName(), ENonSecure, EFalse);
sl@0: 	}
sl@0: 
sl@0: /**
sl@0: @SYMTestCaseID			PDS-SQL-UT-4123
sl@0: @SYMTestCaseDesc		Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
sl@0: 						Execute all SQL pragmas to test the permissions returned from the CSqlSrvDatabase::AuthorizeCallback
sl@0: 						function is correct.
sl@0: 						The test attempts to execute pragmas for the following cases:-
sl@0: 						1) Without paramter (also known as 'Read' access)
sl@0: 						2) With parameter (also known as 'Write' access)
sl@0: 						The database tested in this case is a private database. 
sl@0: @SYMTestPriority		High
sl@0: @SYMTestActions			Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
sl@0: @SYMTestExpectedResults Test must not fail
sl@0: @SYMDEF					DEF129581
sl@0: */
sl@0: void PrivateDbPragmaTest()
sl@0: 	{
sl@0: 	PerformPragmaTest(KPrivateDbName(), ENonSecure, EFalse);
sl@0: 	}
sl@0: 
sl@0: /**
sl@0: @SYMTestCaseID			PDS-SQL-UT-4124
sl@0: @SYMTestCaseDesc		Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
sl@0: 						Execute all SQL pragmas to test the permissions returned from the CSqlSrvDatabase::AuthorizeCallback
sl@0: 						function is correct.
sl@0: 						The test attempts to execute pragmas for the following cases:-
sl@0: 						1) Without paramter (also known as 'Read' access)
sl@0: 						2) With parameter (also known as 'Write' access)
sl@0: 						The database tested in this case is a secure database. 
sl@0: @SYMTestPriority		High
sl@0: @SYMTestActions			Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
sl@0: @SYMTestExpectedResults Test must not fail
sl@0: @SYMDEF					DEF129581
sl@0: */
sl@0: void SecureDbPragmaTest()
sl@0: 	{
sl@0: 	PerformPragmaTest(KSecureDbName(), ESecure, EFalse);
sl@0: 	}
sl@0: 
sl@0: /**
sl@0: @SYMTestCaseID			PDS-SQL-UT-4125
sl@0: @SYMTestCaseDesc		Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
sl@0: 						Execute all SQL pragmas to test the permissions returned from the CSqlSrvDatabase::AuthorizeCallback
sl@0: 						function is correct.
sl@0: 						The test attempts to execute pragmas for the following cases:-
sl@0: 						1) Without paramter (also known as 'Read' access)
sl@0: 						2) With parameter (also known as 'Write' access)
sl@0: 						The database tested in this case is a public attached database.  
sl@0: @SYMTestPriority		High
sl@0: @SYMTestActions			Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
sl@0: @SYMTestExpectedResults Test must not fail
sl@0: @SYMDEF					DEF129581
sl@0: */
sl@0: void PublicAttDbPragmaTest()
sl@0: 	{
sl@0: 	PerformPragmaTest(KPublicDbName(), ENonSecure, ETrue);
sl@0: 	}
sl@0: 
sl@0: /**
sl@0: @SYMTestCaseID			PDS-SQL-UT-4126
sl@0: @SYMTestCaseDesc		Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
sl@0: 						Execute all SQL pragmas to test the permissions returned from the CSqlSrvDatabase::AuthorizeCallback
sl@0: 						function is correct.
sl@0: 						The test attempts to execute pragmas for the following cases:-
sl@0: 						1) Without paramter (also known as 'Read' access)
sl@0: 						2) With parameter (also known as 'Write' access)
sl@0: 						The database tested in this case is a private attached database. 
sl@0: @SYMTestPriority		High
sl@0: @SYMTestActions			Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
sl@0: @SYMTestExpectedResults Test must not fail
sl@0: @SYMDEF					DEF129581
sl@0: */
sl@0: void PrivateAttDbPragmaTest()
sl@0: 	{
sl@0: 	PerformPragmaTest(KPrivateDbName(), ENonSecure, ETrue);
sl@0: 	}
sl@0: 
sl@0: /**
sl@0: @SYMTestCaseID			PDS-SQL-UT-4127
sl@0: @SYMTestCaseDesc		Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
sl@0: 						Execute all SQL pragmas to test the permissions returned from the CSqlSrvDatabase::AuthorizeCallback
sl@0: 						function is correct.
sl@0: 						The test attempts to execute pragmas for the following cases:-
sl@0: 						1) Without paramter (also known as 'Read' access)
sl@0: 						2) With parameter (also known as 'Write' access)
sl@0: 						The database tested in this case is a secure attached database. 
sl@0: @SYMTestPriority		High
sl@0: @SYMTestActions			Test for DEF129581: All Pragmas are allowed to be executed on non-secure SQL databases.
sl@0: @SYMTestExpectedResults Test must not fail
sl@0: @SYMDEF					DEF129581
sl@0: */
sl@0: void SecureAttDbPragmaTest()
sl@0: 	{
sl@0: 	PerformPragmaTest(KSecureDbName(), ESecure, ETrue);
sl@0: 	}
sl@0: 
sl@0: void DoTests()
sl@0: 	{
sl@0: 	TheTest.Start(_L("@SYMTestCaseID:PDS-SQL-UT-4122 Pragma Testing with public databases"));
sl@0: 	PublicDbPragmaTest();
sl@0: 	
sl@0: 	TheTest.Next(_L("@SYMTestCaseID:PDS-SQL-UT-4123 Pragma Testing with private databases"));
sl@0: 	PrivateDbPragmaTest();
sl@0: 	
sl@0: 	TheTest.Next(_L("@SYMTestCaseID:PDS-SQL-UT-4124 Pragma Testing with secure databases"));
sl@0: 	SecureDbPragmaTest();
sl@0: 	
sl@0: 	TheTest.Next(_L("@SYMTestCaseID:PDS-SQL-UT-4125 Pragma Testing with attached public databases"));
sl@0: 	PublicAttDbPragmaTest();
sl@0: 	
sl@0: 	TheTest.Next(_L("@SYMTestCaseID:PDS-SQL-UT-4126 Pragma Testing with attached private databases"));
sl@0: 	PrivateAttDbPragmaTest();
sl@0: 	
sl@0: 	TheTest.Next(_L("@SYMTestCaseID:PDS-SQL-UT-4127 Pragma Testing with attached secure databases"));
sl@0: 	SecureAttDbPragmaTest();
sl@0: 	}
sl@0: 
sl@0: TInt E32Main()
sl@0: 	{
sl@0: 	TheTest.Title();
sl@0: 
sl@0: 	CTrapCleanup* tc = CTrapCleanup::New();
sl@0: 	TheTest(tc != NULL);
sl@0: 	
sl@0: 	__UHEAP_MARK;
sl@0: 	
sl@0: 	CreateTestEnv();
sl@0: 	DeleteTestFiles();
sl@0: 	CreateTestDBs();
sl@0: 	DoTests();
sl@0: 	DeleteTestFiles();
sl@0: 	TheFs.Close();
sl@0: 
sl@0: 	__UHEAP_MARKEND;
sl@0: 
sl@0: 	TheTest.End();
sl@0: 	TheTest.Close();
sl@0: 
sl@0: 	delete tc;
sl@0: 
sl@0: 	User::Heap().Check();
sl@0: 	return KErrNone;
sl@0: 	}