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

Side by Side Diff: chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos_unittest.cc

Issue 2677563005: Chromad: Use DM server reply to determine enrollment type (Closed)
Patch Set: comment+rebase+fix test Created 3 years, 10 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 (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>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/bind_helpers.h" 14 #include "base/bind_helpers.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ptr_util.h" 17 #include "base/memory/ptr_util.h"
18 #include "base/run_loop.h" 18 #include "base/run_loop.h"
19 #include "base/threading/thread_task_runner_handle.h" 19 #include "base/threading/thread_task_runner_handle.h"
20 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" 20 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
21 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h" 21 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h"
22 #include "chrome/browser/chromeos/policy/active_directory_join_delegate.h"
22 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" 23 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h"
23 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" 24 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h"
24 #include "chrome/browser/chromeos/policy/enrollment_config.h" 25 #include "chrome/browser/chromeos/policy/enrollment_config.h"
25 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" 26 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h"
26 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" 27 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
27 #include "chrome/browser/chromeos/settings/cros_settings.h" 28 #include "chrome/browser/chromeos/settings/cros_settings.h"
28 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" 29 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
29 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h " 30 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h "
30 #include "chrome/browser/chromeos/settings/device_settings_service.h" 31 #include "chrome/browser/chromeos/settings/device_settings_service.h"
31 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" 32 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 task_runner, 103 task_runner,
103 state_keys_broker) { 104 state_keys_broker) {
104 set_component_policy_disabled_for_testing(true); 105 set_component_policy_disabled_for_testing(true);
105 } 106 }
106 107
107 ~TestingDeviceCloudPolicyManagerChromeOS() override {} 108 ~TestingDeviceCloudPolicyManagerChromeOS() override {}
108 }; 109 };
109 110
110 class DeviceCloudPolicyManagerChromeOSTest 111 class DeviceCloudPolicyManagerChromeOSTest
111 : public chromeos::DeviceSettingsTestBase, 112 : public chromeos::DeviceSettingsTestBase,
112 public DeviceCloudPolicyManagerChromeOS::Observer { 113 public DeviceCloudPolicyManagerChromeOS::Observer,
114 public chromeos::ActiveDirectoryJoinDelegate {
113 protected: 115 protected:
114 DeviceCloudPolicyManagerChromeOSTest() 116 DeviceCloudPolicyManagerChromeOSTest()
115 : fake_cryptohome_client_(new chromeos::FakeCryptohomeClient()), 117 : fake_cryptohome_client_(new chromeos::FakeCryptohomeClient()),
116 state_keys_broker_(&fake_session_manager_client_, 118 state_keys_broker_(&fake_session_manager_client_,
117 base::ThreadTaskRunnerHandle::Get()), 119 base::ThreadTaskRunnerHandle::Get()),
118 store_(NULL) { 120 store_(NULL) {
119 fake_statistics_provider_.SetMachineStatistic( 121 fake_statistics_provider_.SetMachineStatistic(
120 chromeos::system::kSerialNumberKey, "test_sn"); 122 chromeos::system::kSerialNumberKey, "test_sn");
121 fake_statistics_provider_.SetMachineStatistic( 123 fake_statistics_provider_.SetMachineStatistic(
122 chromeos::system::kHardwareClassKey, "test_hw"); 124 chromeos::system::kHardwareClassKey, "test_hw");
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 DM_STATUS_TEMPORARY_UNAVAILABLE)); 246 DM_STATUS_TEMPORARY_UNAVAILABLE));
245 EXPECT_CALL( 247 EXPECT_CALL(
246 device_management_service_, 248 device_management_service_,
247 StartJob(dm_protocol::kValueRequestRemoteCommands, _, _, _, _, _)) 249 StartJob(dm_protocol::kValueRequestRemoteCommands, _, _, _, _, _))
248 .Times(AnyNumber()); 250 .Times(AnyNumber());
249 } 251 }
250 252
251 MOCK_METHOD0(OnDeviceCloudPolicyManagerConnected, void()); 253 MOCK_METHOD0(OnDeviceCloudPolicyManagerConnected, void());
252 MOCK_METHOD0(OnDeviceCloudPolicyManagerDisconnected, void()); 254 MOCK_METHOD0(OnDeviceCloudPolicyManagerDisconnected, void());
253 255
256 // Overriden from ActiveDirectoryJoinDelegate:
Thiemo Nagel 2017/02/14 14:45:00 Nit: Overridden
Roman Sorokin (ftl) 2017/02/14 16:01:33 Done.
257 void JoinDomain(chromeos::OnDomainJoinedCallback on_joined_callback) {
258 NOTREACHED();
259 }
260
254 std::unique_ptr<chromeos::InstallAttributes> install_attributes_; 261 std::unique_ptr<chromeos::InstallAttributes> install_attributes_;
255 262
256 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 263 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
257 net::TestURLFetcherFactory url_fetcher_factory_; 264 net::TestURLFetcherFactory url_fetcher_factory_;
258 int url_fetcher_response_code_; 265 int url_fetcher_response_code_;
259 std::string url_fetcher_response_string_; 266 std::string url_fetcher_response_string_;
260 TestingPrefServiceSimple local_state_; 267 TestingPrefServiceSimple local_state_;
261 MockDeviceManagementService device_management_service_; 268 MockDeviceManagementService device_management_service_;
262 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; 269 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
263 chromeos::ScopedTestCrosSettings test_cros_settings_; 270 chromeos::ScopedTestCrosSettings test_cros_settings_;
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 profile_.get()); 504 profile_.get());
498 ASSERT_TRUE(owner_settings_service); 505 ASSERT_TRUE(owner_settings_service);
499 506
500 EnrollmentConfig enrollment_config; 507 EnrollmentConfig enrollment_config;
501 enrollment_config.auth_mechanism = 508 enrollment_config.auth_mechanism =
502 EnrollmentConfig::AUTH_MECHANISM_BEST_AVAILABLE; 509 EnrollmentConfig::AUTH_MECHANISM_BEST_AVAILABLE;
503 enrollment_config.mode = with_cert ? EnrollmentConfig::MODE_ATTESTATION 510 enrollment_config.mode = with_cert ? EnrollmentConfig::MODE_ATTESTATION
504 : EnrollmentConfig::MODE_MANUAL; 511 : EnrollmentConfig::MODE_MANUAL;
505 std::string token = with_cert ? "" : "auth token"; 512 std::string token = with_cert ? "" : "auth token";
506 initializer_->StartEnrollment( 513 initializer_->StartEnrollment(
507 &device_management_service_, enrollment_config, token, 514 &device_management_service_, this, enrollment_config, token,
508 base::Bind(&DeviceCloudPolicyManagerChromeOSEnrollmentTest::Done, 515 base::Bind(&DeviceCloudPolicyManagerChromeOSEnrollmentTest::Done,
509 base::Unretained(this))); 516 base::Unretained(this)));
510 base::RunLoop().RunUntilIdle(); 517 base::RunLoop().RunUntilIdle();
511 Mock::VerifyAndClearExpectations(&device_management_service_); 518 Mock::VerifyAndClearExpectations(&device_management_service_);
512 AllowUninterestingRemoteCommandFetches(); 519 AllowUninterestingRemoteCommandFetches();
513 520
514 if (done_) 521 if (done_)
515 return; 522 return;
516 523
517 // Process registration. 524 // Process registration.
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 DeviceCloudPolicyManagerChromeOSEnrollmentTest, 828 DeviceCloudPolicyManagerChromeOSEnrollmentTest,
822 ::testing::Values(false, true)); 829 ::testing::Values(false, true));
823 830
824 INSTANTIATE_TEST_CASE_P( 831 INSTANTIATE_TEST_CASE_P(
825 Cert, 832 Cert,
826 DeviceCloudPolicyManagerChromeOSEnrollmentBlankSystemSaltTest, 833 DeviceCloudPolicyManagerChromeOSEnrollmentBlankSystemSaltTest,
827 ::testing::Values(false, true)); 834 ::testing::Values(false, true));
828 835
829 } // namespace 836 } // namespace
830 } // namespace policy 837 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698