OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 <stdint.h> |
| 6 |
5 #include <string> | 7 #include <string> |
6 | 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
10 #include "chrome/browser/chromeos/attestation/attestation_key_payload.pb.h" | 12 #include "chrome/browser/chromeos/attestation/attestation_key_payload.pb.h" |
11 #include "chrome/browser/chromeos/attestation/attestation_policy_observer.h" | 13 #include "chrome/browser/chromeos/attestation/attestation_policy_observer.h" |
12 #include "chrome/browser/chromeos/attestation/fake_certificate.h" | 14 #include "chrome/browser/chromeos/attestation/fake_certificate.h" |
13 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h" | 15 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h" |
14 #include "chromeos/attestation/mock_attestation_flow.h" | 16 #include "chromeos/attestation/mock_attestation_flow.h" |
15 #include "chromeos/dbus/mock_cryptohome_client.h" | 17 #include "chromeos/dbus/mock_cryptohome_client.h" |
16 #include "chromeos/settings/cros_settings_names.h" | 18 #include "chromeos/settings/cros_settings_names.h" |
17 #include "components/policy/core/common/cloud/mock_cloud_policy_client.h" | 19 #include "components/policy/core/common/cloud/mock_cloud_policy_client.h" |
18 #include "content/public/test/test_browser_thread.h" | 20 #include "content/public/test/test_browser_thread.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
20 | 22 |
21 using testing::_; | 23 using testing::_; |
22 using testing::Invoke; | 24 using testing::Invoke; |
23 using testing::StrictMock; | 25 using testing::StrictMock; |
24 using testing::WithArgs; | 26 using testing::WithArgs; |
25 | 27 |
26 namespace chromeos { | 28 namespace chromeos { |
27 namespace attestation { | 29 namespace attestation { |
28 | 30 |
29 namespace { | 31 namespace { |
30 | 32 |
31 const int64 kCertValid = 90; | 33 const int64_t kCertValid = 90; |
32 const int64 kCertExpiringSoon = 20; | 34 const int64_t kCertExpiringSoon = 20; |
33 const int64 kCertExpired = -20; | 35 const int64_t kCertExpired = -20; |
34 | 36 |
35 void DBusCallbackFalse(const BoolDBusMethodCallback& callback) { | 37 void DBusCallbackFalse(const BoolDBusMethodCallback& callback) { |
36 base::MessageLoop::current()->PostTask( | 38 base::MessageLoop::current()->PostTask( |
37 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, false)); | 39 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, false)); |
38 } | 40 } |
39 | 41 |
40 void DBusCallbackTrue(const BoolDBusMethodCallback& callback) { | 42 void DBusCallbackTrue(const BoolDBusMethodCallback& callback) { |
41 base::MessageLoop::current()->PostTask( | 43 base::MessageLoop::current()->PostTask( |
42 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true)); | 44 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true)); |
43 } | 45 } |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 SetupMocks(MOCK_NEW_KEY, ""); | 218 SetupMocks(MOCK_NEW_KEY, ""); |
217 // Simulate a DBus failure. | 219 // Simulate a DBus failure. |
218 EXPECT_CALL(cryptohome_client_, TpmAttestationDoesKeyExist(_, _, _, _)) | 220 EXPECT_CALL(cryptohome_client_, TpmAttestationDoesKeyExist(_, _, _, _)) |
219 .WillOnce(WithArgs<3>(Invoke(DBusCallbackError))) | 221 .WillOnce(WithArgs<3>(Invoke(DBusCallbackError))) |
220 .WillRepeatedly(WithArgs<3>(Invoke(DBusCallbackFalse))); | 222 .WillRepeatedly(WithArgs<3>(Invoke(DBusCallbackFalse))); |
221 Run(); | 223 Run(); |
222 } | 224 } |
223 | 225 |
224 } // namespace attestation | 226 } // namespace attestation |
225 } // namespace chromeos | 227 } // namespace chromeos |
OLD | NEW |