os/persistentdata/persistentstorage/sql/TEST/t_sqlsecurity1.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 #include <s32file.h>
    20 
    21 ///////////////////////////////////////////////////////////////////////////////////////
    22 
    23 #define UNUSED_VAR(a) (a) = (a)
    24 
    25 RTest TheTest(_L("t_sqlsecurity1 test"));
    26 
    27 _LIT(KTestDir, "c:\\test\\");
    28 _LIT(KTestDbName, "c:[98765432]t_sqlsecurity1_1.db");
    29 _LIT(KTestDbName2, "c:\\test\\t_sqlsecurity1_2.db");
    30 _LIT(KTestDbName3, "c:[98765432]t_sqlsecurity1_3.db");
    31 _LIT(KTestDbName4, "c:\\private\\98765432\\t_sqlsecurity1_4.db");
    32 _LIT(KTestDbName5, "|00110022|33005500|c:");
    33 _LIT(KTestFile, "c:\\test\\policy.strm");
    34 
    35 _LIT(KDb1, "C:[98765432]t_nosettings.db");
    36 _LIT(KDb2, "C:[98765432]t_emptysettings.db");
    37 _LIT(KDb3, "C:[98765432]t_invversion.db");
    38 _LIT(KDb4, "C:[98765432]t_nocollation.db");
    39 _LIT(KDb5, "C:[98765432]t_longcollation.db");
    40 _LIT(KDb6, "C:[98765432]t_nodefaultpolicy.db");
    41 _LIT(KDb7, "C:[98765432]t_invobject.db");
    42 _LIT(KDb8, "C:[98765432]t_2defaultpolicies.db");
    43 
    44 const TSecurityPolicy KDefaultPolicy(ECapabilityDRM);
    45 const TSecurityPolicy KPolicy1(ECapabilityTrustedUI, ECapabilityDiskAdmin);
    46 const TSecurityPolicy KPolicy2(ECapabilityNetworkControl, ECapabilityPowerMgmt, ECapabilityCommDD);
    47 const TSecurityPolicy KPolicy3(ECapabilityTCB, ECapabilityWriteUserData, ECapabilityUserEnvironment);
    48 
    49 _LIT(KTableName1, "A-tbl");
    50 _LIT(KTableName2, "B-table");
    51 _LIT(KTableName3, "T-CCCCCCCCCCCCCC");
    52 _LIT(KTableName11, "A-TBL");
    53 
    54 RFs TheFs;
    55 
    56 ///////////////////////////////////////////////////////////////////////////////////////
    57 
    58 void DeleteTestFiles()
    59 	{
    60 	(void)TheFs.Delete(KTestFile);
    61 	(void)RSqlDatabase::Delete(KTestDbName4);
    62 	(void)RSqlDatabase::Delete(KTestDbName3);
    63 	(void)RSqlDatabase::Delete(KTestDbName2);
    64 	(void)RSqlDatabase::Delete(KTestDbName);
    65 	}
    66 
    67 ///////////////////////////////////////////////////////////////////////////////////////
    68 ///////////////////////////////////////////////////////////////////////////////////////
    69 //Test macros and functions
    70 void Check1(TInt aValue, TInt aLine, TBool aPrintThreadName = EFalse)
    71 	{
    72 	if(!aValue)
    73 		{
    74 		DeleteTestFiles();
    75 		if(aPrintThreadName)
    76 			{
    77 			RThread th;
    78 			TName name = th.Name();
    79 			RDebug::Print(_L("*** Thread %S, Line %d\r\n"), &name, aLine);
    80 			}
    81 		else
    82 			{
    83 			RDebug::Print(_L("*** Line %d\r\n"), aLine);
    84 			}
    85 		TheTest(EFalse, aLine);
    86 		}
    87 	}
    88 void Check2(TInt aValue, TInt aExpected, TInt aLine, TBool aPrintThreadName = EFalse)
    89 	{
    90 	if(aValue != aExpected)
    91 		{
    92 		DeleteTestFiles();
    93 		if(aPrintThreadName)
    94 			{
    95 			RThread th;
    96 			TName name = th.Name();
    97 			RDebug::Print(_L("*** Thread %S, Line %d Expected error: %d, got: %d\r\n"), &name, aLine, aExpected, aValue);
    98 			}
    99 		else
   100 			{
   101 			RDebug::Print(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue);
   102 			}
   103 		TheTest(EFalse, aLine);
   104 		}
   105 	}
   106 #define TEST(arg) ::Check1((arg), __LINE__)
   107 #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
   108 #define TTEST(arg) ::Check1((arg), __LINE__, ETrue)
   109 #define TTEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__, ETrue)
   110 
   111 ///////////////////////////////////////////////////////////////////////////////////////
   112 
   113 void CreateTestEnv()
   114     {
   115 	TInt err = TheFs.Connect();
   116 	TEST2(err, KErrNone);
   117 
   118 	err = TheFs.MkDir(KTestDir);
   119 	TEST(err == KErrNone || err == KErrAlreadyExists);
   120 
   121 	err = TheFs.CreatePrivatePath(EDriveC);
   122 	TEST(err == KErrNone || err == KErrAlreadyExists);
   123 	}
   124 
   125 ///////////////////////////////////////////////////////////////////////////////////////
   126 
   127 TBool operator==(const TSecurityPolicy& aLeft, const TSecurityPolicy& aRight)
   128 	{
   129 	return aLeft.Package() == aRight.Package();
   130 	}
   131 
   132 void CreateTestSecurityPolicy(RSqlSecurityPolicy& aSecurityPolicy)
   133 	{
   134 	TInt err = aSecurityPolicy.Create(KDefaultPolicy);
   135 	TEST2(err, KErrNone);
   136 
   137 	err = aSecurityPolicy.SetDbPolicy(RSqlSecurityPolicy::ESchemaPolicy, KPolicy1);
   138 	TEST2(err, KErrNone);
   139 	err = aSecurityPolicy.SetDbPolicy(RSqlSecurityPolicy::EWritePolicy, KPolicy3);
   140 	TEST2(err, KErrNone);
   141 
   142 	err = aSecurityPolicy.SetPolicy(RSqlSecurityPolicy::ETable, KTableName1, RSqlSecurityPolicy::EReadPolicy, KPolicy1);
   143 	TEST2(err, KErrNone);
   144 	err = aSecurityPolicy.SetPolicy(RSqlSecurityPolicy::ETable, KTableName1, RSqlSecurityPolicy::EWritePolicy, KPolicy2);
   145 	TEST2(err, KErrNone);
   146 
   147 	err = aSecurityPolicy.SetPolicy(RSqlSecurityPolicy::ETable, KTableName2, RSqlSecurityPolicy::EReadPolicy, KPolicy1);
   148 	TEST2(err, KErrNone);
   149 	err = aSecurityPolicy.SetPolicy(RSqlSecurityPolicy::ETable, KTableName3, RSqlSecurityPolicy::EReadPolicy, KPolicy2);
   150 	TEST2(err, KErrNone);
   151 
   152 	err = aSecurityPolicy.SetPolicy(RSqlSecurityPolicy::ETable, KTableName2, RSqlSecurityPolicy::EWritePolicy, KPolicy1);
   153 	TEST2(err, KErrNone);
   154 
   155 	err = aSecurityPolicy.SetPolicy(RSqlSecurityPolicy::ETable, KTableName3, RSqlSecurityPolicy::EWritePolicy, KPolicy3);
   156 	TEST2(err, KErrNone);
   157 	}
   158 
   159 void CheckTestSecurityPolicy(const RSqlSecurityPolicy& aSecurityPolicy)
   160 	{
   161 	//Database policies
   162 	TSecurityPolicy policy = aSecurityPolicy.DbPolicy(RSqlSecurityPolicy::ESchemaPolicy);
   163 	TEST(policy == KPolicy1);
   164 	policy = aSecurityPolicy.DbPolicy(RSqlSecurityPolicy::EReadPolicy);
   165 	TEST(policy == KDefaultPolicy);
   166 	policy = aSecurityPolicy.DbPolicy(RSqlSecurityPolicy::EWritePolicy);
   167 	TEST(policy == KPolicy3);
   168 	//Table  policies
   169 	policy = aSecurityPolicy.Policy(RSqlSecurityPolicy::ETable, KTableName11, RSqlSecurityPolicy::EReadPolicy);
   170 	TEST(policy == KPolicy1);
   171 	policy = aSecurityPolicy.Policy(RSqlSecurityPolicy::ETable, KTableName2, RSqlSecurityPolicy::EReadPolicy);
   172 	TEST(policy == KPolicy1);
   173 	policy = aSecurityPolicy.Policy(RSqlSecurityPolicy::ETable, KTableName3, RSqlSecurityPolicy::EReadPolicy);
   174 	TEST(policy == KPolicy2);
   175 	policy = aSecurityPolicy.Policy(RSqlSecurityPolicy::ETable, KTableName1, RSqlSecurityPolicy::EWritePolicy);
   176 	TEST(policy == KPolicy2);
   177 	policy = aSecurityPolicy.Policy(RSqlSecurityPolicy::ETable, KTableName3, RSqlSecurityPolicy::EWritePolicy);
   178 	TEST(policy == KPolicy3);
   179 	policy = aSecurityPolicy.Policy(RSqlSecurityPolicy::ETable, KTableName2, RSqlSecurityPolicy::EWritePolicy);
   180 	TEST(policy == KPolicy1);
   181 	}
   182 
   183 /**
   184 @SYMTestCaseID			SYSLIB-SQL-CT-1635
   185 @SYMTestCaseDesc		RSqlSecurityPolicy test.
   186 						Tests RSqlSecurityPolicy API.
   187 @SYMTestPriority		High
   188 @SYMTestActions			RSqlSecurityPolicy test.
   189 @SYMTestExpectedResults Test must not fail
   190 @SYMREQ					REQ5792
   191                         REQ5793
   192 */
   193 void SqlSecurityPolicyTest()
   194 	{
   195 	RSqlSecurityPolicy securityPolicy;
   196 	TInt err = securityPolicy.Create(KDefaultPolicy);
   197 	TEST2(err, KErrNone);
   198 
   199 	//Empty RSqlSecurityPolicy object tests
   200 		//Database policies
   201 	TSecurityPolicy policy = securityPolicy.DbPolicy(RSqlSecurityPolicy::ESchemaPolicy);
   202 	TEST(policy == KDefaultPolicy);
   203 	policy = securityPolicy.DbPolicy(RSqlSecurityPolicy::EReadPolicy);
   204 	TEST(policy == KDefaultPolicy);
   205 	policy = securityPolicy.DbPolicy(RSqlSecurityPolicy::EWritePolicy);
   206 	TEST(policy == KDefaultPolicy);
   207 		//Table policies
   208 	policy = securityPolicy.Policy(RSqlSecurityPolicy::ETable, _L("A-Tbl"), RSqlSecurityPolicy::EReadPolicy);
   209 	TEST(policy == KDefaultPolicy);
   210 	policy = securityPolicy.Policy(RSqlSecurityPolicy::ETable, _L("B-Tbl"), RSqlSecurityPolicy::EWritePolicy);
   211 	TEST(policy == KDefaultPolicy);
   212 		//
   213 	securityPolicy.Close();
   214 
   215 	//Tests with initialized RSqlSecurityPolicy object
   216 	CreateTestSecurityPolicy(securityPolicy);
   217 	//Check the created and initialized object
   218 	CheckTestSecurityPolicy(securityPolicy);
   219 
   220 	//Externalize, then internalize and check the security policy object
   221 	RFileWriteStream out;
   222 	err = out.Replace(TheFs, KTestFile, EFileRead | EFileWrite);
   223 	TEST2(err, KErrNone);
   224 	TRAP(err, securityPolicy.ExternalizeL(out));
   225 	TEST2(err, KErrNone);
   226 	TRAP(err, out.CommitL());
   227 	out.Close();
   228 	TEST2(err, KErrNone);
   229 
   230 	securityPolicy.Close();
   231 	err = securityPolicy.Create(KDefaultPolicy);
   232 	TEST2(err, KErrNone);
   233 	RFileReadStream in;
   234 	err = in.Open(TheFs, KTestFile, EFileRead);
   235 	TEST2(err, KErrNone);
   236 	TRAP(err, securityPolicy.InternalizeL(in));
   237 	in.Close();
   238 	TEST2(err, KErrNone);
   239 	CheckTestSecurityPolicy(securityPolicy);
   240 
   241 	//Change some security policies and check that the RqlSecurityPolicy content was properly updated
   242 	err = securityPolicy.SetPolicy(RSqlSecurityPolicy::ETable, KTableName11, RSqlSecurityPolicy::EReadPolicy, KPolicy3);
   243 	TEST2(err, KErrNone);
   244 	policy = securityPolicy.Policy(RSqlSecurityPolicy::ETable, KTableName1, RSqlSecurityPolicy::EReadPolicy);
   245 	TEST(policy == KPolicy3);
   246 	policy = securityPolicy.Policy(RSqlSecurityPolicy::ETable, KTableName11, RSqlSecurityPolicy::EWritePolicy);
   247 	TEST(policy == KPolicy2);
   248 	//
   249 	securityPolicy.Close();
   250 	}
   251 
   252 /**
   253 @SYMTestCaseID			SYSLIB-SQL-CT-1637
   254 @SYMTestCaseDesc		RSqlDatabase::Create() test.
   255 						Tests RSqlDatabase::Create() call when the request is for creation of a secure database.
   256 @SYMTestPriority		High
   257 @SYMTestActions			RSqlDatabase::Create() test.
   258 @SYMTestExpectedResults Test must not fail
   259 @SYMREQ					REQ5792
   260                         REQ5793
   261 */
   262 void CreateSecureDatabaseTest()
   263 	{
   264 	RSqlSecurityPolicy securityPolicy;
   265 
   266 	//Create and initialize RSqlSecurityPolicy object.
   267 	CreateTestSecurityPolicy(securityPolicy);
   268 
   269 	//Create secure database using the data from securityPolicy object.
   270 	RSqlDatabase db;
   271 	TInt err = db.Create(KTestDbName, securityPolicy);
   272 	TEST2(err, KErrNone);
   273 	securityPolicy.Close();
   274 
   275 	//Check that the database security policy matches the policy used when the database was created.
   276 	err = db.GetSecurityPolicy(securityPolicy);
   277 	TEST2(err, KErrNone);
   278 	CheckTestSecurityPolicy(securityPolicy);
   279 	securityPolicy.Close();
   280 
   281 	db.Close();
   282 
   283 	//Reopen the database and check the security policies
   284 	err = db.Open(KTestDbName);
   285 	TEST2(err, KErrNone);
   286 
   287 	//Check that the database security policy matches the policy used when the database was created.
   288 	err = db.GetSecurityPolicy(securityPolicy);
   289 	TEST2(err, KErrNone);
   290 	CheckTestSecurityPolicy(securityPolicy);
   291 	securityPolicy.Close();
   292 
   293 	db.Close();
   294 
   295 	err = RSqlDatabase::Delete(KTestDbName);
   296 	TEST2(err, KErrNone);
   297 
   298 	//An attempt to create a secure database specifying the full database path
   299 	CreateTestSecurityPolicy(securityPolicy);
   300 	err = db.Create(KTestDbName2, securityPolicy);
   301 	securityPolicy.Close();
   302 	TEST2(err, KErrArgument);
   303 
   304 	//An attempt to create a non-secure database formatting the database file name as <drive:><dbFileName>
   305 	err = db.Create(KTestDbName);
   306 	TEST2(err, KErrArgument);
   307 	}
   308 
   309 /**
   310 @SYMTestCaseID			SYSLIB-SQL-CT-1643
   311 @SYMTestCaseDesc		SQL server private path in database file name test.
   312 						Verify that SQL API returns appropriate error, if an attempt is made to create, open
   313 						or delete a secure database, with the full path specified in the database file name.
   314 @SYMTestPriority		High
   315 @SYMTestActions			SQL server private path in database file name test.
   316 @SYMTestExpectedResults Test must not fail
   317 @SYMREQ					REQ5792
   318                         REQ5793
   319 */
   320 void PrivatePathTest()
   321 	{
   322 	RSqlSecurityPolicy securityPolicy;
   323 	CreateTestSecurityPolicy(securityPolicy);
   324 
   325 	RSqlDatabase db;
   326 
   327 	TInt err = db.Create(_L("C:\\PrIVATE\\10281E17\\[98765432]A.DB"), securityPolicy);
   328 	TEST2(err, KErrArgument);
   329 	err = db.Create(_L("C:\\PRIVATE\\10281E17\\[98765432]A.DB"));
   330 	TEST2(err, KErrArgument);
   331 	err = db.Open(_L("C:\\PRIVATE\\10281E17\\[98765432]A.DB"));
   332 	TEST2(err, KErrArgument);
   333 	err = db.Open(_L("C:\\PRIvaTe\\10281E17\\[98765432]A.DB"));
   334 	TEST2(err, KErrArgument);
   335 
   336 	err = db.Create(KTestDbName2);
   337 	TEST2(err, KErrNone);
   338 	err = db.Attach(_L("C:\\PRIVATe\\10281E17\\[98765432]A.DB"), _L("Db"));
   339 	TEST2(err, KErrArgument);
   340 	err = db.Attach(_L("C:\\PRIVAtE\\10281E17\\[98765432]A.DB"), _L("Db"));
   341 	TEST2(err, KErrArgument);
   342 	//This is an attempt to attach a database from the application's private data cage
   343 	err = db.Attach(KTestDbName4, _L("Db"));
   344 	TEST2(err, KErrNotFound);//There is no "Db" database file in the application's private data cage
   345 	db.Close();
   346 
   347 	err = RSqlDatabase::Delete(_L("C:\\pRIVATE\\10281E17\\[98765432]A.DB"));
   348 	TEST2(err, KErrArgument);
   349 	err = RSqlDatabase::Delete(_L("C:\\PRIvATE\\10281E17\\[98765432]A.DB"));
   350 	TEST2(err, KErrArgument);
   351 
   352 	//This is an attempt to create a database in the application's private data cage
   353 	err = db.Create(KTestDbName4);
   354 	TEST2(err, KErrNone);
   355 	db.Close();
   356 	err = RSqlDatabase::Delete(KTestDbName4);
   357 	TEST2(err, KErrNone);
   358 
   359 	err = db.Create(KTestDbName5);
   360 	TEST2(err, KErrArgument);
   361 
   362 	securityPolicy.Close();
   363 	}
   364 
   365 //This test is here to check that the construction of the second database object on the server side passes
   366 //without problems, if there is already one other secure database object (authorizer callback possible problems
   367 //during the construction phase)
   368 //Shortly: the test checks how the construction of the secure database object 2 might be influenced by
   369 //         the already existing secure database object 1.
   370 void TwoSecureDbTest()
   371 	{
   372 	RSqlSecurityPolicy securityPolicy;
   373 	CreateTestSecurityPolicy(securityPolicy);
   374 
   375 	RSqlDatabase db1;
   376 	TInt err = db1.Create(KTestDbName, securityPolicy);
   377 	TEST2(err, KErrNone);
   378 
   379 	RSqlDatabase db2;
   380 	err = db2.Create(KTestDbName3, securityPolicy);
   381 	TEST2(err, KErrNone);
   382 
   383 	securityPolicy.Close();
   384 	db2.Close();
   385 	db1.Close();
   386 	}
   387 
   388 /**
   389 @SYMTestCaseID			SYSLIB-SQL-UT-3508
   390 @SYMTestCaseDesc		Test for DEF109100: SQL, code coverage for TSqlDbSysSettings is low.
   391 						The test attempts to create a secure shared database with a security policy
   392 						specified for the system tables, which is not allowed.
   393 @SYMTestPriority		High
   394 @SYMTestActions			Test for DEF109100: SQL, code coverage for TSqlDbSysSettings is low.
   395 @SYMTestExpectedResults Test must not fail
   396 @SYMDEF					DEF109100
   397 */
   398 void StoreSysTableSecurityPolicyTest()
   399 	{
   400 	_LIT(KSecurityTable, "symbian_security");
   401 	_LIT(KSettingsTable, "symbian_settings");
   402 
   403 	//Case 1: "symbian_security" table
   404 	RSqlSecurityPolicy sp;
   405 	TInt err = sp.Create(KDefaultPolicy);
   406 	TEST2(err, KErrNone);
   407 	err = sp.SetDbPolicy(RSqlSecurityPolicy::ESchemaPolicy, KPolicy1);
   408 	TEST2(err, KErrNone);
   409 	err = sp.SetPolicy(RSqlSecurityPolicy::ETable, KSecurityTable, RSqlSecurityPolicy::EReadPolicy, KPolicy1);
   410 	TEST2(err, KErrNone);
   411 	(void)RSqlDatabase::Delete(KTestDbName);
   412 	RSqlDatabase db;
   413 	err = db.Create(KTestDbName, sp);
   414 	TEST2(err, KErrArgument);
   415 	sp.Close();
   416 
   417 	//Case 2: "symbian_settings" table
   418 	err = sp.Create(KDefaultPolicy);
   419 	TEST2(err, KErrNone);
   420 	err = sp.SetDbPolicy(RSqlSecurityPolicy::ESchemaPolicy, KPolicy1);
   421 	TEST2(err, KErrNone);
   422 	err = sp.SetPolicy(RSqlSecurityPolicy::ETable, KSettingsTable, RSqlSecurityPolicy::EReadPolicy, KPolicy1);
   423 	TEST2(err, KErrNone);
   424 	err = RSqlDatabase::Delete(KTestDbName);
   425 	TEST2(err, KErrNotFound);
   426 	err = db.Create(KTestDbName, sp);
   427 	TEST2(err, KErrArgument);
   428 	sp.Close();
   429 
   430 	err = RSqlDatabase::Delete(KTestDbName);
   431 	TEST2(err, KErrNotFound);
   432 	}
   433 
   434 /**
   435 @SYMTestCaseID			SYSLIB-SQL-UT-3509
   436 @SYMTestCaseDesc		Test for DEF109100: SQL, code coverage for TSqlDbSysSettings is low.
   437 						The test has 5 sub-cases, where the test attempts to open
   438 						a secure shared database with:
   439 						- no settings table;
   440 						- empty settings table;
   441 						- invalid version number of the settings;
   442 						- NULL collation dll name, stored in the settings;
   443 						- too long collation dll name, stored in the settings;
   444 @SYMTestPriority		High
   445 @SYMTestActions			Test for DEF109100: SQL, code coverage for TSqlDbSysSettings is low.
   446 @SYMTestExpectedResults Test must not fail
   447 @SYMDEF					DEF109100
   448 */
   449 void LoadSysSettingsTest()
   450 	{
   451 	//Case 1: no "symbian_settings" table. No error returned, because the table is recreated.
   452 	RSqlDatabase db;
   453 	TInt err = db.Open(KDb1);
   454 	TEST2(err, KErrNone);
   455 	db.Close();
   456 
   457 	//Case 2: "symbian_settings" table is empty.
   458 	err = db.Open(KDb2);
   459 	TEST2(err, KErrGeneral);
   460 	db.Close();
   461 
   462 	//Case 3: Invalid version number in "symbian_settings" table.
   463 	err = db.Open(KDb3);
   464 	TEST2(err, KErrGeneral);
   465 	db.Close();
   466 
   467 	//Case 4: NULL collation dll name in "symbian_settings" table.
   468 	err = db.Open(KDb4);
   469 	TEST2(err, KErrGeneral);
   470 	db.Close();
   471 
   472 	//Case 5: Too long collation dll name in "symbian_settings" table.
   473 	err = db.Open(KDb5);
   474 	TEST2(err, KErrOverflow);
   475 	db.Close();
   476 	}
   477 
   478 /**
   479 @SYMTestCaseID			SYSLIB-SQL-UT-3510
   480 @SYMTestCaseDesc		Test for DEF109100: SQL, code coverage for TSqlDbSysSettings is low.
   481 						The test has 3 sub-cases, where the test attempts to open
   482 						a secure shared database with:
   483 						- missing default policy in the security policy table;
   484 						- invalid database object type in the security policy table;
   485 						- 2 default policies in the security policy table;
   486 @SYMTestPriority		High
   487 @SYMTestActions			Test for DEF109100: SQL, code coverage for TSqlDbSysSettings is low.
   488 @SYMTestExpectedResults Test must not fail
   489 @SYMDEF					DEF109100
   490 */
   491 void LoadSecurityPolicyTest()
   492 	{
   493 	//Case 1: missing default policy.
   494 	RSqlDatabase db;
   495 	TInt err = db.Open(KDb6);
   496 	TEST2(err, KErrGeneral);
   497 	db.Close();
   498 
   499 	//Case 2: invalid database object type.
   500 	err = db.Open(KDb7);
   501 	TEST2(err, KErrGeneral);
   502 	db.Close();
   503 
   504 	//Case 3: 2 default policies.
   505 	err = db.Open(KDb8);
   506 	TEST2(err, KErrGeneral);
   507 	db.Close();
   508 	}
   509 
   510 void DoTests()
   511 	{
   512 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1635 RSqlSecurityPolicy test "));
   513 	SqlSecurityPolicyTest();
   514 
   515 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1637 Create secure database test "));
   516 	CreateSecureDatabaseTest();
   517 
   518 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1643 Sql server private path in the file name test "));
   519 	PrivatePathTest();
   520 
   521 	TheTest.Next(_L("Two secure databases at the same time test"));
   522 	TwoSecureDbTest();
   523 
   524 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-3508 DEF109100 - 1 - SQL, code coverage for TSqlBufRIterator,TSqlAttachDbRefCounter,TSqlDbSysSettings is low "));
   525 	StoreSysTableSecurityPolicyTest();
   526 
   527 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-3509 DEF109100 - 2 - SQL, code coverage for TSqlBufRIterator,TSqlAttachDbRefCounter,TSqlDbSysSettings is low "));
   528 	LoadSysSettingsTest();
   529 
   530 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-3510 DEF109100 - 3 - SQL, code coverage for TSqlBufRIterator,TSqlAttachDbRefCounter,TSqlDbSysSettings is low "));
   531 	LoadSecurityPolicyTest();
   532 	}
   533 
   534 TInt E32Main()
   535 	{
   536 	TheTest.Title();
   537 
   538 	CTrapCleanup* tc = CTrapCleanup::New();
   539 
   540 	__UHEAP_MARK;
   541 
   542 	CreateTestEnv();
   543 	DeleteTestFiles();
   544 	DoTests();
   545 	DeleteTestFiles();
   546 	TheFs.Close();
   547 
   548 	__UHEAP_MARKEND;
   549 
   550 	TheTest.End();
   551 	TheTest.Close();
   552 
   553 	delete tc;
   554 
   555 	User::Heap().Check();
   556 	return KErrNone;
   557 	}