OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/threading/platform_thread.h" | 8 #include "base/threading/platform_thread.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h" | 10 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h" |
11 #include "chrome/browser/chromeos/policy/device_policy_builder.h" | 11 #include "chrome/browser/chromeos/policy/device_policy_builder.h" |
12 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 12 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
13 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 13 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
14 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 14 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
17 #include "chromeos/dbus/fake_cryptohome_client.h" | 17 #include "chromeos/dbus/fake_cryptohome_client.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
20 using chromeos::attestation::PlatformVerificationFlow; | 20 using chromeos::attestation::PlatformVerificationFlow; |
21 | 21 |
22 namespace policy { | 22 namespace policy { |
23 | 23 |
24 class CustomFakeCryptohomeClient : public chromeos::FakeCryptohomeClient { | 24 class CustomFakeCryptohomeClient : public chromeos::FakeCryptohomeClient { |
25 public: | 25 public: |
26 virtual void TpmAttestationIsEnrolled( | 26 virtual void TpmAttestationIsEnrolled( |
27 const chromeos::BoolDBusMethodCallback& callback) OVERRIDE { | 27 const chromeos::BoolDBusMethodCallback& callback) override { |
28 base::MessageLoop::current()->PostTask( | 28 base::MessageLoop::current()->PostTask( |
29 FROM_HERE, | 29 FROM_HERE, |
30 base::Bind(callback, chromeos::DBUS_METHOD_CALL_FAILURE, false)); | 30 base::Bind(callback, chromeos::DBUS_METHOD_CALL_FAILURE, false)); |
31 } | 31 } |
32 }; | 32 }; |
33 | 33 |
34 class AttestationDevicePolicyTest | 34 class AttestationDevicePolicyTest |
35 : public DevicePolicyCrosBrowserTest, | 35 : public DevicePolicyCrosBrowserTest, |
36 public chromeos::DeviceSettingsService::Observer { | 36 public chromeos::DeviceSettingsService::Observer { |
37 public: | 37 public: |
38 // DeviceSettingsService::Observer | 38 // DeviceSettingsService::Observer |
39 virtual void OwnershipStatusChanged() OVERRIDE {} | 39 virtual void OwnershipStatusChanged() override {} |
40 virtual void DeviceSettingsUpdated() OVERRIDE { | 40 virtual void DeviceSettingsUpdated() override { |
41 operation_complete_ = true; | 41 operation_complete_ = true; |
42 } | 42 } |
43 | 43 |
44 protected: | 44 protected: |
45 AttestationDevicePolicyTest() : operation_complete_(false) {} | 45 AttestationDevicePolicyTest() : operation_complete_(false) {} |
46 | 46 |
47 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 47 virtual void SetUpInProcessBrowserTestFixture() override { |
48 DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture(); | 48 DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture(); |
49 InstallOwnerKey(); | 49 InstallOwnerKey(); |
50 RefreshDevicePolicy(); | 50 RefreshDevicePolicy(); |
51 } | 51 } |
52 | 52 |
53 // Refreshes device policy and waits for it to be applied. | 53 // Refreshes device policy and waits for it to be applied. |
54 virtual void SyncRefreshDevicePolicy() { | 54 virtual void SyncRefreshDevicePolicy() { |
55 chromeos::DeviceSettingsService::Get()->AddObserver(this); | 55 chromeos::DeviceSettingsService::Get()->AddObserver(this); |
56 RefreshDevicePolicy(); | 56 RefreshDevicePolicy(); |
57 WaitForAsyncOperation(); | 57 WaitForAsyncOperation(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 SyncContentProtectionAttestation()); | 115 SyncContentProtectionAttestation()); |
116 | 116 |
117 GetDevicePolicyProto()->set_content_protection_enabled(true); | 117 GetDevicePolicyProto()->set_content_protection_enabled(true); |
118 SyncRefreshDevicePolicy(); | 118 SyncRefreshDevicePolicy(); |
119 | 119 |
120 EXPECT_NE(PlatformVerificationFlow::POLICY_REJECTED, | 120 EXPECT_NE(PlatformVerificationFlow::POLICY_REJECTED, |
121 SyncContentProtectionAttestation()); | 121 SyncContentProtectionAttestation()); |
122 } | 122 } |
123 | 123 |
124 } // namespace policy | 124 } // namespace policy |
OLD | NEW |