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

Unified Diff: components/policy/core/common/cloud/cloud_policy_client_unittest.cc

Issue 756133002: Purge cache when the server removes the policy for an extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: components/policy/core/common/cloud/cloud_policy_client_unittest.cc
diff --git a/components/policy/core/common/cloud/cloud_policy_client_unittest.cc b/components/policy/core/common/cloud/cloud_policy_client_unittest.cc
index 852a45c53d934aa8425a377ff72666163c24e819..d825481e7a68fb6ebe2008971bf7f8d48c21df6b 100644
--- a/components/policy/core/common/cloud/cloud_policy_client_unittest.cc
+++ b/components/policy/core/common/cloud/cloud_policy_client_unittest.cc
@@ -12,6 +12,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
+#include "base/stl_util.h"
#include "components/policy/core/common/cloud/mock_cloud_policy_client.h"
#include "components/policy/core/common/cloud/mock_device_management_service.h"
#include "net/url_request/url_request_context_getter.h"
@@ -491,6 +492,7 @@ TEST_F(CloudPolicyClientTest, PolicyFetchWithExtensionPolicy) {
policy_response_.policy_response().response(0));
expected_namespaces.insert(key);
key.first = dm_protocol::kChromeExtensionPolicyType;
+ expected_namespaces.insert(key);
for (size_t i = 0; i < arraysize(kExtensions); ++i) {
key.second = kExtensions[i];
em::PolicyData policy_data;
@@ -499,7 +501,6 @@ TEST_F(CloudPolicyClientTest, PolicyFetchWithExtensionPolicy) {
expected_responses[key].set_policy_data(policy_data.SerializeAsString());
policy_response_.mutable_policy_response()->add_response()->CopyFrom(
expected_responses[key]);
- expected_namespaces.insert(key);
}
// Make a policy fetch.
@@ -514,30 +515,30 @@ TEST_F(CloudPolicyClientTest, PolicyFetchWithExtensionPolicy) {
.WillOnce(SaveArg<6>(&policy_request_));
EXPECT_CALL(observer_, OnPolicyFetched(_));
EXPECT_CALL(status_provider_, OnSubmittedSuccessfully());
- for (size_t i = 0; i < arraysize(kExtensions); ++i) {
- client_->AddNamespaceToFetch(PolicyNamespaceKey(
- dm_protocol::kChromeExtensionPolicyType, kExtensions[i]));
- }
+ client_->AddNamespaceToFetch(
+ PolicyNamespaceKey(dm_protocol::kChromeExtensionPolicyType, ""));
client_->FetchPolicy();
// Verify that the request includes the expected namespaces.
ASSERT_TRUE(policy_request_.has_policy_request());
const em::DevicePolicyRequest& policy_request =
policy_request_.policy_request();
- ASSERT_EQ(static_cast<int>(1 + arraysize(kExtensions)),
- policy_request.request_size());
+ ASSERT_EQ(2, policy_request.request_size());
for (int i = 0; i < policy_request.request_size(); ++i) {
const em::PolicyFetchRequest& fetch_request = policy_request.request(i);
ASSERT_TRUE(fetch_request.has_policy_type());
- std::string entity_id;
- if (fetch_request.has_settings_entity_id())
- entity_id = fetch_request.settings_entity_id();
- PolicyNamespaceKey key(fetch_request.policy_type(), entity_id);
+ EXPECT_FALSE(fetch_request.has_settings_entity_id());
+ PolicyNamespaceKey key(fetch_request.policy_type(), "");
EXPECT_EQ(1u, expected_namespaces.erase(key));
}
EXPECT_TRUE(expected_namespaces.empty());
// Verify that the client got all the responses mapped to their namespaces.
+ EXPECT_EQ(2u, client_->namespaces_requested().size());
+ EXPECT_TRUE(ContainsKey(client_->namespaces_requested(), policy_ns_key_));
+ EXPECT_TRUE(ContainsKey(
+ client_->namespaces_requested(),
+ PolicyNamespaceKey(dm_protocol::kChromeExtensionPolicyType, "")));
for (ResponseMap::iterator it = expected_responses.begin();
it != expected_responses.end(); ++it) {
const em::PolicyFetchResponse* response = client_->GetPolicyFor(it->first);

Powered by Google App Engine
This is Rietveld 408576698