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

Side by Side Diff: chromeos/attestation/attestation_flow_unittest.cc

Issue 12556004: Created AttestationPolicyObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months 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 | Annotate | Revision Log
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h"
6 #include "base/run_loop.h" 7 #include "base/run_loop.h"
7 #include "chromeos/attestation/mock_attestation_flow.h" 8 #include "chromeos/attestation/mock_attestation_flow.h"
8 #include "chromeos/cryptohome/mock_async_method_caller.h" 9 #include "chromeos/cryptohome/mock_async_method_caller.h"
9 #include "chromeos/dbus/mock_cryptohome_client.h" 10 #include "chromeos/dbus/mock_cryptohome_client.h"
10 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 using testing::_; 14 using testing::_;
14 using testing::Invoke; 15 using testing::Invoke;
15 using testing::Sequence; 16 using testing::Sequence;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 .InSequence(flow_order) 62 .InSequence(flow_order)
62 .WillRepeatedly(Invoke(DBusCallbackFalse)); 63 .WillRepeatedly(Invoke(DBusCallbackFalse));
63 64
64 // Use StrictMock when we want to verify invocation frequency. 65 // Use StrictMock when we want to verify invocation frequency.
65 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; 66 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
66 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); 67 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE);
67 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_)) 68 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_))
68 .Times(1) 69 .Times(1)
69 .InSequence(flow_order); 70 .InSequence(flow_order);
70 71
71 StrictMock<MockServerProxy> proxy; 72 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
72 proxy.DeferToFake(true); 73 proxy->DeferToFake(true);
73 EXPECT_CALL(proxy, SendEnrollRequest( 74 EXPECT_CALL(*proxy, SendEnrollRequest(
74 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest, 75 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest,
75 _)).Times(1) 76 _)).Times(1)
76 .InSequence(flow_order); 77 .InSequence(flow_order);
77 78
78 std::string fake_enroll_response = 79 std::string fake_enroll_response =
79 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest; 80 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest;
80 fake_enroll_response += "_response"; 81 fake_enroll_response += "_response";
81 EXPECT_CALL(async_caller, AsyncTpmAttestationEnroll(fake_enroll_response, _)) 82 EXPECT_CALL(async_caller, AsyncTpmAttestationEnroll(fake_enroll_response, _))
82 .Times(1) 83 .Times(1)
83 .InSequence(flow_order); 84 .InSequence(flow_order);
84 85
85 int options = CryptohomeClient::INCLUDE_DEVICE_STATE; 86 int options = CryptohomeClient::INCLUDE_DEVICE_STATE;
86 EXPECT_CALL(async_caller, 87 EXPECT_CALL(async_caller,
87 AsyncTpmAttestationCreateCertRequest(options, _)) 88 AsyncTpmAttestationCreateCertRequest(options, _))
88 .Times(1) 89 .Times(1)
89 .InSequence(flow_order); 90 .InSequence(flow_order);
90 91
91 EXPECT_CALL(proxy, SendCertificateRequest( 92 EXPECT_CALL(*proxy, SendCertificateRequest(
92 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest, 93 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest,
93 _)).Times(1) 94 _)).Times(1)
94 .InSequence(flow_order); 95 .InSequence(flow_order);
95 96
96 std::string fake_cert_response = 97 std::string fake_cert_response =
97 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest; 98 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest;
98 fake_cert_response += "_response"; 99 fake_cert_response += "_response";
99 EXPECT_CALL(async_caller, 100 EXPECT_CALL(async_caller,
100 AsyncTpmAttestationFinishCertRequest(fake_cert_response, 101 AsyncTpmAttestationFinishCertRequest(fake_cert_response,
101 CryptohomeClient::USER_KEY, 102 CryptohomeClient::USER_KEY,
102 "test", 103 "test",
103 _)) 104 _))
104 .Times(1) 105 .Times(1)
105 .InSequence(flow_order); 106 .InSequence(flow_order);
106 107
107 StrictMock<MockObserver> observer; 108 StrictMock<MockObserver> observer;
108 EXPECT_CALL(observer, MockCertificateCallback( 109 EXPECT_CALL(observer, MockCertificateCallback(
109 true, 110 true,
110 cryptohome::MockAsyncMethodCaller::kFakeAttestationCert)) 111 cryptohome::MockAsyncMethodCaller::kFakeAttestationCert))
111 .Times(1) 112 .Times(1)
112 .InSequence(flow_order); 113 .InSequence(flow_order);
113 AttestationFlow::CertificateCallback mock_callback = base::Bind( 114 AttestationFlow::CertificateCallback mock_callback = base::Bind(
114 &MockObserver::MockCertificateCallback, 115 &MockObserver::MockCertificateCallback,
115 base::Unretained(&observer)); 116 base::Unretained(&observer));
116 117
117 AttestationFlow flow(&async_caller, &client, &proxy); 118 AttestationFlow flow(&async_caller,
119 &client,
120 scoped_ptr<ServerProxy>(proxy.release()));
Mattias Nissler (ping if slow) 2013/04/10 17:31:03 Hm, all right, this isn't prettier either.
118 flow.GetCertificate("test", mock_callback); 121 flow.GetCertificate("test", mock_callback);
119 Run(); 122 Run();
120 } 123 }
121 124
122 TEST_F(AttestationFlowTest, GetCertificate_NoEK) { 125 TEST_F(AttestationFlowTest, GetCertificate_NoEK) {
123 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; 126 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
124 async_caller.SetUp(false, cryptohome::MOUNT_ERROR_NONE); 127 async_caller.SetUp(false, cryptohome::MOUNT_ERROR_NONE);
125 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_)) 128 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_))
126 .Times(1); 129 .Times(1);
127 130
128 chromeos::MockCryptohomeClient client; 131 chromeos::MockCryptohomeClient client;
129 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 132 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
130 .WillRepeatedly(Invoke(DBusCallbackFalse)); 133 .WillRepeatedly(Invoke(DBusCallbackFalse));
131 134
132 // We're not expecting any server calls in this case; StrictMock will verify. 135 // We're not expecting any server calls in this case; StrictMock will verify.
133 StrictMock<MockServerProxy> proxy; 136 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
134 137
135 StrictMock<MockObserver> observer; 138 StrictMock<MockObserver> observer;
136 EXPECT_CALL(observer, MockCertificateCallback(false, "")) 139 EXPECT_CALL(observer, MockCertificateCallback(false, ""))
137 .Times(1); 140 .Times(1);
138 AttestationFlow::CertificateCallback mock_callback = base::Bind( 141 AttestationFlow::CertificateCallback mock_callback = base::Bind(
139 &MockObserver::MockCertificateCallback, 142 &MockObserver::MockCertificateCallback,
140 base::Unretained(&observer)); 143 base::Unretained(&observer));
141 144
142 AttestationFlow flow(&async_caller, &client, &proxy); 145 scoped_ptr<ServerProxy> proxy_interface(proxy.release());
146 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass());
143 flow.GetCertificate("test", mock_callback); 147 flow.GetCertificate("test", mock_callback);
144 Run(); 148 Run();
145 } 149 }
146 150
147 TEST_F(AttestationFlowTest, GetCertificate_EKRejected) { 151 TEST_F(AttestationFlowTest, GetCertificate_EKRejected) {
148 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; 152 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
149 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); 153 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE);
150 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_)) 154 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_))
151 .Times(1); 155 .Times(1);
152 156
153 chromeos::MockCryptohomeClient client; 157 chromeos::MockCryptohomeClient client;
154 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 158 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
155 .WillRepeatedly(Invoke(DBusCallbackFalse)); 159 .WillRepeatedly(Invoke(DBusCallbackFalse));
156 160
157 StrictMock<MockServerProxy> proxy; 161 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
158 proxy.DeferToFake(false); 162 proxy->DeferToFake(false);
159 EXPECT_CALL(proxy, SendEnrollRequest( 163 EXPECT_CALL(*proxy, SendEnrollRequest(
160 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest, 164 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest,
161 _)).Times(1); 165 _)).Times(1);
162 166
163 StrictMock<MockObserver> observer; 167 StrictMock<MockObserver> observer;
164 EXPECT_CALL(observer, MockCertificateCallback(false, "")) 168 EXPECT_CALL(observer, MockCertificateCallback(false, ""))
165 .Times(1); 169 .Times(1);
166 AttestationFlow::CertificateCallback mock_callback = base::Bind( 170 AttestationFlow::CertificateCallback mock_callback = base::Bind(
167 &MockObserver::MockCertificateCallback, 171 &MockObserver::MockCertificateCallback,
168 base::Unretained(&observer)); 172 base::Unretained(&observer));
169 173
170 AttestationFlow flow(&async_caller, &client, &proxy); 174 scoped_ptr<ServerProxy> proxy_interface(proxy.release());
175 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass());
171 flow.GetCertificate("test", mock_callback); 176 flow.GetCertificate("test", mock_callback);
172 Run(); 177 Run();
173 } 178 }
174 179
175 TEST_F(AttestationFlowTest, GetCertificate_FailEnroll) { 180 TEST_F(AttestationFlowTest, GetCertificate_FailEnroll) {
176 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; 181 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
177 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); 182 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE);
178 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_)) 183 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_))
179 .Times(1); 184 .Times(1);
180 std::string fake_enroll_response = 185 std::string fake_enroll_response =
181 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest; 186 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest;
182 fake_enroll_response += "_response"; 187 fake_enroll_response += "_response";
183 EXPECT_CALL(async_caller, AsyncTpmAttestationEnroll(fake_enroll_response, _)) 188 EXPECT_CALL(async_caller, AsyncTpmAttestationEnroll(fake_enroll_response, _))
184 .WillOnce(WithArgs<1>(Invoke(AsyncCallbackFalse))); 189 .WillOnce(WithArgs<1>(Invoke(AsyncCallbackFalse)));
185 190
186 chromeos::MockCryptohomeClient client; 191 chromeos::MockCryptohomeClient client;
187 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 192 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
188 .WillRepeatedly(Invoke(DBusCallbackFalse)); 193 .WillRepeatedly(Invoke(DBusCallbackFalse));
189 194
190 StrictMock<MockServerProxy> proxy; 195 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
191 proxy.DeferToFake(true); 196 proxy->DeferToFake(true);
192 EXPECT_CALL(proxy, SendEnrollRequest( 197 EXPECT_CALL(*proxy, SendEnrollRequest(
193 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest, 198 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest,
194 _)).Times(1); 199 _)).Times(1);
195 200
196 StrictMock<MockObserver> observer; 201 StrictMock<MockObserver> observer;
197 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1); 202 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1);
198 AttestationFlow::CertificateCallback mock_callback = base::Bind( 203 AttestationFlow::CertificateCallback mock_callback = base::Bind(
199 &MockObserver::MockCertificateCallback, 204 &MockObserver::MockCertificateCallback,
200 base::Unretained(&observer)); 205 base::Unretained(&observer));
201 206
202 AttestationFlow flow(&async_caller, &client, &proxy); 207 scoped_ptr<ServerProxy> proxy_interface(proxy.release());
208 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass());
203 flow.GetCertificate("test", mock_callback); 209 flow.GetCertificate("test", mock_callback);
204 Run(); 210 Run();
205 } 211 }
206 212
207 TEST_F(AttestationFlowTest, GetOwnerCertificateAlreadyEnrolled) { 213 TEST_F(AttestationFlowTest, GetOwnerCertificateAlreadyEnrolled) {
208 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; 214 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
209 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); 215 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE);
210 int options = CryptohomeClient::INCLUDE_DEVICE_STATE | 216 int options = CryptohomeClient::INCLUDE_DEVICE_STATE |
211 CryptohomeClient::INCLUDE_STABLE_ID; 217 CryptohomeClient::INCLUDE_STABLE_ID;
212 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateCertRequest(options, _)) 218 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateCertRequest(options, _))
213 .Times(1); 219 .Times(1);
214 std::string fake_cert_response = 220 std::string fake_cert_response =
215 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest; 221 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest;
216 fake_cert_response += "_response"; 222 fake_cert_response += "_response";
217 EXPECT_CALL(async_caller, 223 EXPECT_CALL(async_caller,
218 AsyncTpmAttestationFinishCertRequest(fake_cert_response, 224 AsyncTpmAttestationFinishCertRequest(fake_cert_response,
219 CryptohomeClient::DEVICE_KEY, 225 CryptohomeClient::DEVICE_KEY,
220 "attest-ent-machine", 226 "attest-ent-machine",
221 _)) 227 _))
222 .Times(1); 228 .Times(1);
223 229
224 chromeos::MockCryptohomeClient client; 230 chromeos::MockCryptohomeClient client;
225 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 231 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
226 .WillRepeatedly(Invoke(DBusCallbackTrue)); 232 .WillRepeatedly(Invoke(DBusCallbackTrue));
227 233
228 StrictMock<MockServerProxy> proxy; 234 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
229 proxy.DeferToFake(true); 235 proxy->DeferToFake(true);
230 EXPECT_CALL(proxy, SendCertificateRequest( 236 EXPECT_CALL(*proxy, SendCertificateRequest(
231 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest, 237 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest,
232 _)).Times(1); 238 _)).Times(1);
233 239
234 StrictMock<MockObserver> observer; 240 StrictMock<MockObserver> observer;
235 EXPECT_CALL(observer, MockCertificateCallback( 241 EXPECT_CALL(observer, MockCertificateCallback(
236 true, 242 true,
237 cryptohome::MockAsyncMethodCaller::kFakeAttestationCert)).Times(1); 243 cryptohome::MockAsyncMethodCaller::kFakeAttestationCert)).Times(1);
238 AttestationFlow::CertificateCallback mock_callback = base::Bind( 244 AttestationFlow::CertificateCallback mock_callback = base::Bind(
239 &MockObserver::MockCertificateCallback, 245 &MockObserver::MockCertificateCallback,
240 base::Unretained(&observer)); 246 base::Unretained(&observer));
241 247
242 AttestationFlow flow(&async_caller, &client, &proxy); 248 scoped_ptr<ServerProxy> proxy_interface(proxy.release());
249 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass());
243 flow.GetCertificate("attest-ent-machine", mock_callback); 250 flow.GetCertificate("attest-ent-machine", mock_callback);
244 Run(); 251 Run();
245 } 252 }
246 253
247 TEST_F(AttestationFlowTest, GetCertificate_FailCreateCertRequest) { 254 TEST_F(AttestationFlowTest, GetCertificate_FailCreateCertRequest) {
248 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; 255 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
249 async_caller.SetUp(false, cryptohome::MOUNT_ERROR_NONE); 256 async_caller.SetUp(false, cryptohome::MOUNT_ERROR_NONE);
250 int options = CryptohomeClient::INCLUDE_DEVICE_STATE; 257 int options = CryptohomeClient::INCLUDE_DEVICE_STATE;
251 EXPECT_CALL(async_caller, 258 EXPECT_CALL(async_caller,
252 AsyncTpmAttestationCreateCertRequest(options, _)) 259 AsyncTpmAttestationCreateCertRequest(options, _))
253 .Times(1); 260 .Times(1);
254 261
255 chromeos::MockCryptohomeClient client; 262 chromeos::MockCryptohomeClient client;
256 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 263 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
257 .WillRepeatedly(Invoke(DBusCallbackTrue)); 264 .WillRepeatedly(Invoke(DBusCallbackTrue));
258 265
259 // We're not expecting any server calls in this case; StrictMock will verify. 266 // We're not expecting any server calls in this case; StrictMock will verify.
260 StrictMock<MockServerProxy> proxy; 267 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
261 268
262 StrictMock<MockObserver> observer; 269 StrictMock<MockObserver> observer;
263 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1); 270 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1);
264 AttestationFlow::CertificateCallback mock_callback = base::Bind( 271 AttestationFlow::CertificateCallback mock_callback = base::Bind(
265 &MockObserver::MockCertificateCallback, 272 &MockObserver::MockCertificateCallback,
266 base::Unretained(&observer)); 273 base::Unretained(&observer));
267 274
268 AttestationFlow flow(&async_caller, &client, &proxy); 275 scoped_ptr<ServerProxy> proxy_interface(proxy.release());
276 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass());
269 flow.GetCertificate("test", mock_callback); 277 flow.GetCertificate("test", mock_callback);
270 Run(); 278 Run();
271 } 279 }
272 280
273 TEST_F(AttestationFlowTest, GetCertificate_CertRequestRejected) { 281 TEST_F(AttestationFlowTest, GetCertificate_CertRequestRejected) {
274 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; 282 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
275 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); 283 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE);
276 int options = CryptohomeClient::INCLUDE_DEVICE_STATE; 284 int options = CryptohomeClient::INCLUDE_DEVICE_STATE;
277 EXPECT_CALL(async_caller, 285 EXPECT_CALL(async_caller,
278 AsyncTpmAttestationCreateCertRequest(options, _)) 286 AsyncTpmAttestationCreateCertRequest(options, _))
279 .Times(1); 287 .Times(1);
280 288
281 chromeos::MockCryptohomeClient client; 289 chromeos::MockCryptohomeClient client;
282 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 290 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
283 .WillRepeatedly(Invoke(DBusCallbackTrue)); 291 .WillRepeatedly(Invoke(DBusCallbackTrue));
284 292
285 StrictMock<MockServerProxy> proxy; 293 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
286 proxy.DeferToFake(false); 294 proxy->DeferToFake(false);
287 EXPECT_CALL(proxy, SendCertificateRequest( 295 EXPECT_CALL(*proxy, SendCertificateRequest(
288 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest, 296 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest,
289 _)).Times(1); 297 _)).Times(1);
290 298
291 StrictMock<MockObserver> observer; 299 StrictMock<MockObserver> observer;
292 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1); 300 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1);
293 AttestationFlow::CertificateCallback mock_callback = base::Bind( 301 AttestationFlow::CertificateCallback mock_callback = base::Bind(
294 &MockObserver::MockCertificateCallback, 302 &MockObserver::MockCertificateCallback,
295 base::Unretained(&observer)); 303 base::Unretained(&observer));
296 304
297 AttestationFlow flow(&async_caller, &client, &proxy); 305 scoped_ptr<ServerProxy> proxy_interface(proxy.release());
306 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass());
298 flow.GetCertificate("test", mock_callback); 307 flow.GetCertificate("test", mock_callback);
299 Run(); 308 Run();
300 } 309 }
301 310
302 TEST_F(AttestationFlowTest, GetCertificate_FailIsEnrolled) { 311 TEST_F(AttestationFlowTest, GetCertificate_FailIsEnrolled) {
303 // We're not expecting any server calls in this case; StrictMock will verify. 312 // We're not expecting any server calls in this case; StrictMock will verify.
304 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; 313 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
305 314
306 chromeos::MockCryptohomeClient client; 315 chromeos::MockCryptohomeClient client;
307 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 316 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
308 .WillRepeatedly(Invoke(DBusCallbackFail)); 317 .WillRepeatedly(Invoke(DBusCallbackFail));
309 318
310 // We're not expecting any server calls in this case; StrictMock will verify. 319 // We're not expecting any server calls in this case; StrictMock will verify.
311 StrictMock<MockServerProxy> proxy; 320 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
312 321
313 StrictMock<MockObserver> observer; 322 StrictMock<MockObserver> observer;
314 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1); 323 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1);
315 AttestationFlow::CertificateCallback mock_callback = base::Bind( 324 AttestationFlow::CertificateCallback mock_callback = base::Bind(
316 &MockObserver::MockCertificateCallback, 325 &MockObserver::MockCertificateCallback,
317 base::Unretained(&observer)); 326 base::Unretained(&observer));
318 327
319 AttestationFlow flow(&async_caller, &client, &proxy); 328 scoped_ptr<ServerProxy> proxy_interface(proxy.release());
329 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass());
320 flow.GetCertificate("test", mock_callback); 330 flow.GetCertificate("test", mock_callback);
321 Run(); 331 Run();
322 } 332 }
323 333
324 } // namespace attestation 334 } // namespace attestation
325 } // namespace chromeos 335 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698