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 sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: #define UNUSED_VAR(a) (a) = (a) sl@0: sl@0: RTest TheTest(_L("t_sqlsecurity1 test")); sl@0: sl@0: _LIT(KTestDir, "c:\\test\\"); sl@0: _LIT(KTestDbName, "c:[98765432]t_sqlsecurity1_1.db"); sl@0: _LIT(KTestDbName2, "c:\\test\\t_sqlsecurity1_2.db"); sl@0: _LIT(KTestDbName3, "c:[98765432]t_sqlsecurity1_3.db"); sl@0: _LIT(KTestDbName4, "c:\\private\\98765432\\t_sqlsecurity1_4.db"); sl@0: _LIT(KTestDbName5, "|00110022|33005500|c:"); sl@0: _LIT(KTestFile, "c:\\test\\policy.strm"); sl@0: sl@0: _LIT(KDb1, "C:[98765432]t_nosettings.db"); sl@0: _LIT(KDb2, "C:[98765432]t_emptysettings.db"); sl@0: _LIT(KDb3, "C:[98765432]t_invversion.db"); sl@0: _LIT(KDb4, "C:[98765432]t_nocollation.db"); sl@0: _LIT(KDb5, "C:[98765432]t_longcollation.db"); sl@0: _LIT(KDb6, "C:[98765432]t_nodefaultpolicy.db"); sl@0: _LIT(KDb7, "C:[98765432]t_invobject.db"); sl@0: _LIT(KDb8, "C:[98765432]t_2defaultpolicies.db"); sl@0: sl@0: const TSecurityPolicy KDefaultPolicy(ECapabilityDRM); sl@0: const TSecurityPolicy KPolicy1(ECapabilityTrustedUI, ECapabilityDiskAdmin); sl@0: const TSecurityPolicy KPolicy2(ECapabilityNetworkControl, ECapabilityPowerMgmt, ECapabilityCommDD); sl@0: const TSecurityPolicy KPolicy3(ECapabilityTCB, ECapabilityWriteUserData, ECapabilityUserEnvironment); sl@0: sl@0: _LIT(KTableName1, "A-tbl"); sl@0: _LIT(KTableName2, "B-table"); sl@0: _LIT(KTableName3, "T-CCCCCCCCCCCCCC"); sl@0: _LIT(KTableName11, "A-TBL"); sl@0: sl@0: RFs TheFs; sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: void DeleteTestFiles() sl@0: { sl@0: (void)TheFs.Delete(KTestFile); sl@0: (void)RSqlDatabase::Delete(KTestDbName4); sl@0: (void)RSqlDatabase::Delete(KTestDbName3); sl@0: (void)RSqlDatabase::Delete(KTestDbName2); sl@0: (void)RSqlDatabase::Delete(KTestDbName); sl@0: } sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: //Test macros and functions sl@0: void Check1(TInt aValue, TInt aLine, TBool aPrintThreadName = EFalse) sl@0: { sl@0: if(!aValue) sl@0: { sl@0: DeleteTestFiles(); sl@0: if(aPrintThreadName) sl@0: { sl@0: RThread th; sl@0: TName name = th.Name(); sl@0: RDebug::Print(_L("*** Thread %S, Line %d\r\n"), &name, aLine); sl@0: } sl@0: else sl@0: { sl@0: RDebug::Print(_L("*** Line %d\r\n"), aLine); sl@0: } sl@0: TheTest(EFalse, aLine); sl@0: } sl@0: } sl@0: void Check2(TInt aValue, TInt aExpected, TInt aLine, TBool aPrintThreadName = EFalse) sl@0: { sl@0: if(aValue != aExpected) sl@0: { sl@0: DeleteTestFiles(); sl@0: if(aPrintThreadName) sl@0: { sl@0: RThread th; sl@0: TName name = th.Name(); sl@0: RDebug::Print(_L("*** Thread %S, Line %d Expected error: %d, got: %d\r\n"), &name, aLine, aExpected, aValue); sl@0: } sl@0: else sl@0: { sl@0: RDebug::Print(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue); sl@0: } 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: #define TTEST(arg) ::Check1((arg), __LINE__, ETrue) sl@0: #define TTEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__, ETrue) sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: void CreateTestEnv() sl@0: { sl@0: TInt err = TheFs.Connect(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: err = TheFs.MkDir(KTestDir); sl@0: TEST(err == KErrNone || err == KErrAlreadyExists); sl@0: sl@0: err = TheFs.CreatePrivatePath(EDriveC); sl@0: TEST(err == KErrNone || err == KErrAlreadyExists); sl@0: } sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: TBool operator==(const TSecurityPolicy& aLeft, const TSecurityPolicy& aRight) sl@0: { sl@0: return aLeft.Package() == aRight.Package(); sl@0: } sl@0: sl@0: void CreateTestSecurityPolicy(RSqlSecurityPolicy& aSecurityPolicy) sl@0: { sl@0: TInt err = aSecurityPolicy.Create(KDefaultPolicy); sl@0: TEST2(err, KErrNone); sl@0: sl@0: err = aSecurityPolicy.SetDbPolicy(RSqlSecurityPolicy::ESchemaPolicy, KPolicy1); sl@0: TEST2(err, KErrNone); sl@0: err = aSecurityPolicy.SetDbPolicy(RSqlSecurityPolicy::EWritePolicy, KPolicy3); sl@0: TEST2(err, KErrNone); sl@0: sl@0: err = aSecurityPolicy.SetPolicy(RSqlSecurityPolicy::ETable, KTableName1, RSqlSecurityPolicy::EReadPolicy, KPolicy1); sl@0: TEST2(err, KErrNone); sl@0: err = aSecurityPolicy.SetPolicy(RSqlSecurityPolicy::ETable, KTableName1, RSqlSecurityPolicy::EWritePolicy, KPolicy2); sl@0: TEST2(err, KErrNone); sl@0: sl@0: err = aSecurityPolicy.SetPolicy(RSqlSecurityPolicy::ETable, KTableName2, RSqlSecurityPolicy::EReadPolicy, KPolicy1); sl@0: TEST2(err, KErrNone); sl@0: err = aSecurityPolicy.SetPolicy(RSqlSecurityPolicy::ETable, KTableName3, RSqlSecurityPolicy::EReadPolicy, KPolicy2); sl@0: TEST2(err, KErrNone); sl@0: sl@0: err = aSecurityPolicy.SetPolicy(RSqlSecurityPolicy::ETable, KTableName2, RSqlSecurityPolicy::EWritePolicy, KPolicy1); sl@0: TEST2(err, KErrNone); sl@0: sl@0: err = aSecurityPolicy.SetPolicy(RSqlSecurityPolicy::ETable, KTableName3, RSqlSecurityPolicy::EWritePolicy, KPolicy3); sl@0: TEST2(err, KErrNone); sl@0: } sl@0: sl@0: void CheckTestSecurityPolicy(const RSqlSecurityPolicy& aSecurityPolicy) sl@0: { sl@0: //Database policies sl@0: TSecurityPolicy policy = aSecurityPolicy.DbPolicy(RSqlSecurityPolicy::ESchemaPolicy); sl@0: TEST(policy == KPolicy1); sl@0: policy = aSecurityPolicy.DbPolicy(RSqlSecurityPolicy::EReadPolicy); sl@0: TEST(policy == KDefaultPolicy); sl@0: policy = aSecurityPolicy.DbPolicy(RSqlSecurityPolicy::EWritePolicy); sl@0: TEST(policy == KPolicy3); sl@0: //Table policies sl@0: policy = aSecurityPolicy.Policy(RSqlSecurityPolicy::ETable, KTableName11, RSqlSecurityPolicy::EReadPolicy); sl@0: TEST(policy == KPolicy1); sl@0: policy = aSecurityPolicy.Policy(RSqlSecurityPolicy::ETable, KTableName2, RSqlSecurityPolicy::EReadPolicy); sl@0: TEST(policy == KPolicy1); sl@0: policy = aSecurityPolicy.Policy(RSqlSecurityPolicy::ETable, KTableName3, RSqlSecurityPolicy::EReadPolicy); sl@0: TEST(policy == KPolicy2); sl@0: policy = aSecurityPolicy.Policy(RSqlSecurityPolicy::ETable, KTableName1, RSqlSecurityPolicy::EWritePolicy); sl@0: TEST(policy == KPolicy2); sl@0: policy = aSecurityPolicy.Policy(RSqlSecurityPolicy::ETable, KTableName3, RSqlSecurityPolicy::EWritePolicy); sl@0: TEST(policy == KPolicy3); sl@0: policy = aSecurityPolicy.Policy(RSqlSecurityPolicy::ETable, KTableName2, RSqlSecurityPolicy::EWritePolicy); sl@0: TEST(policy == KPolicy1); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-SQL-CT-1635 sl@0: @SYMTestCaseDesc RSqlSecurityPolicy test. sl@0: Tests RSqlSecurityPolicy API. sl@0: @SYMTestPriority High sl@0: @SYMTestActions RSqlSecurityPolicy test. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ5792 sl@0: REQ5793 sl@0: */ sl@0: void SqlSecurityPolicyTest() sl@0: { sl@0: RSqlSecurityPolicy securityPolicy; sl@0: TInt err = securityPolicy.Create(KDefaultPolicy); sl@0: TEST2(err, KErrNone); sl@0: sl@0: //Empty RSqlSecurityPolicy object tests sl@0: //Database policies sl@0: TSecurityPolicy policy = securityPolicy.DbPolicy(RSqlSecurityPolicy::ESchemaPolicy); sl@0: TEST(policy == KDefaultPolicy); sl@0: policy = securityPolicy.DbPolicy(RSqlSecurityPolicy::EReadPolicy); sl@0: TEST(policy == KDefaultPolicy); sl@0: policy = securityPolicy.DbPolicy(RSqlSecurityPolicy::EWritePolicy); sl@0: TEST(policy == KDefaultPolicy); sl@0: //Table policies sl@0: policy = securityPolicy.Policy(RSqlSecurityPolicy::ETable, _L("A-Tbl"), RSqlSecurityPolicy::EReadPolicy); sl@0: TEST(policy == KDefaultPolicy); sl@0: policy = securityPolicy.Policy(RSqlSecurityPolicy::ETable, _L("B-Tbl"), RSqlSecurityPolicy::EWritePolicy); sl@0: TEST(policy == KDefaultPolicy); sl@0: // sl@0: securityPolicy.Close(); sl@0: sl@0: //Tests with initialized RSqlSecurityPolicy object sl@0: CreateTestSecurityPolicy(securityPolicy); sl@0: //Check the created and initialized object sl@0: CheckTestSecurityPolicy(securityPolicy); sl@0: sl@0: //Externalize, then internalize and check the security policy object sl@0: RFileWriteStream out; sl@0: err = out.Replace(TheFs, KTestFile, EFileRead | EFileWrite); sl@0: TEST2(err, KErrNone); sl@0: TRAP(err, securityPolicy.ExternalizeL(out)); sl@0: TEST2(err, KErrNone); sl@0: TRAP(err, out.CommitL()); sl@0: out.Close(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: securityPolicy.Close(); sl@0: err = securityPolicy.Create(KDefaultPolicy); sl@0: TEST2(err, KErrNone); sl@0: RFileReadStream in; sl@0: err = in.Open(TheFs, KTestFile, EFileRead); sl@0: TEST2(err, KErrNone); sl@0: TRAP(err, securityPolicy.InternalizeL(in)); sl@0: in.Close(); sl@0: TEST2(err, KErrNone); sl@0: CheckTestSecurityPolicy(securityPolicy); sl@0: sl@0: //Change some security policies and check that the RqlSecurityPolicy content was properly updated sl@0: err = securityPolicy.SetPolicy(RSqlSecurityPolicy::ETable, KTableName11, RSqlSecurityPolicy::EReadPolicy, KPolicy3); sl@0: TEST2(err, KErrNone); sl@0: policy = securityPolicy.Policy(RSqlSecurityPolicy::ETable, KTableName1, RSqlSecurityPolicy::EReadPolicy); sl@0: TEST(policy == KPolicy3); sl@0: policy = securityPolicy.Policy(RSqlSecurityPolicy::ETable, KTableName11, RSqlSecurityPolicy::EWritePolicy); sl@0: TEST(policy == KPolicy2); sl@0: // sl@0: securityPolicy.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-SQL-CT-1637 sl@0: @SYMTestCaseDesc RSqlDatabase::Create() test. sl@0: Tests RSqlDatabase::Create() call when the request is for creation of a secure database. sl@0: @SYMTestPriority High sl@0: @SYMTestActions RSqlDatabase::Create() test. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ5792 sl@0: REQ5793 sl@0: */ sl@0: void CreateSecureDatabaseTest() sl@0: { sl@0: RSqlSecurityPolicy securityPolicy; sl@0: sl@0: //Create and initialize RSqlSecurityPolicy object. sl@0: CreateTestSecurityPolicy(securityPolicy); sl@0: sl@0: //Create secure database using the data from securityPolicy object. sl@0: RSqlDatabase db; sl@0: TInt err = db.Create(KTestDbName, securityPolicy); sl@0: TEST2(err, KErrNone); sl@0: securityPolicy.Close(); sl@0: sl@0: //Check that the database security policy matches the policy used when the database was created. sl@0: err = db.GetSecurityPolicy(securityPolicy); sl@0: TEST2(err, KErrNone); sl@0: CheckTestSecurityPolicy(securityPolicy); sl@0: securityPolicy.Close(); sl@0: sl@0: db.Close(); sl@0: sl@0: //Reopen the database and check the security policies sl@0: err = db.Open(KTestDbName); sl@0: TEST2(err, KErrNone); sl@0: sl@0: //Check that the database security policy matches the policy used when the database was created. sl@0: err = db.GetSecurityPolicy(securityPolicy); sl@0: TEST2(err, KErrNone); sl@0: CheckTestSecurityPolicy(securityPolicy); sl@0: securityPolicy.Close(); sl@0: sl@0: db.Close(); sl@0: sl@0: err = RSqlDatabase::Delete(KTestDbName); sl@0: TEST2(err, KErrNone); sl@0: sl@0: //An attempt to create a secure database specifying the full database path sl@0: CreateTestSecurityPolicy(securityPolicy); sl@0: err = db.Create(KTestDbName2, securityPolicy); sl@0: securityPolicy.Close(); sl@0: TEST2(err, KErrArgument); sl@0: sl@0: //An attempt to create a non-secure database formatting the database file name as sl@0: err = db.Create(KTestDbName); sl@0: TEST2(err, KErrArgument); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-SQL-CT-1643 sl@0: @SYMTestCaseDesc SQL server private path in database file name test. sl@0: Verify that SQL API returns appropriate error, if an attempt is made to create, open sl@0: or delete a secure database, with the full path specified in the database file name. sl@0: @SYMTestPriority High sl@0: @SYMTestActions SQL server private path in database file name test. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ5792 sl@0: REQ5793 sl@0: */ sl@0: void PrivatePathTest() sl@0: { sl@0: RSqlSecurityPolicy securityPolicy; sl@0: CreateTestSecurityPolicy(securityPolicy); sl@0: sl@0: RSqlDatabase db; sl@0: sl@0: TInt err = db.Create(_L("C:\\PrIVATE\\10281E17\\[98765432]A.DB"), securityPolicy); sl@0: TEST2(err, KErrArgument); sl@0: err = db.Create(_L("C:\\PRIVATE\\10281E17\\[98765432]A.DB")); sl@0: TEST2(err, KErrArgument); sl@0: err = db.Open(_L("C:\\PRIVATE\\10281E17\\[98765432]A.DB")); sl@0: TEST2(err, KErrArgument); sl@0: err = db.Open(_L("C:\\PRIvaTe\\10281E17\\[98765432]A.DB")); sl@0: TEST2(err, KErrArgument); sl@0: sl@0: err = db.Create(KTestDbName2); sl@0: TEST2(err, KErrNone); sl@0: err = db.Attach(_L("C:\\PRIVATe\\10281E17\\[98765432]A.DB"), _L("Db")); sl@0: TEST2(err, KErrArgument); sl@0: err = db.Attach(_L("C:\\PRIVAtE\\10281E17\\[98765432]A.DB"), _L("Db")); sl@0: TEST2(err, KErrArgument); sl@0: //This is an attempt to attach a database from the application's private data cage sl@0: err = db.Attach(KTestDbName4, _L("Db")); sl@0: TEST2(err, KErrNotFound);//There is no "Db" database file in the application's private data cage sl@0: db.Close(); sl@0: sl@0: err = RSqlDatabase::Delete(_L("C:\\pRIVATE\\10281E17\\[98765432]A.DB")); sl@0: TEST2(err, KErrArgument); sl@0: err = RSqlDatabase::Delete(_L("C:\\PRIvATE\\10281E17\\[98765432]A.DB")); sl@0: TEST2(err, KErrArgument); sl@0: sl@0: //This is an attempt to create a database in the application's private data cage sl@0: err = db.Create(KTestDbName4); sl@0: TEST2(err, KErrNone); sl@0: db.Close(); sl@0: err = RSqlDatabase::Delete(KTestDbName4); sl@0: TEST2(err, KErrNone); sl@0: sl@0: err = db.Create(KTestDbName5); sl@0: TEST2(err, KErrArgument); sl@0: sl@0: securityPolicy.Close(); sl@0: } sl@0: sl@0: //This test is here to check that the construction of the second database object on the server side passes sl@0: //without problems, if there is already one other secure database object (authorizer callback possible problems sl@0: //during the construction phase) sl@0: //Shortly: the test checks how the construction of the secure database object 2 might be influenced by sl@0: // the already existing secure database object 1. sl@0: void TwoSecureDbTest() sl@0: { sl@0: RSqlSecurityPolicy securityPolicy; sl@0: CreateTestSecurityPolicy(securityPolicy); sl@0: sl@0: RSqlDatabase db1; sl@0: TInt err = db1.Create(KTestDbName, securityPolicy); sl@0: TEST2(err, KErrNone); sl@0: sl@0: RSqlDatabase db2; sl@0: err = db2.Create(KTestDbName3, securityPolicy); sl@0: TEST2(err, KErrNone); sl@0: sl@0: securityPolicy.Close(); sl@0: db2.Close(); sl@0: db1.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-SQL-UT-3508 sl@0: @SYMTestCaseDesc Test for DEF109100: SQL, code coverage for TSqlDbSysSettings is low. sl@0: The test attempts to create a secure shared database with a security policy sl@0: specified for the system tables, which is not allowed. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Test for DEF109100: SQL, code coverage for TSqlDbSysSettings is low. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMDEF DEF109100 sl@0: */ sl@0: void StoreSysTableSecurityPolicyTest() sl@0: { sl@0: _LIT(KSecurityTable, "symbian_security"); sl@0: _LIT(KSettingsTable, "symbian_settings"); sl@0: sl@0: //Case 1: "symbian_security" table sl@0: RSqlSecurityPolicy sp; sl@0: TInt err = sp.Create(KDefaultPolicy); sl@0: TEST2(err, KErrNone); sl@0: err = sp.SetDbPolicy(RSqlSecurityPolicy::ESchemaPolicy, KPolicy1); sl@0: TEST2(err, KErrNone); sl@0: err = sp.SetPolicy(RSqlSecurityPolicy::ETable, KSecurityTable, RSqlSecurityPolicy::EReadPolicy, KPolicy1); sl@0: TEST2(err, KErrNone); sl@0: (void)RSqlDatabase::Delete(KTestDbName); sl@0: RSqlDatabase db; sl@0: err = db.Create(KTestDbName, sp); sl@0: TEST2(err, KErrArgument); sl@0: sp.Close(); sl@0: sl@0: //Case 2: "symbian_settings" table sl@0: err = sp.Create(KDefaultPolicy); sl@0: TEST2(err, KErrNone); sl@0: err = sp.SetDbPolicy(RSqlSecurityPolicy::ESchemaPolicy, KPolicy1); sl@0: TEST2(err, KErrNone); sl@0: err = sp.SetPolicy(RSqlSecurityPolicy::ETable, KSettingsTable, RSqlSecurityPolicy::EReadPolicy, KPolicy1); sl@0: TEST2(err, KErrNone); sl@0: err = RSqlDatabase::Delete(KTestDbName); sl@0: TEST2(err, KErrNotFound); sl@0: err = db.Create(KTestDbName, sp); sl@0: TEST2(err, KErrArgument); sl@0: sp.Close(); sl@0: sl@0: err = RSqlDatabase::Delete(KTestDbName); sl@0: TEST2(err, KErrNotFound); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-SQL-UT-3509 sl@0: @SYMTestCaseDesc Test for DEF109100: SQL, code coverage for TSqlDbSysSettings is low. sl@0: The test has 5 sub-cases, where the test attempts to open sl@0: a secure shared database with: sl@0: - no settings table; sl@0: - empty settings table; sl@0: - invalid version number of the settings; sl@0: - NULL collation dll name, stored in the settings; sl@0: - too long collation dll name, stored in the settings; sl@0: @SYMTestPriority High sl@0: @SYMTestActions Test for DEF109100: SQL, code coverage for TSqlDbSysSettings is low. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMDEF DEF109100 sl@0: */ sl@0: void LoadSysSettingsTest() sl@0: { sl@0: //Case 1: no "symbian_settings" table. No error returned, because the table is recreated. sl@0: RSqlDatabase db; sl@0: TInt err = db.Open(KDb1); sl@0: TEST2(err, KErrNone); sl@0: db.Close(); sl@0: sl@0: //Case 2: "symbian_settings" table is empty. sl@0: err = db.Open(KDb2); sl@0: TEST2(err, KErrGeneral); sl@0: db.Close(); sl@0: sl@0: //Case 3: Invalid version number in "symbian_settings" table. sl@0: err = db.Open(KDb3); sl@0: TEST2(err, KErrGeneral); sl@0: db.Close(); sl@0: sl@0: //Case 4: NULL collation dll name in "symbian_settings" table. sl@0: err = db.Open(KDb4); sl@0: TEST2(err, KErrGeneral); sl@0: db.Close(); sl@0: sl@0: //Case 5: Too long collation dll name in "symbian_settings" table. sl@0: err = db.Open(KDb5); sl@0: TEST2(err, KErrOverflow); sl@0: db.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-SQL-UT-3510 sl@0: @SYMTestCaseDesc Test for DEF109100: SQL, code coverage for TSqlDbSysSettings is low. sl@0: The test has 3 sub-cases, where the test attempts to open sl@0: a secure shared database with: sl@0: - missing default policy in the security policy table; sl@0: - invalid database object type in the security policy table; sl@0: - 2 default policies in the security policy table; sl@0: @SYMTestPriority High sl@0: @SYMTestActions Test for DEF109100: SQL, code coverage for TSqlDbSysSettings is low. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMDEF DEF109100 sl@0: */ sl@0: void LoadSecurityPolicyTest() sl@0: { sl@0: //Case 1: missing default policy. sl@0: RSqlDatabase db; sl@0: TInt err = db.Open(KDb6); sl@0: TEST2(err, KErrGeneral); sl@0: db.Close(); sl@0: sl@0: //Case 2: invalid database object type. sl@0: err = db.Open(KDb7); sl@0: TEST2(err, KErrGeneral); sl@0: db.Close(); sl@0: sl@0: //Case 3: 2 default policies. sl@0: err = db.Open(KDb8); sl@0: TEST2(err, KErrGeneral); sl@0: db.Close(); sl@0: } sl@0: sl@0: void DoTests() sl@0: { sl@0: TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1635 RSqlSecurityPolicy test ")); sl@0: SqlSecurityPolicyTest(); sl@0: sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1637 Create secure database test ")); sl@0: CreateSecureDatabaseTest(); sl@0: sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1643 Sql server private path in the file name test ")); sl@0: PrivatePathTest(); sl@0: sl@0: TheTest.Next(_L("Two secure databases at the same time test")); sl@0: TwoSecureDbTest(); sl@0: sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-3508 DEF109100 - 1 - SQL, code coverage for TSqlBufRIterator,TSqlAttachDbRefCounter,TSqlDbSysSettings is low ")); sl@0: StoreSysTableSecurityPolicyTest(); sl@0: sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-3509 DEF109100 - 2 - SQL, code coverage for TSqlBufRIterator,TSqlAttachDbRefCounter,TSqlDbSysSettings is low ")); sl@0: LoadSysSettingsTest(); sl@0: sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-3510 DEF109100 - 3 - SQL, code coverage for TSqlBufRIterator,TSqlAttachDbRefCounter,TSqlDbSysSettings is low ")); sl@0: LoadSecurityPolicyTest(); sl@0: } sl@0: sl@0: TInt E32Main() sl@0: { sl@0: TheTest.Title(); sl@0: sl@0: CTrapCleanup* tc = CTrapCleanup::New(); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: CreateTestEnv(); sl@0: DeleteTestFiles(); 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: }