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

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

Issue 17109006: Device robot refresh token integrity validation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: addressed atwilson's review comments Created 7 years, 6 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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/policy/cloud/cloud_policy_client.h" 21 #include "chrome/browser/policy/cloud/cloud_policy_client.h"
22 #include "chrome/browser/policy/cloud/mock_device_management_service.h" 22 #include "chrome/browser/policy/cloud/mock_device_management_service.h"
23 #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h" 23 #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h"
24 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" 24 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h"
25 #include "chrome/browser/prefs/browser_prefs.h" 25 #include "chrome/browser/prefs/browser_prefs.h"
26 #include "chrome/test/base/testing_browser_process.h" 26 #include "chrome/test/base/testing_browser_process.h"
27 #include "chromeos/cryptohome/cryptohome_library.h" 27 #include "chromeos/cryptohome/cryptohome_library.h"
28 #include "chromeos/cryptohome/mock_cryptohome_library.h" 28 #include "chromeos/cryptohome/mock_cryptohome_library.h"
29 #include "chromeos/dbus/cryptohome_client.h" 29 #include "chromeos/dbus/cryptohome_client.h"
30 #include "chromeos/dbus/dbus_client_implementation_type.h" 30 #include "chromeos/dbus/dbus_client_implementation_type.h"
31 #include "google_apis/gaia/gaia_oauth_client.h"
31 #include "net/url_request/test_url_fetcher_factory.h" 32 #include "net/url_request/test_url_fetcher_factory.h"
32 #include "net/url_request/url_request_test_util.h" 33 #include "net/url_request/url_request_test_util.h"
33 #include "policy/policy_constants.h" 34 #include "policy/policy_constants.h"
34 #include "testing/gmock/include/gmock/gmock.h" 35 #include "testing/gmock/include/gmock/gmock.h"
35 #include "testing/gtest/include/gtest/gtest.h" 36 #include "testing/gtest/include/gtest/gtest.h"
36 37
37 using testing::AnyNumber; 38 using testing::AnyNumber;
38 using testing::AtMost; 39 using testing::AtMost;
39 using testing::DoAll; 40 using testing::DoAll;
40 using testing::Mock; 41 using testing::Mock;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 POLICY_SCOPE_MACHINE, 150 POLICY_SCOPE_MACHINE,
150 Value::CreateBooleanValue(false)); 151 Value::CreateBooleanValue(false));
151 EXPECT_TRUE(manager_.policies().Equals(bundle)); 152 EXPECT_TRUE(manager_.policies().Equals(bundle));
152 153
153 manager_.Connect(&local_state_, &device_management_service_, 154 manager_.Connect(&local_state_, &device_management_service_,
154 scoped_ptr<CloudPolicyClient::StatusProvider>(NULL)); 155 scoped_ptr<CloudPolicyClient::StatusProvider>(NULL));
155 EXPECT_TRUE(manager_.policies().Equals(bundle)); 156 EXPECT_TRUE(manager_.policies().Equals(bundle));
156 157
157 manager_.Shutdown(); 158 manager_.Shutdown();
158 EXPECT_TRUE(manager_.policies().Equals(bundle)); 159 EXPECT_TRUE(manager_.policies().Equals(bundle));
160
161 EXPECT_EQ(manager_.GetRobotAccountId(),
162 PolicyBuilder::kFakeServiceAccountIdentity);
159 } 163 }
160 164
161 TEST_F(DeviceCloudPolicyManagerChromeOSTest, ConsumerDevice) { 165 TEST_F(DeviceCloudPolicyManagerChromeOSTest, ConsumerDevice) {
162 FlushDeviceSettings(); 166 FlushDeviceSettings();
163 EXPECT_EQ(CloudPolicyStore::STATUS_BAD_STATE, store_->status()); 167 EXPECT_EQ(CloudPolicyStore::STATUS_BAD_STATE, store_->status());
164 EXPECT_TRUE(manager_.IsInitializationComplete(POLICY_DOMAIN_CHROME)); 168 EXPECT_TRUE(manager_.IsInitializationComplete(POLICY_DOMAIN_CHROME));
165 169
166 PolicyBundle bundle; 170 PolicyBundle bundle;
167 EXPECT_TRUE(manager_.policies().Equals(bundle)); 171 EXPECT_TRUE(manager_.policies().Equals(bundle));
168 172
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 319
316 if (done_) 320 if (done_)
317 return; 321 return;
318 322
319 // Process robot refresh token fetch if the auth code fetch succeeded. 323 // Process robot refresh token fetch if the auth code fetch succeeded.
320 // DeviceCloudPolicyManagerChromeOS holds an EnrollmentHandlerChromeOS which 324 // DeviceCloudPolicyManagerChromeOS holds an EnrollmentHandlerChromeOS which
321 // holds a GaiaOAuthClient that fetches the refresh token during enrollment. 325 // holds a GaiaOAuthClient that fetches the refresh token during enrollment.
322 // We return a successful OAuth response via a TestURLFetcher to trigger the 326 // We return a successful OAuth response via a TestURLFetcher to trigger the
323 // happy path for these classes so that enrollment can continue. 327 // happy path for these classes so that enrollment can continue.
324 if (robot_auth_fetch_status_ == DM_STATUS_SUCCESS) { 328 if (robot_auth_fetch_status_ == DM_STATUS_SUCCESS) {
325 net::TestURLFetcher* url_fetcher = url_fetcher_factory_.GetFetcherByID(0); 329 net::TestURLFetcher* url_fetcher = url_fetcher_factory_.GetFetcherByID(
330 gaia::GaiaOAuthClient::kUrlFetcherId);
326 ASSERT_TRUE(url_fetcher); 331 ASSERT_TRUE(url_fetcher);
327 url_fetcher->SetMaxRetriesOn5xx(0); 332 url_fetcher->SetMaxRetriesOn5xx(0);
328 url_fetcher->set_status(net::URLRequestStatus()); 333 url_fetcher->set_status(net::URLRequestStatus());
329 url_fetcher->set_response_code(url_fetcher_response_code_); 334 url_fetcher->set_response_code(url_fetcher_response_code_);
330 url_fetcher->SetResponseString(url_fetcher_response_string_); 335 url_fetcher->SetResponseString(url_fetcher_response_string_);
331 url_fetcher->delegate()->OnURLFetchComplete(url_fetcher); 336 url_fetcher->delegate()->OnURLFetchComplete(url_fetcher);
332 } 337 }
333 base::RunLoop().RunUntilIdle(); 338 base::RunLoop().RunUntilIdle();
334 339
335 // Process policy store. 340 // Process policy store.
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 } 478 }
474 479
475 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, LoadError) { 480 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, LoadError) {
476 loaded_blob_.clear(); 481 loaded_blob_.clear();
477 RunTest(); 482 RunTest();
478 ExpectFailedEnrollment(EnrollmentStatus::STATUS_STORE_ERROR); 483 ExpectFailedEnrollment(EnrollmentStatus::STATUS_STORE_ERROR);
479 EXPECT_EQ(CloudPolicyStore::STATUS_LOAD_ERROR, 484 EXPECT_EQ(CloudPolicyStore::STATUS_LOAD_ERROR,
480 status_.store_status()); 485 status_.store_status());
481 } 486 }
482 487
483 } // namespace test 488 } // namespace
484 } // namespace policy 489 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698