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

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

Issue 762863002: Removed policy::PolicyNamespaceKey. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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..73e8472631c7dd5da8f6a75b3b88d5979fb860bf 100644
--- a/components/policy/core/common/cloud/cloud_policy_client_unittest.cc
+++ b/components/policy/core/common/cloud/cloud_policy_client_unittest.cc
@@ -73,7 +73,7 @@ class CloudPolicyClientTest : public testing::Test {
protected:
CloudPolicyClientTest()
: client_id_(kClientID),
- policy_ns_key_(dm_protocol::kChromeUserPolicyType, std::string()) {
+ policy_type_(dm_protocol::kChromeUserPolicyType) {
em::DeviceRegisterRequest* register_request =
registration_request_.mutable_register_request();
register_request->set_type(em::DeviceRegisterRequest::USER);
@@ -125,7 +125,7 @@ class CloudPolicyClientTest : public testing::Test {
user_affiliation, &status_provider_,
&service_,
request_context_));
- client_->AddNamespaceToFetch(policy_ns_key_);
+ client_->AddPolicyTypeToFetch(policy_type_, "");
client_->AddObserver(&observer_);
}
@@ -173,8 +173,8 @@ class CloudPolicyClientTest : public testing::Test {
}
void CheckPolicyResponse() {
- ASSERT_TRUE(client_->GetPolicyFor(policy_ns_key_));
- EXPECT_THAT(*client_->GetPolicyFor(policy_ns_key_),
+ ASSERT_TRUE(client_->GetPolicyFor(policy_type_, ""));
+ EXPECT_THAT(*client_->GetPolicyFor(policy_type_, ""),
MatchProto(policy_response_.policy_response().response(0)));
}
@@ -199,7 +199,7 @@ class CloudPolicyClientTest : public testing::Test {
base::MessageLoop loop_;
std::string client_id_;
- PolicyNamespaceKey policy_ns_key_;
+ std::string policy_type_;
MockDeviceManagementService service_;
StrictMock<MockStatusProvider> status_provider_;
StrictMock<MockCloudPolicyClientObserver> observer_;
@@ -212,7 +212,7 @@ class CloudPolicyClientTest : public testing::Test {
TEST_F(CloudPolicyClientTest, Init) {
EXPECT_CALL(service_, CreateJob(_, _)).Times(0);
EXPECT_FALSE(client_->is_registered());
- EXPECT_FALSE(client_->GetPolicyFor(policy_ns_key_));
+ EXPECT_FALSE(client_->GetPolicyFor(policy_type_, ""));
EXPECT_EQ(0, client_->fetched_invalidation_version());
}
@@ -221,7 +221,7 @@ TEST_F(CloudPolicyClientTest, SetupRegistrationAndPolicyFetch) {
EXPECT_CALL(observer_, OnRegistrationStateChanged(_));
client_->SetupRegistration(kDMToken, client_id_);
EXPECT_TRUE(client_->is_registered());
- EXPECT_FALSE(client_->GetPolicyFor(policy_ns_key_));
+ EXPECT_FALSE(client_->GetPolicyFor(policy_type_, ""));
ExpectPolicyFetch(kDMToken, dm_protocol::kValueUserAffiliationNone);
EXPECT_CALL(observer_, OnPolicyFetched(_));
@@ -237,7 +237,7 @@ TEST_F(CloudPolicyClientTest, RegistrationAndPolicyFetch) {
client_->Register(em::DeviceRegisterRequest::USER, kOAuthToken, std::string(),
false, std::string(), std::string());
EXPECT_TRUE(client_->is_registered());
- EXPECT_FALSE(client_->GetPolicyFor(policy_ns_key_));
+ EXPECT_FALSE(client_->GetPolicyFor(policy_type_, ""));
EXPECT_EQ(DM_STATUS_SUCCESS, client_->status());
ExpectPolicyFetch(kDMToken, dm_protocol::kValueUserAffiliationNone);
@@ -270,7 +270,7 @@ TEST_F(CloudPolicyClientTest, RegistrationNoToken) {
client_->Register(em::DeviceRegisterRequest::USER, kOAuthToken, std::string(),
false, std::string(), std::string());
EXPECT_FALSE(client_->is_registered());
- EXPECT_FALSE(client_->GetPolicyFor(policy_ns_key_));
+ EXPECT_FALSE(client_->GetPolicyFor(policy_type_, ""));
EXPECT_EQ(DM_STATUS_RESPONSE_DECODING_ERROR, client_->status());
}
@@ -284,7 +284,7 @@ TEST_F(CloudPolicyClientTest, RegistrationFailure) {
client_->Register(em::DeviceRegisterRequest::USER, kOAuthToken, std::string(),
false, std::string(), std::string());
EXPECT_FALSE(client_->is_registered());
- EXPECT_FALSE(client_->GetPolicyFor(policy_ns_key_));
+ EXPECT_FALSE(client_->GetPolicyFor(policy_type_, ""));
EXPECT_EQ(DM_STATUS_REQUEST_FAILED, client_->status());
}
@@ -404,7 +404,7 @@ TEST_F(CloudPolicyClientTest, BadPolicyResponse) {
ExpectPolicyFetch(kDMToken, dm_protocol::kValueUserAffiliationNone);
EXPECT_CALL(observer_, OnClientError(_));
client_->FetchPolicy();
- EXPECT_FALSE(client_->GetPolicyFor(policy_ns_key_));
+ EXPECT_FALSE(client_->GetPolicyFor(policy_type_, ""));
EXPECT_EQ(DM_STATUS_RESPONSE_DECODING_ERROR, client_->status());
policy_response_.mutable_policy_response()->add_response()->set_policy_data(
@@ -431,7 +431,7 @@ TEST_F(CloudPolicyClientTest, PolicyRequestFailure) {
EXPECT_CALL(status_provider_, OnSubmittedSuccessfully()).Times(0);
client_->FetchPolicy();
EXPECT_EQ(DM_STATUS_REQUEST_FAILED, client_->status());
- EXPECT_FALSE(client_->GetPolicyFor(policy_ns_key_));
+ EXPECT_FALSE(client_->GetPolicyFor(policy_type_, ""));
}
TEST_F(CloudPolicyClientTest, Unregister) {
@@ -482,10 +482,12 @@ TEST_F(CloudPolicyClientTest, PolicyFetchWithExtensionPolicy) {
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
"cccccccccccccccccccccccccccccccc",
};
- typedef std::map<PolicyNamespaceKey, em::PolicyFetchResponse> ResponseMap;
+ typedef std::map<std::pair<std::string, std::string>, em::PolicyFetchResponse>
+ ResponseMap;
ResponseMap expected_responses;
- std::set<PolicyNamespaceKey> expected_namespaces;
- PolicyNamespaceKey key(dm_protocol::kChromeUserPolicyType, std::string());
+ std::set<std::pair<std::string, std::string>> expected_namespaces;
+ std::pair<std::string, std::string> key(dm_protocol::kChromeUserPolicyType,
+ "");
// Copy the user policy fetch request.
expected_responses[key].CopyFrom(
policy_response_.policy_response().response(0));
@@ -515,8 +517,8 @@ TEST_F(CloudPolicyClientTest, PolicyFetchWithExtensionPolicy) {
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_->AddPolicyTypeToFetch(dm_protocol::kChromeExtensionPolicyType,
+ kExtensions[i]);
}
client_->FetchPolicy();
@@ -532,7 +534,8 @@ TEST_F(CloudPolicyClientTest, PolicyFetchWithExtensionPolicy) {
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);
+ std::pair<std::string, std::string> key(fetch_request.policy_type(),
+ entity_id);
EXPECT_EQ(1u, expected_namespaces.erase(key));
}
EXPECT_TRUE(expected_namespaces.empty());
@@ -540,7 +543,8 @@ TEST_F(CloudPolicyClientTest, PolicyFetchWithExtensionPolicy) {
// Verify that the client got all the responses mapped to their namespaces.
for (ResponseMap::iterator it = expected_responses.begin();
it != expected_responses.end(); ++it) {
- const em::PolicyFetchResponse* response = client_->GetPolicyFor(it->first);
+ const em::PolicyFetchResponse* response =
+ client_->GetPolicyFor(it->first.first, it->first.second);
ASSERT_TRUE(response);
EXPECT_EQ(it->second.SerializeAsString(), response->SerializeAsString());
}

Powered by Google App Engine
This is Rietveld 408576698