OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 | 93 |
94 class TestingDeviceCloudPolicyManagerChromeOS | 94 class TestingDeviceCloudPolicyManagerChromeOS |
95 : public DeviceCloudPolicyManagerChromeOS { | 95 : public DeviceCloudPolicyManagerChromeOS { |
96 public: | 96 public: |
97 TestingDeviceCloudPolicyManagerChromeOS( | 97 TestingDeviceCloudPolicyManagerChromeOS( |
98 std::unique_ptr<DeviceCloudPolicyStoreChromeOS> store, | 98 std::unique_ptr<DeviceCloudPolicyStoreChromeOS> store, |
99 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 99 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
100 ServerBackedStateKeysBroker* state_keys_broker) | 100 ServerBackedStateKeysBroker* state_keys_broker) |
101 : DeviceCloudPolicyManagerChromeOS(std::move(store), | 101 : DeviceCloudPolicyManagerChromeOS(std::move(store), |
102 task_runner, | 102 task_runner, |
103 state_keys_broker) {} | 103 state_keys_broker) { |
104 set_is_component_policy_enabled_for_testing(false); | |
105 } | |
106 | |
104 ~TestingDeviceCloudPolicyManagerChromeOS() override {} | 107 ~TestingDeviceCloudPolicyManagerChromeOS() override {} |
105 }; | 108 }; |
106 | 109 |
107 class DeviceCloudPolicyManagerChromeOSTest | 110 class DeviceCloudPolicyManagerChromeOSTest |
108 : public chromeos::DeviceSettingsTestBase, | 111 : public chromeos::DeviceSettingsTestBase, |
109 public DeviceCloudPolicyManagerChromeOS::Observer { | 112 public DeviceCloudPolicyManagerChromeOS::Observer { |
110 protected: | 113 protected: |
111 DeviceCloudPolicyManagerChromeOSTest() | 114 DeviceCloudPolicyManagerChromeOSTest() |
112 : fake_cryptohome_client_(new chromeos::FakeCryptohomeClient()), | 115 : fake_cryptohome_client_(new chromeos::FakeCryptohomeClient()), |
113 state_keys_broker_(&fake_session_manager_client_, | 116 state_keys_broker_(&fake_session_manager_client_, |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
593 | 596 |
594 // Process policy store. | 597 // Process policy store. |
595 device_settings_test_helper_.set_store_result(store_result_); | 598 device_settings_test_helper_.set_store_result(store_result_); |
596 device_settings_test_helper_.FlushStore(); | 599 device_settings_test_helper_.FlushStore(); |
597 EXPECT_EQ(device_policy_.GetBlob(), | 600 EXPECT_EQ(device_policy_.GetBlob(), |
598 device_settings_test_helper_.policy_blob()); | 601 device_settings_test_helper_.policy_blob()); |
599 | 602 |
600 if (done_) | 603 if (done_) |
601 return; | 604 return; |
602 | 605 |
606 // Process the second policy refresh, now with component policy types added. | |
607 MockDeviceManagementJob* component_policy_fetch_job = NULL; | |
608 EXPECT_CALL(device_management_service_, | |
609 CreateJob(DeviceManagementRequestJob::TYPE_POLICY_FETCH, _)) | |
Andrew T Wilson (Slow)
2016/10/28 14:49:56
I'm somewhat confused - doesn't TestingDeviceCloud
emaxx
2016/10/31 15:51:20
Right, the comment was misleading. The second poli
| |
610 .Times(AtMost(1)) | |
611 .WillOnce(device_management_service_.CreateAsyncJob( | |
612 &component_policy_fetch_job)); | |
613 EXPECT_CALL(device_management_service_, | |
614 StartJob(dm_protocol::kValueRequestPolicy, _, _, _, _, _)) | |
615 .Times(AtMost(1)); | |
616 | |
603 // Key installation and policy load. | 617 // Key installation and policy load. |
604 device_settings_test_helper_.set_policy_blob(loaded_blob_); | 618 device_settings_test_helper_.set_policy_blob(loaded_blob_); |
605 owner_key_util_->SetPublicKeyFromPrivateKey( | 619 owner_key_util_->SetPublicKeyFromPrivateKey( |
606 *device_policy_.GetNewSigningKey()); | 620 *device_policy_.GetNewSigningKey()); |
607 ReloadDeviceSettings(); | 621 ReloadDeviceSettings(); |
622 | |
623 // Respond to the second policy refresh. | |
624 if (component_policy_fetch_job) { | |
625 component_policy_fetch_job->SendResponse(policy_fetch_status_, | |
626 policy_fetch_response_); | |
627 } | |
628 Mock::VerifyAndClearExpectations(&device_management_service_); | |
608 } | 629 } |
609 | 630 |
610 bool ShouldRegisterWithCert() const override { return GetParam(); } | 631 bool ShouldRegisterWithCert() const override { return GetParam(); } |
611 | 632 |
612 const std::unique_ptr<em::DeviceRegisterRequest> GetDeviceRegisterRequest() { | 633 const std::unique_ptr<em::DeviceRegisterRequest> GetDeviceRegisterRequest() { |
613 auto req = base::MakeUnique<em::DeviceRegisterRequest>(); | 634 auto req = base::MakeUnique<em::DeviceRegisterRequest>(); |
614 if (ShouldRegisterWithCert()) { | 635 if (ShouldRegisterWithCert()) { |
615 em::CertificateBasedDeviceRegistrationData data; | 636 em::CertificateBasedDeviceRegistrationData data; |
616 const em::SignedData& signed_request = | 637 const em::SignedData& signed_request = |
617 register_request_.certificate_based_register_request() | 638 register_request_.certificate_based_register_request() |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
799 DeviceCloudPolicyManagerChromeOSEnrollmentTest, | 820 DeviceCloudPolicyManagerChromeOSEnrollmentTest, |
800 ::testing::Values(false, true)); | 821 ::testing::Values(false, true)); |
801 | 822 |
802 INSTANTIATE_TEST_CASE_P( | 823 INSTANTIATE_TEST_CASE_P( |
803 Cert, | 824 Cert, |
804 DeviceCloudPolicyManagerChromeOSEnrollmentBlankSystemSaltTest, | 825 DeviceCloudPolicyManagerChromeOSEnrollmentBlankSystemSaltTest, |
805 ::testing::Values(false, true)); | 826 ::testing::Values(false, true)); |
806 | 827 |
807 } // namespace | 828 } // namespace |
808 } // namespace policy | 829 } // namespace policy |
OLD | NEW |