Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: chromeos/cryptohome/mock_homedir_methods.cc

Issue 517653002: Make CryptohomeAuthenticator's Login*() methods work with pre-hashed keys (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@d_3_367847_add_sha256_key_type
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/cryptohome/mock_homedir_methods.h" 5 #include "chromeos/cryptohome/mock_homedir_methods.h"
6 6
7 #include "base/memory/scoped_vector.h"
8 #include "chromeos/cryptohome/cryptohome_parameters.h"
7 #include "chromeos/cryptohome/mock_async_method_caller.h" 9 #include "chromeos/cryptohome/mock_async_method_caller.h"
8 10
9 using ::testing::Invoke; 11 using ::testing::Invoke;
10 using ::testing::WithArgs; 12 using ::testing::WithArgs;
11 using ::testing::_; 13 using ::testing::_;
12 14
13 namespace cryptohome { 15 namespace cryptohome {
14 16
15 MockHomedirMethods::MockHomedirMethods() 17 MockHomedirMethods::MockHomedirMethods()
16 : success_(false), return_code_(cryptohome::MOUNT_ERROR_NONE) {} 18 : success_(false), return_code_(cryptohome::MOUNT_ERROR_NONE) {}
17 19
18 MockHomedirMethods::~MockHomedirMethods() {} 20 MockHomedirMethods::~MockHomedirMethods() {}
19 21
20 void MockHomedirMethods::SetUp(bool success, MountError return_code) { 22 void MockHomedirMethods::SetUp(bool success, MountError return_code) {
21 success_ = success; 23 success_ = success;
22 return_code_ = return_code; 24 return_code_ = return_code;
25 ON_CALL(*this, GetKeyDataEx(_, _, _)).WillByDefault(
26 WithArgs<2>(Invoke(this, &MockHomedirMethods::DoGetDataCallback)));
23 ON_CALL(*this, CheckKeyEx(_, _, _)).WillByDefault( 27 ON_CALL(*this, CheckKeyEx(_, _, _)).WillByDefault(
24 WithArgs<2>(Invoke(this, &MockHomedirMethods::DoCallback))); 28 WithArgs<2>(Invoke(this, &MockHomedirMethods::DoCallback)));
25 ON_CALL(*this, MountEx(_, _, _, _)).WillByDefault( 29 ON_CALL(*this, MountEx(_, _, _, _)).WillByDefault(
26 WithArgs<3>(Invoke(this, &MockHomedirMethods::DoMountCallback))); 30 WithArgs<3>(Invoke(this, &MockHomedirMethods::DoMountCallback)));
27 ON_CALL(*this, AddKeyEx(_, _, _, _, _)).WillByDefault( 31 ON_CALL(*this, AddKeyEx(_, _, _, _, _)).WillByDefault(
28 WithArgs<4>(Invoke(this, &MockHomedirMethods::DoCallback))); 32 WithArgs<4>(Invoke(this, &MockHomedirMethods::DoCallback)));
29 ON_CALL(*this, UpdateKeyEx(_, _, _, _, _)).WillByDefault( 33 ON_CALL(*this, UpdateKeyEx(_, _, _, _, _)).WillByDefault(
30 WithArgs<4>(Invoke(this, &MockHomedirMethods::DoCallback))); 34 WithArgs<4>(Invoke(this, &MockHomedirMethods::DoCallback)));
31 ON_CALL(*this, RemoveKeyEx(_, _, _, _)).WillByDefault( 35 ON_CALL(*this, RemoveKeyEx(_, _, _, _)).WillByDefault(
32 WithArgs<3>(Invoke(this, &MockHomedirMethods::DoCallback))); 36 WithArgs<3>(Invoke(this, &MockHomedirMethods::DoCallback)));
33 } 37 }
34 38
35 void MockHomedirMethods::DoCallback(const Callback& callback) { 39 void MockHomedirMethods::DoCallback(const Callback& callback) {
36 callback.Run(success_, return_code_); 40 callback.Run(success_, return_code_);
37 } 41 }
38 42
43 void MockHomedirMethods::DoGetDataCallback(const GetKeyDataCallback& callback) {
44 callback.Run(success_, return_code_, ScopedVector<RetrievedKeyData>());
45 }
46
39 void MockHomedirMethods::DoMountCallback(const MountCallback& callback) { 47 void MockHomedirMethods::DoMountCallback(const MountCallback& callback) {
40 callback.Run( 48 callback.Run(
41 success_, return_code_, MockAsyncMethodCaller::kFakeSanitizedUsername); 49 success_, return_code_, MockAsyncMethodCaller::kFakeSanitizedUsername);
42 } 50 }
43 51
44 } // namespace cryptohome 52 } // namespace cryptohome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698