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

Side by Side Diff: chrome/browser/chromeos/settings/session_manager_operation_unittest.cc

Issue 2486813002: Add DeviceADPolicyManager to provide AD policy. (Closed)
Patch Set: Address Bernhard's comments Created 4 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 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/settings/session_manager_operation.h" 5 #include "chrome/browser/chromeos/settings/session_manager_operation.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 OwnerSettingsServiceChromeOS* service_; 100 OwnerSettingsServiceChromeOS* service_;
101 101
102 bool validated_; 102 bool validated_;
103 103
104 private: 104 private:
105 DISALLOW_COPY_AND_ASSIGN(SessionManagerOperationTest); 105 DISALLOW_COPY_AND_ASSIGN(SessionManagerOperationTest);
106 }; 106 };
107 107
108 TEST_F(SessionManagerOperationTest, LoadNoPolicyNoKey) { 108 TEST_F(SessionManagerOperationTest, LoadNoPolicyNoKey) {
109 LoadSettingsOperation op( 109 LoadSettingsOperation op(
110 false /* force_key_load */, true /* cloud_validations */,
110 base::Bind(&SessionManagerOperationTest::OnOperationCompleted, 111 base::Bind(&SessionManagerOperationTest::OnOperationCompleted,
111 base::Unretained(this))); 112 base::Unretained(this)));
112 113
113 EXPECT_CALL(*this, 114 EXPECT_CALL(*this,
114 OnOperationCompleted( 115 OnOperationCompleted(
115 &op, DeviceSettingsService::STORE_KEY_UNAVAILABLE)); 116 &op, DeviceSettingsService::STORE_KEY_UNAVAILABLE));
116 op.Start(&device_settings_test_helper_, owner_key_util_, NULL); 117 op.Start(&device_settings_test_helper_, owner_key_util_, NULL);
117 device_settings_test_helper_.Flush(); 118 device_settings_test_helper_.Flush();
118 Mock::VerifyAndClearExpectations(this); 119 Mock::VerifyAndClearExpectations(this);
119 120
120 EXPECT_FALSE(op.policy_data().get()); 121 EXPECT_FALSE(op.policy_data().get());
121 EXPECT_FALSE(op.device_settings().get()); 122 EXPECT_FALSE(op.device_settings().get());
122 ASSERT_TRUE(op.public_key().get()); 123 ASSERT_TRUE(op.public_key().get());
123 EXPECT_FALSE(op.public_key()->is_loaded()); 124 EXPECT_FALSE(op.public_key()->is_loaded());
124 } 125 }
125 126
126 TEST_F(SessionManagerOperationTest, LoadOwnerKey) { 127 TEST_F(SessionManagerOperationTest, LoadOwnerKey) {
127 owner_key_util_->SetPublicKeyFromPrivateKey(*policy_.GetSigningKey()); 128 owner_key_util_->SetPublicKeyFromPrivateKey(*policy_.GetSigningKey());
128 LoadSettingsOperation op( 129 LoadSettingsOperation op(
130 false /* force_key_load */, true /* cloud_validations */,
129 base::Bind(&SessionManagerOperationTest::OnOperationCompleted, 131 base::Bind(&SessionManagerOperationTest::OnOperationCompleted,
130 base::Unretained(this))); 132 base::Unretained(this)));
131 133
132 EXPECT_CALL(*this, 134 EXPECT_CALL(*this,
133 OnOperationCompleted( 135 OnOperationCompleted(
134 &op, DeviceSettingsService::STORE_NO_POLICY)); 136 &op, DeviceSettingsService::STORE_NO_POLICY));
135 op.Start(&device_settings_test_helper_, owner_key_util_, NULL); 137 op.Start(&device_settings_test_helper_, owner_key_util_, NULL);
136 device_settings_test_helper_.Flush(); 138 device_settings_test_helper_.Flush();
137 Mock::VerifyAndClearExpectations(this); 139 Mock::VerifyAndClearExpectations(this);
138 140
139 CheckPublicKeyLoaded(&op); 141 CheckPublicKeyLoaded(&op);
140 } 142 }
141 143
142 TEST_F(SessionManagerOperationTest, LoadPolicy) { 144 TEST_F(SessionManagerOperationTest, LoadPolicy) {
143 owner_key_util_->SetPublicKeyFromPrivateKey(*policy_.GetSigningKey()); 145 owner_key_util_->SetPublicKeyFromPrivateKey(*policy_.GetSigningKey());
144 device_settings_test_helper_.set_policy_blob(policy_.GetBlob()); 146 device_settings_test_helper_.set_policy_blob(policy_.GetBlob());
145 LoadSettingsOperation op( 147 LoadSettingsOperation op(
148 false /* force_key_load */, true /* cloud_validations */,
146 base::Bind(&SessionManagerOperationTest::OnOperationCompleted, 149 base::Bind(&SessionManagerOperationTest::OnOperationCompleted,
147 base::Unretained(this))); 150 base::Unretained(this)));
148 151
149 EXPECT_CALL(*this, 152 EXPECT_CALL(*this,
150 OnOperationCompleted( 153 OnOperationCompleted(
151 &op, DeviceSettingsService::STORE_SUCCESS)); 154 &op, DeviceSettingsService::STORE_SUCCESS));
152 op.Start(&device_settings_test_helper_, owner_key_util_, NULL); 155 op.Start(&device_settings_test_helper_, owner_key_util_, NULL);
153 device_settings_test_helper_.Flush(); 156 device_settings_test_helper_.Flush();
154 Mock::VerifyAndClearExpectations(this); 157 Mock::VerifyAndClearExpectations(this);
155 158
156 ASSERT_TRUE(op.policy_data().get()); 159 ASSERT_TRUE(op.policy_data().get());
157 EXPECT_EQ(policy_.policy_data().SerializeAsString(), 160 EXPECT_EQ(policy_.policy_data().SerializeAsString(),
158 op.policy_data()->SerializeAsString()); 161 op.policy_data()->SerializeAsString());
159 ASSERT_TRUE(op.device_settings().get()); 162 ASSERT_TRUE(op.device_settings().get());
160 EXPECT_EQ(policy_.payload().SerializeAsString(), 163 EXPECT_EQ(policy_.payload().SerializeAsString(),
161 op.device_settings()->SerializeAsString()); 164 op.device_settings()->SerializeAsString());
162 } 165 }
163 166
164 TEST_F(SessionManagerOperationTest, RestartLoad) { 167 TEST_F(SessionManagerOperationTest, RestartLoad) {
165 owner_key_util_->SetPrivateKey(policy_.GetSigningKey()); 168 owner_key_util_->SetPrivateKey(policy_.GetSigningKey());
166 device_settings_test_helper_.set_policy_blob(policy_.GetBlob()); 169 device_settings_test_helper_.set_policy_blob(policy_.GetBlob());
167 LoadSettingsOperation op( 170 LoadSettingsOperation op(
171 false /* force_key_load */, true /* cloud_validations */,
168 base::Bind(&SessionManagerOperationTest::OnOperationCompleted, 172 base::Bind(&SessionManagerOperationTest::OnOperationCompleted,
169 base::Unretained(this))); 173 base::Unretained(this)));
170 174
171 EXPECT_CALL(*this, OnOperationCompleted(&op, _)).Times(0); 175 EXPECT_CALL(*this, OnOperationCompleted(&op, _)).Times(0);
172 op.Start(&device_settings_test_helper_, owner_key_util_, NULL); 176 op.Start(&device_settings_test_helper_, owner_key_util_, NULL);
173 content::RunAllBlockingPoolTasksUntilIdle(); 177 content::RunAllBlockingPoolTasksUntilIdle();
174 device_settings_test_helper_.FlushRetrieve(); 178 device_settings_test_helper_.FlushRetrieve();
175 EXPECT_TRUE(op.public_key().get()); 179 EXPECT_TRUE(op.public_key().get());
176 EXPECT_TRUE(op.public_key()->is_loaded()); 180 EXPECT_TRUE(op.public_key()->is_loaded());
177 Mock::VerifyAndClearExpectations(this); 181 Mock::VerifyAndClearExpectations(this);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 policy_.GetBlob()); 224 policy_.GetBlob());
221 ASSERT_TRUE(op.policy_data().get()); 225 ASSERT_TRUE(op.policy_data().get());
222 EXPECT_EQ(policy_.policy_data().SerializeAsString(), 226 EXPECT_EQ(policy_.policy_data().SerializeAsString(),
223 op.policy_data()->SerializeAsString()); 227 op.policy_data()->SerializeAsString());
224 ASSERT_TRUE(op.device_settings().get()); 228 ASSERT_TRUE(op.device_settings().get());
225 EXPECT_EQ(policy_.payload().SerializeAsString(), 229 EXPECT_EQ(policy_.payload().SerializeAsString(),
226 op.device_settings()->SerializeAsString()); 230 op.device_settings()->SerializeAsString());
227 } 231 }
228 232
229 } // namespace chromeos 233 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698