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

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

Issue 2486813002: Add DeviceADPolicyManager to provide AD policy. (Closed)
Patch Set: 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
emaxx 2016/11/11 15:25:09 Not insisting, but I saw the following style of co
Thiemo Nagel 2016/11/16 19:11:01 Done.
111 true, // verify_signature
110 base::Bind(&SessionManagerOperationTest::OnOperationCompleted, 112 base::Bind(&SessionManagerOperationTest::OnOperationCompleted,
111 base::Unretained(this))); 113 base::Unretained(this)));
112 114
113 EXPECT_CALL(*this, 115 EXPECT_CALL(*this,
114 OnOperationCompleted( 116 OnOperationCompleted(
115 &op, DeviceSettingsService::STORE_KEY_UNAVAILABLE)); 117 &op, DeviceSettingsService::STORE_KEY_UNAVAILABLE));
116 op.Start(&device_settings_test_helper_, owner_key_util_, NULL); 118 op.Start(&device_settings_test_helper_, owner_key_util_, NULL);
117 device_settings_test_helper_.Flush(); 119 device_settings_test_helper_.Flush();
118 Mock::VerifyAndClearExpectations(this); 120 Mock::VerifyAndClearExpectations(this);
119 121
120 EXPECT_FALSE(op.policy_data().get()); 122 EXPECT_FALSE(op.policy_data().get());
121 EXPECT_FALSE(op.device_settings().get()); 123 EXPECT_FALSE(op.device_settings().get());
122 ASSERT_TRUE(op.public_key().get()); 124 ASSERT_TRUE(op.public_key().get());
123 EXPECT_FALSE(op.public_key()->is_loaded()); 125 EXPECT_FALSE(op.public_key()->is_loaded());
124 } 126 }
125 127
126 TEST_F(SessionManagerOperationTest, LoadOwnerKey) { 128 TEST_F(SessionManagerOperationTest, LoadOwnerKey) {
127 owner_key_util_->SetPublicKeyFromPrivateKey(*policy_.GetSigningKey()); 129 owner_key_util_->SetPublicKeyFromPrivateKey(*policy_.GetSigningKey());
128 LoadSettingsOperation op( 130 LoadSettingsOperation op(
131 false, // force_key_load
132 true, // verify_signature
129 base::Bind(&SessionManagerOperationTest::OnOperationCompleted, 133 base::Bind(&SessionManagerOperationTest::OnOperationCompleted,
130 base::Unretained(this))); 134 base::Unretained(this)));
131 135
132 EXPECT_CALL(*this, 136 EXPECT_CALL(*this,
133 OnOperationCompleted( 137 OnOperationCompleted(
134 &op, DeviceSettingsService::STORE_NO_POLICY)); 138 &op, DeviceSettingsService::STORE_NO_POLICY));
135 op.Start(&device_settings_test_helper_, owner_key_util_, NULL); 139 op.Start(&device_settings_test_helper_, owner_key_util_, NULL);
136 device_settings_test_helper_.Flush(); 140 device_settings_test_helper_.Flush();
137 Mock::VerifyAndClearExpectations(this); 141 Mock::VerifyAndClearExpectations(this);
138 142
139 CheckPublicKeyLoaded(&op); 143 CheckPublicKeyLoaded(&op);
140 } 144 }
141 145
142 TEST_F(SessionManagerOperationTest, LoadPolicy) { 146 TEST_F(SessionManagerOperationTest, LoadPolicy) {
143 owner_key_util_->SetPublicKeyFromPrivateKey(*policy_.GetSigningKey()); 147 owner_key_util_->SetPublicKeyFromPrivateKey(*policy_.GetSigningKey());
144 device_settings_test_helper_.set_policy_blob(policy_.GetBlob()); 148 device_settings_test_helper_.set_policy_blob(policy_.GetBlob());
145 LoadSettingsOperation op( 149 LoadSettingsOperation op(
150 false, // force_key_load
151 true, // verify_signature
146 base::Bind(&SessionManagerOperationTest::OnOperationCompleted, 152 base::Bind(&SessionManagerOperationTest::OnOperationCompleted,
147 base::Unretained(this))); 153 base::Unretained(this)));
148 154
149 EXPECT_CALL(*this, 155 EXPECT_CALL(*this,
150 OnOperationCompleted( 156 OnOperationCompleted(
151 &op, DeviceSettingsService::STORE_SUCCESS)); 157 &op, DeviceSettingsService::STORE_SUCCESS));
152 op.Start(&device_settings_test_helper_, owner_key_util_, NULL); 158 op.Start(&device_settings_test_helper_, owner_key_util_, NULL);
153 device_settings_test_helper_.Flush(); 159 device_settings_test_helper_.Flush();
154 Mock::VerifyAndClearExpectations(this); 160 Mock::VerifyAndClearExpectations(this);
155 161
156 ASSERT_TRUE(op.policy_data().get()); 162 ASSERT_TRUE(op.policy_data().get());
157 EXPECT_EQ(policy_.policy_data().SerializeAsString(), 163 EXPECT_EQ(policy_.policy_data().SerializeAsString(),
158 op.policy_data()->SerializeAsString()); 164 op.policy_data()->SerializeAsString());
159 ASSERT_TRUE(op.device_settings().get()); 165 ASSERT_TRUE(op.device_settings().get());
160 EXPECT_EQ(policy_.payload().SerializeAsString(), 166 EXPECT_EQ(policy_.payload().SerializeAsString(),
161 op.device_settings()->SerializeAsString()); 167 op.device_settings()->SerializeAsString());
162 } 168 }
163 169
164 TEST_F(SessionManagerOperationTest, RestartLoad) { 170 TEST_F(SessionManagerOperationTest, RestartLoad) {
165 owner_key_util_->SetPrivateKey(policy_.GetSigningKey()); 171 owner_key_util_->SetPrivateKey(policy_.GetSigningKey());
166 device_settings_test_helper_.set_policy_blob(policy_.GetBlob()); 172 device_settings_test_helper_.set_policy_blob(policy_.GetBlob());
167 LoadSettingsOperation op( 173 LoadSettingsOperation op(
174 false, // force_key_load
175 true, // verify_signature
168 base::Bind(&SessionManagerOperationTest::OnOperationCompleted, 176 base::Bind(&SessionManagerOperationTest::OnOperationCompleted,
169 base::Unretained(this))); 177 base::Unretained(this)));
170 178
171 EXPECT_CALL(*this, OnOperationCompleted(&op, _)).Times(0); 179 EXPECT_CALL(*this, OnOperationCompleted(&op, _)).Times(0);
172 op.Start(&device_settings_test_helper_, owner_key_util_, NULL); 180 op.Start(&device_settings_test_helper_, owner_key_util_, NULL);
173 content::RunAllBlockingPoolTasksUntilIdle(); 181 content::RunAllBlockingPoolTasksUntilIdle();
174 device_settings_test_helper_.FlushRetrieve(); 182 device_settings_test_helper_.FlushRetrieve();
175 EXPECT_TRUE(op.public_key().get()); 183 EXPECT_TRUE(op.public_key().get());
176 EXPECT_TRUE(op.public_key()->is_loaded()); 184 EXPECT_TRUE(op.public_key()->is_loaded());
177 Mock::VerifyAndClearExpectations(this); 185 Mock::VerifyAndClearExpectations(this);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 policy_.GetBlob()); 228 policy_.GetBlob());
221 ASSERT_TRUE(op.policy_data().get()); 229 ASSERT_TRUE(op.policy_data().get());
222 EXPECT_EQ(policy_.policy_data().SerializeAsString(), 230 EXPECT_EQ(policy_.policy_data().SerializeAsString(),
223 op.policy_data()->SerializeAsString()); 231 op.policy_data()->SerializeAsString());
224 ASSERT_TRUE(op.device_settings().get()); 232 ASSERT_TRUE(op.device_settings().get());
225 EXPECT_EQ(policy_.payload().SerializeAsString(), 233 EXPECT_EQ(policy_.payload().SerializeAsString(),
226 op.device_settings()->SerializeAsString()); 234 op.device_settings()->SerializeAsString());
227 } 235 }
228 236
229 } // namespace chromeos 237 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698