| 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 "chrome/browser/chromeos/policy/cloud_external_data_manager_base.h" | 5 #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/browser/chromeos/policy/cloud_external_data_store.h" | 21 #include "chrome/browser/chromeos/policy/cloud_external_data_store.h" |
| 22 #include "chrome/browser/policy/cloud/mock_cloud_policy_store.h" | 22 #include "chrome/browser/policy/cloud/mock_cloud_policy_store.h" |
| 23 #include "chrome/browser/policy/cloud/resource_cache.h" | 23 #include "chrome/browser/policy/cloud/resource_cache.h" |
| 24 #include "chrome/browser/policy/external_data_fetcher.h" | 24 #include "chrome/browser/policy/external_data_fetcher.h" |
| 25 #include "chrome/browser/policy/policy_map.h" | 25 #include "chrome/browser/policy/policy_map.h" |
| 26 #include "chrome/browser/policy/policy_types.h" | 26 #include "chrome/browser/policy/policy_types.h" |
| 27 #include "net/http/http_status_code.h" | 27 #include "net/http/http_status_code.h" |
| 28 #include "net/url_request/test_url_fetcher_factory.h" | 28 #include "net/url_request/test_url_fetcher_factory.h" |
| 29 #include "net/url_request/url_fetcher.h" | 29 #include "net/url_request/url_fetcher.h" |
| 30 #include "net/url_request/url_fetcher_delegate.h" | 30 #include "net/url_request/url_fetcher_delegate.h" |
| 31 #include "net/url_request/url_request_status.h" |
| 31 #include "net/url_request/url_request_test_util.h" | 32 #include "net/url_request/url_request_test_util.h" |
| 32 #include "policy/policy_constants.h" | 33 #include "policy/policy_constants.h" |
| 33 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
| 34 #include "url/gurl.h" | 35 #include "url/gurl.h" |
| 35 | 36 |
| 36 namespace policy { | 37 namespace policy { |
| 37 | 38 |
| 38 namespace { | 39 namespace { |
| 39 | 40 |
| 40 // A string policy. | 41 // A string policy. |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 EXPECT_TRUE(callback_data_.find(2) != callback_data_.end()); | 278 EXPECT_TRUE(callback_data_.find(2) != callback_data_.end()); |
| 278 EXPECT_FALSE(callback_data_[2]); | 279 EXPECT_FALSE(callback_data_[2]); |
| 279 ResetCallbackData(); | 280 ResetCallbackData(); |
| 280 } | 281 } |
| 281 | 282 |
| 282 // Verifies that external data referenced by a policy is downloaded and cached | 283 // Verifies that external data referenced by a policy is downloaded and cached |
| 283 // when first requested. Subsequent requests are served from the cache without | 284 // when first requested. Subsequent requests are served from the cache without |
| 284 // further download attempts. | 285 // further download attempts. |
| 285 TEST_F(CloudExternalDataManagerBaseTest, DownloadAndCache) { | 286 TEST_F(CloudExternalDataManagerBaseTest, DownloadAndCache) { |
| 286 // Serve valid external data for |k10BytePolicy|. | 287 // Serve valid external data for |k10BytePolicy|. |
| 287 SetFakeResponse(k10BytePolicyURL, k10ByteData, net::HTTP_OK); | 288 SetFakeResponse(k10BytePolicyURL, k10ByteData, net::HTTP_OK, |
| 289 net::URLRequestStatus::SUCCESS); |
| 288 external_data_manager_->Connect(request_content_getter_); | 290 external_data_manager_->Connect(request_content_getter_); |
| 289 | 291 |
| 290 // Retrieve external data for |k10BytePolicy|. Verify that a download happens | 292 // Retrieve external data for |k10BytePolicy|. Verify that a download happens |
| 291 // and the callback is invoked with the downloaded data. | 293 // and the callback is invoked with the downloaded data. |
| 292 external_data_manager_->Fetch(k10BytePolicy, ConstructFetchCallback(0)); | 294 external_data_manager_->Fetch(k10BytePolicy, ConstructFetchCallback(0)); |
| 293 base::RunLoop().RunUntilIdle(); | 295 base::RunLoop().RunUntilIdle(); |
| 294 EXPECT_EQ(1u, callback_data_.size()); | 296 EXPECT_EQ(1u, callback_data_.size()); |
| 295 ASSERT_TRUE(callback_data_[0]); | 297 ASSERT_TRUE(callback_data_[0]); |
| 296 EXPECT_EQ(k10ByteData, *callback_data_[0]); | 298 EXPECT_EQ(k10ByteData, *callback_data_[0]); |
| 297 ResetCallbackData(); | 299 ResetCallbackData(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 resource_cache_.get()).Load( | 334 resource_cache_.get()).Load( |
| 333 k10BytePolicy, base::SHA1HashString(k10ByteData), 10, &data)); | 335 k10BytePolicy, base::SHA1HashString(k10ByteData), 10, &data)); |
| 334 EXPECT_EQ(k10ByteData, data); | 336 EXPECT_EQ(k10ByteData, data); |
| 335 } | 337 } |
| 336 | 338 |
| 337 // Verifies that a request to download and cache all external data referenced by | 339 // Verifies that a request to download and cache all external data referenced by |
| 338 // policies is carried out correctly. Subsequent requests for the data are | 340 // policies is carried out correctly. Subsequent requests for the data are |
| 339 // served from the cache without further download attempts. | 341 // served from the cache without further download attempts. |
| 340 TEST_F(CloudExternalDataManagerBaseTest, DownloadAndCacheAll) { | 342 TEST_F(CloudExternalDataManagerBaseTest, DownloadAndCacheAll) { |
| 341 // Serve valid external data for |k10BytePolicy| and |k20BytePolicy|. | 343 // Serve valid external data for |k10BytePolicy| and |k20BytePolicy|. |
| 342 SetFakeResponse(k10BytePolicyURL, k10ByteData, net::HTTP_OK); | 344 SetFakeResponse(k10BytePolicyURL, k10ByteData, net::HTTP_OK, |
| 343 SetFakeResponse(k20BytePolicyURL, k20ByteData, net::HTTP_OK); | 345 net::URLRequestStatus::SUCCESS); |
| 346 SetFakeResponse(k20BytePolicyURL, k20ByteData, net::HTTP_OK, |
| 347 net::URLRequestStatus::SUCCESS); |
| 344 external_data_manager_->Connect(request_content_getter_); | 348 external_data_manager_->Connect(request_content_getter_); |
| 345 | 349 |
| 346 // Request that external data referenced by all policies be downloaded. | 350 // Request that external data referenced by all policies be downloaded. |
| 347 FetchAll(); | 351 FetchAll(); |
| 348 base::RunLoop().RunUntilIdle(); | 352 base::RunLoop().RunUntilIdle(); |
| 349 | 353 |
| 350 // Stop serving external data for |k10BytePolicy| and |k20BytePolicy|. | 354 // Stop serving external data for |k10BytePolicy| and |k20BytePolicy|. |
| 351 fetcher_factory_.ClearFakeResponses(); | 355 fetcher_factory_.ClearFakeResponses(); |
| 352 | 356 |
| 353 // Retrieve external data for |k10BytePolicy| and |k20BytePolicy|. Verify that | 357 // Retrieve external data for |k10BytePolicy| and |k20BytePolicy|. Verify that |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 TEST_F(CloudExternalDataManagerBaseTest, DownloadAfterConnect) { | 405 TEST_F(CloudExternalDataManagerBaseTest, DownloadAfterConnect) { |
| 402 // Attempt to retrieve external data for |k10BytePolicy|. Verify that the | 406 // Attempt to retrieve external data for |k10BytePolicy|. Verify that the |
| 403 // callback is not invoked as the request remains pending. | 407 // callback is not invoked as the request remains pending. |
| 404 external_data_manager_->Fetch(k10BytePolicy, ConstructFetchCallback(0)); | 408 external_data_manager_->Fetch(k10BytePolicy, ConstructFetchCallback(0)); |
| 405 base::RunLoop().RunUntilIdle(); | 409 base::RunLoop().RunUntilIdle(); |
| 406 EXPECT_TRUE(callback_data_.empty()); | 410 EXPECT_TRUE(callback_data_.empty()); |
| 407 ResetCallbackData(); | 411 ResetCallbackData(); |
| 408 | 412 |
| 409 // Serve valid external data for |k10BytePolicy| and allow the | 413 // Serve valid external data for |k10BytePolicy| and allow the |
| 410 // external_data_manager_ to perform downloads. | 414 // external_data_manager_ to perform downloads. |
| 411 SetFakeResponse(k10BytePolicyURL, k10ByteData, net::HTTP_OK); | 415 SetFakeResponse(k10BytePolicyURL, k10ByteData, net::HTTP_OK, |
| 416 net::URLRequestStatus::SUCCESS); |
| 412 external_data_manager_->Connect(request_content_getter_); | 417 external_data_manager_->Connect(request_content_getter_); |
| 413 | 418 |
| 414 // Verify that a download happens and the callback is invoked with the | 419 // Verify that a download happens and the callback is invoked with the |
| 415 // downloaded data. | 420 // downloaded data. |
| 416 base::RunLoop().RunUntilIdle(); | 421 base::RunLoop().RunUntilIdle(); |
| 417 EXPECT_EQ(1u, callback_data_.size()); | 422 EXPECT_EQ(1u, callback_data_.size()); |
| 418 ASSERT_TRUE(callback_data_[0]); | 423 ASSERT_TRUE(callback_data_[0]); |
| 419 EXPECT_EQ(k10ByteData, *callback_data_[0]); | 424 EXPECT_EQ(k10ByteData, *callback_data_[0]); |
| 420 ResetCallbackData(); | 425 ResetCallbackData(); |
| 421 } | 426 } |
| 422 | 427 |
| 423 // Verifies that when the external data referenced by a policy is not present in | 428 // Verifies that when the external data referenced by a policy is not present in |
| 424 // the cache and cannot be downloaded at this time, a request to retrieve the | 429 // the cache and cannot be downloaded at this time, a request to retrieve the |
| 425 // data is enqueued to be retried later. | 430 // data is enqueued to be retried later. |
| 426 TEST_F(CloudExternalDataManagerBaseTest, DownloadError) { | 431 TEST_F(CloudExternalDataManagerBaseTest, DownloadError) { |
| 427 // Make attempts to download the external data for |k20BytePolicy| fail with | 432 // Make attempts to download the external data for |k20BytePolicy| fail with |
| 428 // an error. | 433 // an error. |
| 429 SetFakeResponse(k20BytePolicyURL, std::string(), | 434 SetFakeResponse(k20BytePolicyURL, std::string(), |
| 430 net::HTTP_INTERNAL_SERVER_ERROR); | 435 net::HTTP_INTERNAL_SERVER_ERROR, |
| 436 net::URLRequestStatus::FAILED); |
| 431 external_data_manager_->Connect(request_content_getter_); | 437 external_data_manager_->Connect(request_content_getter_); |
| 432 | 438 |
| 433 // Attempt to retrieve external data for |k20BytePolicy|. Verify that the | 439 // Attempt to retrieve external data for |k20BytePolicy|. Verify that the |
| 434 // callback is not invoked as the download attempt fails and the request | 440 // callback is not invoked as the download attempt fails and the request |
| 435 // remains pending. | 441 // remains pending. |
| 436 external_data_manager_->Fetch(k20BytePolicy, ConstructFetchCallback(0)); | 442 external_data_manager_->Fetch(k20BytePolicy, ConstructFetchCallback(0)); |
| 437 base::RunLoop().RunUntilIdle(); | 443 base::RunLoop().RunUntilIdle(); |
| 438 EXPECT_TRUE(callback_data_.empty()); | 444 EXPECT_TRUE(callback_data_.empty()); |
| 439 ResetCallbackData(); | 445 ResetCallbackData(); |
| 440 | 446 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 455 | 461 |
| 456 // Modify the external data reference for |k20BytePolicy|, allowing the | 462 // Modify the external data reference for |k20BytePolicy|, allowing the |
| 457 // download to be retried immediately. | 463 // download to be retried immediately. |
| 458 SetExternalDataReference( | 464 SetExternalDataReference( |
| 459 k20BytePolicy, | 465 k20BytePolicy, |
| 460 ConstructMetadata(k20BytePolicyURL, base::SHA1HashString(k20ByteData))); | 466 ConstructMetadata(k20BytePolicyURL, base::SHA1HashString(k20ByteData))); |
| 461 cloud_policy_store_.NotifyStoreLoaded(); | 467 cloud_policy_store_.NotifyStoreLoaded(); |
| 462 | 468 |
| 463 // Serve external data for |k20BytePolicy| that does not match the hash | 469 // Serve external data for |k20BytePolicy| that does not match the hash |
| 464 // specified in its current external data reference. | 470 // specified in its current external data reference. |
| 465 SetFakeResponse(k20BytePolicyURL, k10ByteData, net::HTTP_OK); | 471 SetFakeResponse(k20BytePolicyURL, k10ByteData, net::HTTP_OK, |
| 472 net::URLRequestStatus::SUCCESS); |
| 466 | 473 |
| 467 // Attempt to retrieve external data for |k20BytePolicy| again. Verify that | 474 // Attempt to retrieve external data for |k20BytePolicy| again. Verify that |
| 468 // no callback is invoked still as the downloaded succeeds but returns data | 475 // no callback is invoked still as the downloaded succeeds but returns data |
| 469 // that does not match the external data reference. | 476 // that does not match the external data reference. |
| 470 external_data_manager_->Fetch(k20BytePolicy, ConstructFetchCallback(2)); | 477 external_data_manager_->Fetch(k20BytePolicy, ConstructFetchCallback(2)); |
| 471 base::RunLoop().RunUntilIdle(); | 478 base::RunLoop().RunUntilIdle(); |
| 472 EXPECT_TRUE(callback_data_.empty()); | 479 EXPECT_TRUE(callback_data_.empty()); |
| 473 ResetCallbackData(); | 480 ResetCallbackData(); |
| 474 | 481 |
| 475 // Modify the external data reference for |k20BytePolicy|, allowing the | 482 // Modify the external data reference for |k20BytePolicy|, allowing the |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 // Store external data for |k20BytePolicy| that is corrupted and does not | 631 // Store external data for |k20BytePolicy| that is corrupted and does not |
| 625 // match the expected hash. | 632 // match the expected hash. |
| 626 EXPECT_TRUE(cache->Store(k20BytePolicy, | 633 EXPECT_TRUE(cache->Store(k20BytePolicy, |
| 627 base::SHA1HashString(k20ByteData), | 634 base::SHA1HashString(k20ByteData), |
| 628 k10ByteData)); | 635 k10ByteData)); |
| 629 cache.reset(); | 636 cache.reset(); |
| 630 | 637 |
| 631 SetUpExternalDataManager(); | 638 SetUpExternalDataManager(); |
| 632 // Serve external data for |k10BytePolicy| that exceeds the maximal external | 639 // Serve external data for |k10BytePolicy| that exceeds the maximal external |
| 633 // data size allowed for that policy. | 640 // data size allowed for that policy. |
| 634 SetFakeResponse(k10BytePolicyURL, k20ByteData, net::HTTP_OK); | 641 SetFakeResponse(k10BytePolicyURL, k20ByteData, net::HTTP_OK, |
| 642 net::URLRequestStatus::SUCCESS); |
| 635 external_data_manager_->Connect(request_content_getter_); | 643 external_data_manager_->Connect(request_content_getter_); |
| 636 | 644 |
| 637 // Modify the external data reference for |k10BytePolicy| to match the | 645 // Modify the external data reference for |k10BytePolicy| to match the |
| 638 // external data being served. | 646 // external data being served. |
| 639 SetExternalDataReference( | 647 SetExternalDataReference( |
| 640 k10BytePolicy, | 648 k10BytePolicy, |
| 641 ConstructMetadata(k10BytePolicyURL, base::SHA1HashString(k20ByteData))); | 649 ConstructMetadata(k10BytePolicyURL, base::SHA1HashString(k20ByteData))); |
| 642 cloud_policy_store_.NotifyStoreLoaded(); | 650 cloud_policy_store_.NotifyStoreLoaded(); |
| 643 | 651 |
| 644 // Retrieve external data for |k10BytePolicy|. Verify that the callback is | 652 // Retrieve external data for |k10BytePolicy|. Verify that the callback is |
| 645 // not invoked as the cached and downloaded external data exceed the maximal | 653 // not invoked as the cached and downloaded external data exceed the maximal |
| 646 // size allowed for this policy and the request remains pending. | 654 // size allowed for this policy and the request remains pending. |
| 647 external_data_manager_->Fetch(k10BytePolicy, ConstructFetchCallback(0)); | 655 external_data_manager_->Fetch(k10BytePolicy, ConstructFetchCallback(0)); |
| 648 base::RunLoop().RunUntilIdle(); | 656 base::RunLoop().RunUntilIdle(); |
| 649 EXPECT_TRUE(callback_data_.empty()); | 657 EXPECT_TRUE(callback_data_.empty()); |
| 650 ResetCallbackData(); | 658 ResetCallbackData(); |
| 651 | 659 |
| 652 // Serve valid external data for |k20BytePolicy|. | 660 // Serve valid external data for |k20BytePolicy|. |
| 653 SetFakeResponse(k20BytePolicyURL, k20ByteData, net::HTTP_OK); | 661 SetFakeResponse(k20BytePolicyURL, k20ByteData, net::HTTP_OK, |
| 662 net::URLRequestStatus::SUCCESS); |
| 654 | 663 |
| 655 // Retrieve external data for |k20BytePolicy|. Verify that the callback is | 664 // Retrieve external data for |k20BytePolicy|. Verify that the callback is |
| 656 // invoked with the valid downloaded data, not the invalid data in the cache. | 665 // invoked with the valid downloaded data, not the invalid data in the cache. |
| 657 external_data_manager_->Fetch(k20BytePolicy, ConstructFetchCallback(1)); | 666 external_data_manager_->Fetch(k20BytePolicy, ConstructFetchCallback(1)); |
| 658 base::RunLoop().RunUntilIdle(); | 667 base::RunLoop().RunUntilIdle(); |
| 659 EXPECT_EQ(1u, callback_data_.size()); | 668 EXPECT_EQ(1u, callback_data_.size()); |
| 660 ASSERT_TRUE(callback_data_[1]); | 669 ASSERT_TRUE(callback_data_[1]); |
| 661 EXPECT_EQ(k20ByteData, *callback_data_[1]); | 670 EXPECT_EQ(k20ByteData, *callback_data_[1]); |
| 662 ResetCallbackData(); | 671 ResetCallbackData(); |
| 663 | 672 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 685 EXPECT_EQ(k20ByteData, data); | 694 EXPECT_EQ(k20ByteData, data); |
| 686 } | 695 } |
| 687 | 696 |
| 688 // Verifies that when the external data reference for a policy changes while a | 697 // Verifies that when the external data reference for a policy changes while a |
| 689 // download of the external data for that policy is pending, the download is | 698 // download of the external data for that policy is pending, the download is |
| 690 // immediately retried using the new reference. | 699 // immediately retried using the new reference. |
| 691 TEST_F(CloudExternalDataManagerBaseTest, PolicyChangeWhileDownloadPending) { | 700 TEST_F(CloudExternalDataManagerBaseTest, PolicyChangeWhileDownloadPending) { |
| 692 // Make attempts to download the external data for |k10BytePolicy| and | 701 // Make attempts to download the external data for |k10BytePolicy| and |
| 693 // |k20BytePolicy| fail with an error. | 702 // |k20BytePolicy| fail with an error. |
| 694 SetFakeResponse(k10BytePolicyURL, std::string(), | 703 SetFakeResponse(k10BytePolicyURL, std::string(), |
| 695 net::HTTP_INTERNAL_SERVER_ERROR); | 704 net::HTTP_INTERNAL_SERVER_ERROR, |
| 705 net::URLRequestStatus::FAILED); |
| 696 SetFakeResponse(k20BytePolicyURL, std::string(), | 706 SetFakeResponse(k20BytePolicyURL, std::string(), |
| 697 net::HTTP_INTERNAL_SERVER_ERROR); | 707 net::HTTP_INTERNAL_SERVER_ERROR, |
| 708 net::URLRequestStatus::FAILED); |
| 698 external_data_manager_->Connect(request_content_getter_); | 709 external_data_manager_->Connect(request_content_getter_); |
| 699 | 710 |
| 700 // Attempt to retrieve external data for |k10BytePolicy| and |k20BytePolicy|. | 711 // Attempt to retrieve external data for |k10BytePolicy| and |k20BytePolicy|. |
| 701 // Verify that no callbacks are invoked as the download attempts fail and the | 712 // Verify that no callbacks are invoked as the download attempts fail and the |
| 702 // requests remain pending. | 713 // requests remain pending. |
| 703 external_data_manager_->Fetch(k10BytePolicy, ConstructFetchCallback(0)); | 714 external_data_manager_->Fetch(k10BytePolicy, ConstructFetchCallback(0)); |
| 704 external_data_manager_->Fetch(k20BytePolicy, ConstructFetchCallback(1)); | 715 external_data_manager_->Fetch(k20BytePolicy, ConstructFetchCallback(1)); |
| 705 base::RunLoop().RunUntilIdle(); | 716 base::RunLoop().RunUntilIdle(); |
| 706 EXPECT_TRUE(callback_data_.empty()); | 717 EXPECT_TRUE(callback_data_.empty()); |
| 707 ResetCallbackData(); | 718 ResetCallbackData(); |
| 708 | 719 |
| 709 // Modify the external data reference for |k10BytePolicy| to be invalid. | 720 // Modify the external data reference for |k10BytePolicy| to be invalid. |
| 710 // Verify that the callback is invoked as the policy no longer has a valid | 721 // Verify that the callback is invoked as the policy no longer has a valid |
| 711 // external data reference. | 722 // external data reference. |
| 712 cloud_policy_store_.policy_map_.Erase(k10BytePolicy); | 723 cloud_policy_store_.policy_map_.Erase(k10BytePolicy); |
| 713 cloud_policy_store_.NotifyStoreLoaded(); | 724 cloud_policy_store_.NotifyStoreLoaded(); |
| 714 base::RunLoop().RunUntilIdle(); | 725 base::RunLoop().RunUntilIdle(); |
| 715 EXPECT_EQ(1u, callback_data_.size()); | 726 EXPECT_EQ(1u, callback_data_.size()); |
| 716 EXPECT_TRUE(callback_data_.find(0) != callback_data_.end()); | 727 EXPECT_TRUE(callback_data_.find(0) != callback_data_.end()); |
| 717 EXPECT_FALSE(callback_data_[0]); | 728 EXPECT_FALSE(callback_data_[0]); |
| 718 ResetCallbackData(); | 729 ResetCallbackData(); |
| 719 | 730 |
| 720 // Serve valid external data for |k20BytePolicy|. | 731 // Serve valid external data for |k20BytePolicy|. |
| 721 fetcher_factory_.ClearFakeResponses(); | 732 fetcher_factory_.ClearFakeResponses(); |
| 722 SetFakeResponse(k20BytePolicyURL, k10ByteData, net::HTTP_OK); | 733 SetFakeResponse(k20BytePolicyURL, k10ByteData, net::HTTP_OK, |
| 734 net::URLRequestStatus::SUCCESS); |
| 723 | 735 |
| 724 // Modify the external data reference for |k20BytePolicy| to match the | 736 // Modify the external data reference for |k20BytePolicy| to match the |
| 725 // external data now being served. Verify that the callback is invoked with | 737 // external data now being served. Verify that the callback is invoked with |
| 726 // the downloaded data. | 738 // the downloaded data. |
| 727 SetExternalDataReference( | 739 SetExternalDataReference( |
| 728 k20BytePolicy, | 740 k20BytePolicy, |
| 729 ConstructMetadata(k20BytePolicyURL, base::SHA1HashString(k10ByteData))); | 741 ConstructMetadata(k20BytePolicyURL, base::SHA1HashString(k10ByteData))); |
| 730 cloud_policy_store_.NotifyStoreLoaded(); | 742 cloud_policy_store_.NotifyStoreLoaded(); |
| 731 base::RunLoop().RunUntilIdle(); | 743 base::RunLoop().RunUntilIdle(); |
| 732 EXPECT_EQ(1u, callback_data_.size()); | 744 EXPECT_EQ(1u, callback_data_.size()); |
| 733 ASSERT_TRUE(callback_data_[1]); | 745 ASSERT_TRUE(callback_data_[1]); |
| 734 EXPECT_EQ(k10ByteData, *callback_data_[1]); | 746 EXPECT_EQ(k10ByteData, *callback_data_[1]); |
| 735 ResetCallbackData(); | 747 ResetCallbackData(); |
| 736 } | 748 } |
| 737 | 749 |
| 738 } // namespace policy | 750 } // namespace policy |
| OLD | NEW |