os/ossrv/lowlevellibsandfws/apputils/tsrc/T_BackupSrvCap.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 1997-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 <e32debug.h>
    17 #include <e32test.h>
    18 #include <e32std.h>
    19 #include <babackup.h>
    20 
    21 LOCAL_D RTest				TheTest (_L("T_BACKUPSRVCAP"));
    22 
    23 /**
    24 @SYMTestCaseID          SYSLIB-BAFL-UT-4049
    25 @SYMTestCaseDesc        BAFL Backup System Potential Security Vulnerability
    26 @SYMTestPriority        High
    27 @SYMTestActions         Call CloseAll, CloseFileL, RestartAll, RestartFile and NotifyBackupOperationL without correct capablity.
    28 @SYMTestExpectedResults Capablity error is expected. Test must not fail*/
    29 void Defect_DEF103793L()
    30 	{
    31 	TInt err;
    32 
    33 	CBaBackupSessionWrapper* backupSession  = CBaBackupSessionWrapper::NewL();
    34 
    35 	TBackupOperationAttributes attribs;
    36 	attribs.iFileFlag=MBackupObserver::EReleaseLockNoAccess;
    37 	attribs.iOperation=MBackupOperationObserver::EStart;
    38 
    39 	TRAP(err, backupSession->NotifyBackupOperationL(attribs));
    40 	TheTest(err == KErrNone);
    41 
    42 	attribs.iOperation=MBackupOperationObserver::EEnd;
    43 
    44 	TRAP(err, backupSession->NotifyBackupOperationL(attribs));
    45 	TheTest(err == KErrNone);
    46 
    47 	TRequestStatus status;
    48 	backupSession->CloseAll(MBackupObserver::EReleaseLockNoAccess, status);
    49 	User::WaitForRequest (status);
    50 	TheTest(status == KErrPermissionDenied);
    51 
    52 	_LIT(KFileName1, "FileName1");
    53 	TFileName file;
    54 	file.Copy(KFileName1);
    55 
    56 	backupSession->RestartFile(file);
    57 
    58 	backupSession->RestartAll();
    59 
    60 	TRAP(err, backupSession->CloseFileL(file, MBackupObserver::EReleaseLockNoAccess));
    61 	TheTest(err == KErrPermissionDenied);
    62 
    63 	delete backupSession;
    64 	}
    65 
    66 /**
    67 Invoke the tests
    68 */
    69 LOCAL_C void DoTestsL()
    70     {
    71 	Defect_DEF103793L();
    72 	}
    73 
    74 TInt E32Main()
    75 	{
    76 	__UHEAP_MARK;
    77 
    78 	CTrapCleanup* theTrapCleanup=CTrapCleanup::New();
    79 
    80 	TheTest.Printf(_L("\n"));
    81 	TheTest.Title();
    82 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-BAFL-UT-4049 Backupsrc capablity Tests "));
    83 
    84 	TRAPD(err, DoTestsL());
    85 	TheTest(err == KErrNone);
    86 
    87 	TheTest.End();
    88 	TheTest.Close();
    89 
    90 	delete theTrapCleanup;
    91 
    92 	__UHEAP_MARKEND;
    93 	return (KErrNone);
    94 	}