1 // Copyright (c) 2003-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 // EPOC includes |
|
17 #include <e32base.h> |
|
18 #include <commdb.h> |
|
19 #include <d32comm.h> |
|
20 #include <cdbstore.h> |
|
21 |
|
22 // Test system includes |
|
23 #include <networking/log.h> |
|
24 #include <networking/teststep.h> |
|
25 #include "Teststepcommdb.h" |
|
26 #include "TestSuiteCommdb.h" |
|
27 |
|
28 #ifdef SYMBIAN_OLD_EXPORT_LOCATION |
|
29 #include <comms-infras/commdb/protection/protectdb.h> |
|
30 #include <comms-infras/commdb/protection/protectcpdb.h> |
|
31 #else |
|
32 //these headers are user includes in the new env. |
|
33 #include "protectdb.h" |
|
34 #include "protectcpdb.h" |
|
35 #endif |
|
36 |
|
37 #include <cdbpreftable.h> |
|
38 |
|
39 #include "step_056_xx.h" |
|
40 |
|
41 // |
|
42 // Test step 056.01 |
|
43 // |
|
44 |
|
45 //TestProtectRecords |
|
46 CCommDbTest056_01::CCommDbTest056_01() |
|
47 { |
|
48 // store the name of this test case |
|
49 iTestStepName = _L("step_056_01"); |
|
50 } |
|
51 |
|
52 CCommDbTest056_01::~CCommDbTest056_01() |
|
53 { |
|
54 delete iTheDb; |
|
55 } |
|
56 |
|
57 TVerdict CCommDbTest056_01::doTestStepPreambleL() |
|
58 { |
|
59 iTheDb = CCommsDatabase::NewL(EDatabaseTypeIAP); |
|
60 return EPass; |
|
61 } |
|
62 |
|
63 enum TVerdict CCommDbTest056_01::doTestStepL( void ) |
|
64 { |
|
65 |
|
66 Log(_L("Test Normal Records : Protection ..")); |
|
67 iTestStepResult = EPass; |
|
68 |
|
69 CCommsDbProtectTableView* table = (CCommsDbProtectTableView *)iTheDb->OpenTableLC(TPtrC(DIAL_OUT_ISP)); |
|
70 TESTL(iTheDb->BeginTransaction()==KErrNone); |
|
71 |
|
72 TESTL(table->GotoFirstRecord()==KErrNone); |
|
73 |
|
74 // Check record security level is writable |
|
75 TInt recordAccess = 1; |
|
76 TESTL(table->GetRecordAccess(recordAccess) == KErrNone); |
|
77 TESTL(recordAccess == 0); |
|
78 |
|
79 // Modify and test the first record |
|
80 TRAPD(ret,UpdateRecordL(table,KErrNone)); |
|
81 TESTL(ret == KErrNone); |
|
82 |
|
83 TRAP(ret,ProtectRecordL(table,KErrNone)); |
|
84 TESTL(ret == KErrNone); |
|
85 |
|
86 // Test that protection is effective |
|
87 TRAP(ret,UpdateRecordL(table,KErrAccessDenied)); |
|
88 TESTL(ret == KErrNone); |
|
89 TRAP(ret,DeleteRecordL(table,KErrAccessDenied)); |
|
90 TESTL(ret == KErrNone); |
|
91 |
|
92 // Check record security level is read only |
|
93 TESTL(table->GetRecordAccess(recordAccess) == KErrNone); |
|
94 TESTL(recordAccess == 1); |
|
95 |
|
96 table->GotoFirstRecord(); |
|
97 |
|
98 TESTL(iTheDb->CommitTransaction()==KErrNone); |
|
99 |
|
100 |
|
101 iTestStepResult = EPass; |
|
102 Log(_L("\t\tSUCCESS")); |
|
103 |
|
104 CleanupStack::PopAndDestroy(); |
|
105 return iTestStepResult; |
|
106 } |
|
107 |
|
108 |
|
109 // |
|
110 // Test step 056.02 |
|
111 // |
|
112 |
|
113 //TestUnprotectRecords |
|
114 CCommDbTest056_02::CCommDbTest056_02() |
|
115 { |
|
116 // store the name of this test case |
|
117 iTestStepName = _L("step_056_02"); |
|
118 } |
|
119 |
|
120 CCommDbTest056_02::~CCommDbTest056_02() |
|
121 { |
|
122 delete iTheDb; |
|
123 } |
|
124 |
|
125 TVerdict CCommDbTest056_02::doTestStepPreambleL() |
|
126 { |
|
127 iTheDb = CCommsDatabase::NewL(EDatabaseTypeIAP); |
|
128 return EPass; |
|
129 } |
|
130 |
|
131 enum TVerdict CCommDbTest056_02::doTestStepL( void ) |
|
132 { |
|
133 |
|
134 Log(_L("Test Normal Records : unprotection ..")); |
|
135 iTestStepResult = EPass; |
|
136 |
|
137 CCommsDbProtectTableView* table = (CCommsDbProtectTableView *)iTheDb->OpenTableLC(TPtrC(DIAL_OUT_ISP)); |
|
138 TESTL(iTheDb->BeginTransaction()==KErrNone); |
|
139 |
|
140 if(table->GotoFirstRecord()==KErrNone) |
|
141 { |
|
142 // Check record state is read only |
|
143 TInt recordAccess = 0; |
|
144 TESTL(table->GetRecordAccess(recordAccess) == KErrNone); |
|
145 TESTL(recordAccess == 1); |
|
146 |
|
147 // Check record cannot be updated |
|
148 TRAPD(ret, UpdateRecordL(table,KErrAccessDenied)); |
|
149 TESTL(ret == KErrNone); |
|
150 |
|
151 // Unprotect record |
|
152 table->GotoFirstRecord(); |
|
153 TRAP(ret,UnprotectRecordL(table,KErrNone)); |
|
154 TESTL(ret == KErrNone); |
|
155 |
|
156 // Check record state is now writable |
|
157 TESTL(table->GetRecordAccess(recordAccess) == KErrNone); |
|
158 TESTL(recordAccess == 0); |
|
159 |
|
160 // Test record can now be updated |
|
161 TRAP(ret,UpdateRecordL(table,KErrNone)); |
|
162 TESTL(ret == KErrNone); |
|
163 } |
|
164 |
|
165 TESTL(iTheDb->CommitTransaction()==KErrNone); |
|
166 |
|
167 // Do separate transaction to check deletion is |
|
168 // allowed as want to be able to roll this back |
|
169 TESTL(iTheDb->BeginTransaction()==KErrNone); |
|
170 |
|
171 if(table->GotoFirstRecord()==KErrNone) |
|
172 { |
|
173 // Check can delete record |
|
174 TRAPD(ret,DeleteRecordL(table,KErrNone)); |
|
175 TESTL(ret == KErrNone); |
|
176 } |
|
177 |
|
178 //don't commit as don't want to risk making db empty. |
|
179 iTheDb->RollbackTransaction(); |
|
180 |
|
181 |
|
182 iTestStepResult = EPass; |
|
183 Log(_L("\t\tSUCCESS")); |
|
184 |
|
185 CleanupStack::PopAndDestroy(); |
|
186 return iTestStepResult; |
|
187 } |
|
188 |
|