sl@0
|
1 |
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <e32debug.h>
|
sl@0
|
17 |
#include <e32test.h>
|
sl@0
|
18 |
#include <e32std.h>
|
sl@0
|
19 |
#include <babackup.h>
|
sl@0
|
20 |
|
sl@0
|
21 |
LOCAL_D RTest TheTest (_L("T_BACKUPSRVCAP"));
|
sl@0
|
22 |
|
sl@0
|
23 |
/**
|
sl@0
|
24 |
@SYMTestCaseID SYSLIB-BAFL-UT-4049
|
sl@0
|
25 |
@SYMTestCaseDesc BAFL Backup System Potential Security Vulnerability
|
sl@0
|
26 |
@SYMTestPriority High
|
sl@0
|
27 |
@SYMTestActions Call CloseAll, CloseFileL, RestartAll, RestartFile and NotifyBackupOperationL without correct capablity.
|
sl@0
|
28 |
@SYMTestExpectedResults Capablity error is expected. Test must not fail*/
|
sl@0
|
29 |
void Defect_DEF103793L()
|
sl@0
|
30 |
{
|
sl@0
|
31 |
TInt err;
|
sl@0
|
32 |
|
sl@0
|
33 |
CBaBackupSessionWrapper* backupSession = CBaBackupSessionWrapper::NewL();
|
sl@0
|
34 |
|
sl@0
|
35 |
TBackupOperationAttributes attribs;
|
sl@0
|
36 |
attribs.iFileFlag=MBackupObserver::EReleaseLockNoAccess;
|
sl@0
|
37 |
attribs.iOperation=MBackupOperationObserver::EStart;
|
sl@0
|
38 |
|
sl@0
|
39 |
TRAP(err, backupSession->NotifyBackupOperationL(attribs));
|
sl@0
|
40 |
TheTest(err == KErrNone);
|
sl@0
|
41 |
|
sl@0
|
42 |
attribs.iOperation=MBackupOperationObserver::EEnd;
|
sl@0
|
43 |
|
sl@0
|
44 |
TRAP(err, backupSession->NotifyBackupOperationL(attribs));
|
sl@0
|
45 |
TheTest(err == KErrNone);
|
sl@0
|
46 |
|
sl@0
|
47 |
TRequestStatus status;
|
sl@0
|
48 |
backupSession->CloseAll(MBackupObserver::EReleaseLockNoAccess, status);
|
sl@0
|
49 |
User::WaitForRequest (status);
|
sl@0
|
50 |
TheTest(status == KErrPermissionDenied);
|
sl@0
|
51 |
|
sl@0
|
52 |
_LIT(KFileName1, "FileName1");
|
sl@0
|
53 |
TFileName file;
|
sl@0
|
54 |
file.Copy(KFileName1);
|
sl@0
|
55 |
|
sl@0
|
56 |
backupSession->RestartFile(file);
|
sl@0
|
57 |
|
sl@0
|
58 |
backupSession->RestartAll();
|
sl@0
|
59 |
|
sl@0
|
60 |
TRAP(err, backupSession->CloseFileL(file, MBackupObserver::EReleaseLockNoAccess));
|
sl@0
|
61 |
TheTest(err == KErrPermissionDenied);
|
sl@0
|
62 |
|
sl@0
|
63 |
delete backupSession;
|
sl@0
|
64 |
}
|
sl@0
|
65 |
|
sl@0
|
66 |
/**
|
sl@0
|
67 |
Invoke the tests
|
sl@0
|
68 |
*/
|
sl@0
|
69 |
LOCAL_C void DoTestsL()
|
sl@0
|
70 |
{
|
sl@0
|
71 |
Defect_DEF103793L();
|
sl@0
|
72 |
}
|
sl@0
|
73 |
|
sl@0
|
74 |
TInt E32Main()
|
sl@0
|
75 |
{
|
sl@0
|
76 |
__UHEAP_MARK;
|
sl@0
|
77 |
|
sl@0
|
78 |
CTrapCleanup* theTrapCleanup=CTrapCleanup::New();
|
sl@0
|
79 |
|
sl@0
|
80 |
TheTest.Printf(_L("\n"));
|
sl@0
|
81 |
TheTest.Title();
|
sl@0
|
82 |
TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-BAFL-UT-4049 Backupsrc capablity Tests "));
|
sl@0
|
83 |
|
sl@0
|
84 |
TRAPD(err, DoTestsL());
|
sl@0
|
85 |
TheTest(err == KErrNone);
|
sl@0
|
86 |
|
sl@0
|
87 |
TheTest.End();
|
sl@0
|
88 |
TheTest.Close();
|
sl@0
|
89 |
|
sl@0
|
90 |
delete theTrapCleanup;
|
sl@0
|
91 |
|
sl@0
|
92 |
__UHEAP_MARKEND;
|
sl@0
|
93 |
return (KErrNone);
|
sl@0
|
94 |
}
|