|
1 // Copyright (c) 2008-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 /** |
|
17 @file updateentrystep.h |
|
18 @internalTechnology |
|
19 */ |
|
20 |
|
21 #include "updateentrystep.h" |
|
22 |
|
23 #include <x509cert.h> |
|
24 |
|
25 const TInt KDefaultResponseDelay = 3; |
|
26 |
|
27 CUpdateEntryStep::CUpdateEntryStep() |
|
28 : iResponseDelay(KDefaultResponseDelay) |
|
29 { |
|
30 SetTestStepName(KUpdateEntryStep); |
|
31 } |
|
32 |
|
33 TVerdict CUpdateEntryStep::doTestStepPreambleL() |
|
34 { |
|
35 // Initialise the tests |
|
36 InitializeL(); |
|
37 |
|
38 // Parse the parameters required |
|
39 _LIT(KCertEntryApproved, "approved"); |
|
40 _LIT(KResponseDelay, "delay"); |
|
41 _LIT(KCancel, "cancelled"); |
|
42 |
|
43 // Ignore return code from GetBoolFromConfig to keep default of EFalse. |
|
44 GetBoolFromConfig(ConfigSection(), KCancel, iCancel); |
|
45 |
|
46 // Ignore return status from GetIntFromConfig to keep default value. |
|
47 GetIntFromConfig(ConfigSection(), KResponseDelay, iResponseDelay); |
|
48 |
|
49 if (iCancel) |
|
50 { |
|
51 INFO_PRINTF3(_L("Certificate entry will be %S with a delay of %d seconds."), &KResponseDelay, iResponseDelay); |
|
52 } |
|
53 else if (!GetBoolFromConfig(ConfigSection(), KCertEntryApproved, iApproveEntry)) |
|
54 { |
|
55 INFO_PRINTF1(_L("Could not read certificate approval status from INI, abort.")); |
|
56 |
|
57 SetTestStepResult(EAbort); |
|
58 return EAbort; |
|
59 } |
|
60 else if (iApproveEntry) |
|
61 { |
|
62 INFO_PRINTF3(_L("Certificate entry will be %S with a delay of %d seconds."), &KResponseDelay, iResponseDelay); |
|
63 } |
|
64 else |
|
65 { |
|
66 INFO_PRINTF3(_L("Certificate entry will be %S with a delay of %d seconds."), &KResponseDelay, iResponseDelay); |
|
67 } |
|
68 |
|
69 |
|
70 return EPass; |
|
71 |
|
72 } |
|
73 |
|
74 TVerdict CUpdateEntryStep::doTestStepL() |
|
75 { |
|
76 |
|
77 // don't continue if previous phases have aborted |
|
78 if (TestStepResult() != EPass) |
|
79 { |
|
80 return TestStepResult(); |
|
81 } |
|
82 |
|
83 // Entry state should be ENewEntry at this point. |
|
84 TCacheEntryState state = Session().GetStateL(); |
|
85 |
|
86 if (state != ENewEntry) |
|
87 { |
|
88 INFO_PRINTF4(_L("State of cache entry for certificate '%S' is %d, but should be %d (ENewEntry)."), SubjectLC(), state, ENewEntry); |
|
89 CleanupStack::PopAndDestroy(1); // subject |
|
90 SetTestStepResult(EFail); |
|
91 return EFail; |
|
92 } |
|
93 else |
|
94 { |
|
95 INFO_PRINTF2(_L("State of cache entry for certificate '%S' is ENewEntry."), SubjectLC()); |
|
96 CleanupStack::PopAndDestroy(1); // subject |
|
97 } |
|
98 |
|
99 // Wait specifed number of seconds |
|
100 User::After(iResponseDelay * 1000000); |
|
101 |
|
102 if (iCancel) |
|
103 { |
|
104 Session().Cancel(); |
|
105 // log the action |
|
106 INFO_PRINTF2(_L("Cancelled cert cache session opened for certificate '%S'."), SubjectLC()); |
|
107 CleanupStack::PopAndDestroy(1); // subject |
|
108 } |
|
109 else |
|
110 { |
|
111 Session().SetStateL(iApproveEntry ? EEntryApproved : EEntryDenied); |
|
112 // log the action |
|
113 INFO_PRINTF2(_L("Updated cache entry for certificate '%S'."), SubjectLC()); |
|
114 CleanupStack::PopAndDestroy(1); // subject |
|
115 } |
|
116 |
|
117 |
|
118 SetTestStepResult(EPass); |
|
119 return EPass; |
|
120 } |
|
121 |
|
122 TVerdict CUpdateEntryStep::doTestStepPostambleL() |
|
123 { |
|
124 if (TestStepResult() == EPass) |
|
125 { |
|
126 INFO_PRINTF1(_L("Step suceeded.")); |
|
127 return EPass; |
|
128 } |
|
129 else |
|
130 { |
|
131 INFO_PRINTF1(_L("Step failed.")); |
|
132 return EFail; |
|
133 } |
|
134 } |