1 // Copyright (c) 2013 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_FAKE_CRYPTOHOME_CLIENT_H_
6 #define CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_
10 #include "chromeos/dbus/cryptohome_client.h"
14 // A fake implementation of CryptohomeClient. This only calls callbacks given
16 class FakeCryptohomeClient
: public CryptohomeClient
{
18 FakeCryptohomeClient();
19 virtual ~FakeCryptohomeClient();
21 // CryptohomeClient overrides.
22 virtual void SetAsyncCallStatusHandlers(
23 const AsyncCallStatusHandler
& handler
,
24 const AsyncCallStatusWithDataHandler
& data_handler
) OVERRIDE
;
25 virtual void ResetAsyncCallStatusHandlers() OVERRIDE
;
26 virtual void IsMounted(const BoolDBusMethodCallback
& callback
) OVERRIDE
;
27 virtual bool Unmount(bool* success
) OVERRIDE
;
28 virtual void AsyncCheckKey(const std::string
& username
,
29 const std::string
& key
,
30 const AsyncMethodCallback
& callback
) OVERRIDE
;
31 virtual void AsyncMigrateKey(const std::string
& username
,
32 const std::string
& from_key
,
33 const std::string
& to_key
,
34 const AsyncMethodCallback
& callback
) OVERRIDE
;
35 virtual void AsyncRemove(const std::string
& username
,
36 const AsyncMethodCallback
& callback
) OVERRIDE
;
37 virtual bool GetSystemSalt(std::vector
<uint8
>* salt
) OVERRIDE
;
38 virtual void GetSanitizedUsername(
39 const std::string
& username
,
40 const StringDBusMethodCallback
& callback
) OVERRIDE
;
41 virtual void AsyncMount(const std::string
& username
,
42 const std::string
& key
,
44 const AsyncMethodCallback
& callback
) OVERRIDE
;
45 virtual void AsyncMountGuest(const AsyncMethodCallback
& callback
) OVERRIDE
;
46 virtual void TpmIsReady(const BoolDBusMethodCallback
& callback
) OVERRIDE
;
47 virtual void TpmIsEnabled(const BoolDBusMethodCallback
& callback
) OVERRIDE
;
48 virtual bool CallTpmIsEnabledAndBlock(bool* enabled
) OVERRIDE
;
49 virtual void TpmGetPassword(
50 const StringDBusMethodCallback
& callback
) OVERRIDE
;
51 virtual void TpmIsOwned(const BoolDBusMethodCallback
& callback
) OVERRIDE
;
52 virtual bool CallTpmIsOwnedAndBlock(bool* owned
) OVERRIDE
;
53 virtual void TpmIsBeingOwned(const BoolDBusMethodCallback
& callback
) OVERRIDE
;
54 virtual bool CallTpmIsBeingOwnedAndBlock(bool* owning
) OVERRIDE
;
55 virtual void TpmCanAttemptOwnership(
56 const VoidDBusMethodCallback
& callback
) OVERRIDE
;
57 virtual void TpmClearStoredPassword(
58 const VoidDBusMethodCallback
& callback
) OVERRIDE
;
59 virtual bool CallTpmClearStoredPasswordAndBlock() OVERRIDE
;
60 virtual void Pkcs11IsTpmTokenReady(
61 const BoolDBusMethodCallback
& callback
) OVERRIDE
;
62 virtual void Pkcs11GetTpmTokenInfo(
63 const Pkcs11GetTpmTokenInfoCallback
& callback
) OVERRIDE
;
64 virtual bool InstallAttributesGet(const std::string
& name
,
65 std::vector
<uint8
>* value
,
66 bool* successful
) OVERRIDE
;
67 virtual bool InstallAttributesSet(const std::string
& name
,
68 const std::vector
<uint8
>& value
,
69 bool* successful
) OVERRIDE
;
70 virtual bool InstallAttributesFinalize(bool* successful
) OVERRIDE
;
71 virtual void InstallAttributesIsReady(
72 const BoolDBusMethodCallback
& callback
) OVERRIDE
;
73 virtual bool InstallAttributesIsInvalid(bool* is_invalid
) OVERRIDE
;
74 virtual bool InstallAttributesIsFirstInstall(bool* is_first_install
) OVERRIDE
;
75 virtual void TpmAttestationIsPrepared(
76 const BoolDBusMethodCallback
& callback
) OVERRIDE
;
77 virtual void TpmAttestationIsEnrolled(
78 const BoolDBusMethodCallback
& callback
) OVERRIDE
;
79 virtual void AsyncTpmAttestationCreateEnrollRequest(
80 const AsyncMethodCallback
& callback
) OVERRIDE
;
81 virtual void AsyncTpmAttestationEnroll(
82 const std::string
& pca_response
,
83 const AsyncMethodCallback
& callback
) OVERRIDE
;
84 virtual void AsyncTpmAttestationCreateCertRequest(
86 const AsyncMethodCallback
& callback
) OVERRIDE
;
87 virtual void AsyncTpmAttestationFinishCertRequest(
88 const std::string
& pca_response
,
89 attestation::AttestationKeyType key_type
,
90 const std::string
& key_name
,
91 const AsyncMethodCallback
& callback
) OVERRIDE
;
92 virtual void TpmAttestationDoesKeyExist(
93 attestation::AttestationKeyType key_type
,
94 const std::string
& key_name
,
95 const BoolDBusMethodCallback
& callback
) OVERRIDE
;
96 virtual void TpmAttestationGetCertificate(
97 attestation::AttestationKeyType key_type
,
98 const std::string
& key_name
,
99 const DataMethodCallback
& callback
) OVERRIDE
;
100 virtual void TpmAttestationGetPublicKey(
101 attestation::AttestationKeyType key_type
,
102 const std::string
& key_name
,
103 const DataMethodCallback
& callback
) OVERRIDE
;
104 virtual void TpmAttestationRegisterKey(
105 attestation::AttestationKeyType key_type
,
106 const std::string
& key_name
,
107 const AsyncMethodCallback
& callback
) OVERRIDE
;
108 virtual void TpmAttestationSignEnterpriseChallenge(
109 attestation::AttestationKeyType key_type
,
110 const std::string
& key_name
,
111 const std::string
& domain
,
112 const std::string
& device_id
,
113 attestation::AttestationChallengeOptions options
,
114 const std::string
& challenge
,
115 const AsyncMethodCallback
& callback
) OVERRIDE
;
116 virtual void TpmAttestationSignSimpleChallenge(
117 attestation::AttestationKeyType key_type
,
118 const std::string
& key_name
,
119 const std::string
& challenge
,
120 const AsyncMethodCallback
& callback
) OVERRIDE
;
121 virtual void TpmAttestationGetKeyPayload(
122 attestation::AttestationKeyType key_type
,
123 const std::string
& key_name
,
124 const DataMethodCallback
& callback
) OVERRIDE
;
125 virtual void TpmAttestationSetKeyPayload(
126 attestation::AttestationKeyType key_type
,
127 const std::string
& key_name
,
128 const std::string
& payload
,
129 const BoolDBusMethodCallback
& callback
) OVERRIDE
;
131 // Sets the unmount result of Unmount() call. Unmount() always sets the result
132 // and pretends that the underlying method call succeeds.
133 void set_unmount_result(bool result
) {
134 unmount_result_
= result
;
138 AsyncCallStatusHandler handler_
;
139 AsyncCallStatusWithDataHandler data_handler_
;
141 bool unmount_result_
;
143 DISALLOW_COPY_AND_ASSIGN(FakeCryptohomeClient
);
146 } // namespace chromeos
148 #endif // CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_