sl@0: // Copyright (c) 1997-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: LOCAL_D RTest TheTest (_L("T_BACKUPSRVCAP")); sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-UT-4049 sl@0: @SYMTestCaseDesc BAFL Backup System Potential Security Vulnerability sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call CloseAll, CloseFileL, RestartAll, RestartFile and NotifyBackupOperationL without correct capablity. sl@0: @SYMTestExpectedResults Capablity error is expected. Test must not fail*/ sl@0: void Defect_DEF103793L() sl@0: { sl@0: TInt err; sl@0: sl@0: CBaBackupSessionWrapper* backupSession = CBaBackupSessionWrapper::NewL(); sl@0: sl@0: TBackupOperationAttributes attribs; sl@0: attribs.iFileFlag=MBackupObserver::EReleaseLockNoAccess; sl@0: attribs.iOperation=MBackupOperationObserver::EStart; sl@0: sl@0: TRAP(err, backupSession->NotifyBackupOperationL(attribs)); sl@0: TheTest(err == KErrNone); sl@0: sl@0: attribs.iOperation=MBackupOperationObserver::EEnd; sl@0: sl@0: TRAP(err, backupSession->NotifyBackupOperationL(attribs)); sl@0: TheTest(err == KErrNone); sl@0: sl@0: TRequestStatus status; sl@0: backupSession->CloseAll(MBackupObserver::EReleaseLockNoAccess, status); sl@0: User::WaitForRequest (status); sl@0: TheTest(status == KErrPermissionDenied); sl@0: sl@0: _LIT(KFileName1, "FileName1"); sl@0: TFileName file; sl@0: file.Copy(KFileName1); sl@0: sl@0: backupSession->RestartFile(file); sl@0: sl@0: backupSession->RestartAll(); sl@0: sl@0: TRAP(err, backupSession->CloseFileL(file, MBackupObserver::EReleaseLockNoAccess)); sl@0: TheTest(err == KErrPermissionDenied); sl@0: sl@0: delete backupSession; sl@0: } sl@0: sl@0: /** sl@0: Invoke the tests sl@0: */ sl@0: LOCAL_C void DoTestsL() sl@0: { sl@0: Defect_DEF103793L(); sl@0: } sl@0: sl@0: TInt E32Main() sl@0: { sl@0: __UHEAP_MARK; sl@0: sl@0: CTrapCleanup* theTrapCleanup=CTrapCleanup::New(); sl@0: sl@0: TheTest.Printf(_L("\n")); sl@0: TheTest.Title(); sl@0: TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-BAFL-UT-4049 Backupsrc capablity Tests ")); sl@0: sl@0: TRAPD(err, DoTestsL()); sl@0: TheTest(err == KErrNone); sl@0: sl@0: TheTest.End(); sl@0: TheTest.Close(); sl@0: sl@0: delete theTrapCleanup; sl@0: sl@0: __UHEAP_MARKEND; sl@0: return (KErrNone); sl@0: }