1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_DBUS_MOCK_CRYPTOHOME_CLIENT_H_
6 #define CHROMEOS_DBUS_MOCK_CRYPTOHOME_CLIENT_H_
10 #include "chromeos/dbus/cryptohome/rpc.pb.h"
11 #include "chromeos/dbus/cryptohome_client.h"
12 #include "testing/gmock/include/gmock/gmock.h"
16 class MockCryptohomeClient
: public CryptohomeClient
{
18 MockCryptohomeClient();
19 virtual ~MockCryptohomeClient();
21 MOCK_METHOD1(Init
, void(dbus::Bus
* bus
));
22 MOCK_METHOD2(SetAsyncCallStatusHandlers
,
23 void(const AsyncCallStatusHandler
& handler
,
24 const AsyncCallStatusWithDataHandler
& data_handler
));
25 MOCK_METHOD0(ResetAsyncCallStatusHandlers
, void());
26 MOCK_METHOD1(WaitForServiceToBeAvailable
,
27 void(const WaitForServiceToBeAvailableCallback
& callback
));
28 MOCK_METHOD1(IsMounted
, void(const BoolDBusMethodCallback
& callback
));
29 MOCK_METHOD1(Unmount
, bool(bool* success
));
30 MOCK_METHOD3(AsyncCheckKey
,
31 void(const std::string
& username
,
32 const std::string
& key
,
33 const AsyncMethodCallback
& callback
));
34 MOCK_METHOD4(AsyncMigrateKey
,
35 void(const std::string
& username
,
36 const std::string
& from_key
,
37 const std::string
& to_key
,
38 const AsyncMethodCallback
& callback
));
39 MOCK_METHOD2(AsyncRemove
, void(const std::string
& username
,
40 const AsyncMethodCallback
& callback
));
41 MOCK_METHOD1(GetSystemSalt
, void(const GetSystemSaltCallback
& callback
));
42 MOCK_METHOD2(GetSanitizedUsername
,
43 void(const std::string
& username
,
44 const StringDBusMethodCallback
& callback
));
45 MOCK_METHOD1(BlockingGetSanitizedUsername
,
46 std::string(const std::string
& username
));
47 MOCK_METHOD4(AsyncMount
, void(const std::string
& username
,
48 const std::string
& key
,
50 const AsyncMethodCallback
& callback
));
51 MOCK_METHOD4(AsyncAddKey
, void(const std::string
& username
,
52 const std::string
& key
,
53 const std::string
& new_key
,
54 const AsyncMethodCallback
& callback
));
55 MOCK_METHOD1(AsyncMountGuest
,
56 void(const AsyncMethodCallback
& callback
));
57 MOCK_METHOD3(AsyncMountPublic
, void(const std::string
& public_mount_id
,
59 const AsyncMethodCallback
& callback
));
60 MOCK_METHOD1(TpmIsReady
, void(const BoolDBusMethodCallback
& callback
));
61 MOCK_METHOD1(TpmIsEnabled
, void(const BoolDBusMethodCallback
& callback
));
62 MOCK_METHOD1(CallTpmIsEnabledAndBlock
, bool(bool* enabled
));
63 MOCK_METHOD1(TpmGetPassword
, void(const StringDBusMethodCallback
& callback
));
64 MOCK_METHOD1(TpmIsOwned
, void(const BoolDBusMethodCallback
& callback
));
65 MOCK_METHOD1(CallTpmIsOwnedAndBlock
, bool(bool* owned
));
66 MOCK_METHOD1(TpmIsBeingOwned
, void(const BoolDBusMethodCallback
& callback
));
67 MOCK_METHOD1(CallTpmIsBeingOwnedAndBlock
, bool(bool* owning
));
68 MOCK_METHOD1(TpmCanAttemptOwnership
,
69 void(const VoidDBusMethodCallback
& callback
));
70 MOCK_METHOD1(TpmClearStoredPassword
,
71 void(const VoidDBusMethodCallback
& callback
));
72 MOCK_METHOD0(CallTpmClearStoredPasswordAndBlock
, bool());
73 MOCK_METHOD1(Pkcs11IsTpmTokenReady
,
74 void(const BoolDBusMethodCallback
& callback
));
75 MOCK_METHOD1(Pkcs11GetTpmTokenInfo
,
76 void(const Pkcs11GetTpmTokenInfoCallback
& callback
));
77 MOCK_METHOD2(Pkcs11GetTpmTokenInfoForUser
,
78 void(const std::string
& username
,
79 const Pkcs11GetTpmTokenInfoCallback
& callback
));
80 MOCK_METHOD3(InstallAttributesGet
,
81 bool(const std::string
& name
,
82 std::vector
<uint8
>* value
,
84 MOCK_METHOD3(InstallAttributesSet
,
85 bool(const std::string
& name
,
86 const std::vector
<uint8
>& value
,
88 MOCK_METHOD1(InstallAttributesFinalize
, bool(bool* successful
));
89 MOCK_METHOD1(InstallAttributesIsReady
,
90 void(const BoolDBusMethodCallback
& callback
));
91 MOCK_METHOD1(InstallAttributesIsInvalid
, bool(bool* is_invalid
));
92 MOCK_METHOD1(InstallAttributesIsFirstInstall
, bool(bool* is_first_install
));
93 MOCK_METHOD1(TpmAttestationIsPrepared
,
94 void(const BoolDBusMethodCallback
& callback
));
95 MOCK_METHOD1(TpmAttestationIsEnrolled
,
96 void(const BoolDBusMethodCallback
& callback
));
97 MOCK_METHOD2(AsyncTpmAttestationCreateEnrollRequest
,
98 void(attestation::PrivacyCAType pca_type
,
99 const AsyncMethodCallback
& callback
));
100 MOCK_METHOD3(AsyncTpmAttestationEnroll
,
101 void(attestation::PrivacyCAType pca_type
,
102 const std::string
& pca_response
,
103 const AsyncMethodCallback
& callback
));
105 AsyncTpmAttestationCreateCertRequest
,
106 void(attestation::PrivacyCAType pca_type
,
107 attestation::AttestationCertificateProfile certificate_profile
,
108 const std::string
& user_id
,
109 const std::string
& request_origin
,
110 const AsyncMethodCallback
& callback
));
111 MOCK_METHOD5(AsyncTpmAttestationFinishCertRequest
,
112 void(const std::string
& pca_response
,
113 attestation::AttestationKeyType key_type
,
114 const std::string
& user_id
,
115 const std::string
& key_name
,
116 const AsyncMethodCallback
& callback
));
117 MOCK_METHOD4(TpmAttestationDoesKeyExist
,
118 void(attestation::AttestationKeyType key_type
,
119 const std::string
& user_id
,
120 const std::string
& key_name
,
121 const BoolDBusMethodCallback
& callback
));
122 MOCK_METHOD4(TpmAttestationGetCertificate
,
123 void(attestation::AttestationKeyType key_type
,
124 const std::string
& user_id
,
125 const std::string
& key_name
,
126 const DataMethodCallback
& callback
));
127 MOCK_METHOD4(TpmAttestationGetPublicKey
,
128 void(attestation::AttestationKeyType key_type
,
129 const std::string
& user_id
,
130 const std::string
& key_name
,
131 const DataMethodCallback
& callback
));
132 MOCK_METHOD4(TpmAttestationRegisterKey
,
133 void(attestation::AttestationKeyType key_type
,
134 const std::string
& user_id
,
135 const std::string
& key_name
,
136 const AsyncMethodCallback
& callback
));
137 MOCK_METHOD8(TpmAttestationSignEnterpriseChallenge
,
138 void(attestation::AttestationKeyType key_type
,
139 const std::string
& user_id
,
140 const std::string
& key_name
,
141 const std::string
& domain
,
142 const std::string
& device_id
,
143 attestation::AttestationChallengeOptions options
,
144 const std::string
& challenge
,
145 const AsyncMethodCallback
& callback
));
146 MOCK_METHOD5(TpmAttestationSignSimpleChallenge
,
147 void(attestation::AttestationKeyType key_type
,
148 const std::string
& user_id
,
149 const std::string
& key_name
,
150 const std::string
& challenge
,
151 const AsyncMethodCallback
& callback
));
152 MOCK_METHOD4(TpmAttestationGetKeyPayload
,
153 void(attestation::AttestationKeyType key_type
,
154 const std::string
& user_id
,
155 const std::string
& key_name
,
156 const DataMethodCallback
& callback
));
157 MOCK_METHOD5(TpmAttestationSetKeyPayload
,
158 void(attestation::AttestationKeyType key_type
,
159 const std::string
& user_id
,
160 const std::string
& key_name
,
161 const std::string
& payload
,
162 const BoolDBusMethodCallback
& callback
));
163 MOCK_METHOD4(TpmAttestationDeleteKeys
,
164 void(attestation::AttestationKeyType key_type
,
165 const std::string
& user_id
,
166 const std::string
& key_prefix
,
167 const BoolDBusMethodCallback
& callback
));
168 MOCK_METHOD4(GetKeyDataEx
,
169 void(const cryptohome::AccountIdentifier
& id
,
170 const cryptohome::AuthorizationRequest
& auth
,
171 const cryptohome::GetKeyDataRequest
& request
,
172 const ProtobufMethodCallback
& callback
));
173 MOCK_METHOD4(CheckKeyEx
,
174 void(const cryptohome::AccountIdentifier
& id
,
175 const cryptohome::AuthorizationRequest
& auth
,
176 const cryptohome::CheckKeyRequest
& request
,
177 const ProtobufMethodCallback
& callback
));
178 MOCK_METHOD4(MountEx
,
179 void(const cryptohome::AccountIdentifier
& id
,
180 const cryptohome::AuthorizationRequest
& auth
,
181 const cryptohome::MountRequest
& request
,
182 const ProtobufMethodCallback
& callback
));
183 MOCK_METHOD4(AddKeyEx
,
184 void(const cryptohome::AccountIdentifier
& id
,
185 const cryptohome::AuthorizationRequest
& auth
,
186 const cryptohome::AddKeyRequest
& request
,
187 const ProtobufMethodCallback
& callback
));
188 MOCK_METHOD4(UpdateKeyEx
,
189 void(const cryptohome::AccountIdentifier
& id
,
190 const cryptohome::AuthorizationRequest
& auth
,
191 const cryptohome::UpdateKeyRequest
& request
,
192 const ProtobufMethodCallback
& callback
));
193 MOCK_METHOD4(RemoveKeyEx
,
194 void(const cryptohome::AccountIdentifier
& id
,
195 const cryptohome::AuthorizationRequest
& auth
,
196 const cryptohome::RemoveKeyRequest
& request
,
197 const ProtobufMethodCallback
& callback
));
198 MOCK_METHOD2(GetBootAttribute
,
199 void(const cryptohome::GetBootAttributeRequest
& request
,
200 const ProtobufMethodCallback
& callback
));
201 MOCK_METHOD2(SetBootAttribute
,
202 void(const cryptohome::SetBootAttributeRequest
& request
,
203 const ProtobufMethodCallback
& callback
));
205 FlushAndSignBootAttributes
,
206 void(const cryptohome::FlushAndSignBootAttributesRequest
& request
,
207 const ProtobufMethodCallback
& callback
));
210 } // namespace chromeos
212 #endif // CHROMEOS_DBUS_MOCK_CRYPTOHOME_CLIENT_H_