| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_OWNER_KEY_UTILS_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_OWNER_KEY_UTILS_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "base/file_path.h" | |
| 13 #include "crypto/rsa_private_key.h" | |
| 14 #include "chrome/browser/chromeos/login/owner_key_utils.h" | |
| 15 #include "testing/gmock/include/gmock/gmock.h" | |
| 16 #include "testing/gtest/include/gtest/gtest.h" | |
| 17 | |
| 18 namespace chromeos { | |
| 19 | |
| 20 class MockKeyUtils : public OwnerKeyUtils { | |
| 21 public: | |
| 22 MockKeyUtils(); | |
| 23 | |
| 24 MOCK_METHOD2(ImportPublicKey, bool(const FilePath& key_file, | |
| 25 std::vector<uint8>* output)); | |
| 26 MOCK_METHOD3(Verify, bool(const std::string& data, | |
| 27 const std::vector<uint8> signature, | |
| 28 const std::vector<uint8> public_key)); | |
| 29 MOCK_METHOD3(Sign, bool(const std::string& data, | |
| 30 std::vector<uint8>* OUT_signature, | |
| 31 crypto::RSAPrivateKey* key)); | |
| 32 MOCK_METHOD1(FindPrivateKey, | |
| 33 crypto::RSAPrivateKey*(const std::vector<uint8>& key)); | |
| 34 MOCK_METHOD0(GetOwnerKeyFilePath, FilePath()); | |
| 35 MOCK_METHOD2(ExportPublicKeyToFile, bool(crypto::RSAPrivateKey* pair, | |
| 36 const FilePath& key_file)); | |
| 37 protected: | |
| 38 virtual ~MockKeyUtils(); | |
| 39 | |
| 40 private: | |
| 41 DISALLOW_COPY_AND_ASSIGN(MockKeyUtils); | |
| 42 }; | |
| 43 | |
| 44 class MockInjector : public OwnerKeyUtils::Factory { | |
| 45 public: | |
| 46 // Takes ownership of |mock|. | |
| 47 explicit MockInjector(MockKeyUtils* mock); | |
| 48 virtual ~MockInjector(); | |
| 49 | |
| 50 // If this is called, its caller takes ownership of |transient_|. | |
| 51 // If it's never called, |transient_| remains our problem. | |
| 52 virtual OwnerKeyUtils* CreateOwnerKeyUtils() OVERRIDE; | |
| 53 | |
| 54 private: | |
| 55 scoped_refptr<MockKeyUtils> transient_; | |
| 56 DISALLOW_COPY_AND_ASSIGN(MockInjector); | |
| 57 }; | |
| 58 | |
| 59 } // namespace chromeos | |
| 60 | |
| 61 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_OWNER_KEY_UTILS_H_ | |
| OLD | NEW |